WARNING - OLD ARCHIVES

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/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ppc-devel

[XenPPC] [RFC] fix stupid grant table flags

To: xen-ppc-devel <xen-ppc-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [XenPPC] [RFC] fix stupid grant table flags
From: Hollis Blanchard <hollisb@xxxxxxxxxx>
Date: Wed, 21 Jun 2006 13:49:11 -0500
Delivery-date: Wed, 21 Jun 2006 11:48:46 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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
Sender: xen-ppc-devel-bounces@xxxxxxxxxxxxxxxxxxx
The final issue before our upstream merge is sorting out the cmpxchg on
struct grant_entry->flags, which is a 16-bit quantity (and our atomic
instructions only operate on 4/8 byte quanities).

Since it's part of a larger structure, it's safe to do the larger store,
so these patches, just like the evtchn_upcall_pending patch, should
work. I think the structure alignment will also work out...?

diff -r ab08d443113d xen/common/grant_table.c
--- a/xen/common/grant_table.c  Wed Jun 21 13:36:49 2006 -0500
+++ b/xen/common/grant_table.c  Wed Jun 21 13:42:23 2006 -0500
@@ -287,10 +287,10 @@ __gnttab_map_grant_ref(
 
     if ( !(op->flags & GNTMAP_readonly) &&
          !(act->pin & (GNTPIN_hstw_mask|GNTPIN_devw_mask)) )
-        clear_bit(_GTF_writing, &sha->flags);
+        clear_entry_flag(_GTF_writing, &sha->flags);
 
     if ( !act->pin )
-        clear_bit(_GTF_reading, &sha->flags);
+        clear_entry_flag(_GTF_reading, &sha->flags);
 
  unlock_out:
     spin_unlock(&rd->grant_table->lock);
@@ -425,10 +425,10 @@ __gnttab_unmap_grant_ref(
 
     if ( ((act->pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask)) == 0) &&
          !(flags & GNTMAP_readonly) )
-        clear_bit(_GTF_writing, &sha->flags);
+        clear_entry_flag(_GTF_writing, &sha->flags);
 
     if ( act->pin == 0 )
-        clear_bit(_GTF_reading, &sha->flags);
+        clear_entry_flag(_GTF_reading, &sha->flags);
 
  unmap_out:
     op->status = rc;
@@ -889,11 +889,11 @@ gnttab_release_mappings(
             }
 
             if ( (act->pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask)) == 0 )
-                clear_bit(_GTF_writing, &sha->flags);
+                clear_entry_flag(_GTF_writing, &sha->flags);
         }
 
         if ( act->pin == 0 )
-            clear_bit(_GTF_reading, &sha->flags);
+            clear_entry_flag(_GTF_reading, &sha->flags);
 
         spin_unlock(&rd->grant_table->lock);
 
diff -r ab08d443113d xen/include/asm-ppc/grant_table.h
--- a/xen/include/asm-ppc/grant_table.h Wed Jun 21 13:36:49 2006 -0500
+++ b/xen/include/asm-ppc/grant_table.h Wed Jun 21 13:42:23 2006 -0500
@@ -6,4 +6,6 @@
 #define mark_dirty(d, f) ((void )0)
 #include "../asm-x86/grant_table.h"
 
+#define clear_entry_flag(nr, flags) clear_bit((nr), (int *)(flags));
+
 #endif  /* __ASM_PPC_GRANT_TABLE_H__ */
diff -r ab08d443113d xen/include/public/grant_table.h
--- a/xen/include/public/grant_table.h  Wed Jun 21 13:36:49 2006 -0500
+++ b/xen/include/public/grant_table.h  Wed Jun 21 13:42:23 2006 -0500
@@ -73,11 +73,7 @@
  */
 struct grant_entry {
     /* GTF_xxx: various type and flag information.  [XEN,GST] */
-#if defined(__powerpc__)
-    ulong flags;
-#else
     uint16_t flags;
-#endif
     /* The domain being granted foreign privileges. [GST] */
     domid_t  domid;
     /*



And the Linux patch:

diff -r 6f3d44537b76 drivers/xen/core/gnttab.c
--- a/drivers/xen/core/gnttab.c Fri Jun 16 16:07:38 2006 -0500
+++ b/drivers/xen/core/gnttab.c Wed Jun 21 13:42:56 2006 -0500
@@ -201,7 +201,7 @@ gnttab_end_foreign_access_ref(grant_ref_
                        printk(KERN_ALERT "WARNING: g.e. still in use!\n");
                        return 0;
                }
-       } while ((nflags = synch_cmpxchg(&shared[ref].flags, flags, 0)) !=
+       } while ((nflags = gnttab_cmpxchg_flags(&shared[ref].flags, flags, 0)) 
!=
                 flags);
 
        return 1;
@@ -256,7 +256,7 @@ gnttab_end_foreign_transfer_ref(grant_re
          * reference and return failure (== 0).
          */
        while (!((flags = shared[ref].flags) & GTF_transfer_committed)) {
-               if (synch_cmpxchg(&shared[ref].flags, flags, 0) == flags)
+               if (gnttab_cmpxchg_flags(&shared[ref].flags, flags, 0) == flags)
                        return 0;
                cpu_relax();
        }
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)
diff -r 6f3d44537b76 include/xen/interface/grant_table.h
--- a/include/xen/interface/grant_table.h       Fri Jun 16 16:07:38 2006 -0500
+++ b/include/xen/interface/grant_table.h       Wed Jun 21 13:42:56 2006 -0500
@@ -73,11 +73,7 @@
  */
 struct grant_entry {
     /* GTF_xxx: various type and flag information.  [XEN,GST] */
-#if defined(__powerpc__)
-    ulong flags;
-#else
     uint16_t flags;
-#endif
     /* The domain being granted foreign privileges. [GST] */
     domid_t  domid;
     /*


-- 
Hollis Blanchard
IBM Linux Technology Center


_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ppc-devel

<Prev in Thread] Current Thread [Next in Thread>