Skip to contentSkip to conversation

spi-imx -> make DMA optional through DT

PATCH In review Hans Christian Lønstad 3 participants 10 messages Mar 29, 2016 – Mar 31, 2016 3 messages not in the archive

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

PATCH 1/1 spi-imx -> make DMA optional through DT

This patch applies to kernel 4.1.15_ga and fixes a regression for UBIFS on SPI NOR introduced by assigning DMA channels in DT

When UBIFS uses SPI NOR devices, the IO buffer allocation using vmalloc creates problems when the SPI controller is DMA based (as it is for some ARM SoC's).
Introduce a "nodma" boolean DT attribute as a fix for imx SoC.
---
drivers/spi/spi-imx.c | 7 ++++++-

1 file changed, 6 insertions(+), 1 deletion(-)
drivers/spi/spi-imx.c +6 -1
index 8c0e0cc..d0df195 100644
@@ -1163,6 +1163,7 @@ static int spi_imx_probe(struct platform_device *pdev)
       struct spi_imx_data *spi_imx;
       struct resource *res;
       int i, ret, num_cs, irq;
+       bool nodma;
 
       if (!np && !mxc_platform_info) {
               dev_err(&pdev->dev, "can't get the platform data\n");
@@ -1177,6 +1178,7 @@ static int spi_imx_probe(struct platform_device *pdev)
                       return ret;
       }
 
+       nodma = of_property_read_bool(np, "nodma");
       master = spi_alloc_master(&pdev->dev,
                       sizeof(struct spi_imx_data) + sizeof(int) * num_cs);
       if (!master)
@@ -1267,9 +1269,12 @@ static int spi_imx_probe(struct platform_device *pdev)
        * Only validated on i.mx6 now, can remove the constrain if validated on
        * other chips.
        */
+       if (nodma)
+               dev_info(&pdev->dev, "DMA disabled by DT\n");
+
       if ((spi_imx->devtype_data == &imx51_ecspi_devtype_data
           || spi_imx->devtype_data == &imx6ul_ecspi_devtype_data)
-           && spi_imx_sdma_init(&pdev->dev, spi_imx, master, res))
+           && !nodma && spi_imx_sdma_init(&pdev->dev, spi_imx, master, res))
               dev_err(&pdev->dev, "dma setup error,use pio instead\n");
 
       spi_imx->devtype_data->reset(spi_imx);

--
2.5.5

#1 lore raw

Hello Hans,

(Adding Fabio Estevam on Cc)

Quoted 7 lines · Hans Christian Lønstad

This patch applies to kernel 4.1.15_ga and fixes a regression for UBIFS on SPI NOR introduced by assigning DMA channels in DT

