From 346b68bf1f7113b28328c9909fcbbbc0f4375286 Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Mon, 9 Feb 2009 12:05:53 -0800 Subject: [PATCH] swiotlb: use swiotlb_alloc_boot to allocate emergency pool Use swiotlb_alloc_boot() to allocate the emergency pool memory so that it gets set up properly in the architecture code. Also fix xen_swiotlb_fixup() to deal with sub-slab-sized allocations, as the emergency pool is smaller than IO_TLB_SEGSIZE. [ Impact: allocate emergency pool with appropriate allocator ] Signed-off-by: Jeremy Fitzhardinge Acked-by: FUJITA Tomonori --- 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 678a0e5d395..bc64397b756 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 bffe6d7ef9d..095dc616aa7 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c @@ -208,7 +208,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"); -- 2.39.5