[PATCH 03 of 38] swiotlb: allow architectures to override swiotlb pool allocation

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jeremy Fitzhardinge
Date: Thursday, November 13, 2008 - 12:10 pm

Architectures may need to allocate memory specially for use with
the swiotlb.  Create the weak function swiotlb_alloc_boot() and
swiotlb_alloc() defaulting to the current behaviour.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Joerg Roedel <joerg.roedel@amd.com>
Cc: Jan Beulich <jbeulich@novell.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
 include/linux/swiotlb.h |    3 +++
 lib/swiotlb.c           |   16 +++++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -10,6 +10,9 @@
 extern void
 swiotlb_init(void);
 
+extern void *swiotlb_alloc_boot(size_t bytes, unsigned long nslabs);
+extern void *swiotlb_alloc(unsigned order, unsigned long nslabs);
+
 extern void
 *swiotlb_alloc_coherent(struct device *hwdev, size_t size,
 			dma_addr_t *dma_handle, gfp_t flags);
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -21,6 +21,7 @@
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <linux/swiotlb.h>
 #include <linux/string.h>
 #include <linux/types.h>
 #include <linux/ctype.h>
@@ -126,6 +127,16 @@
 __setup("swiotlb=", setup_io_tlb_npages);
 /* make io_tlb_overflow tunable too? */
 
+void * __weak swiotlb_alloc_boot(size_t size, unsigned long nslabs)
+{
+	return alloc_bootmem_low_pages(size);
+}
+
+void * __weak swiotlb_alloc(unsigned order, unsigned long nslabs)
+{
+	return (void *)__get_free_pages(GFP_DMA | __GFP_NOWARN, order);
+}
+
 /*
  * Statically reserve bounce buffer space and initialize bounce buffer data
  * structures for the software IO TLB used to implement the DMA API.
@@ -145,7 +156,7 @@
 	/*
 	 * Get IO TLB memory from the low pages
 	 */
-	io_tlb_start = alloc_bootmem_low_pages(bytes);
+	io_tlb_start = swiotlb_alloc_boot(bytes, io_tlb_nslabs);
 	if (!io_tlb_start)
 		panic("Cannot allocate SWIOTLB buffer");
 	io_tlb_end = io_tlb_start + bytes;
