aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/swiotlb.h1
-rw-r--r--lib/swiotlb.c48
2 files changed, 31 insertions, 18 deletions
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 81a4e213c6cf..b406261d8887 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -23,6 +23,7 @@ extern int swiotlb_force;
23#define IO_TLB_SHIFT 11 23#define IO_TLB_SHIFT 11
24 24
25extern void swiotlb_init(int verbose); 25extern void swiotlb_init(int verbose);
26extern void swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose);
26 27
27extern void 28extern void
28*swiotlb_alloc_coherent(struct device *hwdev, size_t size, 29*swiotlb_alloc_coherent(struct device *hwdev, size_t size,
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 783aff00024c..ec61e1507d0a 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -140,28 +140,14 @@ void swiotlb_print_info(void)
140 (unsigned long long)pend); 140 (unsigned long long)pend);
141} 141}
142 142
143/* 143void __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
144 * Statically reserve bounce buffer space and initialize bounce buffer data
145 * structures for the software IO TLB used to implement the DMA API.
146 */
147void __init
148swiotlb_init_with_default_size(size_t default_size, int verbose)
149{ 144{
150 unsigned long i, bytes; 145 unsigned long i, bytes;
151 146
152 if (!io_tlb_nslabs) { 147 bytes = nslabs << IO_TLB_SHIFT;
153 io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
154 io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
155 }
156 148
157 bytes = io_tlb_nslabs << IO_TLB_SHIFT; 149 io_tlb_nslabs = nslabs;
158 150 io_tlb_start = tlb;
159 /*
160 * Get IO TLB memory from the low pages
161 */
162 io_tlb_start = alloc_bootmem_low_pages(bytes);
163 if (!io_tlb_start)
164 panic("Cannot allocate SWIOTLB buffer");
165 io_tlb_end = io_tlb_start + bytes; 151 io_tlb_end = io_tlb_start + bytes;
166 152
167 /* 153 /*
@@ -185,6 +171,32 @@ swiotlb_init_with_default_size(size_t default_size, int verbose)
185 swiotlb_print_info(); 171 swiotlb_print_info();
186} 172}
187 173
174/*
175 * Statically reserve bounce buffer space and initialize bounce buffer data
176 * structures for the software IO TLB used to implement the DMA API.
177 */
178void __init
179swiotlb_init_with_default_size(size_t default_size, int verbose)
180{
181 unsigned long bytes;
182
183 if (!io_tlb_nslabs) {
184 io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
185 io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
186 }
187
188 bytes = io_tlb_nslabs << IO_TLB_SHIFT;
189
190 /*
191 * Get IO TLB memory from the low pages
192 */
193 io_tlb_start = alloc_bootmem_low_pages(bytes);
194 if (!io_tlb_start)
195 panic("Cannot allocate SWIOTLB buffer");
196
197 swiotlb_init_with_tbl(io_tlb_start, io_tlb_nslabs, verbose);
198}
199
188void __init 200void __init
189swiotlb_init(int verbose) 201swiotlb_init(int verbose)
190{ 202{