[PATCH RFC 090/111] staging: etnaviv: fix cache cleaning for uncached SHM buffers

Lucas Stach l.stach at pengutronix.de
Thu Apr 2 09:36:52 PDT 2015


Am Donnerstag, den 02.04.2015, 17:22 +0100 schrieb Russell King - ARM
Linux:
> On Thu, Apr 02, 2015 at 05:30:32PM +0200, Lucas Stach wrote:
> > The intention clearly was to do the same thing for WC and UC buffers,
> > not for cached ones.
> 
> Err, from one of my previous commits:
> 
>     staging: etnaviv: fix DMA API usage
> 
>     We test for write-combine and non-cacheable mappings before calling the
>     DMA API.  This is werid, because non-cacheable mappings are DMA coherent
>     by definition, whereas cacheable mappings need cache maintanence
>     provided by the DMA API.
> 
>     This seems to be a typo: ETNA_BO_CACHED should be used rather than
>     ETNA_BO_UNCACHED.
> 
> It's utterly senseless to use the DMA API on uncached mappings.
> 
Note that this function here isn't used to do cache maintenance for
buffers at the time the driver owns them. It is used to clean the cache
_before_ we do anything with those buffers.

As we simply allocating SHM buffers here (and threat them as UC/WC for
the userspace mappings) we are not sure if there is any cache writeback
pending on the newly allocated pages. So this is basically a cache
invalidate hidden behind the DMA API. You might treat this as abuse and
I'm happy to fix this, but the point here is we need to do this
operation also on UC buffers. I've certainly seen stray cache writeback
corrupting my data in UC buffers otherwise.

Regards,
Lucas
-- 
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |



More information about the dri-devel mailing list