<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: A bug in the SPI bus driver (iMX6 BSP 4.0.0/4.1.0) in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226230#M16124</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Brian&lt;/P&gt;&lt;P&gt;It is good to know that your issue disappeared after you made change. I guess we can close your post now. If anyone knows the root cause, he/she can come to here post the resolution.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Yixing&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Mar 2014 02:40:08 GMT</pubDate>
    <dc:creator>YixingKong</dc:creator>
    <dc:date>2014-03-21T02:40:08Z</dc:date>
    <item>
      <title>A bug in the SPI bus driver (iMX6 BSP 4.0.0/4.1.0)</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226223#M16117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On our custom iMX6Q board, we use the SPI1 and SPI2 to communicate with other devices.&lt;/P&gt;&lt;P&gt;Currently, we write a program with many threads to access SPI1 and SPI2 simultaneously to do the burn-in test.&lt;/P&gt;&lt;P&gt;And we found that sometimes the one of these two SPI bus will hang on "__spi_sync" function. (use "cat /proc/xxxx/wchan" to check)&lt;/P&gt;&lt;P&gt;After we trace the SPI driver source code in the kernel, we found that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the "spi_imx.c" and in the function "spi_imx_transfer", you call the "clk_enable" and "clk_disable" function.&lt;/P&gt;&lt;P&gt;But the function "spi_imx_transfer" is protected by a spinlock(see the "spi_async_locked" function in "spi.c")&lt;/P&gt;&lt;P&gt;I also check the source code "clock.c" and fount that the "clk_enable" and "clk_disable" function use mutex to protect.&lt;/P&gt;&lt;P&gt;It means you use mutex in the wrong context.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, I have modified the driver to fix the problem and start test again. The board still alive for 16 hours.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--------------------------------------------------------------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;Update:&lt;/P&gt;&lt;P&gt;I found that the "clk_enable" and "clk_disable" were just called in the work queue. It seems OK to use the mutex lock inside the work queue.&lt;/P&gt;&lt;P&gt;But I think there still have problems in the SPI bus driver.&lt;/P&gt;&lt;P&gt;I have tried two methods to fix the SPI hang issue:&lt;/P&gt;&lt;P&gt;1. Modify the SPI bus driver. We just enable the clock at probe function and delete the "clk_enable" and "clk_disable" in the "spi_imx_transfer" and "spi_imx_setupxfer".&lt;/P&gt;&lt;P&gt;2. Modify the clk_enable and clk_disable function. Using the spin lock to protect (not use the mutex lock).&lt;/P&gt;&lt;P&gt;Both of them can fix the hang issue on my test.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Brian&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;消息编辑者为：brian wu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Feb 2014 07:04:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226223#M16117</guid>
      <dc:creator>brianwu</dc:creator>
      <dc:date>2014-02-12T07:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: A bug in the SPI bus driver (iMX6 BSP 4.0.0/4.1.0)</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226224#M16118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does your test run fine if you use 3.10.17 kernel from FSL or 3.13 from kernel.org?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fabio Estevam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Feb 2014 12:39:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226224#M16118</guid>
      <dc:creator>fabio_estevam</dc:creator>
      <dc:date>2014-02-12T12:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: A bug in the SPI bus driver (iMX6 BSP 4.0.0/4.1.0)</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226225#M16119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Fabio&lt;/P&gt;&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;No, I only test on the 3.0.35 kernel.&lt;/P&gt;&lt;P&gt;In our project, we have used the kernel 3.0.35 for about three months. &lt;/P&gt;&lt;P&gt;If we use other version kernel, we have to re-porting the source code and test all the I/O function again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additional information for the SPI hang issue:&lt;/P&gt;&lt;P&gt;1. The issue can be duplicated by using two (or mores) SPI bus simultaneously.&lt;/P&gt;&lt;P&gt;2. Use more threads to access the SPI bus could be more easier to duplicate this issue.&lt;/P&gt;&lt;P&gt;3. Only one SPI bus driver hang and the other one still work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Brian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Feb 2014 02:10:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226225#M16119</guid>
      <dc:creator>brianwu</dc:creator>
      <dc:date>2014-02-13T02:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: A bug in the SPI bus driver (iMX6 BSP 4.0.0/4.1.0)</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226226#M16120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Brian&lt;/P&gt;&lt;P&gt;Had your issue got resolved? If yes, we are going to close the discussion in 3 days. If you still need help, please feel free to reply with an update to this discussion.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Yixing&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Mar 2014 08:25:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226226#M16120</guid>
      <dc:creator>YixingKong</dc:creator>
      <dc:date>2014-03-20T08:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: A bug in the SPI bus driver (iMX6 BSP 4.0.0/4.1.0)</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226227#M16121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/brianwu"&gt;brianwu&lt;/A&gt; I am noticing a similar hang sometimes when using SPI with BSP 4.1.0 - can you post the patch you used to fix this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 01:37:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226227#M16121</guid>
      <dc:creator>alexmurray</dc:creator>
      <dc:date>2014-03-21T01:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: A bug in the SPI bus driver (iMX6 BSP 4.0.0/4.1.0)</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226228#M16122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Yixing,&lt;/P&gt;&lt;P&gt;I couldn't find the root cause about this problem, but there is no hang on SPI bus after I modify the SPI bus driver to enable the clock all the time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Brian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 02:18:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226228#M16122</guid>
      <dc:creator>brianwu</dc:creator>
      <dc:date>2014-03-21T02:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: Re: A bug in the SPI bus driver (iMX6 BSP 4.0.0/4.1.0)</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226229#M16123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Alex,&lt;/P&gt;&lt;P&gt;Did you also get hang on the spi_sync() function?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The attached patch file is for BSP 4.0.0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR&lt;BR /&gt;Brian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 02:26:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226229#M16123</guid>
      <dc:creator>brianwu</dc:creator>
      <dc:date>2014-03-21T02:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: A bug in the SPI bus driver (iMX6 BSP 4.0.0/4.1.0)</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226230#M16124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Brian&lt;/P&gt;&lt;P&gt;It is good to know that your issue disappeared after you made change. I guess we can close your post now. If anyone knows the root cause, he/she can come to here post the resolution.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Yixing&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 02:40:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226230#M16124</guid>
      <dc:creator>YixingKong</dc:creator>
      <dc:date>2014-03-21T02:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: Re: A bug in the SPI bus driver (iMX6 BSP 4.0.0/4.1.0)</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226231#M16125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi brianwu,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a similar issue.&lt;/P&gt;&lt;P&gt;I have a thread which repeatedly call spi_sync for reading from a spi slave device(in a while loop). The size of the data to be received is small in each spi_sync call (maximum of 8 bytes)&lt;/P&gt;&lt;P&gt;My problem is the system freezes after the thread runs for a very short time. But the thread works fine if I give a small sleep (msleep of 1 ms) after each spi_sync. I initially thought it to be a scheduling related issue. But if I comment the spi_sync and msleep calls, the thread loop runs infinitely without any issue. Could this be anyway related to the clock issue you have faced or any other thoughts?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Sebi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2014 06:35:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/A-bug-in-the-SPI-bus-driver-iMX6-BSP-4-0-0-4-1-0/m-p/226231#M16125</guid>
      <dc:creator>sebimohan</dc:creator>
      <dc:date>2014-04-09T06:35:41Z</dc:date>
    </item>
  </channel>
</rss>

