Continuation of the following thread
http://lists.xensource.com/archives/html/xen-devel/2007-04/msg00135.html
I haven't compiled the changes for IA64. Consider the changes as indicative.
Added xen_is_contiguous_region
diff -r a839e331f06f linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c Thu Apr 12
13:13:04 2007
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c Fri Apr 13
23:16:15 2007
@@ -327,7 +327,7 @@
dma = swiotlb_map_single(dev, ptr, size, direction);
} else {
dma = virt_to_bus(ptr);
- IOMMU_BUG_ON(range_straddles_page_boundary(ptr, size));
+ IOMMU_BUG_ON(!xen_is_contiguous_region(ptr, size));
IOMMU_BUG_ON(address_needs_mapping(dev, dma));
}
diff -r a839e331f06f linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c Thu Apr 12 13:13:04 2007
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c Fri Apr 13 23:16:15 2007
@@ -479,7 +479,7 @@
* we can safely return the device addr and not worry about bounce
* buffering it.
*/
- if (!range_straddles_page_boundary(ptr, size) &&
+ if (xen_is_contiguous_region(ptr, size) &&
!address_needs_mapping(hwdev, dev_addr))
return dev_addr;
diff -r a839e331f06f linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c
--- a/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c Thu Apr 12 13:13:04 2007
+++ b/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c Fri Apr 13 23:16:15 2007
@@ -440,6 +440,13 @@
}
EXPORT_SYMBOL_GPL(xen_destroy_contiguous_region);
+int xen_is_contiguous_region(void *vaddr, size_t size)
+{
+ return (((((unsigned long)vaddr & ~PAGE_MASK) + size) <= PAGE_SIZE) ||
+ test_bit(__pa(vaddr) >> PAGE_SHIFT, contiguous_bitmap));
+}
+EXPORT_SYMBOL_GPL(xen_is_contiguous_region);
+
#ifdef __i386__
int write_ldt_entry(void *ldt, int entry, __u32 entry_a, __u32 entry_b)
{
diff -r a839e331f06f
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/dma-mapping.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/dma-mapping.h Thu Apr
12 13:13:04 2007
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/dma-mapping.h Fri Apr
13 23:16:15 2007
@@ -25,9 +25,7 @@
static inline int
range_straddles_page_boundary(void *p, size_t size)
{
- extern unsigned long *contiguous_bitmap;
- return (((((unsigned long)p & ~PAGE_MASK) + size) > PAGE_SIZE) &&
- !test_bit(__pa(p) >> PAGE_SHIFT, contiguous_bitmap));
+ return !xen_is_contiguous_region(p, size);
}
#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
diff -r a839e331f06f
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h Thu Apr
12 13:13:04 2007
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h Fri Apr
13 23:16:15 2007
@@ -118,6 +118,7 @@
unsigned long vstart, unsigned int order, unsigned int address_bits);
void xen_destroy_contiguous_region(
unsigned long vstart, unsigned int order);
+int xen_is_contiguous_region(void *vaddr, size_t size);
/* Turn jiffies into Xen system time. */
u64 jiffies_to_st(unsigned long jiffies);
diff -r a839e331f06f linux-2.6-xen-sparse/include/asm-ia64/dma-mapping.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/dma-mapping.h Thu Apr 12
13:13:04 2007
+++ b/linux-2.6-xen-sparse/include/asm-ia64/dma-mapping.h Fri Apr 13
23:16:15 2007
@@ -127,9 +127,7 @@
static inline int
range_straddles_page_boundary(void *p, size_t size)
{
- extern unsigned long *contiguous_bitmap;
- return (((((unsigned long)p & ~PAGE_MASK) + size) > PAGE_SIZE) &&
- !test_bit(__pa(p) >> PAGE_SHIFT, contiguous_bitmap));
+ return !xen_is_contiguous_region(p, size);
}
#endif
diff -r a839e331f06f linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h Thu Apr 12
13:13:04 2007
+++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h Fri Apr 13
23:16:15 2007
@@ -146,7 +146,7 @@
#ifndef CONFIG_VMX_GUEST
int __xen_create_contiguous_region(unsigned long vstart, unsigned int order,
unsigned int address_bits);
-static inline int
+int
xen_create_contiguous_region(unsigned long vstart,
unsigned int order, unsigned int address_bits)
{
@@ -157,14 +157,24 @@
}
return ret;
}
+EXPORT_SYMBOL_GPL(xen_create_contiguous_region);
void __xen_destroy_contiguous_region(unsigned long vstart, unsigned int order);
-static inline void
+void
xen_destroy_contiguous_region(unsigned long vstart, unsigned int order)
{
if (is_running_on_xen())
__xen_destroy_contiguous_region(vstart, order);
}
+EXPORT_SYMBOL_GPL(xen_create_contiguous_region);
+
+int xen_is_contiguous_region(void *vaddr, size_t size)
+{
+ return (((((unsigned long)vaddr & ~PAGE_MASK) + size) <= PAGE_SIZE) ||
+ test_bit(__pa(vaddr) >> PAGE_SHIFT, contiguous_bitmap));
+}
+EXPORT_SYMBOL_GPL(xen_create_contiguous_region);
+
#endif /* !CONFIG_VMX_GUEST */
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|