Hi all, Here''s the Xen swiotlb changes with ack tags added, minor cleanups, etc. This is logically a continuation of the tip/x86/xen/dom0/pci branch. Thanks, J The following changes since commit e03834d7bc255b4fc35d894141a747a32a6b9cfd: Jeremy Fitzhardinge (1): xen: define BIOVEC_PHYS_MERGEABLE() are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git for-ingo/xen/dom0/swiotlb Ian Campbell (4): xen swiotlb: fixup swiotlb is chunks smaller than MAX_CONTIG_ORDER xen: add hooks for mapping phys<->bus addresses in swiotlb xen/swiotlb: add hook for swiotlb_arch_range_needs_mapping xen: enable swiotlb for xen domain 0. Jeremy Fitzhardinge (6): xen: make sure swiotlb allocation is physically contigious swiotlb: use swiotlb_alloc_boot to allocate emergency pool xen/swiotlb: improve comment on gfp flags in xen_alloc_coherent() xen/swiotlb: add sync functions xen/swiotlb: make sure prototypes are in scope for swiotlb functions xen/swiotlb: define xen_wants_swiotlb when PCI_XEN is not enabled arch/x86/kernel/pci-swiotlb.c | 30 +++--------------- arch/x86/xen/Kconfig | 1 + arch/x86/xen/Makefile | 1 + arch/x86/xen/pci-swiotlb.c | 53 +++++++++++++++++++++++++++++++ drivers/pci/xen-iommu.c | 69 ++++++++++++++++++++++++++++++++++++++-- include/xen/swiotlb.h | 18 +++++++++++ lib/swiotlb.c | 3 +- 7 files changed, 145 insertions(+), 30 deletions(-) create mode 100644 arch/x86/xen/pci-swiotlb.c create mode 100644 include/xen/swiotlb.h _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-12 21:50 UTC
[Xen-devel] [PATCH 01/10] xen: make sure swiotlb allocation is physically contigious
When allocating the swiotlb buffer under Xen, make sure the memory is physically contiguous so that its really suitable for DMA. Do this by allocating the memory as usual, but then call a Xen function to rearrange the underlying pages to be physically contiguous. [ Impact: make swiotlb allocation suitable for Xen ] Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Reviewed-by: "H. Peter Anvin" <hpa@zytor.com> Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> --- arch/x86/kernel/pci-swiotlb.c | 10 ---------- arch/x86/xen/Makefile | 1 + arch/x86/xen/pci-swiotlb.c | 27 +++++++++++++++++++++++++++ drivers/pci/xen-iommu.c | 16 ++++++++++++++++ include/xen/swiotlb.h | 6 ++++++ 5 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 arch/x86/xen/pci-swiotlb.c create mode 100644 include/xen/swiotlb.h diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c index 221a385..880b7bc 100644 --- a/arch/x86/kernel/pci-swiotlb.c +++ b/arch/x86/kernel/pci-swiotlb.c @@ -13,16 +13,6 @@ int swiotlb __read_mostly; -void * __init swiotlb_alloc_boot(size_t size, unsigned long nslabs) -{ - return alloc_bootmem_low_pages(size); -} - -void *swiotlb_alloc(unsigned order, unsigned long nslabs) -{ - return (void *)__get_free_pages(GFP_DMA | __GFP_NOWARN, order); -} - dma_addr_t swiotlb_phys_to_bus(struct device *hwdev, phys_addr_t paddr) { return paddr; diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile index c4cda96..caede49 100644 --- a/arch/x86/xen/Makefile +++ b/arch/x86/xen/Makefile @@ -12,3 +12,4 @@ obj-y := enlighten.o setup.o multicalls.o mmu.o irq.o \ obj-$(CONFIG_SMP) += smp.o spinlock.o obj-$(CONFIG_XEN_DEBUG_FS) += debugfs.o obj-$(CONFIG_XEN_DOM0) += vga.o +obj-$(CONFIG_PCI_XEN) += pci-swiotlb.o \ No newline at end of file diff --git a/arch/x86/xen/pci-swiotlb.c b/arch/x86/xen/pci-swiotlb.c new file mode 100644 index 0000000..7665d3b --- /dev/null +++ b/arch/x86/xen/pci-swiotlb.c @@ -0,0 +1,27 @@ +#include <linux/bootmem.h> +#include <linux/gfp.h> + +#include <xen/swiotlb.h> +#include <asm/xen/hypervisor.h> + +/* + * This file defines overrides for weak functions with default + * implementations in lib/swiotlb.c. + */ + +void * __init swiotlb_alloc_boot(size_t size, unsigned long nslabs) +{ + void *ret = alloc_bootmem_low_pages(size); + + if (ret && xen_pv_domain()) + xen_swiotlb_fixup(ret, size, nslabs); + + return ret; +} + +void *swiotlb_alloc(unsigned order, unsigned long nslabs) +{ + /* Never called on x86. Warn, just in case it ever is. */ + WARN_ON(1); + return NULL; +} diff --git a/drivers/pci/xen-iommu.c b/drivers/pci/xen-iommu.c index ac6bcdb..8c034b8 100644 --- a/drivers/pci/xen-iommu.c +++ b/drivers/pci/xen-iommu.c @@ -12,6 +12,7 @@ #include <xen/grant_table.h> #include <xen/page.h> #include <xen/xen-ops.h> +#include <xen/swiotlb.h> #include <asm/iommu.h> #include <asm/swiotlb.h> @@ -34,6 +35,21 @@ do { \ (unsigned long long)addr + size); \ } while (0) + +void xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs) +{ + unsigned order = get_order(size); + + printk(KERN_DEBUG "xen_swiotlb_fixup: buf=%p size=%zu order=%u\n", + buf, size, order); + + if (WARN_ON(size != (PAGE_SIZE << order))) + return; + + if (xen_create_contiguous_region((unsigned long)buf, + order, DMA_BIT_MASK(32))) + printk(KERN_ERR "xen_create_contiguous_region failed\n"); +} static inline int address_needs_mapping(struct device *hwdev, dma_addr_t addr) { diff --git a/include/xen/swiotlb.h b/include/xen/swiotlb.h new file mode 100644 index 0000000..67b7b42 --- /dev/null +++ b/include/xen/swiotlb.h @@ -0,0 +1,6 @@ +#ifndef _XEN_SWIOTLB_H +#define _XEN_SWIOTLB_H + +extern void xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs); + +#endif /* _XEN_SWIOTLB_H */ -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-12 21:50 UTC
[Xen-devel] [PATCH 02/10] xen swiotlb: fixup swiotlb is chunks smaller than MAX_CONTIG_ORDER
From: Ian Campbell <ian.campbell@citrix.com> Don''t attempt to make larger memory ranges than Xen can cope with contiguous. [ Impact: bugfix ] Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- drivers/pci/xen-iommu.c | 28 +++++++++++++++++++--------- 1 files changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/pci/xen-iommu.c b/drivers/pci/xen-iommu.c index 8c034b8..ee7b9fb 100644 --- a/drivers/pci/xen-iommu.c +++ b/drivers/pci/xen-iommu.c @@ -5,6 +5,7 @@ #include <linux/module.h> #include <linux/version.h> #include <linux/scatterlist.h> +#include <linux/swiotlb.h> #include <linux/io.h> #include <linux/bug.h> @@ -36,20 +37,29 @@ do { \ } while (0) +static int max_dma_bits = 32; + void xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs) { - unsigned order = get_order(size); - - printk(KERN_DEBUG "xen_swiotlb_fixup: buf=%p size=%zu order=%u\n", - buf, size, order); - - if (WARN_ON(size != (PAGE_SIZE << order))) - return; - - if (xen_create_contiguous_region((unsigned long)buf, - order, DMA_BIT_MASK(32))) - printk(KERN_ERR "xen_create_contiguous_region failed\n"); + int i, rc; + int dma_bits; + + printk(KERN_DEBUG "xen_swiotlb_fixup: buf=%p size=%zu\n", + buf, size); + + dma_bits = get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT) + PAGE_SHIFT; + for (i = 0; i < nslabs; i += IO_TLB_SEGSIZE) { + do { + rc = xen_create_contiguous_region( + (unsigned long)buf + (i << IO_TLB_SHIFT), + get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT), + dma_bits); + } while (rc && dma_bits++ < max_dma_bits); + if (rc) + panic(KERN_ERR "xen_create_contiguous_region failed\n"); + } } + static inline int address_needs_mapping(struct device *hwdev, dma_addr_t addr) { -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-12 21:50 UTC
[Xen-devel] [PATCH 03/10] xen: add hooks for mapping phys<->bus addresses in swiotlb
From: Ian Campbell <ian.campbell@citrix.com> Add hooks to allow Xen to do translation between pfn and mfns for the swiotlb layer, so that dma actually ends up going to the proper machine pages. [ Impact: Xen support for DMA ] Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Reviewed-by: "H. Peter Anvin" <hpa@zytor.com> Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Acked-by: Joerg Roedel <joerg.roedel@amd.com> --- arch/x86/kernel/pci-swiotlb.c | 10 ---------- arch/x86/xen/pci-swiotlb.c | 16 ++++++++++++++++ drivers/pci/xen-iommu.c | 10 ++++++++++ include/xen/swiotlb.h | 2 ++ 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c index 880b7bc..3e2ffd6 100644 --- a/arch/x86/kernel/pci-swiotlb.c +++ b/arch/x86/kernel/pci-swiotlb.c @@ -13,16 +13,6 @@ int swiotlb __read_mostly; -dma_addr_t swiotlb_phys_to_bus(struct device *hwdev, phys_addr_t paddr) -{ - return paddr; -} - -phys_addr_t swiotlb_bus_to_phys(dma_addr_t baddr) -{ - return baddr; -} - int __weak swiotlb_arch_range_needs_mapping(phys_addr_t paddr, size_t size) { return 0; diff --git a/arch/x86/xen/pci-swiotlb.c b/arch/x86/xen/pci-swiotlb.c index 7665d3b..646f2bf 100644 --- a/arch/x86/xen/pci-swiotlb.c +++ b/arch/x86/xen/pci-swiotlb.c @@ -25,3 +25,19 @@ void *swiotlb_alloc(unsigned order, unsigned long nslabs) WARN_ON(1); return NULL; } + +dma_addr_t swiotlb_phys_to_bus(struct device *hwdev, phys_addr_t paddr) +{ + if (xen_pv_domain()) + return xen_phys_to_bus(paddr); + + return paddr; +} + +phys_addr_t swiotlb_bus_to_phys(dma_addr_t baddr) +{ + if (xen_pv_domain()) + return xen_bus_to_phys(baddr); + + return baddr; +} diff --git a/drivers/pci/xen-iommu.c b/drivers/pci/xen-iommu.c index ee7b9fb..a5a3b32 100644 --- a/drivers/pci/xen-iommu.c +++ b/drivers/pci/xen-iommu.c @@ -60,6 +60,16 @@ void xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs) } } +dma_addr_t xen_phys_to_bus(phys_addr_t paddr) +{ + return phys_to_machine(XPADDR(paddr)).maddr; +} + +phys_addr_t xen_bus_to_phys(dma_addr_t daddr) +{ + return machine_to_phys(XMADDR(daddr)).paddr; +} + static inline int address_needs_mapping(struct device *hwdev, dma_addr_t addr) { diff --git a/include/xen/swiotlb.h b/include/xen/swiotlb.h index 67b7b42..4229f27 100644 --- a/include/xen/swiotlb.h +++ b/include/xen/swiotlb.h @@ -2,5 +2,7 @@ #define _XEN_SWIOTLB_H extern void xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs); +extern phys_addr_t xen_bus_to_phys(dma_addr_t daddr); +extern dma_addr_t xen_phys_to_bus(phys_addr_t paddr); #endif /* _XEN_SWIOTLB_H */ -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-12 21:50 UTC
[Xen-devel] [PATCH 04/10] xen/swiotlb: add hook for swiotlb_arch_range_needs_mapping
From: Ian Campbell <ian.campbell@citrix.com> Add hook so that Xen can determine whether a particular address range needs pfn<->mfn mapping. [ Impact: make Xen DMA work ] Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Reviewed-by: "H. Peter Anvin" <hpa@zytor.com> Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Acked-by: Joerg Roedel <joerg.roedel@amd.com> --- arch/x86/kernel/pci-swiotlb.c | 5 ----- arch/x86/xen/pci-swiotlb.c | 8 ++++++++ drivers/pci/xen-iommu.c | 5 +++++ include/xen/swiotlb.h | 1 + 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c index 3e2ffd6..9640e17 100644 --- a/arch/x86/kernel/pci-swiotlb.c +++ b/arch/x86/kernel/pci-swiotlb.c @@ -13,11 +13,6 @@ int swiotlb __read_mostly; -int __weak swiotlb_arch_range_needs_mapping(phys_addr_t paddr, size_t size) -{ - return 0; -} - static void *x86_swiotlb_alloc_coherent(struct device *hwdev, size_t size, dma_addr_t *dma_handle, gfp_t flags) { diff --git a/arch/x86/xen/pci-swiotlb.c b/arch/x86/xen/pci-swiotlb.c index 646f2bf..c2850b3 100644 --- a/arch/x86/xen/pci-swiotlb.c +++ b/arch/x86/xen/pci-swiotlb.c @@ -41,3 +41,11 @@ phys_addr_t swiotlb_bus_to_phys(dma_addr_t baddr) return baddr; } + +int swiotlb_arch_range_needs_mapping(phys_addr_t paddr, size_t size) +{ + if (xen_pv_domain()) + return xen_range_needs_mapping(paddr, size); + + return 0; +} diff --git a/drivers/pci/xen-iommu.c b/drivers/pci/xen-iommu.c index a5a3b32..be50f0f 100644 --- a/drivers/pci/xen-iommu.c +++ b/drivers/pci/xen-iommu.c @@ -119,6 +119,11 @@ static int range_straddles_page_boundary(phys_addr_t p, size_t size) return 1; } +int xen_range_needs_mapping(phys_addr_t paddr, size_t size) +{ + return range_straddles_page_boundary(paddr, size); +} + static inline void xen_dma_unmap_page(struct page *page) { /* Xen TODO: 2.6.18 xen calls __gnttab_dma_unmap_page here diff --git a/include/xen/swiotlb.h b/include/xen/swiotlb.h index 4229f27..8b51ff7 100644 --- a/include/xen/swiotlb.h +++ b/include/xen/swiotlb.h @@ -4,5 +4,6 @@ extern void xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs); extern phys_addr_t xen_bus_to_phys(dma_addr_t daddr); extern dma_addr_t xen_phys_to_bus(phys_addr_t paddr); +extern int xen_range_needs_mapping(phys_addr_t phys, size_t size); #endif /* _XEN_SWIOTLB_H */ -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-12 21:50 UTC
[Xen-devel] [PATCH 05/10] xen: enable swiotlb for xen domain 0.
From: Ian Campbell <ian.campbell@citrix.com> Enable swiotlb when running as a Xen dom0 domain. [ Impact: enable swiotlb under Xen ] Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Acked-by: Joerg Roedel <joerg.roedel@amd.com> --- arch/x86/kernel/pci-swiotlb.c | 5 +++++ arch/x86/xen/Kconfig | 1 + drivers/pci/xen-iommu.c | 5 +++++ include/xen/swiotlb.h | 1 + 4 files changed, 12 insertions(+), 0 deletions(-) diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c index 9640e17..7267376 100644 --- a/arch/x86/kernel/pci-swiotlb.c +++ b/arch/x86/kernel/pci-swiotlb.c @@ -11,6 +11,8 @@ #include <asm/swiotlb.h> #include <asm/dma.h> +#include <xen/swiotlb.h> + int swiotlb __read_mostly; static void *x86_swiotlb_alloc_coherent(struct device *hwdev, size_t size, @@ -49,6 +51,9 @@ void __init pci_swiotlb_init(void) if (!iommu_detected && !no_iommu && max_pfn > MAX_DMA32_PFN) swiotlb = 1; #endif + if (xen_wants_swiotlb()) + swiotlb = 1; + if (swiotlb_force) swiotlb = 1; if (swiotlb) { diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig index 87c13db..2c85967 100644 --- a/arch/x86/xen/Kconfig +++ b/arch/x86/xen/Kconfig @@ -6,6 +6,7 @@ config XEN bool "Xen guest support" select PARAVIRT select PARAVIRT_CLOCK + select SWIOTLB depends on X86_64 || (X86_32 && X86_PAE && !X86_VISWS) depends on X86_CMPXCHG && X86_TSC help diff --git a/drivers/pci/xen-iommu.c b/drivers/pci/xen-iommu.c index be50f0f..678a0e5 100644 --- a/drivers/pci/xen-iommu.c +++ b/drivers/pci/xen-iommu.c @@ -60,6 +60,11 @@ void xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs) } } +int xen_wants_swiotlb(void) +{ + return xen_initial_domain(); +} + dma_addr_t xen_phys_to_bus(phys_addr_t paddr) { return phys_to_machine(XPADDR(paddr)).maddr; diff --git a/include/xen/swiotlb.h b/include/xen/swiotlb.h index 8b51ff7..f35183b 100644 --- a/include/xen/swiotlb.h +++ b/include/xen/swiotlb.h @@ -5,5 +5,6 @@ extern void xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs); extern phys_addr_t xen_bus_to_phys(dma_addr_t daddr); extern dma_addr_t xen_phys_to_bus(phys_addr_t paddr); extern int xen_range_needs_mapping(phys_addr_t phys, size_t size); +extern int xen_wants_swiotlb(void); #endif /* _XEN_SWIOTLB_H */ -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-12 21:50 UTC
[Xen-devel] [PATCH 06/10] swiotlb: use swiotlb_alloc_boot to allocate emergency pool
Also fix xen_swiotlb_fixup() to deal with sub-slab-sized allocations. [ Impact: bugfix ] Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> --- drivers/pci/xen-iommu.c | 12 +++++++++--- lib/swiotlb.c | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/pci/xen-iommu.c b/drivers/pci/xen-iommu.c index 678a0e5..bc64397 100644 --- a/drivers/pci/xen-iommu.c +++ b/drivers/pci/xen-iommu.c @@ -48,16 +48,22 @@ void xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs) buf, size); dma_bits = get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT) + PAGE_SHIFT; - for (i = 0; i < nslabs; i += IO_TLB_SEGSIZE) { + + i = 0; + do { + int slabs = min(nslabs - i, (unsigned long)IO_TLB_SEGSIZE); + do { rc = xen_create_contiguous_region( (unsigned long)buf + (i << IO_TLB_SHIFT), - get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT), + get_order(slabs << IO_TLB_SHIFT), dma_bits); } while (rc && dma_bits++ < max_dma_bits); if (rc) panic(KERN_ERR "xen_create_contiguous_region failed\n"); - } + + i += slabs; + } while(i < nslabs); } int xen_wants_swiotlb(void) diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 2b0b5a7..a69834c 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c @@ -202,7 +202,8 @@ swiotlb_init_with_default_size(size_t default_size) /* * Get the overflow emergency buffer */ - io_tlb_overflow_buffer = alloc_bootmem_low(io_tlb_overflow); + io_tlb_overflow_buffer = swiotlb_alloc_boot(io_tlb_overflow, + io_tlb_overflow >> IO_TLB_SHIFT); if (!io_tlb_overflow_buffer) panic("Cannot allocate SWIOTLB overflow buffer!\n"); -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-12 21:50 UTC
[Xen-devel] [PATCH 07/10] xen/swiotlb: improve comment on gfp flags in xen_alloc_coherent()
From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Clarify why we don''t care about the kernel''s pseudo-phys restrictions, so long as the underlying pages are in the right place. [ Impact: cleanup ] Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- drivers/pci/xen-iommu.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/pci/xen-iommu.c b/drivers/pci/xen-iommu.c index bc64397..d09ff91 100644 --- a/drivers/pci/xen-iommu.c +++ b/drivers/pci/xen-iommu.c @@ -203,15 +203,17 @@ static void *xen_alloc_coherent(struct device *dev, size_t size, unsigned long vstart; u64 mask; - /* ignore region specifiers */ + /* + * Ignore region specifiers - the kernel''s ideas of + * pseudo-phys memory layout has nothing to do with the + * machine physical layout. We can''t allocate highmem + * because we can''t return a pointer to it. + */ gfp &= ~(__GFP_DMA | __GFP_HIGHMEM); if (dma_alloc_from_coherent(dev, size, dma_handle, &ret)) return ret; - if (dev == NULL || (dev->coherent_dma_mask < DMA_BIT_MASK(32))) - gfp |= GFP_DMA; - vstart = __get_free_pages(gfp, order); ret = (void *)vstart; -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-12 21:50 UTC
[Xen-devel] [PATCH 08/10] xen/swiotlb: add sync functions
From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Add all the missing sync functions. This fixes iwlagn. (Need to think about what to do with non-swiotlb mode.) [ Impact: bugfix; makes iwlagn driver work under Xen ] Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- drivers/pci/xen-iommu.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/drivers/pci/xen-iommu.c b/drivers/pci/xen-iommu.c index d09ff91..b1a7d93 100644 --- a/drivers/pci/xen-iommu.c +++ b/drivers/pci/xen-iommu.c @@ -304,6 +304,13 @@ static struct dma_map_ops xen_swiotlb_dma_ops = { .mapping_error = swiotlb_dma_mapping_error, + .sync_single_for_cpu = swiotlb_sync_single_for_cpu, + .sync_single_for_device = swiotlb_sync_single_for_device, + .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu, + .sync_single_range_for_device = swiotlb_sync_single_range_for_device, + .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, + .sync_sg_for_device = swiotlb_sync_sg_for_device, + .is_phys = 0, }; -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-12 21:50 UTC
[Xen-devel] [PATCH 09/10] xen/swiotlb: make sure prototypes are in scope for swiotlb functions
From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> This makes sure the functions overriding the lib/swiotlb.c weak functions have the right prototype. [ Impact: cleanup; better compile checking ] Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- arch/x86/xen/pci-swiotlb.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/arch/x86/xen/pci-swiotlb.c b/arch/x86/xen/pci-swiotlb.c index c2850b3..544c0c0 100644 --- a/arch/x86/xen/pci-swiotlb.c +++ b/arch/x86/xen/pci-swiotlb.c @@ -1,5 +1,7 @@ #include <linux/bootmem.h> #include <linux/gfp.h> +#include <linux/dma-mapping.h> +#include <linux/swiotlb.h> #include <xen/swiotlb.h> #include <asm/xen/hypervisor.h> -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-12 21:50 UTC
[Xen-devel] [PATCH 10/10] xen/swiotlb: define xen_wants_swiotlb when PCI_XEN is not enabled
From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> If CONFIG_PCI is disabled, CONFIG_SWIOTLB can still be enabled on x86-64, which calls xen_wants_swiotlb(). Define a stub version when CONFIG_PCI (and, implicitly, CONFIG_PCI_XEN) is not enabled. [ Impact: compile fix with !CONFIG_PCI ] Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- include/xen/swiotlb.h | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/include/xen/swiotlb.h b/include/xen/swiotlb.h index f35183b..75d1da1 100644 --- a/include/xen/swiotlb.h +++ b/include/xen/swiotlb.h @@ -5,6 +5,14 @@ extern void xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs); extern phys_addr_t xen_bus_to_phys(dma_addr_t daddr); extern dma_addr_t xen_phys_to_bus(phys_addr_t paddr); extern int xen_range_needs_mapping(phys_addr_t phys, size_t size); + +#ifdef CONFIG_PCI_XEN extern int xen_wants_swiotlb(void); +#else +static inline int xen_wants_swiotlb(void) +{ + return 0; +} +#endif #endif /* _XEN_SWIOTLB_H */ -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel