* [PATCH] spinlock: don't use deprecated barriers on ARMv7
@ 2010-01-13 15:45 Rabin Vincent
2010-01-24 20:42 ` Russell King - ARM Linux
0 siblings, 1 reply; 5+ messages in thread
From: Rabin Vincent @ 2010-01-13 15:45 UTC (permalink / raw)
To: linux-arm-kernel
On ARMv7, the use of the cp15 operations for barriers is deprecated in
favour of the isb, dsb, and dmb instructions. Change the locking
functions to use the appropriate type of dsb for the architecture being
built for.
Signed-off-by: Rabin Vincent <rabin@rab.in>
---
arch/arm/include/asm/spinlock.h | 20 +++++++-------------
arch/arm/include/asm/system.h | 8 ++++++++
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/arch/arm/include/asm/spinlock.h b/arch/arm/include/asm/spinlock.h
index c91c64c..9ed1064 100644
--- a/arch/arm/include/asm/spinlock.h
+++ b/arch/arm/include/asm/spinlock.h
@@ -69,13 +69,11 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock)
__asm__ __volatile__(
" str %1, [%0]\n"
-#ifdef CONFIG_CPU_32v6K
-" mcr p15, 0, %1, c7, c10, 4\n" /* DSB */
-" sev"
-#endif
:
: "r" (&lock->lock), "r" (0)
: "cc");
+
+ smp_sev();
}
/*
@@ -132,13 +130,11 @@ static inline void arch_write_unlock(arch_rwlock_t *rw)
__asm__ __volatile__(
"str %1, [%0]\n"
-#ifdef CONFIG_CPU_32v6K
-" mcr p15, 0, %1, c7, c10, 4\n" /* DSB */
-" sev\n"
-#endif
:
: "r" (&rw->lock), "r" (0)
: "cc");
+
+ smp_sev();
}
/* write_can_lock - would write_trylock() succeed? */
@@ -188,14 +184,12 @@ static inline void arch_read_unlock(arch_rwlock_t *rw)
" strex %1, %0, [%2]\n"
" teq %1, #0\n"
" bne 1b"
-#ifdef CONFIG_CPU_32v6K
-"\n cmp %0, #0\n"
-" mcreq p15, 0, %0, c7, c10, 4\n"
-" seveq"
-#endif
: "=&r" (tmp), "=&r" (tmp2)
: "r" (&rw->lock)
: "cc");
+
+ if (tmp == 0)
+ smp_sev();
}
static inline int arch_read_trylock(arch_rwlock_t *rw)
diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 058e7e9..0b371ba 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -164,6 +164,14 @@ extern unsigned int user_debug;
#define set_mb(var, value) do { var = value; smp_mb(); } while (0)
#define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");
+static inline void smp_sev(void)
+{
+#if defined(CONFIG_SMP) && defined(CONFIG_CPU_32v6K)
+ dsb();
+ __asm__ __volatile__ ("sev" : : : "memory");
+#endif
+}
+
extern unsigned long cr_no_alignment; /* defined in entry-armv.S */
extern unsigned long cr_alignment; /* defined in entry-armv.S */
--
1.6.5
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH] spinlock: don't use deprecated barriers on ARMv7
2010-01-13 15:45 [PATCH] spinlock: don't use deprecated barriers on ARMv7 Rabin Vincent
@ 2010-01-24 20:42 ` Russell King - ARM Linux
2010-01-25 17:50 ` Rabin Vincent
0 siblings, 1 reply; 5+ messages in thread
From: Russell King - ARM Linux @ 2010-01-24 20:42 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jan 13, 2010 at 09:15:36PM +0530, Rabin Vincent wrote:
> On ARMv7, the use of the cp15 operations for barriers is deprecated in
> favour of the isb, dsb, and dmb instructions. Change the locking
> functions to use the appropriate type of dsb for the architecture being
> built for.
Umm...
> diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
> index 058e7e9..0b371ba 100644
> --- a/arch/arm/include/asm/system.h
> +++ b/arch/arm/include/asm/system.h
> @@ -164,6 +164,14 @@ extern unsigned int user_debug;
> #define set_mb(var, value) do { var = value; smp_mb(); } while (0)
> #define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");
>
> +static inline void smp_sev(void)
> +{
> +#if defined(CONFIG_SMP) && defined(CONFIG_CPU_32v6K)
> + dsb();
> + __asm__ __volatile__ ("sev" : : : "memory");
Why are you introducing a compiler memory barrier where there was none
before?
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH] spinlock: don't use deprecated barriers on ARMv7
2010-01-24 20:42 ` Russell King - ARM Linux
@ 2010-01-25 17:50 ` Rabin Vincent
2010-01-25 18:03 ` Russell King - ARM Linux
0 siblings, 1 reply; 5+ messages in thread
From: Rabin Vincent @ 2010-01-25 17:50 UTC (permalink / raw)
To: linux-arm-kernel
On Sun, Jan 24, 2010 at 08:42:33PM +0000, Russell King - ARM Linux wrote:
> > +static inline void smp_sev(void)
> > +{
> > +#if defined(CONFIG_SMP) && defined(CONFIG_CPU_32v6K)
> > + dsb();
> > + __asm__ __volatile__ ("sev" : : : "memory");
>
> Why are you introducing a compiler memory barrier where there was none
> before?
I've removed it (and the additional memory barrier from the dsb()
helper) in the updated patch below. I've also moved the helper into
spinlock.h itself, to avoid unnecessarily cluttering system.h:
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH] spinlock: don't use deprecated barriers on ARMv7
2010-01-25 17:50 ` Rabin Vincent
@ 2010-01-25 18:03 ` Russell King - ARM Linux
0 siblings, 0 replies; 5+ messages in thread
From: Russell King - ARM Linux @ 2010-01-25 18:03 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Jan 25, 2010 at 11:20:29PM +0530, Rabin Vincent wrote:
> On Sun, Jan 24, 2010 at 08:42:33PM +0000, Russell King - ARM Linux wrote:
> > > +static inline void smp_sev(void)
> > > +{
> > > +#if defined(CONFIG_SMP) && defined(CONFIG_CPU_32v6K)
> > > + dsb();
> > > + __asm__ __volatile__ ("sev" : : : "memory");
> >
> > Why are you introducing a compiler memory barrier where there was none
> > before?
>
> I've removed it (and the additional memory barrier from the dsb()
> helper) in the updated patch below. I've also moved the helper into
> spinlock.h itself, to avoid unnecessarily cluttering system.h:
>
> >From a701fe2c665f9d80aa2c96ae6f312a25ee1136a2 Mon Sep 17 00:00:00 2001
> From: Rabin Vincent <rabin@rab.in>
> Date: Mon, 11 Jan 2010 20:36:26 +0530
> Subject: [PATCH] spinlock: don't use deprecated barriers on ARMv7
>
> On ARMv7, the use of the cp15 operations for barriers is deprecated in
> favour of the isb, dsb, and dmb instructions. Change the locking
> functions to use the appropriate type of dsb for the architecture being
> built for.
This version looks better, thanks. Care to send it to the patch system?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] spinlock: don't use deprecated barriers on ARMv7
@ 2010-01-11 15:06 Rabin Vincent
0 siblings, 0 replies; 5+ messages in thread
From: Rabin Vincent @ 2010-01-11 15:06 UTC (permalink / raw)
To: linux-arm-kernel
On ARMv7, the use of the cp15 operations for barriers is deprecated in
favour of the isb, dsb, and dmb instructions. Change the locking
functions to use the appropriate type of dsb for the architecture being
built for.
Signed-off-by: Rabin Vincent <rabin@rab.in>
---
arch/arm/include/asm/spinlock.h | 36 +++++++++++++++++++++++-------------
1 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/arch/arm/include/asm/spinlock.h b/arch/arm/include/asm/spinlock.h
index c91c64c..17eb355 100644
--- a/arch/arm/include/asm/spinlock.h
+++ b/arch/arm/include/asm/spinlock.h
@@ -5,6 +5,22 @@
#error SMP not supported on pre-ARMv6 CPUs
#endif
+static inline void dsb_sev(void)
+{
+#if __LINUX_ARM_ARCH__ >= 7
+ __asm__ __volatile__ (
+ "dsb\n"
+ "sev"
+ );
+#elif defined(CONFIG_CPU_32v6K)
+ __asm__ __volatile__ (
+ "mcr p15, 0, %0, c7, c10, 4\n"
+ "sev"
+ : : "r" (0)
+ );
+#endif
+}
+
/*
* ARMv6 Spin-locking.
*
@@ -69,13 +85,11 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock)
__asm__ __volatile__(
" str %1, [%0]\n"
-#ifdef CONFIG_CPU_32v6K
-" mcr p15, 0, %1, c7, c10, 4\n" /* DSB */
-" sev"
-#endif
:
: "r" (&lock->lock), "r" (0)
: "cc");
+
+ dsb_sev();
}
/*
@@ -132,13 +146,11 @@ static inline void arch_write_unlock(arch_rwlock_t *rw)
__asm__ __volatile__(
"str %1, [%0]\n"
-#ifdef CONFIG_CPU_32v6K
-" mcr p15, 0, %1, c7, c10, 4\n" /* DSB */
-" sev\n"
-#endif
:
: "r" (&rw->lock), "r" (0)
: "cc");
+
+ dsb_sev();
}
/* write_can_lock - would write_trylock() succeed? */
@@ -188,14 +200,12 @@ static inline void arch_read_unlock(arch_rwlock_t *rw)
" strex %1, %0, [%2]\n"
" teq %1, #0\n"
" bne 1b"
-#ifdef CONFIG_CPU_32v6K
-"\n cmp %0, #0\n"
-" mcreq p15, 0, %0, c7, c10, 4\n"
-" seveq"
-#endif
: "=&r" (tmp), "=&r" (tmp2)
: "r" (&rw->lock)
: "cc");
+
+ if (tmp == 0)
+ dsb_sev();
}
static inline int arch_read_trylock(arch_rwlock_t *rw)
--
1.6.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-01-25 18:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-13 15:45 [PATCH] spinlock: don't use deprecated barriers on ARMv7 Rabin Vincent
2010-01-24 20:42 ` Russell King - ARM Linux
2010-01-25 17:50 ` Rabin Vincent
2010-01-25 18:03 ` Russell King - ARM Linux
-- strict thread matches above, loose matches on Subject: below --
2010-01-11 15:06 Rabin Vincent
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).