When UBIFS uses SPI NOR devices, the IO buffer allocation using vmalloc creates problems when the SPI controller is DMA based (as it is for some ARM SoC's).
Introduce a "nodma" boolean DT attribute as a fix for imx SoC.

Is this a NXP's specific regression? or this is also found on mainline kernel? If so, we ought to address this on mainline and backport the referred fixes for the issue.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#2 lore raw

Thank you for your quick response. Please find my comments inserted below.

BTW: will the current vivante cpu user space code run on the 4.1.15_ga kernel?

Regards

Hans Chr
--------------------------------------------------
Hans Christian Lønstad, CTO
Data Respons AS
Sandviksveien 26
P.O. Box 489
NO-1323 Høvik, Norway

[email protected]<mailto:[email protected]>
www.datarespons.com<http://www.datarespons.com/>
-------------------------------------------------

On 29. mar. 2016, at 22.44, Otavio Salvador <[email protected]<mailto:[email protected]>> wrote:

Hello Hans,

(Adding Fabio Estevam on Cc)

On Tue, Mar 29, 2016 at 4:28 PM, Hans Christian Lønstad <[email protected]<mailto:[email protected]>> wrote:
This patch applies to kernel 4.1.15_ga and fixes a regression for UBIFS on SPI NOR introduced by assigning DMA channels in DT

When UBIFS uses SPI NOR devices, the IO buffer allocation using vmalloc creates problems when the SPI controller is DMA based (as it is for some ARM SoC's).
Introduce a "nodma" boolean DT attribute as a fix for imx SoC.

Is this a NXP's specific regression? or this is also found on mainline kernel? If so, we ought to address this on mainline and backport the referred fixes for the issue.

The issue surfaced after DT introduced the DMA functionality (imx6qdl.dtsi). This applies to mainline kernels (checked 4.1 and up) as well.
It is my understanding that SPI DMA is performed using scatter/gather which should be able to handle vmalloc’ed memory, so the question remains wether the root cause lies within the DMA code or is some kind of coherence issue within the UBIFS code.

Anyway, the benefit from DMA might be questionable for this use case (we are using SPI NOR for VPD product data), so we are happy just disabling it.

The issue must be considered grave as it bricks systemd trying to mount an UBIFS during startup.

--
Otavio Salvador O.S. Systems
http://www.ossystems.com.br http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854 Mobile: +1 (347) 903-9750

A message that is not in the archive (sent off-list or not yet received): [email protected]

reviewer
#4 lore raw

Hi Hans,

Quoted 7 lines · Hans Christian Lønstad

The issue surfaced after DT introduced the DMA functionality (imx6qdl.dtsi). This applies to mainline kernels (checked 4.1 and up) as well. It is my understanding that SPI DMA is performed using scatter/gather which should be able to handle vmalloc’ed memory, so the question remains wether the root cause lies within the DMA code or is some kind of coherence issue within the UBIFS code.

Quoted 5 lines

Anyway, the benefit from DMA might be questionable for this use case (we are using SPI NOR for VPD product data), so we are happy just disabling it.

The issue must be considered grave as it bricks systemd trying to mount an UBIFS during startup.

Thanks for reporting the issue.

It would be better if we could fix the DMA issue instead of disabling it.

If you are able to reproduce this with a mainline kernel, it would be nice to report this bug into the linux-spi mailing list, so that other people could potentially help with it.

reviewer
#5 lore raw
Quoted 7 lines · Fabio Estevam

Thanks for reporting the issue.

It would be better if we could fix the DMA issue instead of disabling it.

If you are able to reproduce this with a mainline kernel, it would be nice to report this bug into the linux-spi mailing list, so that other people could potentially help with it.

Looks like this same issue has been reported before:
https://freescale.jiveon.com/thread/375328

And here too:
http://lists.infradead.org/pipermail/linux-mtd/2009-August/026817.html

Please report this on linux-mtd list so that we can hopefully have a proper fix for this issue.

reviewer
#6 lore raw

Hi Hans,

Quoted 2 lines · Fabio Estevam

Looks like this same issue has been reported before:
https://freescale.jiveon.com/thread/375328

Just tested the steps provided in the community thread on a 4.6-rc1 kernel and it worked well here.

I do see the failure on 4.1.15 though running the same sequence.

Can you also try it on 4.6-rc1 on your side? I think we will need to backport some of the fixes in drivers/spi/spi.c.

#7 lore raw
Quoted 11 lines · Fabio Estevam

Hi Hans,

Quoted 2 lines · Fabio Estevam

Looks like this same issue has been reported before:
https://freescale.jiveon.com/thread/375328

Quoted 7 lines

Just tested the steps provided in the community thread on a 4.6-rc1 kernel and it worked well here.

I do see the failure on 4.1.15 though running the same sequence.

Can you also try it on 4.6-rc1 on your side? I think we will need to backport some of the fixes in drivers/spi/spi.c.

Implying the bug is in the SPI class driver and fixed in 4.6?
It appears to be changes in the spi-imx as well, so back porting might need to include this.

If I find time, I might try out 4.6, but as said earlier, we are fine disabling DMA for now. What´s more troubling with 4.1.15 is that vivante user space crashes opening EGLFS. (I noticed some config/board file changes regarding DMA_CMA that might point in this direction)

Hans

A message that is not in the archive (sent off-list or not yet received): 56fd5cea.01d3190a.84316.ffffde1fSMTPIN_ADDED_MISSING@mx.google.com

reviewer
#9 lore raw
Quoted 2 lines · Hans Christian Lønstad

Implying the bug is in the SPI class driver and fixed in 4.6?
It appears to be changes in the spi-imx as well, so back porting might need to include this.

This issue is not i.MX6 related. There are reports on this issue with different SoCs.

Quoted 3 lines

If I find time, I might try out 4.6, but as said earlier, we are fine disabling DMA for now. What´s more troubling with 4.1.15 is that vivante user space crashes opening EGLFS. (I noticed some config/board file changes regarding DMA_CMA that might point in this direction)

That's a different bug.

#10 lore raw
Quoted 12 lines · Fabio Estevam
Quoted 2 lines · Hans Christian Lønstad

Implying the bug is in the SPI class driver and fixed in 4.6?
It appears to be changes in the spi-imx as well, so back porting might need to include this.

This issue is not i.MX6 related. There are reports on this issue with different SoCs.

As in TI SoC yes.

Quoted 6 lines
Quoted 4 lines

If I find time, I might try out 4.6, but as said earlier, we are fine disabling DMA for now. What´s more troubling with 4.1.15 is that vivante user space crashes opening EGLFS. (I noticed some config/board file changes regarding DMA_CMA that might point in this direction)

That's a different bug.

Completely agreed, just wandered if you could point me in some direction ,->

Hans

A message that is not in the archive (sent off-list or not yet received): 56fd5ecd.0203190a.7dd8a.ffffefa6SMTPIN_ADDED_MISSING@mx.google.com

reviewer
#12 lore raw
Quoted 1 line · Hans Christian Lønstad

Completely agreed, just wandered if you could point me in some direction ,->

I am not familiar with GPU code. Maybe you could start a new thread explaining in details this GPU issue.