Messages in this thread Patch in this message | | | Date | Tue, 18 Oct 2005 12:54:23 -0700 | From | Ravikiran G Thirumalai <> | Subject | Re: [discuss] Re: x86_64: 2.6.14-rc4 swiotlb broken |
| |
On Tue, Oct 18, 2005 at 08:50:18AM -0700, Linus Torvalds wrote: > > > On Tue, 18 Oct 2005, Linus Torvalds wrote: > > > > I vote for this one, assuming everybody who can test is happy. > > Of course, just after sending the patch I noticed that there was a new > version, even simpler. Can people test that one? >
This version should work for everyone. It falls back to the old 2.6.13 behaviour when it does not find suitable memory from any of the nodes.
Yasunori-san, Alex, can you confirm. (Please use stock 2.6.14)
Thanks, Kiran
--
Patch to ensure low32 mem allocation for x86_64 swiotlb
Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Index: linux-2.6.14-rc4/arch/ia64/lib/swiotlb.c =================================================================== --- linux-2.6.14-rc4.orig/arch/ia64/lib/swiotlb.c 2005-10-17 22:48:25.000000000 -0700 +++ linux-2.6.14-rc4/arch/ia64/lib/swiotlb.c 2005-10-18 12:44:17.000000000 -0700 @@ -106,6 +106,8 @@ __setup("swiotlb=", setup_io_tlb_npages); /* make io_tlb_overflow tunable too? */ +#define IS_LOWPAGES(paddr, size) ((paddr < 0xffffffff) && ((paddr+size) < 0xffffffff)) + /* * Statically reserve bounce buffer space and initialize bounce buffer data * structures for the software IO TLB used to implement the PCI DMA API. @@ -114,17 +116,43 @@ swiotlb_init_with_default_size (size_t default_size) { unsigned long i; + unsigned long iotlbsz; + int node; if (!io_tlb_nslabs) { io_tlb_nslabs = (default_size >> IO_TLB_SHIFT); io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE); } + iotlbsz = io_tlb_nslabs * (1 << IO_TLB_SHIFT); + /* - * Get IO TLB memory from the low pages + * Get IO TLB memory from the 0-4G range */ - io_tlb_start = alloc_bootmem_low_pages(io_tlb_nslabs * - (1 << IO_TLB_SHIFT)); + + for_each_online_node(node) { + io_tlb_start = alloc_bootmem_node(NODE_DATA(node), iotlbsz); + if (io_tlb_start) { + if (IS_LOWPAGES(virt_to_phys(io_tlb_start), iotlbsz)) + break; + free_bootmem_node(NODE_DATA(node), + virt_to_phys(io_tlb_start), iotlbsz); + io_tlb_start = NULL; + } + } + + /* + * FIXME: This should go away when the bootmem allocator is fixed to + * guarantee lowmem32 allocations somehow, and the swiotlb mess is + * cleaned. The alloc_bootmem_low_pages fall back is to ensure + * boxes like amd64 which donot use swiotlb but still have + * swiotlb compiled in, falls back to the 2.6.13 behaviour instead + * of panicking, when proper low32 pages are not available + */ + if (!io_tlb_start) + io_tlb_start = alloc_bootmem_low_pages(io_tlb_nslabs * + (1 << IO_TLB_SHIFT)); + if (!io_tlb_start) panic("Cannot allocate SWIOTLB buffer"); io_tlb_end = io_tlb_start + io_tlb_nslabs * (1 << IO_TLB_SHIFT); - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |