Skip to contentSkip to conversation

mmc: spi: disable dma mapping code, as it does not work

PATCH In review Phil Elwell 2 participants 4 messages May 22, 2017 – May 23, 2017

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

PATCH 1/1 mmc: spi: disable dma mapping code, as it does not work

since:
commit 0589342c27944e50ebd7a54f5215002b6598b748
Author: Rob Herring <[email protected]>
Date: Tue Oct 29 23:36:46 2013 -0500

of: set dma_mask to point to coherent_dma_mask

Platform devices created by DT code don't initialize dma_mask pointer to anything. Set it to coherent_dma_mask by default if the architecture code has not set it.

the mmc-spi driver no longer detects the sd-cards any longer.

This patch disables the offending section in mmc_spi so that the driver works again and detects the sd card normally.

There is no real negative impact as the spi-framework does no longer rely on driver-provided DMA mappings but maps the transfers transparently.

---
 drivers/mmc/host/mmc_spi.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/mmc/host/mmc_spi.c +11 -0
index ae19d83bb9de0..16946e2513afa 100644
@@ -1387,6 +1387,16 @@ static int mmc_spi_probe(struct spi_device *spi)
 	if (!host->data)
 		goto fail_nobuf1;
 
+	/* for some reason mmc_spi does not work with this enabled
+	 * it is not needed anyway, as the SPI framework does DMA
+	 * transfers now automatically
+	 * the patch that introduced this was:
+	 * commit 0589342c27944e50ebd7a54f5215002b6598b748
+	 * Author: Rob Herring <[email protected]>
+	 * Date:   Tue Oct 29 23:36:46 2013 -0500
+	 *      of: set dma_mask to point to coherent_dma_mask
+	 */
+#if 0
 	if (spi->master->dev.parent->dma_mask) {
 		struct device	*dev = spi->master->dev.parent;
 
@@ -1402,6 +1412,7 @@ static int mmc_spi_probe(struct spi_device *spi)
 				host->data_dma, sizeof(*host->data),
 				DMA_BIDIRECTIONAL);
 	}
+#endif
 
 	/* setup message for status/busy readback */
 	spi_message_init(&host->readback);
#1 lore raw
Quoted 48 lines · Phil Elwell

since:
commit 0589342c27944e50ebd7a54f5215002b6598b748
Author: Rob Herring <[email protected]>
Date: Tue Oct 29 23:36:46 2013 -0500

of: set dma_mask to point to coherent_dma_mask

Platform devices created by DT code don't initialize dma_mask pointer to anything. Set it to coherent_dma_mask by default if the architecture code has not set it.

the mmc-spi driver no longer detects the sd-cards any longer.

This patch disables the offending section in mmc_spi so that the driver works again and detects the sd card normally.

There is no real negative impact as the spi-framework does no longer rely on driver-provided DMA mappings but maps the transfers transparently.

---
 drivers/mmc/host/mmc_spi.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/mmc/host/mmc_spi.c +10 -0
index ae19d83bb9de0..16946e2513afa 100644
@@ -1387,6 +1387,16 @@ static int mmc_spi_probe(struct spi_device *spi)
        if (!host->data)
                goto fail_nobuf1;
 
+       /* for some reason mmc_spi does not work with this enabled
+        * it is not needed anyway, as the SPI framework does DMA
+        * transfers now automatically
+        * the patch that introduced this was:
+        * commit 0589342c27944e50ebd7a54f5215002b6598b748
+        * Author: Rob Herring <[email protected]>
+        * Date:   Tue Oct 29 23:36:46 2013 -0500
+        *      of: set dma_mask to point to coherent_dma_mask
+        */
+#if 0
        if (spi->master->dev.parent->dma_mask) {
                struct device   *dev = spi->master->dev.parent;
 

drivers/mmc/host/mmc_spi.c static int mmc_spi_probe(struct spi_device *spi) · line 1418

Quoted 7 lines
drivers/mmc/host/mmc_spi.c +1 -0
@@ -1402,6 +1412,7 @@ static int mmc_spi_probe(struct spi_device *spi)
                                host->data_dma, sizeof(*host->data),
                                DMA_BIDIRECTIONAL);
        }
+#endif
 
        /* setup message for status/busy readback */
        spi_message_init(&host->readback);

Phil, I am not sure how to go with this.

Your change drops the dma implementation in the mmc_spi driver as host->dma_dev now never gets assigned. I do think that makes sense as the dma support should be implemented in the spi master driver and not in the spi client driver, which currently is the case for mmc_spi.

Then perhaps a more proper change would be to remove the dma implementation in mmc_spi altogether?

And one more thing, next time also cc the spi-list and Mark Brown, to try to some broader input.

Kind regards
Uffe

#2 lore raw
Quoted 59 lines · Ulf Hansson
Quoted 48 lines · Phil Elwell

since:
commit 0589342c27944e50ebd7a54f5215002b6598b748
Author: Rob Herring <[email protected]>
Date: Tue Oct 29 23:36:46 2013 -0500

of: set dma_mask to point to coherent_dma_mask

Platform devices created by DT code don't initialize dma_mask pointer to anything. Set it to coherent_dma_mask by default if the architecture code has not set it.

the mmc-spi driver no longer detects the sd-cards any longer.

This patch disables the offending section in mmc_spi so that the driver works again and detects the sd card normally.

