[PATCH] udmabuf: fix dma-buf cpu access

Gerd Hoffmann kraxel at redhat.com
Wed Dec 18 08:13:49 UTC 2019


On Tue, Dec 17, 2019 at 03:02:28PM -0800, Gurchetan Singh wrote:
> I'm just going to put Chia's review comment here since it sums
> the issue rather nicely:
> 
> "(1) Semantically, a dma-buf is in DMA domain.  CPU access from the
> importer must be surrounded by {begin,end}_cpu_access.  This gives the
> exporter a chance to move the buffer to the CPU domain temporarily.
> 
> (2) When the exporter itself has other means to do CPU access, it is
> only reasonable for the exporter to move the buffer to the CPU domain
> before access, and to the DMA domain after access.  The exporter can
> potentially reuse {begin,end}_cpu_access for that purpose.
> 
> Because of (1), udmabuf does need to implement the
> {begin,end}_cpu_access hooks.  But "begin" should mean
> dma_sync_sg_for_cpu and "end" should mean dma_sync_sg_for_device.
> 
> Because of (2), if userspace wants to continuing accessing through the
> memfd mapping, it should call udmabuf's {begin,end}_cpu_access to
> avoid cache issues."
> 
> Reported-by: Chia-I Wu <olvaffe at gmail.com>
> Suggested-by: Chia-I Wu <olvaffe at gmail.com>
> Fixes: 284562e1f348 ("udmabuf: implement begin_cpu_access/end_cpu_access hooks")
> Signed-off-by: Gurchetan Singh <gurchetansingh at chromium.org>

Pushed to drm-misc-next.

thanks,
  Gerd



More information about the dri-devel mailing list