Skip to content

Commit e200565

Browse files
committed
s390/cio/ioasm: Convert to use flag output macros
Use flag output macros in inline asm to allow for better code generation if the compiler has support for the flag output constraint. Reviewed-by: Juergen Christ <jchrist@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
1 parent f62ad90 commit e200565

File tree

1 file changed

+54
-53
lines changed

1 file changed

+54
-53
lines changed

drivers/s390/cio/ioasm.c

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <asm/asm-extable.h>
99
#include <asm/chpid.h>
1010
#include <asm/schid.h>
11+
#include <asm/asm.h>
1112
#include <asm/crw.h>
1213

1314
#include "ioasm.h"
@@ -18,19 +19,20 @@
1819
static inline int __stsch(struct subchannel_id schid, struct schib *addr)
1920
{
2021
unsigned long r1 = *(unsigned int *)&schid;
21-
int ccode = -EIO;
22+
int ccode, exception;
2223

24+
exception = 1;
2325
asm volatile(
2426
" lgr 1,%[r1]\n"
2527
" stsch %[addr]\n"
26-
"0: ipm %[cc]\n"
27-
" srl %[cc],28\n"
28+
"0: lhi %[exc],0\n"
2829
"1:\n"
30+
CC_IPM(cc)
2931
EX_TABLE(0b, 1b)
30-
: [cc] "+&d" (ccode), [addr] "=Q" (*addr)
32+
: CC_OUT(cc, ccode), [addr] "=Q" (*addr), [exc] "+d" (exception)
3133
: [r1] "d" (r1)
32-
: "cc", "1");
33-
return ccode;
34+
: CC_CLOBBER_LIST("1"));
35+
return exception ? -EIO : CC_TRANSFORM(ccode);
3436
}
3537

3638
int stsch(struct subchannel_id schid, struct schib *addr)
@@ -47,19 +49,20 @@ EXPORT_SYMBOL(stsch);
4749
static inline int __msch(struct subchannel_id schid, struct schib *addr)
4850
{
4951
unsigned long r1 = *(unsigned int *)&schid;
50-
int ccode = -EIO;
52+
int ccode, exception;
5153

54+
exception = 1;
5255
asm volatile(
5356
" lgr 1,%[r1]\n"
5457
" msch %[addr]\n"
55-
"0: ipm %[cc]\n"
56-
" srl %[cc],28\n"
58+
"0: lhi %[exc],0\n"
5759
"1:\n"
60+
CC_IPM(cc)
5861
EX_TABLE(0b, 1b)
59-
: [cc] "+&d" (ccode)
62+
: CC_OUT(cc, ccode), [exc] "+d" (exception)
6063
: [r1] "d" (r1), [addr] "Q" (*addr)
61-
: "cc", "1");
62-
return ccode;
64+
: CC_CLOBBER_LIST("1"));
65+
return exception ? -EIO : CC_TRANSFORM(ccode);
6366
}
6467

6568
int msch(struct subchannel_id schid, struct schib *addr)
@@ -80,12 +83,11 @@ static inline int __tsch(struct subchannel_id schid, struct irb *addr)
8083
asm volatile(
8184
" lgr 1,%[r1]\n"
8285
" tsch %[addr]\n"
83-
" ipm %[cc]\n"
84-
" srl %[cc],28"
85-
: [cc] "=&d" (ccode), [addr] "=Q" (*addr)
86+
CC_IPM(cc)
87+
: CC_OUT(cc, ccode), [addr] "=Q" (*addr)
8688
: [r1] "d" (r1)
87-
: "cc", "1");
88-
return ccode;
89+
: CC_CLOBBER_LIST("1"));
90+
return CC_TRANSFORM(ccode);
8991
}
9092

9193
int tsch(struct subchannel_id schid, struct irb *addr)
@@ -101,19 +103,20 @@ int tsch(struct subchannel_id schid, struct irb *addr)
101103
static inline int __ssch(struct subchannel_id schid, union orb *addr)
102104
{
103105
unsigned long r1 = *(unsigned int *)&schid;
104-
int ccode = -EIO;
106+
int ccode, exception;
105107

108+
exception = 1;
106109
asm volatile(
107110
" lgr 1,%[r1]\n"
108111
" ssch %[addr]\n"
109-
"0: ipm %[cc]\n"
110-
" srl %[cc],28\n"
112+
"0: lhi %[exc],0\n"
111113
"1:\n"
114+
CC_IPM(cc)
112115
EX_TABLE(0b, 1b)
113-
: [cc] "+&d" (ccode)
116+
: CC_OUT(cc, ccode), [exc] "+d" (exception)
114117
: [r1] "d" (r1), [addr] "Q" (*addr)
115-
: "cc", "memory", "1");
116-
return ccode;
118+
: CC_CLOBBER_LIST("memory", "1"));
119+
return CC_TRANSFORM(ccode);
117120
}
118121

