Skip to content

Commit

Permalink
swiotlb: bail out of swiotlb_init_late() if swiotlb is already allocated
Browse files Browse the repository at this point in the history
If swiotlb is allocated, immediately return 0, so callers do not have to
check io_tlb_default_mem.nslabs explicitly.

Signed-off-by: Petr Tesarik <petr.tesarik.ext@huawei.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Petr Tesarik authored and Christoph Hellwig committed Aug 1, 2023
1 parent 3fa6456 commit 0c6874a
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 4 additions & 6 deletions arch/arm/xen/mm.c
Original file line number Diff line number Diff line change
@@ -125,12 +125,10 @@ static int __init xen_mm_init(void)
return 0;

/* we can work with the default swiotlb */
if (!io_tlb_default_mem.nslabs) {
rc = swiotlb_init_late(swiotlb_size_or_default(),
xen_swiotlb_gfp(), NULL);
if (rc < 0)
return rc;
}
rc = swiotlb_init_late(swiotlb_size_or_default(),
xen_swiotlb_gfp(), NULL);
if (rc < 0)
return rc;

cflush.op = 0;
cflush.a.dev_bus_addr = 0;
3 changes: 3 additions & 0 deletions kernel/dma/swiotlb.c
Original file line number Diff line number Diff line change
@@ -384,6 +384,9 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask,
bool retried = false;
int rc = 0;

if (io_tlb_default_mem.nslabs)
return 0;

if (swiotlb_force_disable)
return 0;

0 comments on commit 0c6874a

Please sign in to comment.