linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC] arm: Add for atomic half word exchange
@ 2015-05-19  9:39 Sarbojit Ganguly
  2015-05-19  9:51 ` Arnd Bergmann
  0 siblings, 1 reply; 11+ messages in thread
From: Sarbojit Ganguly @ 2015-05-19  9:39 UTC (permalink / raw)
  To: linux-arm-kernel

Since 16 bit half word exchange was not there and MCS based qspinlock by Waiman's xchg_tail() requires an atomic exchange on a half word,
here is a small modification to __xchg() code.

--- /linux.trees.git/tip/arch/arm/include/asm/cmpxchg.h      2015-05-11     23:36:06.942583615 +0530
+++ arch/arm/include/asm/cmpxchg.h      2015-04-08 18:40:43.276255712 +0530
@@ -2,9 +2,12 @@
 #define __ASM_ARM_CMPXCHG_H

 #include <linux/irqflags.h>
 #include <asm/barrier.h>

 #if defined(CONFIG_CPU_SA1100) || defined(CONFIG_CPU_SA110)
 /*
  * On the StrongARM, "swp" is terminally broken since it bypasses the
@@ -36,7 +39,6 @@
 #endif

        smp_mb();

        switch (size) {
 #if __LINUX_ARM_ARCH__ >= 6
@@ -50,6 +52,23 @@
                        : "r" (x), "r" (ptr)
                        : "memory", "cc");
                break;
+               /* 
+                * halfword exclusive exchange
+                * This is new implementation as qspinlock
+                * wants 16 bit atomic CAS.
+                */
+       case 2:
+               asm volatile("@ __xchg2\n"
+               "1:     ldrexh  %0, [%3]\n"
+               "       strexh  %1, %2, [%3]\n"
+               "       teq     %1, #0\n"
+               "       bne     1b"
+                       : "=&r" (ret), "=&r" (tmp)
+                       : "r" (x), "r" (ptr)
+                       : "memory", "cc");
+               break;
        case 4: 
                asm volatile("@ __xchg4\n"
                "1:     ldrex   %0, [%3]\n"
@@ -94,6 +113,10 @@ 
                break;
 #endif 
        default:
                __bad_xchg(ptr, size), ret = 0;
                break;
        }


Regards,
Sarbojit

^ permalink raw reply	[flat|nested] 11+ messages in thread
* [RFC] arm: Add for atomic half word exchange
@ 2015-05-19 11:20 Sarbojit Ganguly
  2015-05-19 11:42 ` Arnd Bergmann
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Sarbojit Ganguly @ 2015-05-19 11:20 UTC (permalink / raw)
  To: linux-arm-kernel

Yes, I will try to do that. OTOH, I saw that  there was a discussion on removal of bad_xchg() altogether. Perhaps that approach be better than adding this half word exchange?


Regards,
Sarbojit

------- Original Message -------
Sender : Arnd Bergmann<arnd@arndb.de>
Date : May 19, 2015 18:51 (GMT+09:00)
Title : Re: [RFC] arm: Add for atomic half word exchange

On Tuesday 19 May 2015 09:39:33 Sarbojit Ganguly wrote:
> Since 16 bit half word exchange was not there and MCS based qspinlock by Waiman's xchg_tail() requires an atomic exchange on a half word,
> here is a small modification to __xchg() code.

We have discussed a similar patch before, see
https://lkml.org/lkml/2015/2/25/390

>  #if __LINUX_ARM_ARCH__ >= 6
> @@ -50,6 +52,23 @@
>                         : "r" (x), "r" (ptr)
>                         : "memory", "cc");
>                 break;
> +               /* 
> +                * halfword exclusive exchange
> +                * This is new implementation as qspinlock
> +                * wants 16 bit atomic CAS.
> +                */
> +       case 2:
> +               asm volatile("@ __xchg2\n"
> +               "1:     ldrexh  %0, [%3]\n"
> +               "       strexh  %1, %2, [%3]\n"
> +               "       teq     %1, #0\n"
> +               "       bne     1b"
> +                       : "=&r" (ret), "=&r" (tmp)
> +                       : "r" (x), "r" (ptr)
> +                       : "memory", "cc");
> +               break;
>         case 4: 
>                 asm volatile("@ __xchg4\n"
>                 "1:     ldrex   %0, [%3]\n"

Please try to find a way to make this compile when CONFIG_CPU_V6
is set.

Arnd

^ permalink raw reply	[flat|nested] 11+ messages in thread
[parent not found: <1348896100.440561432098574765.JavaMail.weblogic@ep2mlwas07a>]
[parent not found: <1357570181.391771433224164775.JavaMail.weblogic@epmlwas06d>]
[parent not found: <146879519.394951433226103227.JavaMail.weblogic@epmlwas06d>]
[parent not found: <274749765.566061433467033693.JavaMail.weblogic@epmlwas07c>]

end of thread, other threads:[~2015-06-05 12:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-19  9:39 [RFC] arm: Add for atomic half word exchange Sarbojit Ganguly
2015-05-19  9:51 ` Arnd Bergmann
  -- strict thread matches above, loose matches on Subject: below --
2015-05-19 11:20 Sarbojit Ganguly
2015-05-19 11:42 ` Arnd Bergmann
2015-05-19 12:13 ` Russell King - ARM Linux
2015-05-19 12:43 ` Peter Zijlstra
     [not found] <1348896100.440561432098574765.JavaMail.weblogic@ep2mlwas07a>
2015-05-20  6:51 ` Arnd Bergmann
2015-05-20  6:57 ` Peter Zijlstra
     [not found] <1357570181.391771433224164775.JavaMail.weblogic@epmlwas06d>
2015-06-02  6:11 ` Raghavendra K T
     [not found] <146879519.394951433226103227.JavaMail.weblogic@epmlwas06d>
2015-06-02 10:49 ` Arnd Bergmann
     [not found] <274749765.566061433467033693.JavaMail.weblogic@epmlwas07c>
2015-06-05 12:33 ` Arnd Bergmann

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).