Re: Try to address the DMA-buf coherency problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Nicolas,

Am 28.10.22 um 17:46 schrieb Nicolas Dufresne:
Hi,

just dropping some real live use case, sorry I'm not really proposing solutions,
I believe you are much more knowledgeable in this regard.

Well, I think each of us has a lot of specialized knowledge. For example I don't know to much about gralloc/minigbm. So this input is very valuable.

Le vendredi 28 octobre 2022 à 16:26 +0200, Christian König a écrit :
Am 28.10.22 um 13:42 schrieb Lucas Stach:
Am Freitag, dem 28.10.2022 um 10:40 +0200 schrieb Christian König:
But essentially the right thing to do. The only alternative I can see is
to reverse the role of exporter and importer.

I don't think that would work generally either, as buffer exporter and
importer isn't always a 1:1 thing. As soon as any attached importer has
a different coherency behavior than the others, things fall apart.
I've just mentioned it because somebody noted that when you reverse the
roles of exporter and importer with the V4L driver and i915 then the use
case suddenly starts working.
Though, its not generically possible to reverse these roles. If you want to do
so, you endup having to do like Android (gralloc) and ChromeOS (minigbm),
because you will have to allocate DRM buffers that knows about importer specific
requirements. See link [1] for what it looks like for RK3399, with Motion Vector
size calculation copied from the kernel driver into a userspace lib (arguably
that was available from V4L2 sizeimage, but this is technically difficult to
communicate within the software layers). If you could let the decoder export
(with proper cache management) the non-generic code would not be needed.

Yeah, but I can also reverse the argument:

Getting the parameters for V4L right so that we can share the image is tricky, but getting the parameters so that the stuff is actually directly displayable by GPUs is even trickier.

Essentially you need to look at both sides and interference to get to a common ground, e.g. alignment, pitch, width/height, padding, etc.....

Deciding from which side to allocate from is just one step in this process. For example most dGPUs can't display directly from system memory altogether, but it is possible to allocate the DMA-buf through the GPU driver and then write into device memory with P2P PCI transfers.

So as far as I can see switching importer and exporter roles and even having performant extra fallbacks should be a standard feature of userspace.

Another case where reversing the role is difficult is for case where you need to
multiplex the streams (let's use a camera to illustrate) and share that with
multiple processes. In these uses case, the DRM importers are volatile, which
one do you abuse to do allocation from ? In multimedia server like PipeWire, you
are not really aware if the camera will be used by DRM or not, and if something
"special" is needed in term of role inversion. It is relatively easy to deal
with matching modifiers, but using downstream (display/gpu) as an exporter is
always difficult (and require some level of abuse and guessing).

Oh, very good point! Yeah we do have use cases for this where an input buffer is both displayed as well as encoded.


Well, no. What I mean with coherency is that the devices don't need
insert special operation to access each others data.

This can be archived by multiple approaches, e.g. by the PCI coherency
requirements, device internal connections (XGMI, NVLink, CXL etc...) as
well as using uncached system memory.

The key point is what we certainly don't want is special operations
which say: Ok, now device A can access the data, now device B.....
because this breaks tons of use cases.
I'm coming back again with the multiplexing case. We keep having mixed uses case
with multiple receiver. In some case, data may endup on CPU while being encoded
in HW. Current approach of disabling cache does work, but CPU algorithm truly
suffer in performance. Doing a full memcpy to a cached buffer helps, but remains
slower then if the cache had been snooped by the importer (encoder here) driver.

Yeah, that was another reason why we ended up rather having an extra copy than working with uncached buffers for display as well.

Regards,
Christian.



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux