diff mbox

[1/6] arm: Fix in-correct barrier usage in SWP{B} emulation

Message ID 1409048930-21598-2-git-send-email-punit.agrawal@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Punit Agrawal Aug. 26, 2014, 10:28 a.m. UTC
According to the ARM ARMv7, explicit barriers are necessary when using
synchronisation primitives such as SWP{B}. The use of these
instructions does not automatically imply a barrier and any ordering
requirements by the software must be explicitly expressed with the use
of suitable barriers.

Based on this, remove the barriers from SWP{B} emulation.

Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 arch/arm/kernel/swp_emulate.c |   15 ---------------
 1 file changed, 15 deletions(-)

Comments

Will Deacon Aug. 26, 2014, 1:04 p.m. UTC | #1
On Tue, Aug 26, 2014 at 11:28:45AM +0100, Punit Agrawal wrote:
> According to the ARM ARMv7, explicit barriers are necessary when using
> synchronisation primitives such as SWP{B}. The use of these
> instructions does not automatically imply a barrier and any ordering
> requirements by the software must be explicitly expressed with the use
> of suitable barriers.
> 
> Based on this, remove the barriers from SWP{B} emulation.
> 
> Cc: Russell King <linux@arm.linux.org.uk>
> Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
> ---
>  arch/arm/kernel/swp_emulate.c |   15 ---------------
>  1 file changed, 15 deletions(-)

Acked-by: Will Deacon <will.deacon@arm.com>

Will
Catalin Marinas Aug. 27, 2014, 4:40 p.m. UTC | #2
On Tue, Aug 26, 2014 at 11:28:45AM +0100, Punit Agrawal wrote:
> According to the ARM ARMv7, explicit barriers are necessary when using
> synchronisation primitives such as SWP{B}. The use of these
> instructions does not automatically imply a barrier and any ordering
> requirements by the software must be explicitly expressed with the use
> of suitable barriers.
> 
> Based on this, remove the barriers from SWP{B} emulation.
> 
> Cc: Russell King <linux@arm.linux.org.uk>
> Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>

This patch is independent to the SWP emulation for arm64 series. Unless
Russell has any objections, you should send it to his patch system (git
send-email to patches@arm.linux.org.uk with "KernelVersion: v3..." after
the commit log; I hope Russell drops the KernelVersion requirement some
day ;)).
Punit Agrawal Aug. 27, 2014, 5:05 p.m. UTC | #3
Catalin Marinas <catalin.marinas@arm.com> writes:

> On Tue, Aug 26, 2014 at 11:28:45AM +0100, Punit Agrawal wrote:
>> According to the ARM ARMv7, explicit barriers are necessary when using
>> synchronisation primitives such as SWP{B}. The use of these
>> instructions does not automatically imply a barrier and any ordering
>> requirements by the software must be explicitly expressed with the use
>> of suitable barriers.
>> 
>> Based on this, remove the barriers from SWP{B} emulation.
>> 
>> Cc: Russell King <linux@arm.linux.org.uk>
>> Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
>
> This patch is independent to the SWP emulation for arm64 series. Unless
> Russell has any objections, you should send it to his patch system (git
> send-email to patches@arm.linux.org.uk with "KernelVersion: v3..." after
> the commit log; I hope Russell drops the KernelVersion requirement some
> day ;)).

OK. Unless I hear any objections, I'll send the patch to Russell's
system tomorrow.
diff mbox

Patch

diff --git a/arch/arm/kernel/swp_emulate.c b/arch/arm/kernel/swp_emulate.c
index b1b8988..74117b5 100644
--- a/arch/arm/kernel/swp_emulate.c
+++ b/arch/arm/kernel/swp_emulate.c
@@ -141,14 +141,6 @@  static int emulate_swpX(unsigned int address, unsigned int *data,
 	while (1) {
 		unsigned long temp;
 
-		/*
-		 * Barrier required between accessing protected resource and
-		 * releasing a lock for it. Legacy code might not have done
-		 * this, and we cannot determine that this is not the case
-		 * being emulated, so insert always.
-		 */
-		smp_mb();
-
 		if (type == TYPE_SWPB)
 			__user_swpb_asm(*data, address, res, temp);
 		else
@@ -161,13 +153,6 @@  static int emulate_swpX(unsigned int address, unsigned int *data,
 	}
 
 	if (res == 0) {
-		/*
-		 * Barrier also required between acquiring a lock for a
-		 * protected resource and accessing the resource. Inserted for
-		 * same reason as above.
-		 */
-		smp_mb();
-
 		if (type == TYPE_SWPB)
 			swpbcounter++;
 		else