<?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>Kinetis MicrocontrollersのトピックRe: DMA with Cache is Fraught with Peril</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/DMA-with-Cache-is-Fraught-with-Peril/m-p/305524#M12945</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For cache write mechanism is below:&lt;/P&gt;&lt;P&gt;Write-through: Write is done synchronously both to the cache and to the backing store.&lt;/P&gt;&lt;P&gt;Write-back (or Write-behind): Writing is done only to the cache. A modified cache block is written back to the store, just before it is replaced.&lt;/P&gt;&lt;P&gt;For the DAM transfer is from source address to destination address, DMA works way is match with "write-through" way. &lt;/P&gt;&lt;P&gt;Or customer can consider disable cache function of DMA transfer address range.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Wish it help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;best regards,&lt;BR /&gt;Ma Hui&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 May 2014 06:48:52 GMT</pubDate>
    <dc:creator>Hui_Ma</dc:creator>
    <dc:date>2014-05-08T06:48:52Z</dc:date>
    <item>
      <title>DMA with Cache is Fraught with Peril</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/DMA-with-Cache-is-Fraught-with-Peril/m-p/305523#M12944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've been writing a number of device drivers that use DMA, and now I am trying to get them working properly with offchip (FlexBus) attached memory.&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;It looks like in these processors the DMA is completely agnostic to the data cache.&amp;nbsp; My question is what is the most efficient way to maintain cache coherency in general applications?&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like the steps I should take are the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For DMA write to memory:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; Use "write-through" cache mode (instead of "write-back") which will immediately execute any write commits to memory and make sure there are no pending writes that may happen after DMA to a memory block is started.&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; Do DMA write&lt;/P&gt;&lt;P&gt;3.&amp;nbsp; After the DMA operation is complete "invalidate" all cache lines that are in the memory region over which DMA occurred.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For DMA read from memory:&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; Use "write-through" cache mode.&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; Flush all cache lines that are in the memory region over which DMA will occur. &lt;/P&gt;&lt;P&gt;3.&amp;nbsp; Do DMA read.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems like "write-back" cache mode is more or less incompatible with DMA, as this would require a cache flush before DMA and a cache invalidate after DMA, with the need to do this in an atomic fashion (disabling interrupts).&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a better way?&amp;nbsp; It seems that with all the invalidation and flushing of the caches that you might be better off only DMA'ing to non-cacheable memory then using the CPU to copy to the cacheable region.&amp;nbsp; All this manipulation of the caches sort of defeats the purpose of DMA however.&amp;nbsp; Was it an issue to have DMA work with the cache in this processor?&amp;nbsp; Any good application note that explains all of this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;PMT&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Apr 2014 13:46:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/DMA-with-Cache-is-Fraught-with-Peril/m-p/305523#M12944</guid>
      <dc:creator>pmt</dc:creator>
      <dc:date>2014-04-28T13:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: DMA with Cache is Fraught with Peril</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/DMA-with-Cache-is-Fraught-with-Peril/m-p/305524#M12945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For cache write mechanism is below:&lt;/P&gt;&lt;P&gt;Write-through: Write is done synchronously both to the cache and to the backing store.&lt;/P&gt;&lt;P&gt;Write-back (or Write-behind): Writing is done only to the cache. A modified cache block is written back to the store, just before it is replaced.&lt;/P&gt;&lt;P&gt;For the DAM transfer is from source address to destination address, DMA works way is match with "write-through" way. &lt;/P&gt;&lt;P&gt;Or customer can consider disable cache function of DMA transfer address range.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Wish it help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;best regards,&lt;BR /&gt;Ma Hui&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 May 2014 06:48:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/DMA-with-Cache-is-Fraught-with-Peril/m-p/305524#M12945</guid>
      <dc:creator>Hui_Ma</dc:creator>
      <dc:date>2014-05-08T06:48:52Z</dc:date>
    </item>
  </channel>
</rss>

