From: "Christian König" <christian.koenig@amd.com>
To: Daniel Vetter <daniel@ffwll.ch>, Rob Clark <robdclark@gmail.com>
Cc: linux-media@vger.kernel.org, Tomasz Figa <tfiga@chromium.org>,
linaro-mm-sig@lists.linaro.org, ppaalanen@gmail.com,
dri-devel@lists.freedesktop.org,
Nicolas Dufresne <nicolas@ndufresne.ca>,
sumit.semwal@linaro.org
Subject: Re: Try to address the DMA-buf coherency problem
Date: Tue, 22 Nov 2022 18:33:59 +0100 [thread overview]
Message-ID: <ae9ba9ba-3ad3-af23-be66-1540862bf571@amd.com> (raw)
In-Reply-To: <Y3zeYnufgXJHQAbN@phenom.ffwll.local>
Am 22.11.22 um 15:36 schrieb Daniel Vetter:
> On Fri, Nov 18, 2022 at 11:32:19AM -0800, Rob Clark wrote:
>> On Thu, Nov 17, 2022 at 7:38 AM Nicolas Dufresne <nicolas@ndufresne.ca> wrote:
>>> Le jeudi 17 novembre 2022 à 13:10 +0100, Christian König a écrit :
>>>>>> DMA-Buf let's the exporter setup the DMA addresses the importer uses to
>>>>>> be able to directly decided where a certain operation should go. E.g. we
>>>>>> have cases where for example a P2P write doesn't even go to memory, but
>>>>>> rather a doorbell BAR to trigger another operation. Throwing in CPU
>>>>>> round trips for explicit ownership transfer completely breaks that
>>>>>> concept.
>>>>> It sounds like we should have a dma_dev_is_coherent_with_dev() which
>>>>> accepts two (or an array?) of devices and tells the caller whether the
>>>>> devices need explicit ownership transfer.
>>>> No, exactly that's the concept I'm pushing back on very hard here.
>>>>
>>>> In other words explicit ownership transfer is not something we would
>>>> want as requirement in the framework, cause otherwise we break tons of
>>>> use cases which require concurrent access to the underlying buffer.
>>> I'm not pushing for this solution, but really felt the need to correct you here.
>>> I have quite some experience with ownership transfer mechanism, as this is how
>>> GStreamer framework works since 2000. Concurrent access is a really common use
>>> cases and it is quite well defined in that context. The bracketing system (in
>>> this case called map() unmap(), with flag stating the usage intention like reads
>>> and write) is combined the the refcount. The basic rules are simple:
>> This is all CPU oriented, I think Christian is talking about the case
>> where ownership transfer happens without CPU involvement, such as via
>> GPU waiting on a fence
> Yeah for pure device2device handover the rule pretty much has to be that
> any coherency management that needs to be done must be done from the
> device side (flushing device side caches and stuff like that) only. But
> under the assumption that _all_ cpu side management has been done already
> before the first device access started.
>
> And then the map/unmap respectively begin/end_cpu_access can be used what
> it was meant for with cpu side invalidation/flushing and stuff like that,
> while having pretty clear handover/ownership rules and hopefully not doing
> no unecessary flushes. And all that while allowing device acces to be
> pipelined. Worst case the exporter has to insert some pipelined cache
> flushes as a dma_fence pipelined work of its own between the device access
> when moving from one device to the other. That last part sucks a bit right
> now, because we don't have any dma_buf_attachment method which does this
> syncing without recreating the mapping, but in reality this is solved by
> caching mappings in the exporter (well dma-buf layer) nowadays.
>
> True concurrent access like vk/compute expects is still a model that
> dma-buf needs to support on top, but that's a special case and pretty much
> needs hw that supports such concurrent access without explicit handover
> and fencing.
>
> Aside from some historical accidents and still a few warts, I do think
> dma-buf does support both of these models.
We should have come up with dma-heaps earlier and make it clear that
exporting a DMA-buf from a device gives you something device specific
which might or might not work with others.
Apart from that I agree, DMA-buf should be capable of handling this.
Question left is what documentation is missing to make it clear how
things are supposed to work?
Regards,
Christian.
> Of course in the case of
> gpu/drm drivers, userspace must know whats possible and act accordingly,
> otherwise you just get to keep all the pieces.
> -Daniel
next prev parent reply other threads:[~2022-11-22 17:34 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-20 12:13 Try to address the DMA-buf coherency problem Christian König
2022-10-20 12:13 ` [PATCH 1/3] dma-buf: add dma_coherent flag Christian König
2022-10-20 12:13 ` [PATCH 2/3] drm/prime: set the dma_coherent flag for export Christian König
2022-10-20 14:43 ` Rob Clark
2022-10-20 14:56 ` Christian König
2022-10-28 1:11 ` Rob Clark
2022-10-20 12:13 ` [PATCH 3/3] media: videobuf2: set dma_coherent flag for DMA-buf Christian König
2022-11-04 10:42 ` Hans Verkuil
2022-10-27 12:14 ` Try to address the DMA-buf coherency problem Christian König
2022-10-28 8:09 ` Lucas Stach
2022-10-28 8:40 ` Christian König
2022-10-28 11:42 ` Lucas Stach
2022-10-28 14:26 ` Christian König
2022-10-28 15:46 ` Nicolas Dufresne
2022-10-28 17:50 ` Christian König
2022-10-28 18:47 ` Daniel Stone
2022-11-01 17:40 ` Christian König
2022-11-01 21:09 ` Nicolas Dufresne
2022-11-02 11:18 ` Christian König
2022-11-02 11:39 ` Lucas Stach
2022-11-02 12:21 ` Christian König
2022-11-02 17:10 ` Lucas Stach
2022-11-02 19:13 ` Christian König
2022-11-02 19:48 ` Lucas Stach
2022-11-17 9:35 ` Tomasz Figa
2022-11-17 12:10 ` Christian König
2022-11-17 15:38 ` Nicolas Dufresne
2022-11-18 19:32 ` Rob Clark
2022-11-19 20:35 ` Nicolas Dufresne
2022-11-22 14:36 ` Daniel Vetter
2022-11-22 17:33 ` Christian König [this message]
2022-11-22 18:26 ` Daniel Vetter
2022-11-23 8:33 ` Pekka Paalanen
2022-11-23 16:33 ` Daniel Vetter
2022-11-25 16:40 ` Nicolas Dufresne
2022-11-30 10:30 ` Daniel Vetter
2022-12-02 15:27 ` Christian König
2023-01-05 11:46 ` Daniel Vetter
2022-12-05 6:41 ` Tomasz Figa
2022-12-05 8:28 ` Christian König
2022-12-06 18:26 ` Nicolas Dufresne
2022-12-06 18:37 ` Christian König
2022-12-09 8:26 ` Tomasz Figa
2022-12-09 9:32 ` Pekka Paalanen
2022-12-09 17:07 ` Alex Deucher
2023-01-05 11:50 ` [Linaro-mm-sig] " Daniel Vetter
2022-12-12 3:13 ` Tomasz Figa
2022-12-09 10:27 ` Christian König
2022-12-12 3:00 ` Tomasz Figa
2022-12-12 11:15 ` Christian König
2023-01-05 20:39 ` Sebastian Wick
2022-11-04 14:58 ` Rob Clark
2022-11-04 15:00 ` Christian König
2022-11-02 12:19 ` Pekka Paalanen
2022-11-02 12:27 ` Christian König
2022-11-02 12:50 ` Pekka Paalanen
2022-11-02 12:56 ` Christian König
2022-11-03 22:16 ` Nicolas Dufresne
2022-11-04 9:03 ` Christian König
2022-11-04 13:38 ` Nicolas Dufresne
2022-11-04 14:51 ` Christian König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ae9ba9ba-3ad3-af23-be66-1540862bf571@amd.com \
--to=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-media@vger.kernel.org \
--cc=nicolas@ndufresne.ca \
--cc=ppaalanen@gmail.com \
--cc=robdclark@gmail.com \
--cc=sumit.semwal@linaro.org \
--cc=tfiga@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox