[ofa-general] Re: [PATCH] uDAPL PPC fixes for dapl_osd.h

Arlin Davis ardavis at ichips.intel.com
Tue Oct 2 16:06:53 PDT 2007


Anton Blanchard wrote:
> Hi Arlin,
> 
> I have a patch to allow PowerPC to compile dapl as both 32 and 64bit.
> This is for OFED1.2, if there are issues I can rebase to mainline.
> 
>  

Thanks, committed for 1.2 and 2.0.

> --
> 
> Fix dapl to compile as both 32bit and 64bit on PowerPC. Instead of using
> the kernel atomic routines, code them explicitely like x86 does.
> 
> Signed-off-by: Anton Blanchard <anton at samba.org>
> ---
> 
> --- ./dapl/udapl/linux/dapl_osd.h.orig	2007-06-23 18:24:09.000000000 -0500
> +++ ./dapl/udapl/linux/dapl_osd.h	2007-06-23 18:38:01.000000000 -0500
> @@ -49,7 +49,7 @@
>  #error UNDEFINED OS TYPE
>  #endif /* __linux__ */
>  
> -#if !defined (__i386__) && !defined (__ia64__) && !defined(__x86_64__) && !defined(__PPC64__)
> +#if !defined (__i386__) && !defined (__ia64__) && !defined(__x86_64__) && !defined(__PPC__) && !defined(__PPC64__)
>  #error UNDEFINED ARCH
>  #endif
>  
> @@ -78,12 +78,9 @@
>  #include <sys/socket.h>
>  #include <ctype.h>
>  
> -#if !defined(REDHAT_EL5) && (defined(__ia64__) || defined(__PPC64__))
> +#if !defined(REDHAT_EL5) && (defined(__ia64__))
>  #include <asm/atomic.h>
>  #endif
> -#if defined(__PPC64__)
> -#include <asm/system.h>
> -#endif
>  
>  /* Useful debug definitions */
>  #ifndef STATIC
> @@ -163,8 +160,17 @@
>  #else
>  	IA64_FETCHADD(old_value,v,1,4);
>  #endif
> -#elif defined(__PPC64__)
> -   atomic_inc((atomic_t *) v);
> +#elif defined(__PPC__) || defined(__PPC64__)
> +	int tmp;
> +
> +    __asm__ __volatile__(
> +	"1:	lwarx	%0,0,%2\n\
> +		addic	%0,%0,1\n\
> +		stwcx.	%0,0,%2\n\
> +		bne-	1b"
> +	: "=&r" (tmp), "+m" (v)
> +	: "r" (&v)
> +	: "cc");
>  #else  /* !__ia64__ */
>      __asm__ __volatile__ (
>  	"lock;" "incl %0"
> @@ -193,9 +199,17 @@
>  #else
>  	IA64_FETCHADD(old_value,v,-1,4);
>  #endif
> -#elif defined (__PPC64__)
> -   atomic_dec((atomic_t *)v);
> +#elif defined (__PPC__) || defined(__PPC64__)
> +	int tmp;
>  
> +    __asm__ __volatile__(
> +	"1:	lwarx	%0,0,%2\n\
> +		addic	%0,%0,-1\n\
> +		stwcx.	%0,0,%2\n\
> +		bne-	1b"
> +	: "=&r" (tmp), "+m" (v)
> +	: "r" (&v)
> +	: "cc");
>  #else  /* !__ia64__ */
>      __asm__ __volatile__ (
>  	"lock;" "decl %0"
> @@ -240,7 +254,7 @@
>  #else
>      current_value = ia64_cmpxchg(acq,v,match_value,new_value,4);
>  #endif /* __ia64__ */
> -#elif defined(__PPC64__)
> +#elif defined(__PPC__) || defined(__PPC64__)
>          __asm__ __volatile__ (
>  "       lwsync\n\
>  1:      lwarx   %0,0,%2         # __cmpxchg_u32\n\
> --- ./test/dapltest/mdep/linux/dapl_mdep_user.h.orig	2007-06-23 18:26:45.000000000 -0500
> +++ ./test/dapltest/mdep/linux/dapl_mdep_user.h	2007-06-23 18:43:24.000000000 -0500
> @@ -124,7 +124,7 @@
>      __asm__ __volatile__ ("mov %0=ar.itc" : "=r"(ret));
>      return ret;
>  #else
> -#if defined(__PPC64__)
> +#if defined(__PPC__) || defined(__PPC64__)
>      unsigned int tbl, tbu0, tbu1;
>      do {
>           __asm__ __volatile__ ("mftbu %0" : "=r"(tbu0));
> --- ./test/dapltest/mdep/linux/dapl_mdep_user.c.orig	2007-06-24 02:56:12.000000000 -0500
> +++ ./test/dapltest/mdep/linux/dapl_mdep_user.c	2007-06-24 02:56:27.000000000 -0500
> @@ -186,7 +186,7 @@
>      void )
>  {
>  #define DT_CPU_MHZ_BUFFER_SIZE 	128
> -#if defined (__PPC64__)
> +#if defined (__PPC__) || defined (__PPC64__)
>  #define DT_CPU_MHZ_MHZ          "clock"
>  #else
>  #define DT_CPU_MHZ_MHZ 		"cpu MHz"
> 



More information about the general mailing list