Skip to content

Commit adbe7e2

Browse files
rmurphy-armwildea01
authored andcommitted
arm64: dma-mapping: Fix dma_mapping_error() when bypassing SWIOTLB
When bypassing SWIOTLB on small-memory systems, we need to avoid calling into swiotlb_dma_mapping_error() in exactly the same way as we avoid swiotlb_dma_supported(), because the former also relies on SWIOTLB state being initialised. Under the assumptions for which we skip SWIOTLB, dma_map_{single,page}() will only ever return the DMA-offset-adjusted physical address of the page passed in, thus we can report success unconditionally. Fixes: b67a8b2 ("arm64: mm: only initialize swiotlb when necessary") CC: stable@vger.kernel.org CC: Jisheng Zhang <jszhang@marvell.com> Reported-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent 2e44904 commit adbe7e2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

arch/arm64/mm/dma-mapping.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,13 @@ static int __swiotlb_dma_supported(struct device *hwdev, u64 mask)
356356
return 1;
357357
}
358358

359+
static int __swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t addr)
360+
{
361+
if (swiotlb)
362+
return swiotlb_dma_mapping_error(hwdev, addr);
363+
return 0;
364+
}
365+
359366
static struct dma_map_ops swiotlb_dma_ops = {
360367
.alloc = __dma_alloc,
361368
.free = __dma_free,
@@ -370,7 +377,7 @@ static struct dma_map_ops swiotlb_dma_ops = {
370377
.sync_sg_for_cpu = __swiotlb_sync_sg_for_cpu,
371378
.sync_sg_for_device = __swiotlb_sync_sg_for_device,
372379
.dma_supported = __swiotlb_dma_supported,
373-
.mapping_error = swiotlb_dma_mapping_error,
380+
.mapping_error = __swiotlb_dma_mapping_error,
374381
};
375382

376383
static int __init atomic_pool_init(void)

0 commit comments

Comments
 (0)