Skip to contentSkip to conversation

fsldma: Set correct dma_mask based on hw capability

PATCH Applied Ben Collins 2 participants 2 messages May 5, 2025 – May 14, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 fsldma: Set correct dma_mask based on hw capability

The driver currently hardcodes DMA_BIT_MASK to 36-bits, which is only correct on eloplus:

elo3 supports 40-bits
eloplus supports 36-bits
elo supports 32-bits

This is based on 0x08 cdar register documention in the respective reference manuals. Set the dma mask accordingly.

Feedback from Arnd Bergmann:

- Use match data to set address bit mask

---
 drivers/dma/fsldma.c | 20 ++++++++++++++++----
 drivers/dma/fsldma.h |  1 +
 2 files changed, 17 insertions(+), 4 deletions(-)
drivers/dma/fsldma.c +16 -4
index b5e7d18b97669..566db5a1b0bab 100644
@@ -1226,6 +1226,8 @@ static int fsldma_of_probe(struct platform_device *op)
 
 	fdev->dev = &op->dev;
 	INIT_LIST_HEAD(&fdev->common.channels);
+	/* The DMA address bits supported for this device. */
+	fdev->addr_bits = (long)device_get_match_data(fdev->dev);
 
 	/* ioremap the registers for use */
 	fdev->regs = of_iomap(op->dev.of_node, 0);
@@ -1254,7 +1256,7 @@ static int fsldma_of_probe(struct platform_device *op)
 	fdev->common.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
 	fdev->common.residue_granularity = DMA_RESIDUE_GRANULARITY_DESCRIPTOR;
 
-	dma_set_mask(&(op->dev), DMA_BIT_MASK(36));
+	dma_set_mask(&(op->dev), DMA_BIT_MASK(fdev->addr_bits));
 
 	platform_set_drvdata(op, fdev);
 
@@ -1387,10 +1389,20 @@ static const struct dev_pm_ops fsldma_pm_ops = {
 };
 #endif
 
+/* The .data field is used for dma-bit-mask. */
 static const struct of_device_id fsldma_of_ids[] = {
-	{ .compatible = "fsl,elo3-dma", },
-	{ .compatible = "fsl,eloplus-dma", },
-	{ .compatible = "fsl,elo-dma", },
+	{
+		.compatible = "fsl,elo3-dma",
+		.data = (void *)40,
+	},
+	{
+		.compatible = "fsl,eloplus-dma",
+		.data = (void *)36,
+	},
+	{
+		.compatible = "fsl,elo-dma",
+		.data = (void *)32,
+	},
 	{}
 };
 MODULE_DEVICE_TABLE(of, fsldma_of_ids);
drivers/dma/fsldma.h +1 -0
index 308bed0a560ac..2ea57df9b7f7d 100644
@@ -124,6 +124,7 @@ struct fsldma_device {
 	struct fsldma_chan *chan[FSL_DMA_MAX_CHANS_PER_DEVICE];
 	u32 feature;		/* The same as DMA channels */
 	int irq;		/* Channel IRQ */
+	int addr_bits;		/* DMA addressing bits supported */
 };
 
 /* Define macros for fsldma_chan->feature property */
Signature · 9 lines
2.49.0


-- 
 Ben Collins
 https://libjwt.io
 https://github.com/benmcollins
 --
 3EC9 7598 1672 961A 1139  173A 5D5A 57C7 242B 22CF
maintainer Applied
#1 lore raw
Quoted 8 lines · Ben Collins

The driver currently hardcodes DMA_BIT_MASK to 36-bits, which is only correct on eloplus:

elo3 supports 40-bits
eloplus supports 36-bits
elo supports 32-bits

[...]

Applied, thanks!

[1/1] fsldma: Set correct dma_mask based on hw capability

      commit: 00ff4d68a9ae4c9315c166f1fafa47f4c0a65f6f

Best regards,

Signature · 1 line
~Vinod