<?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: mdelay() in hot path in esdhc_pltfm_set_clock looses CAN (!) frames in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/mdelay-in-hot-path-in-esdhc-pltfm-set-clock-looses-CAN-frames/m-p/444244#M68377</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just saw your post in linux-mmc :-)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Jul 2015 18:15:28 GMT</pubDate>
    <dc:creator>fabio_estevam</dc:creator>
    <dc:date>2015-07-07T18:15:28Z</dc:date>
    <item>
      <title>mdelay() in hot path in esdhc_pltfm_set_clock looses CAN (!) frames</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/mdelay-in-hot-path-in-esdhc-pltfm-set-clock-looses-CAN-frames/m-p/444241#M68374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi people,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I noticed in a kernel 4.0.7 that I loose CAN packets when an incoming rsync transfer changes my eMMC or SD-Card image. I used CONFIG_FRACE to find why this is the case, and came to this trace:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;# tracer: preemptoff&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;# preemptoff latency trace v1.1.5 on 4.0.7&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;# --------------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;# latency: 1046 us, #756/756, CPU#2 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:4)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp; -----------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp; | task: mmcqd/0-76 (uid:0 nice:0 policy:0 rt_prio:0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp; -----------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#&amp;nbsp; =&amp;gt; started at: sdhci_do_set_ios&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#&amp;nbsp; =&amp;gt; ended at:&amp;nbsp;&amp;nbsp; sdhci_do_set_ios&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _------=&amp;gt; CPU#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; / _-----=&amp;gt; irqs-off&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | / _----=&amp;gt; need-resched&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; || / _---=&amp;gt; hardirq/softirq &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ||| / _--=&amp;gt; preempt-depth&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |||| /&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#&amp;nbsp; cmd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pid&amp;nbsp;&amp;nbsp; ||||| time&amp;nbsp; |&amp;nbsp;&amp;nbsp; caller&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; \&amp;nbsp;&amp;nbsp; /&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |||||&amp;nbsp; \&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp; /&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..1&amp;nbsp;&amp;nbsp;&amp;nbsp; 1us : _raw_spin_lock_irq &amp;lt;-sdhci_do_set_ios&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp;&amp;nbsp; 2us : esdhc_writeb_le &amp;lt;-sdhci_do_set_ios&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp;&amp;nbsp; 4us : esdhc_pltfm_set_bus_width &amp;lt;-sdhci_do_set_ios&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp;&amp;nbsp; 5us : l2c210_sync &amp;lt;-esdhc_pltfm_set_bus_width&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp;&amp;nbsp; 7us : esdhc_writeb_le &amp;lt;-sdhci_do_set_ios&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp;&amp;nbsp; 9us : l2c210_sync &amp;lt;-esdhc_writeb_le&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 10us : esdhc_readw_le &amp;lt;-sdhci_do_set_ios&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 12us : esdhc_writew_le &amp;lt;-sdhci_do_set_ios&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 14us : l2c210_sync &amp;lt;-esdhc_writew_le&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 16us : l2c210_sync &amp;lt;-esdhc_writew_le&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 18us : esdhc_readw_le &amp;lt;-sdhci_do_set_ios&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 19us : esdhc_writew_le &amp;lt;-sdhci_do_set_ios&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 21us : l2c210_sync &amp;lt;-esdhc_writew_le&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 22us : esdhc_set_uhs_signaling &amp;lt;-sdhci_do_set_ios&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 24us : pinctrl_select_state &amp;lt;-esdhc_set_uhs_signaling&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 26us : esdhc_readl_le &amp;lt;-esdhc_pltfm_set_clock&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 28us : esdhc_writel_le &amp;lt;-esdhc_pltfm_set_clock&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 29us : l2c210_sync &amp;lt;-esdhc_writel_le&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 31us : esdhc_readl_le &amp;lt;-esdhc_pltfm_set_clock&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 33us : esdhc_writel_le &amp;lt;-esdhc_pltfm_set_clock&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 34us : l2c210_sync &amp;lt;-esdhc_writel_le&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 36us : l2c210_sync &amp;lt;-esdhc_pltfm_set_clock&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 37us : __timer_const_udelay &amp;lt;-esdhc_pltfm_set_clock&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 39us : __timer_delay &amp;lt;-__timer_const_udelay&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 40us : read_current_timer &amp;lt;-__timer_delay&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 41us : imx_read_current_timer &amp;lt;-read_current_timer&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 43us : read_current_timer &amp;lt;-__timer_delay&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 44us : imx_read_current_timer &amp;lt;-read_current_timer&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; mmcqd/0-76&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2d..2&amp;nbsp;&amp;nbsp; 45us : read_current_timer &amp;lt;-__timer_delay&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;....&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it seems that esdhc_pltfm_set_clock() somehow waits. And really there is an mdelay() there. What's worse: I put a printk() into this function, just before the mdelay(). And it get's called hundreds of times when I boot, or when I update via rsync. And for each call we have an mdelay() that kills preemption.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is bad because in the FlexCAN driver the ISR calls napi_schedule(), which in turn clears the CAN RxFIFO. And if this scheduling is taking too long, CAN packets are dropped. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The mdelay() is also bad because it makes eMMC/SD-Card accesses WAY slower than they could be.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jun 2015 13:28:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/mdelay-in-hot-path-in-esdhc-pltfm-set-clock-looses-CAN-frames/m-p/444241#M68374</guid>
      <dc:creator>holgerschurig</dc:creator>
      <dc:date>2015-06-30T13:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: mdelay() in hot path in esdhc_pltfm_set_clock looses CAN (!) frames</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/mdelay-in-hot-path-in-esdhc-pltfm-set-clock-looses-CAN-frames/m-p/444242#M68375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you getting the same behavior using our BSP? Could you try with one of our official versions of Linux?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Alejandro&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 17:20:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/mdelay-in-hot-path-in-esdhc-pltfm-set-clock-looses-CAN-frames/m-p/444242#M68375</guid>
      <dc:creator>alejandrolozan1</dc:creator>
      <dc:date>2015-07-07T17:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: mdelay() in hot path in esdhc_pltfm_set_clock looses CAN (!) frames</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/mdelay-in-hot-path-in-esdhc-pltfm-set-clock-looses-CAN-frames/m-p/444243#M68376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Holger,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the detailed analysis.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried using usleep_range(1000, 1500) instead of mdelay and then I got "inconsistent lock state" warnings.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just curious: what happens if the mdelay() is removed. I haven't gone through the git log to understand why it was placed there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, it would be nice to report this into linux-mmc and linux-arm-kernel lists.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&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>Tue, 07 Jul 2015 18:13:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/mdelay-in-hot-path-in-esdhc-pltfm-set-clock-looses-CAN-frames/m-p/444243#M68376</guid>
      <dc:creator>fabio_estevam</dc:creator>
      <dc:date>2015-07-07T18:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: mdelay() in hot path in esdhc_pltfm_set_clock looses CAN (!) frames</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/mdelay-in-hot-path-in-esdhc-pltfm-set-clock-looses-CAN-frames/m-p/444244#M68377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just saw your post in linux-mmc :-)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 18:15:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/mdelay-in-hot-path-in-esdhc-pltfm-set-clock-looses-CAN-frames/m-p/444244#M68377</guid>
      <dc:creator>fabio_estevam</dc:creator>
      <dc:date>2015-07-07T18:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: mdelay() in hot path in esdhc_pltfm_set_clock looses CAN (!) frames</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/mdelay-in-hot-path-in-esdhc-pltfm-set-clock-looses-CAN-frames/m-p/444245#M68378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why, doesn't the SDHCI driver from your BSP not contain the mdelay's ???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Generally, I don't like vendor-BSPs. Some of the code I see from vendors is quite hacky. I expect any vendor to submit their patches upstream. Yes, code-review can be harsh. Or time-consuming. But the end-result is usually much better. I yet have to see any vendor where the "private driver" is better than what is upstream.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Currently I have my own patches to the relatively new kernels in form of a "quilt" managed stack. AFAIK Freescale's BSPs use outdated kernels, so applying them would need a considerable effort in work (both software updates, but also more testing).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If Freescale would guarantee me that their BSP is free of preemption issues, or even CONFIG_PREEMPT_RT able *), then I'd do that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*) I noticed that CONFIG_PREEMPT_RT fixes all my lost CAN frame issues, but it is quite unstable on Linux 3.18.17 (-rt17) and also on 4.0.4 (-rt4) when run on the i.MX6. I even had eMMC image corruptions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 09:46:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/mdelay-in-hot-path-in-esdhc-pltfm-set-clock-looses-CAN-frames/m-p/444245#M68378</guid>
      <dc:creator>holgerschurig</dc:creator>
      <dc:date>2015-07-08T09:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: mdelay() in hot path in esdhc_pltfm_set_clock looses CAN (!) frames</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/mdelay-in-hot-path-in-esdhc-pltfm-set-clock-looses-CAN-frames/m-p/444246#M68379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Fabia,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The mdelay(1) is taken when sdhci_set_ios() much higher took a lock (spin_lock_irq). Maybe this prevents the ranged delay?&amp;nbsp; Unfortunately, I'm a mediocre kernel hacker: I have patches in the kernel, but I'm usually at loss when it comes to locks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Just curious: what happens if the mdelay() is removed.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Wild guess: when I removed CONFIG_MMC_CLKGATE this mdelay() was no longer in the hot-path. Seems that currently, when clock gating is on, for every sector (or MMC operation) this happens:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;* clock is turned on&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;* operation&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;* clock is turned off&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;And in the on-case there is an mdelay(1). I hate when people put an mdelay() into the code without an explanation, e.g. why it's where, any why it's this time. My guess however is, that after turning on the clock, the programmer wanted to make sure that the clock became stable, e.g. that a PLL locked. If that is 1ms in the worst case I cannot say.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Generally such things should be written in the style of a state-machine. That would allow the code to relinquish the code (to "sleep") back to other processes. And this in turn would not kill latency and cause hickups in the form of lost CAN frames at other places.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Alternatively/Additionally, it would have been swell if the FlexCAN IP would have more than 6 packets in the RxFIFO, e.g. unused mailbox slots. But we cannot change the IP ...&amp;nbsp;&amp;nbsp; at 500 kB/s a latency of more than 500 uS can already cause lost CAN packets.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 09:56:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/mdelay-in-hot-path-in-esdhc-pltfm-set-clock-looses-CAN-frames/m-p/444246#M68379</guid>
      <dc:creator>holgerschurig</dc:creator>
      <dc:date>2015-07-08T09:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: mdelay() in hot path in esdhc_pltfm_set_clock looses CAN (!) frames</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/mdelay-in-hot-path-in-esdhc-pltfm-set-clock-looses-CAN-frames/m-p/444247#M68380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nothing worse than loose packets. As long as they weren't getting lost...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;at 500 kB/s a latency of more than 500 uS can already cause lost CAN packets.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;At 1MHz even more-so.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;The problem is whoever thought it would be a good idea to empty a 6 MB FIFO at NAPI level. While the FEC driver didn't! I rewrote my 3.4 driver to empty during the interrupt, and no more problems.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;The Freescale driver for i.MX53 (on 2.6.35) uses 32 receive MBs and 32 transmit MBs. It handles them all in interrupts, so no NAPI delays at all.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Unfortunately it sends packets in "random order" and receives them in "random order" too. The Reference Manual says to fix the receive problem by sorting the packets in timestamp order, but the code doesn't do that. However the FIFO works fine under interrupts, until it gets out of sync because the driver handles interrupts the wrong way. I'm about to document that.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;There's been some recent discussion on the linux-can list about FlexCAN drivers allowing reading using interrupts and using "message pooling", so a newer driver may help you.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;The other take-home message is to not use an MMC card or eMMC chip while the supplied drivers do things like "mdelay()". That should be a major item in memory selection and in CPU selection.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Tom&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Dec 2015 04:47:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/mdelay-in-hot-path-in-esdhc-pltfm-set-clock-looses-CAN-frames/m-p/444247#M68380</guid>
      <dc:creator>TomE</dc:creator>
      <dc:date>2015-12-01T04:47:06Z</dc:date>
    </item>
  </channel>
</rss>

