Re: [PATCH v6 2/5] dma-buf: heaps: Add heap helpers
From: Rob Clark
Date: Tue Jul 23 2019 - 16:10:09 EST
On Mon, Jul 22, 2019 at 9:09 PM John Stultz <john.stultz@xxxxxxxxxx> wrote:
>
> On Thu, Jul 18, 2019 at 3:06 AM Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote:
> >
> > Is there any exlusion between mmap / vmap and the device accessing
> > the data? Without that you are going to run into a lot of coherency
> > problems.
dma_fence is basically the way to handle exclusion between different
device access (since device access tends to be asynchronous). For
device<->device access, each driver is expected to take care of any
cache(s) that the device might have. (Ie. device writing to buffer
should flush it's caches if needed before signalling fence to let
reading device know that it is safe to read, etc.)
_begin/end_cpu_access() is intended to be the exclusion for CPU access
(which is synchronous)
BR,
-R
> This has actually been a concern of mine recently, but at the higher
> dma-buf core level. Conceptually, there is the
> dma_buf_map_attachment() and dma_buf_unmap_attachment() calls drivers
> use to map the buffer to an attached device, and there are the
> dma_buf_begin_cpu_access() and dma_buf_end_cpu_access() calls which
> are to be done when touching the cpu mapped pages. These look like
> serializing functions, but actually don't seem to have any enforcement
> mechanism to exclude parallel access.
>
> To me it seems like adding the exclusion between those operations
> should be done at the dmabuf core level, and would actually be helpful
> for optimizing some of the cache maintenance rules w/ dmabuf. Does
> this sound like something closer to what your suggesting, or am I
> misunderstanding your point?
>
> Again, I really appreciate the review and feedback!
>
> Thanks so much!
> -john