On Fri, Aug 14, 2020 at 2:17 AM Daniel Vetter daniel@ffwll.ch wrote:
On Fri, Aug 14, 2020 at 06:24:58AM +0000, John Stultz wrote:
This adds a heap that allocates non-contiguous buffers that are marked as writecombined, so they are not cached by the CPU.
This is useful, as most graphics buffers are usually not touched by the CPU or only written into once by the CPU. So when mapping the buffer over and over between devices, we can skip the CPU syncing, which saves a lot of cache management overhead, greatly improving performance.
For folk using ION, there was a ION_FLAG_CACHED flag, which signaled if the returned buffer should be CPU cacheable or not. With DMA-BUF heaps, we have no such flag, and by default the current heaps (system and cma) produce CPU cachable buffers. So for folks transitioning from ION to DMA-BUF Heaps, this fills in some of that missing functionality.
This does have a few "ugly" bits that were required to get the buffer properly flushed out initially which I'd like to improve. So feedback would be very welcome!
Many thanks to Liam Mark for his help to get this working.
Cc: Sumit Semwal sumit.semwal@linaro.org Cc: Andrew F. Davis afd@ti.com Cc: Benjamin Gaignard benjamin.gaignard@linaro.org Cc: Liam Mark lmark@codeaurora.org Cc: Laura Abbott labbott@kernel.org Cc: Brian Starkey Brian.Starkey@arm.com Cc: Hridya Valsaraju hridya@google.com Cc: Robin Murphy robin.murphy@arm.com Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Signed-off-by: John Stultz john.stultz@linaro.org
v2:
- Fix build issue on sh reported-by: kernel test robot lkp@intel.com
- Rework to use for_each_sgtable_sg(), dma_map_sgtable(), and for_each_sg_page() along with numerous other cleanups suggested by Robin Murphy
Mildly annoying me, but where's the userspace for this? Do we have a gralloc somewhere that works with open driver stacks and uses this?
So this is still early RFC, but I've added support to the HiKey960 gralloc, and have pending patches (following DRM rules) I pushed here: https://android-review.googlesource.com/c/device/linaro/hikey/+/1399519
And avoiding the cache syncing overhead improves performance nicely on that board.
There is also work in progress to change the codec2 implementation in AOSP (which uses ion directly), to move over to DMA BUF heaps and as it used the !ION_FLAG_CACHED case there this heap would be useful to match ION's functionality.
The latest patches for that are here: https://android-review.googlesource.com/c/platform/frameworks/av/+/1360640 (though I'm expecting a deeper rework on those)
thanks -john