Skip to content

Commit 0c6874a

Browse files
Petr TesarikChristoph Hellwig
authored andcommitted
swiotlb: bail out of swiotlb_init_late() if swiotlb is already allocated
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>
1 parent 3fa6456 commit 0c6874a

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

arch/arm/xen/mm.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,10 @@ static int __init xen_mm_init(void)
125125
return 0;
126126

127127
/* we can work with the default swiotlb */
128-
if (!io_tlb_default_mem.nslabs) {
129-
rc = swiotlb_init_late(swiotlb_size_or_default(),
130-
xen_swiotlb_gfp(), NULL);
131-
if (rc < 0)
132-
return rc;
133-
}
128+
rc = swiotlb_init_late(swiotlb_size_or_default(),
129+
xen_swiotlb_gfp(), NULL);
130+
if (rc < 0)
131+
return rc;
134132

135133
cflush.op = 0;
136134
cflush.a.dev_bus_addr = 0;

kernel/dma/swiotlb.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ int swiotlb_init_late(size_t size, gfp_t gfp_mask,
384384
bool retried = false;
385385
int rc = 0;
386386

387+
if (io_tlb_default_mem.nslabs)
388+
return 0;
389+
387390
if (swiotlb_force_disable)
388391
return 0;
389392

0 commit comments

Comments
 (0)