Skip to content

Commit 3e5ee32

Browse files
committed
s390/atomic,cmpxchg: make constraints work with old compilers
Old gcc versions may fail with an internal compiler error if only the T or S constraint is specified for an operand, and no displacement is needed at all. To fix this use RT and QS as constraints, which reflects the union of both. Later gcc versions do the right thing and always accept single T and S constraints. See gcc commit 3e4be43f69da ("S/390: Memory constraint cleanup"). Fixes: ca897bb ("s390/atomic: use proper constraints") Fixes: b23eb63 ("s390/atomic: get rid of gcc atomic builtins") Fixes: d2b1f6d ("s390/cmpxchg: get rid of gcc atomic builtins") Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
1 parent 5d8da69 commit 3e5ee32

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

arch/s390/include/asm/atomic_ops.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ static inline s64 __atomic64_read(const atomic64_t *v)
3131

3232
asm volatile(
3333
" lg %0,%1\n"
34-
: "=d" (c) : "T" (v->counter));
34+
: "=d" (c) : "RT" (v->counter));
3535
return c;
3636
}
3737

3838
static inline void __atomic64_set(atomic64_t *v, s64 i)
3939
{
4040
asm volatile(
4141
" stg %1,%0\n"
42-
: "=T" (v->counter) : "d" (i));
42+
: "=RT" (v->counter) : "d" (i));
4343
}
4444

4545
#ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
@@ -52,7 +52,7 @@ static inline op_type op_name(op_type val, op_type *ptr) \
5252
asm volatile( \
5353
op_string " %[old],%[val],%[ptr]\n" \
5454
op_barrier \
55-
: [old] "=d" (old), [ptr] "+S" (*ptr) \
55+
: [old] "=d" (old), [ptr] "+QS" (*ptr) \
5656
: [val] "d" (val) : "cc", "memory"); \
5757
return old; \
5858
} \
@@ -80,7 +80,7 @@ static __always_inline void op_name(op_type val, op_type *ptr) \
8080
asm volatile( \
8181
op_string " %[ptr],%[val]\n" \
8282
op_barrier \
83-
: [ptr] "+S" (*ptr) : [val] "i" (val) : "cc", "memory");\
83+
: [ptr] "+QS" (*ptr) : [val] "i" (val) : "cc", "memory");\
8484
}
8585

8686
#define __ATOMIC_CONST_OPS(op_name, op_type, op_string) \
@@ -131,7 +131,7 @@ static inline long op_name(long val, long *ptr) \
131131
op_string " %[new],%[val]\n" \
132132
" csg %[old],%[new],%[ptr]\n" \
133133
" jl 0b" \
134-
: [old] "=d" (old), [new] "=&d" (new), [ptr] "+S" (*ptr)\
134+
: [old] "=d" (old), [new] "=&d" (new), [ptr] "+QS" (*ptr)\
135135
: [val] "d" (val), "0" (*ptr) : "cc", "memory"); \
136136
return old; \
137137
}
@@ -180,7 +180,7 @@ static inline long __atomic64_cmpxchg(long *ptr, long old, long new)
180180
{
181181
asm volatile(
182182
" csg %[old],%[new],%[ptr]"
183-
: [old] "+d" (old), [ptr] "+S" (*ptr)
183+
: [old] "+d" (old), [ptr] "+QS" (*ptr)
184184
: [new] "d" (new)
185185
: "cc", "memory");
186186
return old;
@@ -192,7 +192,7 @@ static inline bool __atomic64_cmpxchg_bool(long *ptr, long old, long new)
192192

193193
asm volatile(
194194
" csg %[old],%[new],%[ptr]"
195-
: [old] "+d" (old), [ptr] "+S" (*ptr)
195+
: [old] "+d" (old), [ptr] "+QS" (*ptr)
196196
: [new] "d" (new)
197197
: "cc", "memory");
198198
return old == old_expected;

arch/s390/include/asm/cmpxchg.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static inline unsigned long __xchg(unsigned long x, unsigned long address, int s
6262
" lg %0,%1\n"
6363
"0: csg %0,%2,%1\n"
6464
" jl 0b\n"
65-
: "=&d" (old), "+S" (*(long *) address)
65+
: "=&d" (old), "+QS" (*(long *) address)
6666
: "d" (x)
6767
: "memory", "cc");
6868
return old;
@@ -142,7 +142,7 @@ static inline unsigned long __cmpxchg(unsigned long address, unsigned long old,
142142
case 8:
143143
asm volatile(
144144
" csg %0,%3,%1\n"
145-
: "=&d" (prev), "+S" (*(long *) address)
145+
: "=&d" (prev), "+QS" (*(long *) address)
146146
: "0" (old), "d" (new)
147147
: "memory", "cc");
148148
return prev;

0 commit comments

Comments
 (0)