s390/arm/arm64: include: asm: atomic.h: use 'unsigned int' and 'atomic_t' instead of 'unsigned long' for atomic_*_mask()
Subsystems (4)
cover s390/arm/arm64: include: asm: atomic.h: use 'unsigned int' and 'atomic_t' instead of 'unsigned long' for atomic_*_mask()
For atomic_*_mask(), the 'atomic_t' is 32-bit, so for the 'mask', also need mach it.
Patch 1/3: s390: include: asm: atomic.h: use 'unsigned int' instead of 'unsigned long' for atomic_*_mask().
Patch 2/3: arm: include: asm: atomic.h: use 'unsigned int' and 'atomic' instead of 'unsigned long' for atomic_clear_mask().
Patch 3/3: arm64: include: asm: atomic.h: use 'unsigned int' and 'atomic_t' instead of 'unsigned long' for atomic_clear_mask().
--- arch/arm/include/asm/atomic.h | 13 +++++++------ arch/arm64/include/asm/atomic.h | 13 +++++++------ arch/s390/include/asm/atomic.h | 4 ++-- 3 files changed, 16 insertions(+), 14 deletions(-)
PATCH 1/3 s390: include: asm: atomic.h: use 'unsigned int' instead of 'unsigned long' for atomic_*_mask()
The type of 'v->counter' is always 'int', and related inline assembly code also process 'int', so use 'unsigned int' instead of 'unsigned long' for the 'mask'.
--- arch/s390/include/asm/atomic.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/s390/include/asm/atomic.h +2 -2
@@ -113,12 +113,12 @@ static inline void atomic_add(int i, atomic_t *v)#define atomic_dec_return (_v) atomic_sub_return(1, _v)#define atomic_dec_and_test (_v) (atomic_sub_return(1, _v) == 0) -static inline void atomic_clear_mask (unsigned long mask,atomic_t *v) +static inline void atomic_clear_mask (unsigned int mask,atomic_t *v) {__ATOMIC_LOOP (v, ~mask, __ATOMIC_AND); } -static inline void atomic_set_mask (unsigned long mask,atomic_t *v) +static inline void atomic_set_mask (unsigned int mask,atomic_t *v) {__ATOMIC_LOOP (v, mask, __ATOMIC_OR); }
Signature · 1 line
1.7.7.6
PATCH 2/3 arm: include: asm: atomic.h: use 'unsigned int' and 'atomic' instead of 'unsigned long' for atomic_clear_mask()
In current kernel wide source, for arm, only s390 scsi drivers use atomic_clear_mask(), now, s390 itself need use 'unsigned int' and 'atomic_t', so need match s390's atomic_clear_mask().
--- arch/arm/include/asm/atomic.h | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
arch/arm/include/asm/atomic.h +7 -6
@@ -134,9 +134,10 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)return oldval; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) +static inline void atomic_clear_mask (unsigned int mask,atomic_t *ptr) { -unsigned long tmp, tmp2; +unsigned int tmp; +unsigned long tmp2; __asm__ __volatile__("@ atomic_clear_mask\n" "1: ldrex %0, [%3]\n"
@@ -144,8 +145,8 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr) " strex %1, %0, [%3]\n" " teq %1, #0\n" " bne 1b" - : "=&r" (tmp), "=&r" (tmp2), "+Qo" (*addr) - : "r" (addr), "Ir" (mask) + : "=&r" (tmp), "=&r" (tmp2), "+Qo" (ptr->counter) + : "r" (&ptr->counter), "Ir" (mask) : "cc"); }
@@ -197,12 +198,12 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)return ret; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) +static inline void atomic_clear_mask (unsigned int mask,atomic_t *v) {unsigned long flags;raw_local_irq_save (flags); - *addr &= ~mask; + v->counter &= ~mask;raw_local_irq_restore (flags); }
Signature · 1 line
1.7.7.6
PATCH 3/3 arm64: include: asm: atomic.h: use 'unsigned int' and 'atomic_t' instead of 'unsigned long' for atomic_clear_mask()
In current kernel wide source, for arm64, only s390 scsi drivers use atomic_clear_mask(), now, s390 itself need use 'unsigned int' and 'atomic_t', so need match s390's atomic_clear_mask().
--- arch/arm64/include/asm/atomic.h | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
arch/arm64/include/asm/atomic.h +7 -6
@@ -126,16 +126,17 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)return oldval; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) +static inline void atomic_clear_mask (unsigned int mask,atomic_t *ptr) { -unsigned long tmp, tmp2; +unsigned int tmp; +unsigned long tmp2; asmvolatile ("// atomic_clear_mask\n" -"1: ldxr %0, %2\n" -" bic %0, %0, %3\n" -" stxr %w1, %0, %2\n" +"1: ldxr %w0, %2\n" +" bic %w0, %w0, %w3\n" +" stxr %w1, %w0, %2\n" " cbnz %w1, 1b" - :"=&r" (tmp),"=&r" (tmp2),"+Q" (*addr) + :"=&r" (tmp),"=&r" (tmp2),"+Q" (ptr->counter) :"Ir" (mask) :"cc" ); }
Signature · 1 line
1.7.7.6
Re: [PATCH 3/3] arm64: include: asm: atomic.h: use 'unsigned int' and 'atomic_t' instead of 'unsigned long' for atomic_clear_mask()
Quoted 15 lines · Chen Gang
In current kernel wide source, for arm64, only s390 scsi drivers use
atomic_clear_mask(), now, s390 itself need use 'unsigned int' and 'atomic_t', so need match s390'satomic_clear_mask().Signed-off-by Chen Gang <[email protected]>--- arch/arm64/include/asm/atomic.h | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)arch/arm64/include/asm/atomic.h +0
-0
arch/arm64/include/asm/atomic.h static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new) · line 131
Quoted 8 lines
arch/arm64/include/asm/atomic.h +2
-2@@ -126,16 +126,17 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)return oldval; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) +static inline void atomic_clear_mask (unsigned int mask,atomic_t *ptr) { -unsigned long tmp, tmp2; +unsigned int tmp;
Same comment here as for ARM; I think you want a signed int.
Will
Re: [PATCH 3/3] arm64: include: asm: atomic.h: use 'unsigned int' and 'atomic_t' instead of 'unsigned long' for atomic_clear_mask()
Quoted 19 lines · Will Deacon
Quoted 18 lines · Chen Gang
In current kernel wide source, for arm64, only s390 scsi drivers use
atomic_clear_mask(), now, s390 itself need use 'unsigned int' and 'atomic_t', so need match s390'satomic_clear_mask().Signed-off-by Chen Gang <[email protected]>--- arch/arm64/include/asm/atomic.h | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)arch/arm64/include/asm/atomic.h +0
-0@@ -126,16 +126,17 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)return oldval; }
Quoted 8 lines
arch/arm64/include/asm/atomic.h static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new) · line 131
Quoted 5 lines
arch/arm64/include/asm/atomic.h +2
-2-static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) +static inline void atomic_clear_mask (unsigned int mask,atomic_t *ptr) { -unsigned long tmp, tmp2; +unsigned int tmp;Same comment here as for ARM; I think you want a signed int.
OK, replied in patch 2/3 for ARM.
BTW: do arm64 need atomic_clear_mask()?
Quoted 3 lines
Will
Thanks.
Signature · 1 line
Chen Gang
Re: [PATCH 3/3] arm64: include: asm: atomic.h: use 'unsigned int' and 'atomic_t' instead of 'unsigned long' for atomic_clear_mask()
Quoted 29 lines · Chen Gang
Quoted 19 lines · Will Deacon
Quoted 18 lines · Chen Gang
In current kernel wide source, for arm64, only s390 scsi drivers use
atomic_clear_mask(), now, s390 itself need use 'unsigned int' and 'atomic_t', so need match s390'satomic_clear_mask().Signed-off-by Chen Gang <[email protected]>--- arch/arm64/include/asm/atomic.h | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)arch/arm64/include/asm/atomic.h +0
-0@@ -126,16 +126,17 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)return oldval; }Quoted 8 lines
arch/arm64/include/asm/atomic.h static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new) · line 131
Quoted 5 lines
arch/arm64/include/asm/atomic.h +2
-2-static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) +static inline void atomic_clear_mask (unsigned int mask,atomic_t *ptr) { -unsigned long tmp, tmp2; +unsigned int tmp;Same comment here as for ARM; I think you want a signed int.
Quoted 3 lines
OK, replied in patch 2/3 for ARM.
BTW: do arm64 need
atomic_clear_mask()?
No. Neither ARM nor arm64 need this function.
Will
Re: [PATCH 3/3] arm64: include: asm: atomic.h: use 'unsigned int' and 'atomic_t' instead of 'unsigned long' for atomic_clear_mask()
Quoted 30 lines · Will Deacon
Quoted 29 lines · Chen Gang
Quoted 27 lines · Will Deacon
Quoted 15 lines · Chen Gang
In current kernel wide source, for arm64, only s390 scsi drivers use
atomic_clear_mask(), now, s390 itself need use 'unsigned int' and 'atomic_t', so need match s390'satomic_clear_mask().Signed-off-by Chen Gang <[email protected]>--- arch/arm64/include/asm/atomic.h | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)arch/arm64/include/asm/atomic.h +0
-0arch/arm64/include/asm/atomic.h static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new) · line 131
Quoted 8 lines
arch/arm64/include/asm/atomic.h +2
-2@@ -126,16 +126,17 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)return oldval; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) +static inline void atomic_clear_mask (unsigned int mask,atomic_t *ptr) { -unsigned long tmp, tmp2; +unsigned int tmp;Same comment here as for ARM; I think you want a signed int.
Quoted 6 lines
Quoted 3 lines
OK, replied in patch 2/3 for ARM.
BTW: do arm64 need
atomic_clear_mask()?No. Neither ARM nor arm64 need this function.
OK, thank you for your confirmation.
Hmm... can we remove atomic_clear_mask() from ARM and arm64? (in my opinion, if not need, better to remove it).
Quoted 3 lines
Will
Thanks.
Signature · 1 line
Chen Gang
Re: [PATCH 3/3] arm64: include: asm: atomic.h: use 'unsigned int' and 'atomic_t' instead of 'unsigned long' for atomic_clear_mask()
Quoted 10 lines · Chen Gang
Quoted 4 lines · Will Deacon
Quoted 1 line · Chen Gang
BTW: do arm64 need
atomic_clear_mask()?No. Neither ARM nor arm64 need this function.
OK, thank you for your confirmation.
Hmm... can we remove
atomic_clear_mask()from ARM and arm64? (in my opinion, if not need, better to remove it).
Yes!
I mentioned this a few times already...
Will
Re: [PATCH 3/3] arm64: include: asm: atomic.h: use 'unsigned int' and 'atomic_t' instead of 'unsigned long' for atomic_clear_mask()
Quoted 5 lines · Will Deacon
Quoted 4 lines · Chen Gang
Quoted 3 lines · Will Deacon
Quoted 1 line · Chen Gang
BTW: do arm64 need
atomic_clear_mask()?
Quoted 9 lines
Quoted 6 lines
Quoted 1 line
No. Neither ARM nor arm64 need this function.
OK, thank you for your confirmation.
Hmm... can we remove
atomic_clear_mask()from ARM and arm64? (in my opinion, if not need, better to remove it).Yes!
OK, thanks.
Quoted 2 lines
I mentioned this a few times already...
Hmm... firstly, you mentioned "except architectures, this is only used under s390" (so I reply we need follow s390), and then you mentioned "they are useless for arm/arm64" (so I ask whether it can be removed).
Excuse me, as a 'programmer' (at least, I am a 'programmer'), when programming (assume our discussing belongs to programming), I have to consider precisely (especially for confirmation words). ;-)
I will send one patch for removing it from arm and arm64.
Thanks.
Quoted 7 lines
Will
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Thanks.
Signature · 4 lines
Chen Gang -- Chen Gang
PATCH 1/1 arm/arm64: remove atomic_clear_mask() in "include/asm/atomic.h"
In current kernel wide source code, except other architectures, only s390 scsi drivers use atomic_clear_mask(), and arm/arm64 need not support s390 drivers.
So remove atomic_clear_mask() from "arm[64]/include/asm/atomic.h".
--- arch/arm/include/asm/atomic.h | 24 ------------------------ arch/arm64/include/asm/atomic.h | 14 -------------- 2 files changed, 0 insertions(+), 38 deletions(-)
arch/arm/include/asm/atomic.h +0 -24
@@ -134,21 +134,6 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new) return oldval; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) -{ -unsigned long tmp, tmp2; - - __asm__ __volatile__("@ atomic_clear_mask\n" -"1: ldrex %0, [%3]\n" -" bic %0, %0, %4\n" -" strex %1, %0, [%3]\n" -" teq %1, #0\n" -" bne 1b" - :"=&r" (tmp),"=&r" (tmp2),"+Qo" (*addr) - :"r" (addr),"Ir" (mask) - :"cc" ); -} -#else /* ARM_ARCH_6 */ #ifdef CONFIG_SMP
@@ -197,15 +182,6 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new) return ret; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) -{ -unsigned long flags; - -raw_local_irq_save (flags); - *addr &= ~mask; -raw_local_irq_restore (flags); -} -#endif /* __LINUX_ARM_ARCH__ */ #define atomic_xchg (v, new) (xchg(&((v)->counter), new))
arch/arm64/include/asm/atomic.h +0 -14
@@ -126,20 +126,6 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)return oldval; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) -{ -unsigned long tmp, tmp2; - - asmvolatile ("// atomic_clear_mask\n" -"1: ldxr %0, %2\n" -" bic %0, %0, %3\n" -" stxr %w1, %0, %2\n" -" cbnz %w1, 1b" - :"=&r" (tmp),"=&r" (tmp2),"+Q" (*addr) - :"Ir" (mask) - :"cc" ); -} -#define atomic_xchg (v, new) (xchg(&((v)->counter), new))static inline int __atomic_add_unless (atomic_t *v,int a,int u)
Signature · 1 line
1.7.7.6
Re: [PATCH] arm/arm64: remove atomic_clear_mask() in "include/asm/atomic.h"
Quoted 5 lines · Chen Gang
In current kernel wide source code, except other architectures, only s390 scsi drivers use
atomic_clear_mask(), and arm/arm64 need not support s390 drivers.So remove
atomic_clear_mask()from "arm[64]/include/asm/atomic.h".
Is it really worth removing such a primitive?
If someone needs it later he has to implement it from scratch and introduces bugs...
Quoted 81 lines
Signed-off-by Chen Gang <[email protected]>--- arch/arm/include/asm/atomic.h | 24 ------------------------ arch/arm64/include/asm/atomic.h | 14 -------------- 2 files changed, 0 insertions(+), 38 deletions(-)arch/arm/include/asm/atomic.h +0
-24@@ -134,21 +134,6 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new) return oldval; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) -{ -unsigned long tmp, tmp2; - - __asm__ __volatile__("@ atomic_clear_mask\n" -"1: ldrex %0, [%3]\n" -" bic %0, %0, %4\n" -" strex %1, %0, [%3]\n" -" teq %1, #0\n" -" bne 1b" - :"=&r" (tmp),"=&r" (tmp2),"+Qo" (*addr) - :"r" (addr),"Ir" (mask) - :"cc" ); -} -#else /* ARM_ARCH_6 */ #ifdef CONFIG_SMP @@ -197,15 +182,6 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new) return ret; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) -{ -unsigned long flags; - -raw_local_irq_save (flags); - *addr &= ~mask; -raw_local_irq_restore (flags); -} -#endif /* __LINUX_ARM_ARCH__ */ #define atomic_xchg (v, new) (xchg(&((v)->counter), new))arch/arm64/include/asm/atomic.h +0
-15@@ -126,20 +126,6 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)return oldval; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) -{ -unsigned long tmp, tmp2; - - asmvolatile ("// atomic_clear_mask\n" -"1: ldxr %0, %2\n" -" bic %0, %0, %3\n" -" stxr %w1, %0, %2\n" -" cbnz %w1, 1b" - :"=&r" (tmp),"=&r" (tmp2),"+Q" (*addr) - :"Ir" (mask) - :"cc" ); -} -#define atomic_xchg (v, new) (xchg(&((v)->counter), new))static inline int __atomic_add_unless (atomic_t *v,int a,int u) --1.7.7.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 2 lines
Thanks, //richard
Re: [PATCH] arm/arm64: remove atomic_clear_mask() in "include/asm/atomic.h"
Quoted 10 lines · Richard Weinberger
Quoted 5 lines · Chen Gang
In current kernel wide source code, except other architectures, only s390 scsi drivers use
atomic_clear_mask(), and arm/arm64 need not support s390 drivers.So remove
atomic_clear_mask()from "arm[64]/include/asm/atomic.h".Is it really worth removing such a primitive?
If someone needs it later he has to implement it from scratch and introduces bugs...
The version we have (on ARM64 anyway) already has bugs. Given the choice between fixing code that has no callers and simply removing it, I'd go for the latter.
Will
Re: [PATCH] arm/arm64: remove atomic_clear_mask() in "include/asm/atomic.h"
Am 11.10.2013 14:28, schrieb Will Deacon:
Quoted 8 lines · Richard Weinberger
Quoted 7 lines · Chen Gang
Quoted 5 lines
In current kernel wide source code, except other architectures, only s390 scsi drivers use
atomic_clear_mask(), and arm/arm64 need not support s390 drivers.So remove
atomic_clear_mask()from "arm[64]/include/asm/atomic.h".
Quoted 7 lines
Quoted 3 lines
Is it really worth removing such a primitive?
If someone needs it later he has to implement it from scratch and introduces bugs...The version we have (on ARM64 anyway) already has bugs. Given the choice between fixing code that has no callers and simply removing it, I'd go for the latter.
Yeah, if it's broken and has no real users, send it to hell. :)
Thanks,
//richard
Re: [PATCH] arm/arm64: remove atomic_clear_mask() in "include/asm/atomic.h"
Quoted 13 lines · Richard Weinberger
Am 11.10.2013 14:28, schrieb Will Deacon:
Quoted 12 lines · Richard Weinberger
Quoted 10 lines · Chen Gang
Quoted 5 lines
In current kernel wide source code, except other architectures, only s390 scsi drivers use
atomic_clear_mask(), and arm/arm64 need not support s390 drivers.So remove
atomic_clear_mask()from "arm[64]/include/asm/atomic.h".Is it really worth removing such a primitive?
If someone needs it later he has to implement it from scratch and introduces bugs...
Quoted 6 lines
Quoted 3 lines
The version we have (on ARM64 anyway) already has bugs. Given the choice between fixing code that has no callers and simply removing it, I'd go for the latter.
Yeah, if it's broken and has no real users, send it to hell. :)
OK, thanks.
Hmm... at least, the original API definition is not well enough: "need use 'unsigned int' and 'atomic_t' instead of 'unsigned long' for the type of parameters".
But can we say "under arm64, it must be a bug"? (although I agree it is very easy to let callers miss using it -- then may cause issue).
In my opinion, it belongs to "API definition issue" not implementation
bug: "if all callers are carefully enough, it will not make issues" (e.g. in "./kernel" sub-system, we can meet many such kinds of things).
Thanks.
Quoted 5 lines
Thanks,
//richard
Signature · 1 line
Chen Gang
Re: [PATCH] arm/arm64: remove atomic_clear_mask() in "include/asm/atomic.h"
Quoted 28 lines · Chen Gang
Quoted 13 lines · Richard Weinberger
Am 11.10.2013 14:28, schrieb Will Deacon:
Quoted 12 lines · Richard Weinberger
Quoted 10 lines · Chen Gang
Quoted 5 lines
In current kernel wide source code, except other architectures, only s390 scsi drivers use
atomic_clear_mask(), and arm/arm64 need not support s390 drivers.So remove
atomic_clear_mask()from "arm[64]/include/asm/atomic.h".Is it really worth removing such a primitive?
If someone needs it later he has to implement it from scratch and introduces bugs...Quoted 6 lines
Quoted 3 lines
The version we have (on ARM64 anyway) already has bugs. Given the choice between fixing code that has no callers and simply removing it, I'd go for the latter.
Yeah, if it's broken and has no real users, send it to hell. :)
OK, thanks.
Hmm... at least, the original API definition is not well enough: "need use 'unsigned int' and '
atomic_t' instead of 'unsigned long' for the type of parameters".
Quoted 7 lines
But can we say "under arm64, it must be a bug"? (although I agree it is very easy to let callers miss using it -- then may cause issue).
In my opinion, it belongs to "API definition issue" not implementation
bug: "if all callers are carefully enough, it will not make issues" (e.g. in "./kernel" sub-system, we can meet many such kinds of things).
For "./kernel" sub-system, it really it is, if necessary, I can provide 3 samples. ;-)
Quoted 10 lines
Thanks.
Quoted 5 lines
Thanks,
//richard
Signature · 1 line
Chen Gang
Re: [PATCH] arm/arm64: remove atomic_clear_mask() in "include/asm/atomic.h"
In reply to Chen GangQuoted 5 lines · Chen Gang
In current kernel wide source code, except other architectures, only s390 scsi drivers use
atomic_clear_mask(), and arm/arm64 need not support s390 drivers.So remove
atomic_clear_mask()from "arm[64]/include/asm/atomic.h".
Catalin, are you happy for me to send this via the ARM tree?
Will
Quoted 77 lines
Signed-off-by Chen Gang <[email protected]>--- arch/arm/include/asm/atomic.h | 24 ------------------------ arch/arm64/include/asm/atomic.h | 14 -------------- 2 files changed, 0 insertions(+), 38 deletions(-)arch/arm/include/asm/atomic.h +0
-24@@ -134,21 +134,6 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new) return oldval; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) -{ -unsigned long tmp, tmp2; - - __asm__ __volatile__("@ atomic_clear_mask\n" -"1: ldrex %0, [%3]\n" -" bic %0, %0, %4\n" -" strex %1, %0, [%3]\n" -" teq %1, #0\n" -" bne 1b" - :"=&r" (tmp),"=&r" (tmp2),"+Qo" (*addr) - :"r" (addr),"Ir" (mask) - :"cc" ); -} -#else /* ARM_ARCH_6 */ #ifdef CONFIG_SMP @@ -197,15 +182,6 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new) return ret; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) -{ -unsigned long flags; - -raw_local_irq_save (flags); - *addr &= ~mask; -raw_local_irq_restore (flags); -} -#endif /* __LINUX_ARM_ARCH__ */ #define atomic_xchg (v, new) (xchg(&((v)->counter), new))arch/arm64/include/asm/atomic.h +0
-14@@ -126,20 +126,6 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)return oldval; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) -{ -unsigned long tmp, tmp2; - - asmvolatile ("// atomic_clear_mask\n" -"1: ldxr %0, %2\n" -" bic %0, %0, %3\n" -" stxr %w1, %0, %2\n" -" cbnz %w1, 1b" - :"=&r" (tmp),"=&r" (tmp2),"+Q" (*addr) - :"Ir" (mask) - :"cc" ); -} -#define atomic_xchg (v, new) (xchg(&((v)->counter), new))static inline int __atomic_add_unless (atomic_t *v,int a,int u)Signature · 1 line
1.7.7.6
Re: [PATCH] arm/arm64: remove atomic_clear_mask() in "include/asm/atomic.h"
Quoted 9 lines · Will Deacon
Quoted 5 lines · Chen Gang
In current kernel wide source code, except other architectures, only s390 scsi drivers use
atomic_clear_mask(), and arm/arm64 need not support s390 drivers.So remove
atomic_clear_mask()from "arm[64]/include/asm/atomic.h".Acked-by Will Deacon <[email protected]>
Thank you for your whole work.
Quoted 4 lines
Catalin, are you happy for me to send this via the ARM tree?
Will
Thanks.
--
Chen Gang
Quoted 79 lines
Quoted 77 lines
Signed-off-by Chen Gang <[email protected]>--- arch/arm/include/asm/atomic.h | 24 ------------------------ arch/arm64/include/asm/atomic.h | 14 -------------- 2 files changed, 0 insertions(+), 38 deletions(-)arch/arm/include/asm/atomic.h +0
-24@@ -134,21 +134,6 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new) return oldval; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) -{ -unsigned long tmp, tmp2; - - __asm__ __volatile__("@ atomic_clear_mask\n" -"1: ldrex %0, [%3]\n" -" bic %0, %0, %4\n" -" strex %1, %0, [%3]\n" -" teq %1, #0\n" -" bne 1b" - :"=&r" (tmp),"=&r" (tmp2),"+Qo" (*addr) - :"r" (addr),"Ir" (mask) - :"cc" ); -} -#else /* ARM_ARCH_6 */ #ifdef CONFIG_SMP @@ -197,15 +182,6 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new) return ret; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) -{ -unsigned long flags; - -raw_local_irq_save (flags); - *addr &= ~mask; -raw_local_irq_restore (flags); -} -#endif /* __LINUX_ARM_ARCH__ */ #define atomic_xchg (v, new) (xchg(&((v)->counter), new))arch/arm64/include/asm/atomic.h +0
-14@@ -126,20 +126,6 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)return oldval; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) -{ -unsigned long tmp, tmp2; - - asmvolatile ("// atomic_clear_mask\n" -"1: ldxr %0, %2\n" -" bic %0, %0, %3\n" -" stxr %w1, %0, %2\n" -" cbnz %w1, 1b" - :"=&r" (tmp),"=&r" (tmp2),"+Q" (*addr) - :"Ir" (mask) - :"cc" ); -} -#define atomic_xchg (v, new) (xchg(&((v)->counter), new))static inline int __atomic_add_unless (atomic_t *v,int a,int u)Signature · 1 line
1.7.7.6
Signature · 1 line
Chen Gang
Catalin Marinas
maintainerRe: [PATCH] arm/arm64: remove atomic_clear_mask() in "include/asm/atomic.h"
In reply to Will DeaconQuoted 10 lines · Will Deacon
Quoted 5 lines · Chen Gang
In current kernel wide source code, except other architectures, only s390 scsi drivers use
atomic_clear_mask(), and arm/arm64 need not support s390 drivers.So remove
atomic_clear_mask()from "arm[64]/include/asm/atomic.h".Acked-by Will Deacon <[email protected]>Catalin, are you happy for me to send this via the ARM tree?
Fine by me.
Catalin
PATCH 1/1 arm/arm64: remove atomic_clear_mask() in "include/asm/atomic.h"
Hello Maintainers:
Are these related patches for "arm[64]/include/asm/atomic.h" OK? If also need me do something, please let me know, and I will/should try.
Thanks.
Quoted 17 lines · Catalin Marinas
Quoted 10 lines · Will Deacon
Quoted 5 lines · Chen Gang
In current kernel wide source code, except other architectures, only s390 scsi drivers use
atomic_clear_mask(), and arm/arm64 need not support s390 drivers.So remove
atomic_clear_mask()from "arm[64]/include/asm/atomic.h".Acked-by Will Deacon <[email protected]>Catalin, are you happy for me to send this via the ARM tree?
Fine by me.
Catalin
Signature · 1 line
Chen Gang
PATCH 1/1 arm/arm64: remove atomic_clear_mask() in "include/asm/atomic.h"
Quoted 4 lines · Chen Gang
Hello Maintainers:
Are these related patches for "arm[64]/include/asm/atomic.h" OK? If also need me do something, please let me know, and I will/should try.
They're sitting in the patch system, so you don't need to do anything else unless there is a merge conflict.
Will
PATCH 1/1 arm/arm64: remove atomic_clear_mask() in "include/asm/atomic.h"
Quoted 7 lines · Will Deacon
Quoted 4 lines · Chen Gang
Quoted 4 lines
Hello Maintainers:
Are these related patches for "arm[64]/include/asm/atomic.h" OK? If also need me do something, please let me know, and I will/should try.
They're sitting in the patch system, so you don't need to do anything else unless there is a merge conflict.
OK, thanks.
And excuse me, I am not quite familiar with our kernel version merging, so send the original redundant mail.
Thanks.
Signature · 1 line
Chen Gang
Re: [PATCH 2/3] arm: include: asm: atomic.h: use 'unsigned int' and 'atomic' instead of 'unsigned long' for atomic_clear_mask()
In reply to Chen GangQuoted 15 lines · Chen Gang
In current kernel wide source, for arm, only s390 scsi drivers use
atomic_clear_mask(), now, s390 itself need use 'unsigned int' and 'atomic_t', so need match s390'satomic_clear_mask().Signed-off-by Chen Gang <[email protected]>--- arch/arm/include/asm/atomic.h | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)arch/arm/include/asm/atomic.h +0
-0
arch/arm/include/asm/atomic.h static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new) · line 139
Quoted 8 lines
arch/arm/include/asm/atomic.h +2
-2@@ -134,9 +134,10 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)return oldval; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) +static inline void atomic_clear_mask (unsigned int mask,atomic_t *ptr) { -unsigned long tmp, tmp2; +unsigned int tmp;
I reckon this should be int (the mask parameter is unsigned, but atomic_t.counter is signed).
Quoted 19 lines
arch/arm/include/asm/atomic.h +3
-2+unsigned long tmp2; __asm__ __volatile__("@ atomic_clear_mask\n" "1: ldrex %0, [%3]\n"@@ -144,8 +145,8 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr) " strex %1, %0, [%3]\n" " teq %1, #0\n" " bne 1b" - : "=&r" (tmp), "=&r" (tmp2), "+Qo" (*addr) - : "r" (addr), "Ir" (mask) + : "=&r" (tmp), "=&r" (tmp2), "+Qo" (ptr->counter) + : "r" (&ptr->counter), "Ir" (mask) : "cc"); }@@ -197,12 +198,12 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)return ret; }
arch/arm/include/asm/atomic.h static inline int atomic_cmpxchg(atomic_t *v, int old, int new) · line 208
Quoted 10 lines
arch/arm/include/asm/atomic.h +2
-2-static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) +static inline void atomic_clear_mask (unsigned int mask,atomic_t *v) {unsigned long flags;raw_local_irq_save (flags); - *addr &= ~mask; + v->counter &= ~mask;raw_local_irq_restore (flags); }
This is now identical to asm-generic/atomic.h. I wonder whether we could just #include that file for the ARMv6 case? You'd need to check the differences carefully.
Finally, I still question the need for the clear_mask function anyway. We don't implement set_mask, and these functions are only used by either other arch code or in drivers that don't work on ARM anyway.
Will
Re: [PATCH 2/3] arm: include: asm: atomic.h: use 'unsigned int' and 'atomic' instead of 'unsigned long' for atomic_clear_mask()
Quoted 19 lines · Will Deacon
Quoted 18 lines · Chen Gang
In current kernel wide source, for arm, only s390 scsi drivers use
atomic_clear_mask(), now, s390 itself need use 'unsigned int' and 'atomic_t', so need match s390'satomic_clear_mask().Signed-off-by Chen Gang <[email protected]>--- arch/arm/include/asm/atomic.h | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)arch/arm/include/asm/atomic.h +0
-0@@ -134,9 +134,10 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)return oldval; }
Quoted 8 lines
arch/arm/include/asm/atomic.h static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new) · line 139
Quoted 5 lines
arch/arm/include/asm/atomic.h +2
-2-static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) +static inline void atomic_clear_mask (unsigned int mask,atomic_t *ptr) { -unsigned long tmp, tmp2; +unsigned int tmp;I reckon this should be int (the mask parameter is unsigned, but atomic_t.counter is signed).
For 'ldrex' and 'strex' (loading/storing instruction), it is really better to match 'atomic_t.counter', but for 'bic' (operating instruction), it is better to match 'mask'.
In my opinion, for signed/unsigned, 'operating' has higher priority than 'loading/storing' (especially for *mask functions, by default, suggest using unsigned).
Commonly, for loading/storing (e.g. 'ldrex', 'strex'), must be sure of bits wide (signed/unsigned will not cause real issues), but for operating, signed/unsigned may cause real issues.
Quoted 25 lines
Quoted 25 lines
arch/arm/include/asm/atomic.h +4
-3+unsigned long tmp2; __asm__ __volatile__("@ atomic_clear_mask\n" "1: ldrex %0, [%3]\n"@@ -144,8 +145,8 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr) " strex %1, %0, [%3]\n" " teq %1, #0\n" " bne 1b" - : "=&r" (tmp), "=&r" (tmp2), "+Qo" (*addr) - : "r" (addr), "Ir" (mask) + : "=&r" (tmp), "=&r" (tmp2), "+Qo" (ptr->counter) + : "r" (&ptr->counter), "Ir" (mask) : "cc"); }@@ -197,12 +198,12 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)return ret; } -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) +static inline void atomic_clear_mask (unsigned int mask,atomic_t *v) {unsigned long flags;
Quoted 10 lines
arch/arm/include/asm/atomic.h static inline int atomic_cmpxchg(atomic_t *v, int old, int new) · line 208
Quoted 5 lines
arch/arm/include/asm/atomic.h +1
-1raw_local_irq_save (flags); - *addr &= ~mask; + v->counter &= ~mask;raw_local_irq_restore (flags); }This is now identical to
asm-generic/atomic.h. I wonder whether we could just #include that file for the ARMv6 case? You'd need to check the differences carefully.
If most of functions for ARMv6 case can use "asm-generic/atomic.h", your idea sounds good to me, although we don't need 'atomic_set_mask' (it is inconsistent with 'atomic_clear_mask' in "asm-generic/atomic.h").
Quoted 4 lines
Finally, I still question the need for the
clear_maskfunction anyway. We don't implementset_mask, and these functions are only used by either other arch code or in drivers that don't work on ARM anyway.
Hmm... can we remove atomic_*_mask() for both arm and arm64?
It seems before get a conclusion, it is necessary to let arm and arm64 pass 'allmodconfig' firstly (and then try to remove these functions to see the compiling result).
I will/should try 'allmodconfig' for them, but excuse me, it needs waiting (I am just trying 'arc' architecture with 'allmodconfig', and already delayed, because I have no enough time resources on it :-( ).
Quoted 3 lines
Will
Thanks.
Signature · 1 line
Chen Gang
Heiko Carstens
AppliedRe: [PATCH 1/3] s390: include: asm: atomic.h: use 'unsigned int' instead of 'unsigned long' for atomic_*_mask()
In reply to Chen GangQuoted 15 lines · Chen Gang
The type of '
v->counter' is always 'int', and related inline assembly code also process 'int', so use 'unsigned int' instead of 'unsigned long' for the 'mask'.Signed-off-by Chen Gang <[email protected]>--- arch/s390/include/asm/atomic.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)arch/s390/include/asm/atomic.h +0
-0
arch/s390/include/asm/atomic.h static inline void atomic_add(int i, atomic_t *v) · line 117
Quoted 6 lines
arch/s390/include/asm/atomic.h +1
-1@@ -113,12 +113,12 @@ static inline void atomic_add(int i, atomic_t *v)#define atomic_dec_return (_v) atomic_sub_return(1, _v)#define atomic_dec_and_test (_v) (atomic_sub_return(1, _v) == 0) -static inline void atomic_clear_mask (unsigned long mask,atomic_t *v) +static inline void atomic_clear_mask (unsigned int mask,atomic_t *v) {
Applied. Thanks!
Re: [PATCH 1/3] s390: include: asm: atomic.h: use 'unsigned int' instead of 'unsigned long' for atomic_*_mask()
Quoted 19 lines · Heiko Carstens
Quoted 18 lines · Chen Gang
The type of '
v->counter' is always 'int', and related inline assembly code also process 'int', so use 'unsigned int' instead of 'unsigned long' for the 'mask'.Signed-off-by Chen Gang <[email protected]>--- arch/s390/include/asm/atomic.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)arch/s390/include/asm/atomic.h +0
-0@@ -113,12 +113,12 @@ static inline void atomic_add(int i, atomic_t *v)#define atomic_dec_return (_v) atomic_sub_return(1, _v)#define atomic_dec_and_test (_v) (atomic_sub_return(1, _v) == 0)
Quoted 8 lines
arch/s390/include/asm/atomic.h static inline void atomic_add(int i, atomic_t *v) · line 117
Quoted 3 lines
arch/s390/include/asm/atomic.h +1
-1-static inline void atomic_clear_mask (unsigned long mask,atomic_t *v) +static inline void atomic_clear_mask (unsigned int mask,atomic_t *v) {Applied. Thanks!
Thank you very much!!
Signature · 1 line
Chen Gang