linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] Enable DMA transfers for SAM9 and fix cache aliasing
@ 2017-11-15 16:35 Radu Pirea
       [not found] ` <1510763732-10151-1-git-send-email-radu.pirea-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Radu Pirea @ 2017-11-15 16:35 UTC (permalink / raw)
  To: linux-spi-u79uwXL29TY76Z2rM5mHXA, broonie-DgEjT+Ai2ygdnm+yROfE0A,
	nicolas.ferre-UWL1GkI3JZL3oGB3hsPCZA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: Radu Pirea

This patches are an attempt to fix the following problem:
On SAM9 SoCs the cache model is VIVT thus 2 different cache may exist for
the same physical address, and because of that, when we allocate memory
with vmalloc and try to use DMA to read or write from/to this region it's
possible to get cache coherency problems.

To solve this, I have investigated the mailing list for possible solutions
and other drivers as well. The buffers coming from the filesystem allocated
with vmalloc are not in a DMA coherent area in this scenario. MTDblock
layer solve this problem for the other file system, but for file systems
based on MTD directly like UBIFS, this is not happening.

One solution is to use bounce buffers to copy the data in a DMA coherent
area. This will add a certain delay though and impact the performance. To
have best possible outcome we need to pass the same buffer to the DMA
engine, but insure that the memory is cache coherent before we read from
it, and the cache is invalidated after we write to the memory. To achieve
that I have added a cache flush on the buffer before starting the DMA
operation and a cache invalidate after DMA operation completes.

>From my point of view this is the best and most simple approach.

I based these patches on Russell King idea
https://lkml.org/lkml/2017/6/23/509

I welcome any feedback about this solution.

Thanks.



Radu Pirea (2):
  Revert "spi: atmel: fix corrupted data issue on SAM9 family SoCs"
  spi: atmel: Fix DMA transfers data corruption

 drivers/spi/spi-atmel.c | 44 +++++++++++++++++++++-----------------------
 1 file changed, 21 insertions(+), 23 deletions(-)

-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2017-12-08 13:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-15 16:35 [RFC PATCH 0/2] Enable DMA transfers for SAM9 and fix cache aliasing Radu Pirea
     [not found] ` <1510763732-10151-1-git-send-email-radu.pirea-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org>
2017-11-15 16:35   ` [RFC PATCH 1/2] Revert "spi: atmel: fix corrupted data issue on SAM9 family SoCs" Radu Pirea
2017-11-16 10:36     ` Mark Brown
2017-11-15 16:35   ` [RFC PATCH 2/2] spi: atmel: Fix DMA transfers data corruption Radu Pirea
     [not found]     ` <1510763732-10151-3-git-send-email-radu.pirea-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org>
2017-11-15 19:01       ` Trent Piepho
2017-11-16 10:26         ` Radu Nicolae Pirea
2017-11-16 10:45       ` Mark Brown
2017-12-08 13:26         ` Radu Nicolae Pirea

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).