There is no real negative impact as the spi-framework does no longer rely on driver-provided DMA mappings but maps the transfers transparently.

---
 drivers/mmc/host/mmc_spi.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/mmc/host/mmc_spi.c +10 -0
index ae19d83bb9de0..16946e2513afa 100644
@@ -1387,6 +1387,16 @@ static int mmc_spi_probe(struct spi_device *spi)
        if (!host->data)
                goto fail_nobuf1;
 
+       /* for some reason mmc_spi does not work with this enabled
+        * it is not needed anyway, as the SPI framework does DMA
+        * transfers now automatically
+        * the patch that introduced this was:
+        * commit 0589342c27944e50ebd7a54f5215002b6598b748
+        * Author: Rob Herring <[email protected]>
+        * Date:   Tue Oct 29 23:36:46 2013 -0500
+        *      of: set dma_mask to point to coherent_dma_mask
+        */
+#if 0
        if (spi->master->dev.parent->dma_mask) {
                struct device   *dev = spi->master->dev.parent;
 

drivers/mmc/host/mmc_spi.c static int mmc_spi_probe(struct spi_device *spi) · line 1418

Quoted 7 lines
drivers/mmc/host/mmc_spi.c +1 -0
@@ -1402,6 +1412,7 @@ static int mmc_spi_probe(struct spi_device *spi)
                                host->data_dma, sizeof(*host->data),
                                DMA_BIDIRECTIONAL);
        }
+#endif
 
        /* setup message for status/busy readback */
        spi_message_init(&host->readback);

Phil, I am not sure how to go with this.

Quoted 7 lines

Your change drops the dma implementation in the mmc_spi driver as host->dma_dev now never gets assigned. I do think that makes sense as the dma support should be implemented in the spi master driver and not in the spi client driver, which currently is the case for mmc_spi.

Then perhaps a more proper change would be to remove the dma implementation in mmc_spi altogether?

I don't have enough in-depth SPI knowledge to make that decision - I'm happy to go with what the SPI experts recommend.

Quoted 2 lines

And one more thing, next time also cc the spi-list and Mark Brown, to try to some broader input.

Thanks for the tip, Ulf - I just went with what scripts/get_maintainer.pl suggested. Perhaps that list needs to be updated?

Phil

#3 lore raw
Quoted 65 lines · Phil Elwell
Quoted 64 lines · Ulf Hansson
Quoted 48 lines · Phil Elwell

since:
commit 0589342c27944e50ebd7a54f5215002b6598b748
Author: Rob Herring <[email protected]>
Date: Tue Oct 29 23:36:46 2013 -0500

of: set dma_mask to point to coherent_dma_mask

Platform devices created by DT code don't initialize dma_mask pointer to anything. Set it to coherent_dma_mask by default if the architecture code has not set it.

the mmc-spi driver no longer detects the sd-cards any longer.

This patch disables the offending section in mmc_spi so that the driver works again and detects the sd card normally.

There is no real negative impact as the spi-framework does no longer rely on driver-provided DMA mappings but maps the transfers transparently.

---
 drivers/mmc/host/mmc_spi.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/mmc/host/mmc_spi.c +10 -0
index ae19d83bb9de0..16946e2513afa 100644
@@ -1387,6 +1387,16 @@ static int mmc_spi_probe(struct spi_device *spi)
        if (!host->data)
                goto fail_nobuf1;
 
+       /* for some reason mmc_spi does not work with this enabled
+        * it is not needed anyway, as the SPI framework does DMA
+        * transfers now automatically
+        * the patch that introduced this was:
+        * commit 0589342c27944e50ebd7a54f5215002b6598b748
+        * Author: Rob Herring <[email protected]>
+        * Date:   Tue Oct 29 23:36:46 2013 -0500
+        *      of: set dma_mask to point to coherent_dma_mask
+        */
+#if 0
        if (spi->master->dev.parent->dma_mask) {
                struct device   *dev = spi->master->dev.parent;
 

drivers/mmc/host/mmc_spi.c static int mmc_spi_probe(struct spi_device *spi) · line 1418

Quoted 7 lines
drivers/mmc/host/mmc_spi.c +1 -0
@@ -1402,6 +1412,7 @@ static int mmc_spi_probe(struct spi_device *spi)
                                host->data_dma, sizeof(*host->data),
                                DMA_BIDIRECTIONAL);
        }
+#endif
 
        /* setup message for status/busy readback */
        spi_message_init(&host->readback);

Phil, I am not sure how to go with this.

Your change drops the dma implementation in the mmc_spi driver as host->dma_dev now never gets assigned. I do think that makes sense as the dma support should be implemented in the spi master driver and not in the spi client driver, which currently is the case for mmc_spi.

Quoted 5 lines
Quoted 2 lines

Then perhaps a more proper change would be to remove the dma implementation in mmc_spi altogether?

I don't have enough in-depth SPI knowledge to make that decision - I'm happy to go with what the SPI experts recommend.

Okay. Let's see.

Quoted 6 lines
Quoted 3 lines

And one more thing, next time also cc the spi-list and Mark Brown, to try to some broader input.

Thanks for the tip, Ulf - I just went with what scripts/get_maintainer.pl suggested. Perhaps that list needs to be updated?

No, this is more a special case I would say.

Kind regards
Uffe