Skip to contentSkip to conversation

mmc: renesas_sdhi_internal_dmac: set scatter/gather max segment size

PATCH In review Wolfram Sang 2 participants 2 messages Sep 13, 2018 – Sep 18, 2018

Subsystems (2)
lore
Share & tools
lore

Wolfram Sang

author maintainer
#0 lore raw

PATCH v3 1/1 mmc: renesas_sdhi_internal_dmac: set scatter/gather max segment size

From: Niklas Söderlund <[email protected]>

Fix warning when running with CONFIG_DMA_API_DEBUG_SG=y by allocating a device_dma_parameters structure and filling in the max segment size. The size used is the result of a discussion with Renesas hardware engineers and unfortunately not found in the datasheet.

renesas_sdhi_internal_dmac ee140000.sd: DMA-API: mapping sg segment longer than device claims to support [len=126976] [max=65536]

[wsa: simplified some logic after validating intended dma_parms life cycle
and added comment]

---

After discussing with DMA maintainers [1], this really seems the intended way of using dma_parms. Took Niklas patch V2 and simplified the logic a bit more given the information from above (but I'll still tackle the dangling pointer issue in the DMA core seperately).

[1] https://www.spinics.net/lists/iommu/msg29861.html

 drivers/mmc/host/renesas_sdhi_internal_dmac.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mmc/host/renesas_sdhi_internal_dmac.c +8 -0
index ca0b43973769..e0823acaa3c2 100644
@@ -309,12 +309,20 @@ static const struct soc_device_attribute gen3_soc_whitelist[] = {
 static int renesas_sdhi_internal_dmac_probe(struct platform_device *pdev)
 {
 	const struct soc_device_attribute *soc = soc_device_match(gen3_soc_whitelist);
+	struct device *dev = &pdev->dev;
 
 	if (!soc)
 		return -ENODEV;
 
 	global_flags |= (unsigned long)soc->data;
 
+	dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms), GFP_KERNEL);
+	if (!dev->dma_parms)
+		return -ENOMEM;
+
+	/* value is max of SD_SECCNT. Confirmed by HW engineers */
+	dma_set_max_seg_size(dev, 0xffffffff);
+
 	return renesas_sdhi_probe(pdev, &renesas_sdhi_internal_dmac_dma_ops);
 }
 
Signature · 1 line
2.11.0
#1 lore raw
Quoted 7 lines · Wolfram Sang

From: Niklas Söderlund <[email protected]>

Fix warning when running with CONFIG_DMA_API_DEBUG_SG=y by allocating a device_dma_parameters structure and filling in the max segment size. The size used is the result of a discussion with Renesas hardware engineers and unfortunately not found in the datasheet.

Quoted 8 lines

renesas_sdhi_internal_dmac ee140000.sd: DMA-API: mapping sg segment longer than device claims to support [len=126976] [max=65536]

[wsa: simplified some logic after validating intended dma_parms life cycle
and added comment]

Applied for next, thanks!

Kind regards
Uffe

Quoted 40 lines

---

After discussing with DMA maintainers [1], this really seems the intended way of using dma_parms. Took Niklas patch V2 and simplified the logic a bit more given the information from above (but I'll still tackle the dangling pointer issue in the DMA core seperately).

[1] https://www.spinics.net/lists/iommu/msg29861.html

 drivers/mmc/host/renesas_sdhi_internal_dmac.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mmc/host/renesas_sdhi_internal_dmac.c +8 -1
index ca0b43973769..e0823acaa3c2 100644
@@ -309,12 +309,20 @@ static const struct soc_device_attribute gen3_soc_whitelist[] = {
 static int renesas_sdhi_internal_dmac_probe(struct platform_device *pdev)
 {
        const struct soc_device_attribute *soc = soc_device_match(gen3_soc_whitelist);
+       struct device *dev = &pdev->dev;
 
        if (!soc)
                return -ENODEV;
 
        global_flags |= (unsigned long)soc->data;
 
+       dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms), GFP_KERNEL);
+       if (!dev->dma_parms)
+               return -ENOMEM;
+
+       /* value is max of SD_SECCNT. Confirmed by HW engineers */
+       dma_set_max_seg_size(dev, 0xffffffff);
+
        return renesas_sdhi_probe(pdev, &renesas_sdhi_internal_dmac_dma_ops);
 }
 
--

2.11.0