@@ -202,8 +213,7 @@
 	bytes = io_tlb_nslabs << IO_TLB_SHIFT;
 
 	while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) {
-		io_tlb_start = (char *)__get_free_pages(GFP_DMA | __GFP_NOWARN,
-		                                        order);
+		io_tlb_start = swiotlb_alloc(order, io_tlb_nslabs);
 		if (io_tlb_start)
 			break;
 		order--;


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00 of 38] xen: add more Xen dom0 support, Jeremy Fitzhardinge, (Thu Nov 13, 12:09 pm)
[PATCH 01 of 38] xen: various whitespace and other formatt ..., Jeremy Fitzhardinge, (Thu Nov 13, 12:09 pm)
[PATCH 02 of 38] x86: remove unused iommu_nr_pages, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 03 of 38] swiotlb: allow architectures to override ..., Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 04 of 38] swiotlb: move some definitions to header, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 05 of 38] swiotlb: allow architectures to override ..., Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 06 of 38] xen: clean up asm-x86/xen/hypervisor.h, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 07 of 38] x86: add io_apic_ops, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 08 of 38] x86: make apic_* operations inline functions, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 09 of 38] x86: make sure we really have an hpet map ..., Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 10 of 38] x86: add handle_irq() to allow interrupt ..., Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 11 of 38] x86: define no-op exit_idle() on 32-bit, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 12 of 38] xen/dom0: handle acpi lapic parsing in Xe ..., Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 13 of 38] x86: unstatic mp_find_ioapic so it can be ..., Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 14 of 38] x86: add mp_find_ioapic_pin, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 15 of 38] x86: unstatic ioapic entry funcs, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 16 of 38] x86: include linux/init.h in asm/numa_64.h, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 17 of 38] x86: add swiotlb allocation functions, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 18 of 38] x86: unify pci iommu setup and allow swio ..., Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 19 of 38] x86: add arch specific version of the swi ..., Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 20 of 38] xen dom0: Make hvc_xen console work for dom0, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 21 of 38] xen dom0: Initialize xenbus for dom0, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 22 of 38] xen dom0: Set up basic IO permissions for ..., Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 23 of 38] xen-dom0: only selectively disable cpu fe ..., Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 24 of 38] xen dom0: Add support for the platform_op ..., Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 25 of 38] xen mtrr: Add mtrr_ops support for Xen mtrr, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 26 of 38] xen: forcibly disable PAT support, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 27 of 38] xen/dom0: use _PAGE_IOMAP in ioremap to d ..., Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 28 of 38] paravirt/xen: add pvop for page_is_ram, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 29 of 38] xen: create dummy ioapic mapping, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 30 of 38] xen: implement io_apic_ops, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 31 of 38] xen: set irq_chip disable, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 32 of 38] xen: use our own eventchannel-&gt;irq path, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 33 of 38] xen: pack all irq-related info together, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 34 of 38] xen: remove irq bindcount, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 35 of 38] xen: implement pirq type event channels, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 36 of 38] xen: route hardware irqs via Xen, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 37 of 38] xen: bind pirq to vector and event channel, Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
[PATCH 38 of 38] xen: make sure that softirqs get handled ..., Jeremy Fitzhardinge, (Thu Nov 13, 12:10 pm)
Re: [PATCH 25 of 38] xen mtrr: Add mtrr_ops support for Xe ..., Jeremy Fitzhardinge, (Thu Nov 13, 5:35 pm)
Re: [Xen-devel] [PATCH 03 of 38] swiotlb: allow architectu ..., Jeremy Fitzhardinge, (Fri Nov 14, 12:33 pm)
Re: [PATCH 30 of 38] xen: implement io_apic_ops, Simon Horman, (Thu Nov 20, 1:33 am)
Re: [PATCH 36 of 38] xen: route hardware irqs via Xen, Ingo Molnar, (Thu Nov 20, 2:31 am)
Re: [PATCH 30 of 38] xen: implement io_apic_ops, Ingo Molnar, (Thu Nov 20, 2:35 am)
Re: [PATCH 30 of 38] xen: implement io_apic_ops, Jeremy Fitzhardinge, (Thu Nov 20, 10:00 am)
Re: [PATCH 36 of 38] xen: route hardware irqs via Xen, Jeremy Fitzhardinge, (Thu Nov 20, 10:06 am)
Re: [PATCH 30 of 38] xen: implement io_apic_ops, Jeremy Fitzhardinge, (Thu Nov 20, 10:07 am)
Re: [PATCH 30 of 38] xen: implement io_apic_ops, Ingo Molnar, (Thu Nov 20, 12:22 pm)
Re: [PATCH 30 of 38] xen: implement io_apic_ops, Yinghai Lu, (Thu Nov 20, 12:29 pm)
Re: [PATCH 30 of 38] xen: implement io_apic_ops, Jeremy Fitzhardinge, (Thu Nov 20, 12:38 pm)
Re: [PATCH 30 of 38] xen: implement io_apic_ops, Jeremy Fitzhardinge, (Thu Nov 20, 12:39 pm)
Re: [PATCH 30 of 38] xen: implement io_apic_ops, Yinghai Lu, (Thu Nov 20, 12:40 pm)
Re: [PATCH 30 of 38] xen: implement io_apic_ops, Eric W. Biederman, (Thu Nov 20, 1:22 pm)
Re: [PATCH 30 of 38] xen: implement io_apic_ops, Jeremy Fitzhardinge, (Thu Nov 20, 2:32 pm)
Re: [PATCH 30 of 38] xen: implement io_apic_ops, Eric W. Biederman, (Thu Nov 20, 5:58 pm)
Re: [PATCH 30 of 38] xen: implement io_apic_ops, Jeremy Fitzhardinge, (Thu Nov 20, 6:16 pm)
Re: [PATCH 30 of 38] xen: implement io_apic_ops, H. Peter Anvin, (Thu Nov 20, 6:30 pm)
Re: [PATCH 30 of 38] xen: implement io_apic_ops, Eric W. Biederman, (Thu Nov 20, 9:27 pm)
Re: [PATCH 36 of 38] xen: route hardware irqs via Xen, Simon Horman, (Fri Nov 21, 12:17 am)
Re: [PATCH 30 of 38] xen: implement io_apic_ops, Jeremy Fitzhardinge, (Mon Nov 24, 12:18 pm)
Re: [PATCH 30 of 38] xen: implement io_apic_ops, Eric W. Biederman, (Mon Nov 24, 3:02 pm)
Re: [PATCH 18 of 38] x86: unify pci iommu setup and allow ..., FUJITA Tomonori, (Thu Nov 27, 11:28 pm)