iMX8MM ECSPI DMA not working, although FW is loading (only PIO mode works)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iMX8MM ECSPI DMA not working, although FW is loading (only PIO mode works)

1,502 Views
MaBe
Contributor I

Hey guys,

i'm working with the ECSPI1:

 

			ecspi1: spi@30820000 {
				compatible = "fsl,imx8mm-ecspi", "fsl,imx51-ecspi";
				#address-cells = <1>;
				#size-cells = <0>;
				reg = <0x30820000 0x10000>;
				interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
				clocks = <&clk IMX8MM_CLK_ECSPI1_ROOT>,
					 <&clk IMX8MM_CLK_ECSPI1_ROOT>;
				clock-names = "ipg", "per";
				dmas = <&sdma2 10 24 0>, <&sdma2 11 24 0>;
				dma-names = "rx", "tx";
				status = "disabled";
			};
			sdma2: dma-controller@302c0000 {
				compatible = "fsl,imx8mm-sdma", "fsl,imx8mq-sdma";
				reg = <0x302c0000 0x10000>;
				interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>;
				clocks = <&clk IMX8MM_CLK_SDMA2_ROOT>,
					 <&clk IMX8MM_CLK_SDMA2_ROOT>;
				clock-names = "ipg", "ahb";
				#dma-cells = <3>;
				fsl,sdma-ram-script-name = "imx/sdma/sdma-imx7d.bin";
			};

 

(Source: imx8mm.dtsi)

The init looks okay (or not?):

 

   14.336944] imx-sdma 30bd0000.dma-controller: external firmware not found, using ROM firmware
[   14.337188] imx-sdma 302b0000.dma-controller: external firmware not found, using ROM firmware
[   14.544537] imx-sdma 302c0000.dma-controller: loaded firmware 4.5
[   16.637457] dmaengine: __dma_request_channel: success (dma0chan0)
[   16.637475] imx-sdma 302c0000.dma-controller: private_candidate: dma0chan0 busy
[   16.637480] dmaengine: __dma_request_channel: success (dma0chan1)
[   17.037288] dmaengine: __dma_request_channel: success (dma2chan0)
[   17.037306] imx-sdma 30bd0000.dma-controller: private_candidate: dma2chan0 busy
[   17.037311] dmaengine: __dma_request_channel: success (dma2chan1)

 

But when i try to send more than 63 bytes, the spi-imx module switches to DMA mode and failed:

 

[ 1110.091034] imx-sdma 302c0000.dma-controller: load_address = 685
[ 1110.091045] imx-sdma 302c0000.dma-controller: wml = 0x00000020
[ 1110.091050] imx-sdma 302c0000.dma-controller: shp_addr = 0x30820000
[ 1110.091055] imx-sdma 302c0000.dma-controller: per_addr = 0x00000000
[ 1110.091059] imx-sdma 302c0000.dma-controller: event_mask0 = 0x00000400
[ 1110.091064] imx-sdma 302c0000.dma-controller: event_mask1 = 0x00000000
[ 1110.091073] imx-sdma 302c0000.dma-controller: setting up 1 entries for channel 2.
[ 1110.091078] imx-sdma 302c0000.dma-controller: entry 0: count: 128 dma: 0x69ce8000  intr
[ 1110.091086] imx-sdma 302c0000.dma-controller: vchan 0000000029ea9014: txd 0000000096283d2e[2]: submitted
[ 1110.091102] imx-sdma 302c0000.dma-controller: load_address = 749
[ 1110.091106] imx-sdma 302c0000.dma-controller: wml = 0x00000020
[ 1110.091111] imx-sdma 302c0000.dma-controller: shp_addr = 0x30820004
[ 1110.091115] imx-sdma 302c0000.dma-controller: per_addr = 0x00000000
[ 1110.091119] imx-sdma 302c0000.dma-controller: event_mask0 = 0x00000800
[ 1110.091123] imx-sdma 302c0000.dma-controller: event_mask1 = 0x00000000
[ 1110.091132] imx-sdma 302c0000.dma-controller: setting up 1 entries for channel 1.
[ 1110.091136] imx-sdma 302c0000.dma-controller: entry 0: count: 128 dma: 0x69cea000  intr
[ 1110.091143] imx-sdma 302c0000.dma-controller: vchan 00000000903699c1: txd 00000000e90c4730[2]: submitted
[ 1112.115453] spi_imx 30820000.spi: I/O Error in DMA TX
[ 1112.115478] spidev spi0.0: SPI transfer failed: -110
[ 1112.115527] spi_master spi0: failed to transfer one message from queue

 

I have no clue whats wrong, please can you help me?

0 Kudos
Reply
5 Replies

1,466 Views
ceggers
Contributor V

Hi,

I also had much fun with the ECSPI on i.MX in the past. Some problems were always reproducible others happened only on high bus pressure...

At first you should switch to the RAM routines of the SDMA instead of using the ROM routines. Please ensure that

  1. The firmware file is available (under /lib/firmware/imx/sdma/sdma-imx7d.bin)
  2. The SDMA kernel driver as built as a module.

After that, these message should disappear:

imx-sdma 30bd0000.dma-controller: external firmware not found, using ROM firmware

See also here:

https://community.nxp.com/t5/i-MX-Processors/IMX8MM-EVK-kernel-hang-on-imx-yocto-L5-4-24-2-1-0/m-p/1...

regards
Christian

0 Kudos
Reply

1,457 Views
MaBe
Contributor I

Hi Christian,

thanks for reply. As you can see above, the FW is loading for the relevant controller and all requests are successful. The DMA access is also working, but failed.

Do you really have a working ECSPI/DMA configuration? That means, you can send more than 63 bytes and DMA is used. Can you post it?

First i thought, everything is working, but then i saw i'm always in PIO mode.

 

0 Kudos
Reply

1,441 Views
ceggers
Contributor V

As you can see above, the FW is loading for the relevant controller and all requests are successful.

From the log I see that the firmware cannot be found. So the SDMA uses the ROM firmware as a fallback.

Do you really have a working ECSPI/DMA configuration? That means, you can send more than 63 bytes and DMA is used. Can you post it?

I have made several modifications to the SDMA firmware (and the Linux driver) in order to solve problems which occur only on high bus load scenarios (simultaneous use of multiple UARTs and SDMA).

But for normal load, it should work with the correct combination of the Linux kernel and the SDMA RAM firmware.

regards,
Christian

0 Kudos
Reply

1,432 Views
MaBe
Contributor I

Sorry, it's not really helpful when you ignore the entire log:

[   14.544537] imx-sdma 302c0000.dma-controller: loaded firmware 4.5

 And this is exactly the controller i'm using (see above). Please explain, why there should be a correlation to the other SDMA controllers in terms of the FW!

You modified the SDMA FW? Where did you get the source code?

0 Kudos
Reply

1,409 Views
ceggers
Contributor V

Hi MaBe,

Sorry, it's not really helpful when you ignore the entire log

you're right, I should read the entire log. I am not used to have more than one SDMA controller...

I think that your problem should be examined in a debugger. I'll try to get my i.MX8 setup running this week (currently I use only i.MX6ULL). How do you access the SPI device. Do you use spidev?

regards,
Christian

 

0 Kudos
Reply