[PATCH v2 1/3] mmc: sunxi: Set the IDMA DMA mask
From: Jernej Skrabec
Date: Thu Nov 26 2026 - 13:29:59 EST
Controllers with a non-zero idma_des_shift (D1, A100 and H616) store
buffer and descriptor addresses shifted right by two, so they can
address 34 bits of physical memory. The driver never sets a DMA mask,
so the default 32-bit mask applies. On boards with DRAM above 4 GiB,
like H616 boards with 4 GiB of DRAM starting at 0x40000000, every
buffer above that limit is needlessly bounced through SWIOTLB.
Set the DMA mask to the range the controller can address. For the
other controllers, it stays at 32 bits.
Signed-off-by: Jernej Skrabec <jernej.skrabec@xxxxxxxxx>
---
drivers/mmc/host/sunxi-mmc.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
index c7fda9c66537..c53d47576864 100644
--- a/drivers/mmc/host/sunxi-mmc.c
+++ b/drivers/mmc/host/sunxi-mmc.c
@@ -1390,6 +1390,11 @@ static int sunxi_mmc_probe(struct platform_device *pdev)
if (ret)
return ret;
+ ret = dma_set_mask_and_coherent(&pdev->dev,
+ DMA_BIT_MASK(32 + host->cfg->idma_des_shift));
+ if (ret)
+ goto error_disable_mmc;
+
host->sg_cpu = dma_alloc_coherent(&pdev->dev, PAGE_SIZE,
&host->sg_dma, GFP_KERNEL);
if (!host->sg_cpu) {
--
2.43.0