[openib-general] [PATCH] udapl: PPC64 atomic function additions

Todd Bowman twbowman at gmail.com
Thu Oct 6 10:48:06 PDT 2005


This patch in addition to "PPC64 cpuinfo change" provides udapl support on
PPC64 platform.

Added PPC64 dependent code to dapl_os_atomic_inc, dapl_os_atomic_dec,
dapl_os_atomic_assign and DT_Mdep_GetTimeStamp.
Also added PPC64 to platform checks.

Signed-off-by: Todd Bowman <twbowman at gmail.com>

Index: userspace/dapl/dapl/udapl/linux/dapl_osd.h
===================================================================
--- userspace/dapl/dapl/udapl/linux/dapl_osd.h (revision 3547)
+++ userspace/dapl/dapl/udapl/linux/dapl_osd.h (working copy)
@@ -49,7 +49,7 @@
#error UNDEFINED OS TYPE
#endif /* __linux__ */

-#if !defined (__i386__) && !defined (__ia64__) && !defined(__x86_64__)
+#if !defined (__i386__) && !defined (__ia64__) && !defined(__x86_64__) &&
!defined(__PPC64__)
#error UNDEFINED ARCH
#endif

@@ -78,7 +78,7 @@
#include <sys/socket.h>
#include <ctype.h>

-#ifdef __ia64__
+#if defined(__ia64__) || defined(__PPC64__)
#include <asm/atomic.h>
#include <asm/system.h>
#endif
@@ -162,6 +160,8 @@
IA64_FETCHADD (old_value,v,1,4);
#endif

+#elif defined(__PPC64__)
+ atomic_inc((atomic_t *) v);
#else /* !__ia64__ */
__asm__ __volatile__ (
"lock;" "incl %0"
@@ -190,6 +190,9 @@
IA64_FETCHADD (old_value,v,-1,4);
#endif

+#elif defined (__PPC64__)
+ atomic_dec((atomic_t *)v);
+
#else /* !__ia64__ */
__asm__ __volatile__ (
"lock;" "decl %0"
@@ -230,6 +233,22 @@

current_value = ia64_cmpxchg("acq",v,match_value,new_value,4);

+#elif defined(__PPC64__)
+
+ __asm__ __volatile__ (
+ EIEIO_ON_SMP
+"1: lwarx %0,0,%2 # __cmpxchg_u64\n\
+ cmpd 0,%0,%3\n\
+ bne- 2f\n\
+ stwcx. %4,0,%2\n\
+ bne- 1b"
+ ISYNC_ON_SMP
+ "\n\
+2:"
+ : "=&r" (current_value), "=m" (*v)
+ : "r" (v), "r" (match_value), "r" (new_value), "m" (*v)
+ : "cc", "memory");
+
#else
__asm__ __volatile__ (
"lock; cmpxchgl %1, %2"
Index: userspace/dapl/test/dapltest/mdep/linux/dapl_mdep_user.h
===================================================================
--- userspace/dapl/test/dapltest/mdep/linux/dapl_mdep_user.h (revision 3547)
+++ userspace/dapl/test/dapltest/mdep/linux/dapl_mdep_user.h (working copy)
@@ -128,10 +128,20 @@

x = get_cycles ();
return x;
+#else
+#if defined(__PPC64__)
+ unsigned int tbl, tbu0, tbu1;
+ do {
+ __asm__ __volatile__ ("mftbu %0" : "=r"(tbu0));
+ __asm__ __volatile__ ("mftb %0" : "=r"(tbl));
+ __asm__ __volatile__ ("mftbu %0" : "=r"(tbu1));
+ } while (tbu0 != tbu1);
+ return (((unsigned long long)tbu0) << 32) | tbl;
#else
-#error "Non-Pentium Linux - unimplemented"
+#error "Non-Pentium and Non-PPC Linux - unimplemented"
#endif
#endif
+#endif
}

/*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20051006/90243b61/attachment.html>


More information about the general mailing list