Skip to contentSkip to conversation

mmc: renesas_sdhi_internal_dmac: fall back to PIO if scatterlist doesn't match

RFC PATCH In review Wolfram Sang 3 participants 4 messages Apr 4, 2018 – Apr 6, 2018

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

RFC PATCH 1/1 mmc: renesas_sdhi_internal_dmac: fall back to PIO if scatterlist doesn't match

From: Wolfram Sang <[email protected]>

If we detect an incompatible scatterlist, we should fall back to PIO, too.

---

I found this while working on the RX DMA issue. I don't see a reason why we shouldn't fall back in this case as well. But maybe I am missing something.

Shimoda-san: what do you think?

 drivers/mmc/host/renesas_sdhi_internal_dmac.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/mmc/host/renesas_sdhi_internal_dmac.c +1 -5
index 380570a26a09..561e90755a3b 100644
@@ -161,11 +161,7 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host,
 	enum dma_data_direction dir;
 	int ret;
 
-	/* This DMAC cannot handle if sg_len is not 1 */
-	WARN_ON(host->sg_len > 1);
-
-	/* This DMAC cannot handle if buffer is not 8-bytes alignment */
-	if (!IS_ALIGNED(sg->offset, 8))
+	if (WARN_ON(host->sg_len > 1) || !IS_ALIGNED(sg->offset, 8))
 		goto force_pio;
 
 	if (data->flags & MMC_DATA_READ) {
Signature · 1 line
2.11.0
#1 lore raw
Quoted 21 lines · Wolfram Sang

From: Wolfram Sang <[email protected]>

If we detect an incompatible scatterlist, we should fall back to PIO, too.

---

I found this while working on the RX DMA issue. I don't see a reason why we shouldn't fall back in this case as well. But maybe I am missing something.

Shimoda-san: what do you think?

 drivers/mmc/host/renesas_sdhi_internal_dmac.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/mmc/host/renesas_sdhi_internal_dmac.c +0 -0
index 380570a26a09..561e90755a3b 100644

drivers/mmc/host/renesas_sdhi_internal_dmac.c renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host, · line 164

Quoted 9 lines
drivers/mmc/host/renesas_sdhi_internal_dmac.c +1 -5
@@ -161,11 +161,7 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host,
        enum dma_data_direction dir;
        int ret;
 
-       /* This DMAC cannot handle if sg_len is not 1 */
-       WARN_ON(host->sg_len > 1);
-
-       /* This DMAC cannot handle if buffer is not 8-bytes alignment */
-       if (!IS_ALIGNED(sg->offset, 8))
+       if (WARN_ON(host->sg_len > 1) || !IS_ALIGNED(sg->offset, 8))

The WARN_ON becomes a bit misleading being a part of the if statement, as it should never happen when the driver has set ->max_segs = 1.

For the alignment check, and the moving to PIO, this certainly makes sense to me.

drivers/mmc/host/renesas_sdhi_internal_dmac.c renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host, · line 167

Quoted 3 lines
drivers/mmc/host/renesas_sdhi_internal_dmac.c +0 -0
                goto force_pio;
 
        if (data->flags & MMC_DATA_READ) {

Kind regards
Uffe

#2 lore raw
Quoted 10 lines

drivers/mmc/host/renesas_sdhi_internal_dmac.c renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host, · line 164

Quoted 7 lines
drivers/mmc/host/renesas_sdhi_internal_dmac.c +1 -5
-       /* This DMAC cannot handle if sg_len is not 1 */
-       WARN_ON(host->sg_len > 1);
-
-       /* This DMAC cannot handle if buffer is not 8-bytes alignment */
-       if (!IS_ALIGNED(sg->offset, 8))
+       if (WARN_ON(host->sg_len > 1) || !IS_ALIGNED(sg->offset, 8))

The WARN_ON becomes a bit misleading being a part of the if statement, as it should never happen when the driver has set ->max_segs = 1.

Uh, yeah, right. So, we could simply drop the WARN_ON?

#3 lore raw
In reply to Wolfram Sang

Hi Wolfram-san,

Thank you for the patch!

Quoted 23 lines

From: Wolfram Sang, Sent: Thursday, April 5, 2018 2:01 AM

From: Wolfram Sang <[email protected]>

If we detect an incompatible scatterlist, we should fall back to PIO, too.

---

I found this while working on the RX DMA issue. I don't see a reason why we shouldn't fall back in this case as well. But maybe I am missing something.

Shimoda-san: what do you think?

 drivers/mmc/host/renesas_sdhi_internal_dmac.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/mmc/host/renesas_sdhi_internal_dmac.c +0 -0
index 380570a26a09..561e90755a3b 100644

drivers/mmc/host/renesas_sdhi_internal_dmac.c renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host, · line 164

Quoted 4 lines
drivers/mmc/host/renesas_sdhi_internal_dmac.c +0 -1
@@ -161,11 +161,7 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host,
 	enum dma_data_direction dir;
 	int ret;
 
-	/* This DMAC cannot handle if sg_len is not 1 */

I would like to keep this comment.

drivers/mmc/host/renesas_sdhi_internal_dmac.c renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host, · line 164

Quoted 5 lines
drivers/mmc/host/renesas_sdhi_internal_dmac.c +1 -4
-	WARN_ON(host->sg_len > 1);
-
-	/* This DMAC cannot handle if buffer is not 8-bytes alignment */
-	if (!IS_ALIGNED(sg->offset, 8))
+	if (WARN_ON(host->sg_len > 1) || !IS_ALIGNED(sg->offset, 8))

As Ulf-san said on other thread about this WARN_ON(), I think dropping the WARN_ON() is better.

Best regards,
Yoshihiro Shimoda