Commit abbceff7d7a884968e876e52578da1db4a4f6b54

Authored by FUJITA Tomonori
Committed by Konrad Rzeszutek Wilk
1 parent eb605a5754

swiotlb: add the swiotlb initialization function with iotlb memory

This enables the caller to initialize swiotlb with its own iotlb
memory.

See "swiotlb: swiotlb: add swiotlb_tbl_map_single library function" for
full description of patchset.

[v2: changed ..with_tlb to ..with_tbl]

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-by: Albert Herranz <albert_herranz@yahoo.es>

Showing 2 changed files with 31 additions and 18 deletions Side-by-side Diff

include/linux/swiotlb.h
... ... @@ -23,6 +23,7 @@
23 23 #define IO_TLB_SHIFT 11
24 24  
25 25 extern void swiotlb_init(int verbose);
  26 +extern void swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose);
26 27  
27 28 extern void
28 29 *swiotlb_alloc_coherent(struct device *hwdev, size_t size,
... ... @@ -140,28 +140,14 @@
140 140 (unsigned long long)pend);
141 141 }
142 142  
143   -/*
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   - */
147   -void __init
148   -swiotlb_init_with_default_size(size_t default_size, int verbose)
  143 +void __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
149 144 {
150 145 unsigned long i, bytes;
151 146  
152   - if (!io_tlb_nslabs) {
153   - io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
154   - io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
155   - }
  147 + bytes = nslabs << IO_TLB_SHIFT;
156 148  
157   - bytes = io_tlb_nslabs << IO_TLB_SHIFT;
158   -
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");
  149 + io_tlb_nslabs = nslabs;
  150 + io_tlb_start = tlb;
165 151 io_tlb_end = io_tlb_start + bytes;
166 152  
167 153 /*
... ... @@ -183,6 +169,32 @@
183 169 panic("Cannot allocate SWIOTLB overflow buffer!\n");
184 170 if (verbose)
185 171 swiotlb_print_info();
  172 +}
  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 + */
  178 +void __init
  179 +swiotlb_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);
186 198 }
187 199  
188 200 void __init