Skip to content

Commit 6424e31

Browse files
author
Christoph Hellwig
committed
swiotlb: remove swiotlb_init_with_tbl and swiotlb_init_late_with_tbl
No users left. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Konrad Rzeszutek Wilk <[email protected]> Tested-by: Boris Ostrovsky <[email protected]>
1 parent 3f70356 commit 6424e31

File tree

2 files changed

+20
-59
lines changed

2 files changed

+20
-59
lines changed

include/linux/swiotlb.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ struct scatterlist;
3434
/* default to 64MB */
3535
#define IO_TLB_DEFAULT_SIZE (64UL<<20)
3636

37-
int swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, unsigned int flags);
3837
unsigned long swiotlb_size_or_default(void);
3938
void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags,
4039
int (*remap)(void *tlb, unsigned long nslabs));
4140
int swiotlb_init_late(size_t size, gfp_t gfp_mask,
4241
int (*remap)(void *tlb, unsigned long nslabs));
43-
extern int swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs);
4442
extern void __init swiotlb_update_mem_attributes(void);
4543

4644
phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, phys_addr_t phys,

kernel/dma/swiotlb.c

Lines changed: 20 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -225,41 +225,16 @@ static void swiotlb_init_io_tlb_mem(struct io_tlb_mem *mem, phys_addr_t start,
225225
return;
226226
}
227227

228-
int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs,
229-
unsigned int flags)
230-
{
231-
struct io_tlb_mem *mem = &io_tlb_default_mem;
232-
size_t alloc_size;
233-
234-
if (swiotlb_force_disable)
235-
return 0;
236-
237-
/* protect against double initialization */
238-
if (WARN_ON_ONCE(mem->nslabs))
239-
return -ENOMEM;
240-
241-
alloc_size = PAGE_ALIGN(array_size(sizeof(*mem->slots), nslabs));
242-
mem->slots = memblock_alloc(alloc_size, PAGE_SIZE);
243-
if (!mem->slots)
244-
panic("%s: Failed to allocate %zu bytes align=0x%lx\n",
245-
__func__, alloc_size, PAGE_SIZE);
246-
247-
swiotlb_init_io_tlb_mem(mem, __pa(tlb), nslabs, false);
248-
mem->force_bounce = flags & SWIOTLB_FORCE;
249-
250-
if (flags & SWIOTLB_VERBOSE)
251-
swiotlb_print_info();
252-
return 0;
253-
}
254-
255228
/*
256229
* Statically reserve bounce buffer space and initialize bounce buffer data
257230
* structures for the software IO TLB used to implement the DMA API.
258231
*/
259232
void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags,
260233
int (*remap)(void *tlb, unsigned long nslabs))
261234
{
235+
struct io_tlb_mem *mem = &io_tlb_default_mem;
262236
unsigned long nslabs = default_nslabs;
237+
size_t alloc_size = PAGE_ALIGN(array_size(sizeof(*mem->slots), nslabs));
263238
size_t bytes;
264239
void *tlb;
265240

@@ -280,7 +255,8 @@ void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags,
280255
else
281256
tlb = memblock_alloc_low(bytes, PAGE_SIZE);
282257
if (!tlb)
283-
goto fail;
258+
panic("%s: failed to allocate tlb structure\n", __func__);
259+
284260
if (remap && remap(tlb, nslabs) < 0) {
285261
memblock_free(tlb, PAGE_ALIGN(bytes));
286262

@@ -290,14 +266,17 @@ void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags,
290266
__func__, bytes);
291267
goto retry;
292268
}
293-
if (swiotlb_init_with_tbl(tlb, default_nslabs, flags))
294-
goto fail_free_mem;
295-
return;
296269

297-
fail_free_mem:
298-
memblock_free(tlb, bytes);
299-
fail:
300-
pr_warn("Cannot allocate buffer");
270+
mem->slots = memblock_alloc(alloc_size, PAGE_SIZE);
271+
if (!mem->slots)
272+
panic("%s: Failed to allocate %zu bytes align=0x%lx\n",
273+
__func__, alloc_size, PAGE_SIZE);
274+
275+
swiotlb_init_io_tlb_mem(mem, __pa(tlb), default_nslabs, false);
276+
mem->force_bounce = flags & SWIOTLB_FORCE;
277+
278+
if (flags & SWIOTLB_VERBOSE)
279+
swiotlb_print_info();
301280
}
302281

303282
void __init swiotlb_init(bool addressing_limit, unsigned int flags)
@@ -313,6 +292,7 @@ void __init swiotlb_init(bool addressing_limit, unsigned int flags)
313292
int swiotlb_init_late(size_t size, gfp_t gfp_mask,
314293
int (*remap)(void *tlb, unsigned long nslabs))
315294
{
295+
struct io_tlb_mem *mem = &io_tlb_default_mem;
316296
unsigned long nslabs = ALIGN(size >> IO_TLB_SHIFT, IO_TLB_SEGSIZE);
317297
unsigned long bytes;
318298
unsigned char *vstart = NULL;
@@ -353,33 +333,16 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask,
353333
return rc;
354334
goto retry;
355335
}
356-
rc = swiotlb_late_init_with_tbl(vstart, nslabs);
357-
if (rc)
358-
free_pages((unsigned long)vstart, order);
359-
360-
return rc;
361-
}
362-
363-
int
364-
swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)
365-
{
366-
struct io_tlb_mem *mem = &io_tlb_default_mem;
367-
unsigned long bytes = nslabs << IO_TLB_SHIFT;
368-
369-
if (swiotlb_force_disable)
370-
return 0;
371-
372-
/* protect against double initialization */
373-
if (WARN_ON_ONCE(mem->nslabs))
374-
return -ENOMEM;
375336

376337
mem->slots = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
377338
get_order(array_size(sizeof(*mem->slots), nslabs)));
378-
if (!mem->slots)
339+
if (!mem->slots) {
340+
free_pages((unsigned long)vstart, order);
379341
return -ENOMEM;
342+
}
380343

381-
set_memory_decrypted((unsigned long)tlb, bytes >> PAGE_SHIFT);
382-
swiotlb_init_io_tlb_mem(mem, virt_to_phys(tlb), nslabs, true);
344+
set_memory_decrypted((unsigned long)vstart, bytes >> PAGE_SHIFT);
345+
swiotlb_init_io_tlb_mem(mem, virt_to_phys(vstart), nslabs, true);
383346

384347
swiotlb_print_info();
385348
return 0;

0 commit comments

Comments
 (0)