Issue with SPI communication

Hello!

I have an issue with SPI communication.

Information about my system

cat /etc/issue

The Angstrom Distribution
Angstrom v2017.12 - Kernel
cr7_Console-Image 2.8b3 20181115

uname -a

Linux cr7 4.9.87-2.8.3+g1341129ea22d #1 SMP Mon Mar 18 09:50:27 UTC 2019 armv7l armv7l armv7l GNU/Linux

Description of Issue

I have my custom Linux kernel driver for DSP. It communicate with 6 DSPs through SPI bus by means of spi_write() functions.

Driver was taken from AT91SAM9G20 plaftorm, where it works flawless.

But, i.MX6 SPI driver periodically throw errors like

[ 2485.327595] spi_master spi1: I/O Error in DMA RX

[ 2485.344001] gs_mgms_dsp spi1.2: SPI transfer failed: -110

[ 2485.361039] spi_master spi1: failed to transfer one message from queue

[ 2485.378422] gs_mgms_dsp spi1.2: SPI read error.

Sometimes this happens due to timeouts for 512 byte DMA transfers, sometimes due timeouts for 1 byte PIO transfers.

As higher the SPI bus frequency, then more often errors occur.

At 16 MHz, they occur after some seconds from start of communication.

At 12 MHz, they occur once per 3-4 hours.

I think, issue is in drivers/spi/spi-imx.c.

Maybe this is a known issue and somebody know about patch to fix it?

Best wishes.

Igor Plyatov

hi @plyatov

Welcome to the Toradex Community!

Linux cr7 4.9.87-2.8.3+g1341129ea22d

Could you update to Bsp 2.8b5 and check if you still have this issue?

I have my custom Linux kernel driver for DSP. It communicate with 6 DSPs through SPI bus by means of spi_write() functions.

Could you provide your kernel config and the source code of the kernel driver?

Sometimes this happens due to timeouts for 512 byte DMA transfers, sometimes due timeouts for 1 byte PIO transfers.

As higher the SPI bus frequency, then more often errors occur.

At 16 MHz, they occur after some seconds from start of communication.

How often does the error occur?

Best regards,
Jaski

Dear Jaski,

I have tested this issue and it looks very similar to i.MX7D spidev - Technical Support - Toradex Community.

Additionally, I have tested linux-5.1.0-rc2 and result reported to different Linux e-mail lists.

Please, look at conversation:

Best wishes.

Igor Plyatov

Dear Igor

Thanks for your Input.

I have tested this issue and it looks very similar to i.MX7D spidev - Technical Support - Toradex Community.

Is your kernel driver working with DMA disabled or not?

Additionally, I have tested linux-5.1.0-rc2 and result reported to different Linux e-mail lists.

Let us know, once you got feedback there.

Best regards,
Jaski

Hi
With Colibri iMX6dl we conntected a SRAM (microchip,mchp23lcv1024) with SPI.
I encountered after ~10-100k access SPI transfer failed: -110 using the bsp 2.8b3.
Then we migrated to mainlinekernel 4.19.y and have never seen the problem again
even after heavy testing.
Regards Stefan

@plyatov We are working on this issue and we will get back to you.

Best regards,
Philippe

Is your kernel driver working with DMA disabled or not?
Yes. It works, but performance of Linux-4.9 SPI driver is quite bad under heavy OS load.

Linux-5.1.0-rc3 works better - performance is better on 80 %.

The DMA transfers are less effective than PIO.

See continuation of thread with my letters in above mentioned e-mail lists.

Be careful with pseudo good test results!

The issue of i.MX6 SPI transfers trough DMA is quite bad - bad operation of eCSPI interfaces depends from SOC chip to chip.

If you have success with eCSPI tested on one i.MX6 SOC chip, it does not mean so other exemplar of i.MX6 SOC chip will work good.

See continuation of thread with my letters in above mentioned e-mail lists.

Thanks for your Input.

hi @plyatov

Which SPI output/Bus (number) are you using?

Hi jaski.tx!

I use 3 SPI bus:

  • spi0 - eCSPI1;
  • spi1 - eCSPI2;
  • spi4 - eCSPI5.

So do you have timeouts on every SPI bus or a single specific one?

Thanks for your Input. So is the Issue solved now?

Hello @plyatov

Could you please confirm that your patch to change SDMA type in DTS files solves the “timeouts issue” on your board?

Yes, my patch for imx6q.dtsi and imx6qdl.dtsi resolve issue of timeout in linux-5.1.0-rc4.
link text

Thanks for your valuable Input.

Timeouts was because of incorrect Device Tree data. See 'Re: Issues with i.MX SPI DMA transfers' - MARC