aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/swiotlb.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 5f6c629a924d..abecb2857556 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -21,6 +21,7 @@
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/spinlock.h> 23#include <linux/spinlock.h>
24#include <linux/swiotlb.h>
24#include <linux/string.h> 25#include <linux/string.h>
25#include <linux/types.h> 26#include <linux/types.h>
26#include <linux/ctype.h> 27#include <linux/ctype.h>
@@ -126,6 +127,16 @@ setup_io_tlb_npages(char *str)
126__setup("swiotlb=", setup_io_tlb_npages); 127__setup("swiotlb=", setup_io_tlb_npages);
127/* make io_tlb_overflow tunable too? */ 128/* make io_tlb_overflow tunable too? */
128 129
130void * __weak swiotlb_alloc_boot(size_t size, unsigned long nslabs)
131{
132 return alloc_bootmem_low_pages(size);
133}
134
135void * __weak swiotlb_alloc(unsigned order, unsigned long nslabs)
136{
137 return (void *)__get_free_pages(GFP_DMA | __GFP_NOWARN, order);
138}
139
129/* 140/*
130 * Statically reserve bounce buffer space and initialize bounce buffer data 141 * Statically reserve bounce buffer space and initialize bounce buffer data
131 * structures for the software IO TLB used to implement the DMA API. 142 * structures for the software IO TLB used to implement the DMA API.
@@ -145,7 +156,7 @@ swiotlb_init_with_default_size(size_t default_size)
145 /* 156 /*
146 * Get IO TLB memory from the low pages 157 * Get IO TLB memory from the low pages
147 */ 158 */
148 io_tlb_start = alloc_bootmem_low_pages(bytes); 159 io_tlb_start = swiotlb_alloc_boot(bytes, io_tlb_nslabs);
149 if (!io_tlb_start) 160 if (!io_tlb_start)
150 panic("Cannot allocate SWIOTLB buffer"); 161 panic("Cannot allocate SWIOTLB buffer");
151 io_tlb_end = io_tlb_start + bytes; 162 io_tlb_end = io_tlb_start + bytes;
@@ -202,8 +213,7 @@ swiotlb_late_init_with_default_size(size_t default_size)
202 bytes = io_tlb_nslabs << IO_TLB_SHIFT; 213 bytes = io_tlb_nslabs << IO_TLB_SHIFT;
203 214
204 while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) { 215 while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) {
205 io_tlb_start = (char *)__get_free_pages(GFP_DMA | __GFP_NOWARN, 216 io_tlb_start = swiotlb_alloc(order, io_tlb_nslabs);
206 order);
207 if (io_tlb_start) 217 if (io_tlb_start)
208 break; 218 break;
209 order--; 219 order--;