119122
int ssch(struct subchannel_id schid, union orb *addr)
@@ -135,12 +138,11 @@ static inline int __csch(struct subchannel_id schid)
135138
asm volatile(
136139
" lgr 1,%[r1]\n"
137140
" csch\n"
138-
" ipm %[cc]\n"
139-
" srl %[cc],28\n"
140-
: [cc] "=&d" (ccode)
141+
CC_IPM(cc)
142+
: CC_OUT(cc, ccode)
141143
: [r1] "d" (r1)
142-
: "cc", "1");
143-
return ccode;
144+
: CC_CLOBBER_LIST("1"));
145+
return CC_TRANSFORM(ccode);
144146
}
145147

146148
int csch(struct subchannel_id schid)
@@ -160,11 +162,11 @@ int tpi(struct tpi_info *addr)
160162

161163
asm volatile(
162164
" tpi %[addr]\n"
163-
" ipm %[cc]\n"
164-
" srl %[cc],28"
165-
: [cc] "=&d" (ccode), [addr] "=Q" (*addr)
165+
CC_IPM(cc)
166+
: CC_OUT(cc, ccode), [addr] "=Q" (*addr)
166167
:
167-
: "cc");
168+
: CC_CLOBBER);
169+
ccode = CC_TRANSFORM(ccode);
168170
trace_s390_cio_tpi(addr, ccode);
169171

170172
return ccode;
@@ -173,17 +175,19 @@ int tpi(struct tpi_info *addr)
173175
int chsc(void *chsc_area)
174176
{
175177
typedef struct { char _[4096]; } addr_type;
176-
int cc = -EIO;
178+
int cc, exception;
177179

180+
exception = 1;
178181
asm volatile(
179182
" .insn rre,0xb25f0000,%[chsc_area],0\n"
180-
"0: ipm %[cc]\n"
181-
" srl %[cc],28\n"
183+
"0: lhi %[exc],0\n"
182184
"1:\n"
185+
CC_IPM(cc)
183186
EX_TABLE(0b, 1b)
184-
: [cc] "+&d" (cc), "+m" (*(addr_type *)chsc_area)
187+
: CC_OUT(cc, cc), "+m" (*(addr_type *)chsc_area), [exc] "+d" (exception)
185188
: [chsc_area] "d" (chsc_area)
186-
: "cc");
189+
: CC_CLOBBER);
190+
cc = exception ? -EIO : CC_TRANSFORM(cc);
187191
trace_s390_cio_chsc(chsc_area, cc);
188192

189193
return cc;
@@ -198,12 +202,11 @@ static inline int __rsch(struct subchannel_id schid)
198202
asm volatile(
199203
" lgr 1,%[r1]\n"
200204
" rsch\n"
201-
" ipm %[cc]\n"
202-
" srl %[cc],28\n"
203-
: [cc] "=&d" (ccode)
205+
CC_IPM(cc)
206+
: CC_OUT(cc, ccode)
204207
: [r1] "d" (r1)
205-
: "cc", "memory", "1");
206-
return ccode;
208+
: CC_CLOBBER_LIST("memory", "1"));
209+
return CC_TRANSFORM(ccode);
207210
}
208211

209212
int rsch(struct subchannel_id schid)
@@ -224,12 +227,11 @@ static inline int __hsch(struct subchannel_id schid)
224227
asm volatile(
225228
" lgr 1,%[r1]\n"
226229
" hsch\n"
227-
" ipm %[cc]\n"
228-
" srl %[cc],28\n"
229-
: [cc] "=&d" (ccode)
230+
CC_IPM(cc)
231+
: CC_OUT(cc, ccode)
230232
: [r1] "d" (r1)
231-
: "cc", "1");
232-
return ccode;
233+
: CC_CLOBBER_LIST("1"));
234+
return CC_TRANSFORM(ccode);
233235
}
234236

235237
int hsch(struct subchannel_id schid)
@@ -256,7 +258,7 @@ static inline int __xsch(struct subchannel_id schid)
256258
: [cc] "=&d" (ccode)
257259
: [r1] "d" (r1)
258260
: "cc", "1");
259-
return ccode;
261+
return CC_TRANSFORM(ccode);
260262
}
261263

262264
int xsch(struct subchannel_id schid)
@@ -275,12 +277,11 @@ static inline int __stcrw(struct crw *crw)
275277

276278
asm volatile(
277279
" stcrw %[crw]\n"
278-
" ipm %[cc]\n"
279-
" srl %[cc],28\n"
280-
: [cc] "=&d" (ccode), [crw] "=Q" (*crw)
280+
CC_IPM(cc)
281+
: CC_OUT(cc, ccode), [crw] "=Q" (*crw)
281282
:
282-
: "cc");
283-
return ccode;
283+
: CC_CLOBBER);
284+
return CC_TRANSFORM(ccode);
284285
}
285286

286287
static inline int _stcrw(struct crw *crw)

0 commit comments

Comments
 (0)