Skip to contentSkip to conversation

mmc: omap_hsmmc: fix DMA API warning

PATCH In review Russell King 3 participants 3 messages Dec 11, 2018 – Dec 17, 2018

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

PATCH 1/1 mmc: omap_hsmmc: fix DMA API warning

While booting with rootfs on MMC, the following warning is encountered on OMAP4430:

omap-dma-engine 4a056000.dma-controller: DMA-API: mapping sg segment longer than device claims to support [len=69632] [max=65536]

This is because the DMA engine has a default maximum segment size of 64K but HSMMC sets:

        mmc->max_blk_size = 512;       /* Block Length at max can be 1024 */
        mmc->max_blk_count = 0xFFFF;    /* No. of Blocks is 16 bits */
        mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
        mmc->max_seg_size = mmc->max_req_size;

which ends up telling the block layer that we support a maximum segment size of 65535*512, which exceeds the advertised DMA engine capabilities.

Fix this by clamping the maximum segment size to the lower of the maximum request size and of the DMA engine device used for either DMA channel.

---
 drivers/mmc/host/omap_hsmmc.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/mmc/host/omap_hsmmc.c +11 -1
index 467d889a1638..55100974fb95 100644
@@ -1909,7 +1909,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 	mmc->max_blk_size = 512;       /* Block Length at max can be 1024 */
 	mmc->max_blk_count = 0xFFFF;    /* No. of Blocks is 16 bits */
 	mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
-	mmc->max_seg_size = mmc->max_req_size;
 
 	mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
 		     MMC_CAP_WAIT_WHILE_BUSY | MMC_CAP_ERASE | MMC_CAP_CMD23;
@@ -1939,6 +1938,17 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 		goto err_irq;
 	}
 
+	/*
+	 * Limit the maximum segment size to the lower of the request size
+	 * and the DMA engine device segment size limits.  In reality, with
+	 * 32-bit transfers, the DMA engine can do longer segments than this
+	 * but there is no way to represent that in the DMA model - if we
+	 * increase this figure here, we get warnings from the DMA API debug.
+	 */
+	mmc->max_seg_size = min(mmc->max_req_size,
+				min(dma_get_max_seg_size(host->rx_chan->device->dev),
+				    dma_get_max_seg_size(host->tx_chan->device->dev)));
+
 	/* Request IRQ for MMC operations */
 	ret = devm_request_irq(&pdev->dev, host->irq, omap_hsmmc_irq, 0,
 			mmc_hostname(mmc), host);
Signature · 1 line
2.7.4
#1 lore raw

Hi,

Quoted 5 lines · Russell King
drivers/mmc/host/omap_hsmmc.c +1 -0
@@ -1939,6 +1938,17 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 		goto err_irq;
 	}
 
+	/*

drivers/mmc/host/omap_hsmmc.c static int omap_hsmmc_probe(struct platform_device *pdev) · line 1951

Quoted 10 lines
drivers/mmc/host/omap_hsmmc.c +10 -0
+	 * Limit the maximum segment size to the lower of the request size
+	 * and the DMA engine device segment size limits.  In reality, with
+	 * 32-bit transfers, the DMA engine can do longer segments than this
+	 * but there is no way to represent that in the DMA model - if we
+	 * increase this figure here, we get warnings from the DMA API debug.
+	 */
+	mmc->max_seg_size = min(mmc->max_req_size,
+				min(dma_get_max_seg_size(host->rx_chan->device->dev),
+				    dma_get_max_seg_size(host->tx_chan->device->dev)));
+

Looks like using min3() here would be handy?

Regards,

Tony

#2 lore raw
In reply to Russell King
Quoted 14 lines · Russell King

While booting with rootfs on MMC, the following warning is encountered on OMAP4430:

omap-dma-engine 4a056000.dma-controller: DMA-API: mapping sg segment longer than device claims to support [len=69632] [max=65536]

This is because the DMA engine has a default maximum segment size of 64K but HSMMC sets:

        mmc->max_blk_size = 512;       /* Block Length at max can be 1024 */
        mmc->max_blk_count = 0xFFFF;    /* No. of Blocks is 16 bits */
        mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
        mmc->max_seg_size = mmc->max_req_size;
Quoted 8 lines

which ends up telling the block layer that we support a maximum segment size of 65535*512, which exceeds the advertised DMA engine capabilities.

Fix this by clamping the maximum segment size to the lower of the maximum request size and of the DMA engine device used for either DMA channel.

I have applied this for fixes, amending the change by modifying the min-min check to min3 according to the suggestion from Tony. I assumed adding a stable tag makes sense so I did, however, please tell if you want me to drop that.

Thanks and kind regards
Uffe

Quoted 37 lines
---
 drivers/mmc/host/omap_hsmmc.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/mmc/host/omap_hsmmc.c +11 -2
index 467d889a1638..55100974fb95 100644
@@ -1909,7 +1909,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
        mmc->max_blk_size = 512;       /* Block Length at max can be 1024 */
        mmc->max_blk_count = 0xFFFF;    /* No. of Blocks is 16 bits */
        mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
-       mmc->max_seg_size = mmc->max_req_size;
 
        mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
                     MMC_CAP_WAIT_WHILE_BUSY | MMC_CAP_ERASE | MMC_CAP_CMD23;
@@ -1939,6 +1938,17 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
                goto err_irq;
        }
 
+       /*
+        * Limit the maximum segment size to the lower of the request size
+        * and the DMA engine device segment size limits.  In reality, with
+        * 32-bit transfers, the DMA engine can do longer segments than this
+        * but there is no way to represent that in the DMA model - if we
+        * increase this figure here, we get warnings from the DMA API debug.
+        */
+       mmc->max_seg_size = min(mmc->max_req_size,
+                               min(dma_get_max_seg_size(host->rx_chan->device->dev),
+                                   dma_get_max_seg_size(host->tx_chan->device->dev)));
+
        /* Request IRQ for MMC operations */
        ret = devm_request_irq(&pdev->dev, host->irq, omap_hsmmc_irq, 0,
                        mmc_hostname(mmc), host);
--

2.7.4