ia64/xen-unstable
changeset 13135:301bcae16928
[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@gondor.apana.org.au>
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@xensource.com>
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@gondor.apana.org.au>
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@xensource.com>
author | kfraser@localhost.localdomain |
---|---|
date | Wed Dec 20 11:21:04 2006 +0000 (2006-12-20) |
parents | 3a28be71b667 |
children | e99ba0c6c046 |
files | linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h |
line diff
1.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c Wed Dec 20 11:09:56 2006 +0000 1.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c Wed Dec 20 11:21:04 2006 +0000 1.3 @@ -15,6 +15,7 @@ 1.4 #include <linux/version.h> 1.5 #include <asm/io.h> 1.6 #include <xen/balloon.h> 1.7 +#include <asm/swiotlb.h> 1.8 #include <asm/tlbflush.h> 1.9 #include <asm-i386/mach-xen/asm/swiotlb.h> 1.10 #include <asm/bug.h> 1.11 @@ -183,8 +184,8 @@ void *dma_alloc_coherent(struct device * 1.12 ret = (void *)vstart; 1.13 1.14 if (ret != NULL) { 1.15 - /* NB. Hardcode 31 address bits for now: aacraid limitation. */ 1.16 - if (xen_create_contiguous_region(vstart, order, 31) != 0) { 1.17 + if (xen_create_contiguous_region(vstart, order, 1.18 + dma_bits) != 0) { 1.19 free_pages(vstart, order); 1.20 return NULL; 1.21 }
2.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c Wed Dec 20 11:09:56 2006 +0000 2.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c Wed Dec 20 11:21:04 2006 +0000 2.3 @@ -47,8 +47,8 @@ EXPORT_SYMBOL(swiotlb); 2.4 */ 2.5 #define IO_TLB_SHIFT 11 2.6 2.7 -/* Width of DMA addresses in the IO TLB. 30 bits is a b44 limitation. */ 2.8 -#define DEFAULT_IO_TLB_DMA_BITS 30 2.9 +/* Width of DMA addresses. 30 bits is a b44 limitation. */ 2.10 +#define DEFAULT_DMA_BITS 30 2.11 2.12 static int swiotlb_force; 2.13 static char *iotlb_virt_start; 2.14 @@ -98,14 +98,14 @@ static struct phys_addr { 2.15 */ 2.16 static DEFINE_SPINLOCK(io_tlb_lock); 2.17 2.18 -static unsigned int io_tlb_dma_bits = DEFAULT_IO_TLB_DMA_BITS; 2.19 +unsigned int dma_bits = DEFAULT_DMA_BITS; 2.20 static int __init 2.21 -setup_io_tlb_bits(char *str) 2.22 +setup_dma_bits(char *str) 2.23 { 2.24 - io_tlb_dma_bits = simple_strtoul(str, NULL, 0); 2.25 + dma_bits = simple_strtoul(str, NULL, 0); 2.26 return 0; 2.27 } 2.28 -__setup("swiotlb_bits=", setup_io_tlb_bits); 2.29 +__setup("dma_bits=", setup_dma_bits); 2.30 2.31 static int __init 2.32 setup_io_tlb_npages(char *str) 2.33 @@ -167,7 +167,7 @@ swiotlb_init_with_default_size (size_t d 2.34 int rc = xen_create_contiguous_region( 2.35 (unsigned long)iotlb_virt_start + (i << IO_TLB_SHIFT), 2.36 get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT), 2.37 - io_tlb_dma_bits); 2.38 + dma_bits); 2.39 BUG_ON(rc); 2.40 } 2.41 2.42 @@ -197,7 +197,7 @@ swiotlb_init_with_default_size (size_t d 2.43 bytes >> 20, 2.44 (unsigned long)iotlb_virt_start, 2.45 (unsigned long)iotlb_virt_start + bytes, 2.46 - io_tlb_dma_bits); 2.47 + dma_bits); 2.48 } 2.49 2.50 void 2.51 @@ -665,7 +665,7 @@ swiotlb_dma_mapping_error(dma_addr_t dma 2.52 int 2.53 swiotlb_dma_supported (struct device *hwdev, u64 mask) 2.54 { 2.55 - return (mask >= ((1UL << io_tlb_dma_bits) - 1)); 2.56 + return (mask >= ((1UL << dma_bits) - 1)); 2.57 } 2.58 2.59 EXPORT_SYMBOL(swiotlb_init);
3.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h Wed Dec 20 11:09:56 2006 +0000 3.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h Wed Dec 20 11:21:04 2006 +0000 3.3 @@ -34,6 +34,8 @@ extern void swiotlb_unmap_page(struct de 3.4 extern int swiotlb_dma_supported(struct device *hwdev, u64 mask); 3.5 extern void swiotlb_init(void); 3.6 3.7 +extern unsigned int dma_bits; 3.8 + 3.9 #ifdef CONFIG_SWIOTLB 3.10 extern int swiotlb; 3.11 #else