This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


Re: [XenPPC] [RFC] fix stupid grant table flags

To: xen-ppc-devel <xen-ppc-devel@xxxxxxxxxxxxxxxxxxx>
Subject: Re: [XenPPC] [RFC] fix stupid grant table flags
From: Hollis Blanchard <hollisb@xxxxxxxxxx>
Date: Thu, 22 Jun 2006 16:27:20 -0500
Delivery-date: Thu, 22 Jun 2006 14:27:06 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <1150915751.26633.19.camel@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-ppc-devel-request@lists.xensource.com?subject=help>
List-id: Xen PPC development <xen-ppc-devel.lists.xensource.com>
List-post: <mailto:xen-ppc-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: IBM Linux Technology Center
References: <1150915751.26633.19.camel@xxxxxxxxxxxxxxxxxxxxx>
Sender: xen-ppc-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Wed, 2006-06-21 at 13:49 -0500, Hollis Blanchard wrote:
> diff -r 6f3d44537b76 include/asm-powerpc/xen/asm/synch_bitops.h
> --- a/include/asm-powerpc/xen/asm/synch_bitops.h        Fri Jun 16 16:07:38 
> 2006 -0500
> +++ b/include/asm-powerpc/xen/asm/synch_bitops.h        Wed Jun 21 13:42:56 
> 2006 -0500
> @@ -6,6 +6,8 @@
>  #ifdef CONFIG_SMP
>  #include <asm/bitops.h>
> +
> +#define gnttab_cmpxchg_flags(ptr,o,n) synch_cmpxchg((int *)(ptr),o,n)
>  #define synch_change_bit(a,b) change_bit(a,b)
>  #define synch_clear_bit(a,b) clear_bit(a,b)

Of course, this won't work. This should be better:

static inline __u16 gnttab_cmpxchg_flags(__u16 *ptr, __u16 o, __u16 n)
        unsigned long *laddr;
        unsigned long old;
        unsigned long new;
        unsigned long shift = (sizeof(long) - sizeof(*ptr)) * 8;

        BUG_ON((long)ptr % sizeof(long));

        laddr = (unsigned long *)ptr;
        old = ((unsigned long)o << shift) | (*laddr & ((1UL<<shift)-1));
        new = ((unsigned long)n << shift) | (*laddr & ((1UL<<shift)-1));

        return synch_cmpxchg(laddr, old, new);

It builds at least, and currently there's no way to test this code
(since the virtual IO drivers aren't quite ready yet). If there aren't
any obvious errors detected by inspection, I'll check these revised
versions in tomorrow.

Hollis Blanchard
IBM Linux Technology Center

Xen-ppc-devel mailing list