[PATCH] hsi: omap_ssi_core: fix missing DMA mask setup for SSI controller device

Ivaylo Dimitrov posted 1 patch 7 hours ago
drivers/hsi/controllers/omap_ssi_core.c | 6 ++++++
1 file changed, 6 insertions(+)
[PATCH] hsi: omap_ssi_core: fix missing DMA mask setup for SSI controller device
Posted by Ivaylo Dimitrov 7 hours ago
The OMAP SSI driver uses a synthetic HSI controller device
allocated via hsi_alloc_controller(), which does not go through
the normal OF/platform device initialization path.

As a result, the embedded struct device does not have a DMA mask
initialized by default.

After recent DMA API hardening changes, dma_map_sg() and related
helpers now require a valid dma_mask to be present, otherwise
the driver may crash or trigger warnings when attempting DMA
mapping operations.

Fix this by explicitly initializing the DMA mask for the SSI
controller device and setting a 32-bit DMA mask, which matches
the hardware capabilities.

Fixes: f959dcd6ddfd ("dma-direct: Fix potential NULL pointer dereference")

Reported-by: Merlijn Wajer <merlijn@wizzup.org>
Closes: https://marc.info/?l=linux-omap&m=163799095101818&w=2
Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
---
 drivers/hsi/controllers/omap_ssi_core.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/hsi/controllers/omap_ssi_core.c b/drivers/hsi/controllers/omap_ssi_core.c
index eeacc427fd659..47826315d7d62 100644
--- a/drivers/hsi/controllers/omap_ssi_core.c
+++ b/drivers/hsi/controllers/omap_ssi_core.c
@@ -502,6 +502,12 @@ static int ssi_probe(struct platform_device *pd)
 
 	pm_runtime_enable(&pd->dev);
 
+	ssi->device.dma_mask = &ssi->device.coherent_dma_mask;
+
+	err = dma_set_mask_and_coherent(&ssi->device, DMA_BIT_MASK(32));
+	if (err)
+		goto out2;
+
 	err = ssi_hw_init(ssi);
 	if (err < 0)
 		goto out2;
-- 
2.39.5