swiotlb: use swiotlb_alloc_boot to allocate emergency pool
Subsystems (3)
PATCH 1/1 swiotlb: use swiotlb_alloc_boot to allocate emergency pool
Impact: bugfix
Also fix xen_swiotlb_fixup() to deal with sub-slab-sized allocations.
lib/swiotlb.c +0 -0
@@ -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");drivers/pci/xen-iommu.c +0 -0
@@ -47,16 +47,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)
Quoted 40 lines · On Mon, 30 Mar 2009 17:51:34 -0700 Jeremy Fitzhardinge <[email protected]> wrote:
Impact: bugfix
Also fix
xen_swiotlb_fixup()to deal with sub-slab-sized allocations.Signed-off-by Jeremy Fitzhardinge <[email protected]>lib/swiotlb.c +2
-1@@ -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" );drivers/pci/xen-iommu.c +6
-2@@ -47,16 +47,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);
drivers/pci/xen-iommu.c void xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs) · line 68
Quoted 10 lines
drivers/pci/xen-iommu.c +3
-1}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 )
This is a patch for a tree for dom0? I have no idea what xen-iommu.c is doing (I don't know if dom0 support will be merged into mainline or not). But the change to lib/swiotlb.c is fine by me.
Quoted 4 lines · FUJITA Tomonori
This is a patch for a tree for dom0? I have no idea what
xen-iommu.cis doing (I don't know if dom0 support will be merged into mainline or not). But the change tolib/swiotlb.cis fine by me.
Yes, sorry, I was just asking about the lib/swiotlb.c change.
Thanks,
J