[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [LINUX] dma: Use swiotlb mask for coherent mappings too



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1166613664 0
# Node ID 301bcae1692814d4261560cb053278ee51bfb1c0
# Parent  3a28be71b667a336c7589cbb7056841f9e42df6a
[LINUX] dma: Use swiotlb mask for coherent mappings too

The recent change to use a default DMA bit width of 30 bits (required
by chips like the b44) only converted the streaming DMA primitives.
The coherent mappings are still hard-coded to 31 bits.  This means
that b44 still doesn't work under Xen.

This patch makes the io_tlb_dma_bits variable global and uses it for
coherent memory mappings.

Thanks to Calvin Webster for providing a machine with a b44 and 2G
of memory I've been able to verify that this finally makes the b44
work under Xen.

Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>

Rename 'io_tlb_dma_bits' to the more correct 'dma_bits'. This also
affects the name of the boot parameter, which is now 'dma_bits='.

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c          |    5 +-
 linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c              |   20 +++++------
 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h |    2 +
 3 files changed, 15 insertions(+), 12 deletions(-)

diff -r 3a28be71b667 -r 301bcae16928 
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       Wed Dec 20 
11:09:56 2006 +0000
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c       Wed Dec 20 
11:21:04 2006 +0000
@@ -15,6 +15,7 @@
 #include <linux/version.h>
 #include <asm/io.h>
 #include <xen/balloon.h>
+#include <asm/swiotlb.h>
 #include <asm/tlbflush.h>
 #include <asm-i386/mach-xen/asm/swiotlb.h>
 #include <asm/bug.h>
@@ -183,8 +184,8 @@ void *dma_alloc_coherent(struct device *
        ret = (void *)vstart;
 
        if (ret != NULL) {
-               /* NB. Hardcode 31 address bits for now: aacraid limitation. */
-               if (xen_create_contiguous_region(vstart, order, 31) != 0) {
+               if (xen_create_contiguous_region(vstart, order,
+                                                dma_bits) != 0) {
                        free_pages(vstart, order);
                        return NULL;
                }
diff -r 3a28be71b667 -r 301bcae16928 
linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c   Wed Dec 20 11:09:56 
2006 +0000
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c   Wed Dec 20 11:21:04 
2006 +0000
@@ -47,8 +47,8 @@ EXPORT_SYMBOL(swiotlb);
  */
 #define IO_TLB_SHIFT 11
 
-/* Width of DMA addresses in the IO TLB. 30 bits is a b44 limitation. */
-#define DEFAULT_IO_TLB_DMA_BITS 30
+/* Width of DMA addresses. 30 bits is a b44 limitation. */
+#define DEFAULT_DMA_BITS 30
 
 static int swiotlb_force;
 static char *iotlb_virt_start;
@@ -98,14 +98,14 @@ static struct phys_addr {
  */
 static DEFINE_SPINLOCK(io_tlb_lock);
 
-static unsigned int io_tlb_dma_bits = DEFAULT_IO_TLB_DMA_BITS;
+unsigned int dma_bits = DEFAULT_DMA_BITS;
 static int __init
-setup_io_tlb_bits(char *str)
-{
-       io_tlb_dma_bits = simple_strtoul(str, NULL, 0);
+setup_dma_bits(char *str)
+{
+       dma_bits = simple_strtoul(str, NULL, 0);
        return 0;
 }
-__setup("swiotlb_bits=", setup_io_tlb_bits);
+__setup("dma_bits=", setup_dma_bits);
 
 static int __init
 setup_io_tlb_npages(char *str)
@@ -167,7 +167,7 @@ swiotlb_init_with_default_size (size_t d
                int rc = xen_create_contiguous_region(
                        (unsigned long)iotlb_virt_start + (i << IO_TLB_SHIFT),
                        get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT),
-                       io_tlb_dma_bits);
+                       dma_bits);
                BUG_ON(rc);
        }
 
@@ -197,7 +197,7 @@ swiotlb_init_with_default_size (size_t d
               bytes >> 20,
               (unsigned long)iotlb_virt_start,
               (unsigned long)iotlb_virt_start + bytes,
-              io_tlb_dma_bits);
+              dma_bits);
 }
 
 void
@@ -665,7 +665,7 @@ int
 int
 swiotlb_dma_supported (struct device *hwdev, u64 mask)
 {
-       return (mask >= ((1UL << io_tlb_dma_bits) - 1));
+       return (mask >= ((1UL << dma_bits) - 1));
 }
 
 EXPORT_SYMBOL(swiotlb_init);
diff -r 3a28be71b667 -r 301bcae16928 
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h      Wed Dec 
20 11:09:56 2006 +0000
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h      Wed Dec 
20 11:21:04 2006 +0000
@@ -34,6 +34,8 @@ extern int swiotlb_dma_supported(struct 
 extern int swiotlb_dma_supported(struct device *hwdev, u64 mask);
 extern void swiotlb_init(void);
 
+extern unsigned int dma_bits;
+
 #ifdef CONFIG_SWIOTLB
 extern int swiotlb;
 #else

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.