public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [MTD/NAND] Blackfin NFC driver DMA bug ?
@ 2008-02-21 17:58 Ivan Djelic
  2008-02-22  2:52 ` Bryan Wu
  0 siblings, 1 reply; 7+ messages in thread
From: Ivan Djelic @ 2008-02-21 17:58 UTC (permalink / raw)
  To: linux-mtd

Hello All,

While working on a NAND flash MTD driver, I came across the following piece of
code in the Blackfin bf5xx NAND flash controller driver:

>From linux-2.6.24.2, file bf5xx_nand.c:418, function bf5xx_nand_dma_rw():

	/*
	 * Before starting a dma transfer, be sure to invalidate/flush
	 * the cache over the address range of your DMA buffer to
	 * prevent cache coherency problems. Otherwise very subtle bugs
	 * can be introduced to your driver.
	 */
	if (is_read)
		invalidate_dcache_range((unsigned int)buf,
				(unsigned int)(buf + page_size));
	else
		flush_dcache_range((unsigned int)buf,
				(unsigned int)(buf + page_size));

Since 'buf' is allocated outside MTD, are we allowed to assume it is
cache-aligned ? Because if it's not, invalidating dcache on read is not enough
to prevent cache coherency problems. For instance, a cache line partially
spanning across the buffer address range could be flushed just after DMA has
completed, corrupting DMA data in the process...
Or am I missing something, since I am not familiar with the Blackfin arch ?

Thanks,

Ivan

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-02-25 11:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-21 17:58 [MTD/NAND] Blackfin NFC driver DMA bug ? Ivan Djelic
2008-02-22  2:52 ` Bryan Wu
2008-02-22  7:05   ` David Woodhouse
2008-02-25 10:29     ` Bryan Wu
2008-02-22  8:45   ` Ivan Djelic
2008-02-22  8:54     ` Ivan Djelic
2008-02-25 11:15       ` Bryan Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox