dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Nicolas Dufresne <nicolas@ndufresne.ca>,
	Daniel Stone <daniel@fooishbar.org>
Cc: ppaalanen@gmail.com, dri-devel@lists.freedesktop.org,
	linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org,
	sumit.semwal@linaro.org
Subject: Re: Try to address the DMA-buf coherency problem
Date: Wed, 2 Nov 2022 12:18:01 +0100	[thread overview]
Message-ID: <b422be59-4b4b-2d0d-8e8c-b19f27c6832e@gmail.com> (raw)
In-Reply-To: <caf4d6b82843788db97555a58bc9e33915e5b50a.camel@ndufresne.ca>

Am 01.11.22 um 22:09 schrieb Nicolas Dufresne:
> [SNIP]
>>> But the client is just a video player. It doesn't understand how to
>>> allocate BOs for Panfrost or AMD or etnaviv. So without a universal
>>> allocator (again ...), 'just allocate on the GPU' isn't a useful
>>> response to the client.
>> Well exactly that's the point I'm raising: The client *must* understand
>> that!
>>
>> See we need to be able to handle all restrictions here, coherency of the
>> data is just one of them.
>>
>> For example the much more important question is the location of the data
>> and for this allocating from the V4L2 device is in most cases just not
>> going to fly.
> It feels like this is a generic statement and there is no reason it could not be
> the other way around.

And exactly that's my point. You always need to look at both ways to 
share the buffer and can't assume that one will always work.

As far as I can see it you guys just allocate a buffer from a V4L2 
device, fill it with data and send it to Wayland for displaying.

To be honest I'm really surprised that the Wayland guys hasn't pushed 
back on this practice already.

This only works because the Wayland as well as X display pipeline is 
smart enough to insert an extra copy when it find that an imported 
buffer can't be used as a framebuffer directly.

>   I have colleague who integrated PCIe CODEC (Blaize Xplorer
> X1600P PCIe Accelerator) hosting their own RAM. There was large amount of ways
> to use it. Of course, in current state of DMABuf, you have to be an exporter to
> do anything fancy, but it did not have to be like this, its a design choice. I'm
> not sure in the end what was the final method used, the driver isn't yet
> upstream, so maybe that is not even final. What I know is that there is various
> condition you may use the CODEC for which the optimal location will vary. As an
> example, using the post processor or not, see my next comment for more details.

Yeah, and stuff like this was already discussed multiple times. Local 
memory of devices can only be made available by the exporter, not the 
importer.

So in the case of separated camera and encoder you run into exactly the 
same limitation that some device needs the allocation to happen on the 
camera while others need it on the encoder.

>> The more common case is that you need to allocate from the GPU and then
>> import that into the V4L2 device. The background is that all dGPUs I
>> know of need the data inside local memory (VRAM) to be able to scan out
>> from it.
> The reality is that what is common to you, might not be to others. In my work,
> most ARM SoC have display that just handle direct scannout from cameras and
> codecs.

> The only case the commonly fails is whenever we try to display UVC
> created dmabuf,

Well, exactly that's not correct! The whole x86 use cases of direct 
display for dGPUs are broken because media players think they can do the 
simple thing and offload all the problematic cases to the display server.

This is absolutely *not* the common use case you describe here, but 
rather something completely special to ARM.

>   which have dirty CPU write cache and this is the type of thing
> we'd like to see solved. I think this series was addressing it in principle, but
> failing the import and the raised point is that this wasn't the optimal way.
>
> There is a community project called LibreELEC, if you aren't aware, they run
> Khodi with direct scanout of video stream on a wide variety of SoC and they use
> the CODEC as exporter all the time. They simply don't have cases were the
> opposite is needed (or any kind of remote RAM to deal with). In fact, FFMPEG
> does not really offer you any API to reverse the allocation.

Ok, let me try to explain it once more. It sounds like I wasn't able to 
get my point through.

That we haven't heard anybody screaming that x86 doesn't work is just 
because we handle the case that a buffer isn't directly displayable in 
X/Wayland anyway, but this is absolutely not the optimal solution.

The argument that you want to keep the allocation on the codec side is 
completely false as far as I can see.

We already had numerous projects where we reported this practice as bugs 
to the GStreamer and FFMPEG project because it won't work on x86 with dGPUs.

This is just a software solution which works because of coincident and 
not because of engineering.

Regards,
Christian.



  reply	other threads:[~2022-11-02 11:18 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 [this message]
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
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=b422be59-4b4b-2d0d-8e8c-b19f27c6832e@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=daniel@fooishbar.org \
    --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=sumit.semwal@linaro.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