Hi Keir, here is the resend based on your feedback. The Linux patch
applies with small offsets to the sparse tree. The Xen patch follows
that.
Use explicit accessors to handle unusually-sized atomic operations in
grant table code.
Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx>
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 Fri Jun 23 15:57:39 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 = synch_cmpxchg_subword(&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 (synch_cmpxchg_subword(&shared[ref].flags, flags, 0) ==
flags)
return 0;
cpu_relax();
}
diff -r 6f3d44537b76 include/asm-i386/mach-xen/asm/synch_bitops.h
--- a/include/asm-i386/mach-xen/asm/synch_bitops.h Fri Jun 16 16:07:38
2006 -0500
+++ b/include/asm-i386/mach-xen/asm/synch_bitops.h Fri Jun 23 15:57:39
2006 -0500
@@ -138,4 +138,6 @@ static __inline__ int synch_var_test_bit
synch_const_test_bit((nr),(addr)) : \
synch_var_test_bit((nr),(addr)))
+#define synch_cmpxchg_subword synch_cmpxchg
+
#endif /* __XEN_SYNCH_BITOPS_H__ */
diff -r 6f3d44537b76 include/asm-ia64/synch_bitops.h
--- a/include/asm-ia64/synch_bitops.h Fri Jun 16 16:07:38 2006 -0500
+++ b/include/asm-ia64/synch_bitops.h Fri Jun 23 15:57:39 2006 -0500
@@ -58,4 +58,6 @@ static __inline__ int synch_var_test_bit
synch_const_test_bit((nr),(addr)) : \
synch_var_test_bit((nr),(addr)))
+#define synch_cmpxchg_subword synch_cmpxchg
+
#endif /* __XEN_SYNCH_BITOPS_H__ */
The Xen patch:
diff -r e06866a6e2b7 xen/common/grant_table.c
--- a/xen/common/grant_table.c Thu Jun 29 13:10:42 2006 -0400
+++ b/xen/common/grant_table.c Thu Jun 29 15:27:06 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);
+ gnttab_clear_flag(_GTF_writing, &sha->flags);
if ( !act->pin )
- clear_bit(_GTF_reading, &sha->flags);
+ gnttab_clear_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);
+ gnttab_clear_flag(_GTF_writing, &sha->flags);
if ( act->pin == 0 )
- clear_bit(_GTF_reading, &sha->flags);
+ gnttab_clear_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);
+ gnttab_clear_flag(_GTF_writing, &sha->flags);
}
if ( act->pin == 0 )
- clear_bit(_GTF_reading, &sha->flags);
+ gnttab_clear_flag(_GTF_reading, &sha->flags);
spin_unlock(&rd->grant_table->lock);
diff -r e06866a6e2b7 xen/include/asm-ia64/grant_table.h
--- a/xen/include/asm-ia64/grant_table.h Thu Jun 29 13:10:42 2006 -0400
+++ b/xen/include/asm-ia64/grant_table.h Thu Jun 29 15:27:06 2006 -0500
@@ -55,4 +55,9 @@ void guest_physmap_add_page(struct domai
#define gnttab_log_dirty(d, f) ((void)0)
+static inline void gnttab_clear_flag(unsigned long nr, uint16_t *addr)
+{
+ clear_bit(nr, addr);
+}
+
#endif /* __ASM_GRANT_TABLE_H__ */
diff -r e06866a6e2b7 xen/include/asm-x86/grant_table.h
--- a/xen/include/asm-x86/grant_table.h Thu Jun 29 13:10:42 2006 -0400
+++ b/xen/include/asm-x86/grant_table.h Thu Jun 29 15:27:06 2006 -0500
@@ -33,4 +33,9 @@ int destroy_grant_host_mapping(
#define gnttab_log_dirty(d, f) mark_dirty((d), (f))
+static inline void gnttab_clear_flag(unsigned long nr, uint16_t *addr)
+{
+ clear_bit(nr, addr);
+}
+
#endif /* __ASM_GRANT_TABLE_H__ */
--
Hollis Blanchard
IBM Linux Technology Center
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|