[SNIP]
Sure, all the non-coherent arches have some way to do the cacheOn most of the multimediaWell for the AMD and Intel use cases we at least have the opportunity to
targeted ARM SoCs being unable to snoop the cache is the norm, not an
exception.
See for example on AMD/Intel hardware most of the engines can perfectlySo for those mixed use cases, wouldn't it help to have something
deal with cache coherent memory accesses. Only the display engines can't.
So on import time we can't even say if the access can be coherent and
snoop the CPU cache or not because we don't know how the imported
DMA-buf will be used later on.
similar to the dma_sync in the DMA-buf API, so your scanout usage can
tell the exporter that it's going to do non-snoop access and any dirty
cache lines must be cleaned? Signaling this to the exporter would allow
to skip the cache maintenance if the buffer is in CPU uncached memory,
which again is a default case for the ARM SoC world.
signal cache flushing, but I'm not sure if that counts for everybody.
maintenance in some explicit way. Non coherent and no cache maintenance
instruction would be a recipe for desaster. ;)
What we would rather do for those use cases is an indicator on theThat's a very x86 centric world view you have there. 99% of DMA-buf
DMA-buf if the underlying backing store is CPU cached or not. The
importer can then cleanly reject the use cases where it can't support
CPU cache snooping.
This then results in the normal fallback paths which we have anyway for
those use cases because DMA-buf sharing is not always possible.
uses on those cheap ARM SoCs is non-snooping. We can not do any
fallbacks here, as the whole graphics world on those SoCs with their
different IP cores mixed together depends on DMA-buf sharing working
efficiently even when the SoC is mostly non coherent.
In fact DMA-buf sharing works fine on most of those SoCs because
everyone just assumes that all the accelerators don't snoop, so the
memory shared via DMA-buf is mostly CPU uncached. It only falls apart
for uses like the UVC cameras, where the shared buffer ends up being
CPU cached.
Non-coherent without explicit domain transfer points is just not going
to work. So why can't we solve the issue for DMA-buf in the same way as
the DMA API already solved it years ago: by adding the equivalent of
the dma_sync calls that do cache maintenance when necessary? On x86 (or
any system where things are mostly coherent) you could still no-op them
for the common case and only trigger cache cleaning if the importer
explicitly says that is going to do a non-snooping access.
Regards,
Lucas