ia64/xen-unstable

changeset 5391:11dce3390a66

bitkeeper revision 1.1696 (42a81fe89VPLawDxu2WTiKLZH-Br3Q)

Make sure the grant table stuff uses locked cmpxchg instructions even when compiled
!CONFIG_SMP.

Signed-off-by: Steven Smith <sos22@cam.ac.uk>
author sos22@douglas.cl.cam.ac.uk
date Thu Jun 09 10:54:32 2005 +0000 (2005-06-09)
parents 1c2fe32ca700
children d58565963ee7
files linux-2.6.11-xen-sparse/arch/xen/kernel/gnttab.c linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/synch_bitops.h
line diff
     1.1 --- a/linux-2.6.11-xen-sparse/arch/xen/kernel/gnttab.c	Thu Jun 09 09:41:04 2005 +0000
     1.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/kernel/gnttab.c	Thu Jun 09 10:54:32 2005 +0000
     1.3 @@ -19,6 +19,7 @@
     1.4  #include <asm-xen/xen_proc.h>
     1.5  #include <asm-xen/linux-public/privcmd.h>
     1.6  #include <asm-xen/gnttab.h>
     1.7 +#include <asm/synch_bitops.h>
     1.8  
     1.9  #if 1
    1.10  #define ASSERT(_p) \
    1.11 @@ -125,7 +126,7 @@ gnttab_end_foreign_access( grant_ref_t r
    1.12          if ( (flags = nflags) & (GTF_reading|GTF_writing) )
    1.13              printk(KERN_ALERT "WARNING: g.e. still in use!\n");
    1.14      }
    1.15 -    while ( (nflags = cmpxchg(&shared[ref].flags, flags, 0)) != flags );
    1.16 +    while ( (nflags = synch_cmpxchg(&shared[ref].flags, flags, 0)) != flags );
    1.17  
    1.18      put_free_entry(ref);
    1.19  }
    1.20 @@ -172,7 +173,7 @@ gnttab_end_foreign_transfer(
    1.21       * Otherwise invalidate the grant entry against future use.
    1.22       */
    1.23      if ( likely(flags != GTF_accept_transfer) ||
    1.24 -         (cmpxchg(&shared[ref].flags, flags, 0) != GTF_accept_transfer) )
    1.25 +         (synch_cmpxchg(&shared[ref].flags, flags, 0) != GTF_accept_transfer) )
    1.26          while ( unlikely((frame = shared[ref].frame) == 0) )
    1.27              cpu_relax();
    1.28  
     2.1 --- a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/synch_bitops.h	Thu Jun 09 09:41:04 2005 +0000
     2.2 +++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/synch_bitops.h	Thu Jun 09 10:54:32 2005 +0000
     2.3 @@ -60,6 +60,46 @@ static __inline__ int synch_test_and_cha
     2.4      return oldbit;
     2.5  }
     2.6  
     2.7 +struct __synch_xchg_dummy { unsigned long a[100]; };
     2.8 +#define __synch_xg(x) ((struct __synch_xchg_dummy *)(x))
     2.9 +
    2.10 +#define synch_cmpxchg(ptr, old, new) \
    2.11 +((__typeof__(*(ptr)))__synch_cmpxchg((ptr),\
    2.12 +                                     (unsigned long)(old), \
    2.13 +                                     (unsigned long)(new), \
    2.14 +                                     sizeof(*(ptr))))
    2.15 +
    2.16 +static inline unsigned long __synch_cmpxchg(volatile void *ptr,
    2.17 +					    unsigned long old,
    2.18 +					    unsigned long new, int size)
    2.19 +{
    2.20 +	unsigned long prev;
    2.21 +	switch (size) {
    2.22 +	case 1:
    2.23 +		__asm__ __volatile__("lock; cmpxchgb %b1,%2"
    2.24 +				     : "=a"(prev)
    2.25 +				     : "q"(new), "m"(*__synch_xg(ptr)),
    2.26 +				       "0"(old)
    2.27 +				     : "memory");
    2.28 +		return prev;
    2.29 +	case 2:
    2.30 +		__asm__ __volatile__("lock; cmpxchgw %w1,%2"
    2.31 +				     : "=a"(prev)
    2.32 +				     : "q"(new), "m"(*__synch_xg(ptr)),
    2.33 +				       "0"(old)
    2.34 +				     : "memory");
    2.35 +		return prev;
    2.36 +	case 4:
    2.37 +		__asm__ __volatile__("lock; cmpxchgl %1,%2"
    2.38 +				     : "=a"(prev)
    2.39 +				     : "q"(new), "m"(*__synch_xg(ptr)),
    2.40 +				       "0"(old)
    2.41 +				     : "memory");
    2.42 +		return prev;
    2.43 +	}
    2.44 +	return old;
    2.45 +}
    2.46 +
    2.47  static __inline__ int synch_const_test_bit(int nr, const volatile void * addr)
    2.48  {
    2.49      return ((1UL << (nr & 31)) &