Am 28.01.21 um 11:01 schrieb Pekka Paalanen:
On Wed, 27 Jan 2021 12:01:55 +0100
Christian König <christian.koenig@xxxxxxx> wrote:
Somewhat correct. This interface here really doesn't make sense since
the file descriptor representation of DMA-buf is only meant to be used
for short term usage.
E.g. the idea is that you can export a DMA-buf fd from your device
driver, transfer that to another process and then import it again into a
device driver.
Keeping a long term reference to a DMA-buf fd sounds like a design bug
in userspace to me.
Except keeping the fd is exactly what userspace must do if it wishes to
re-use the buffer without passing a new fd over IPC again. Particularly
Wayland compositors need to keep the client buffer dmabuf fd open after
receiving it, so that they can re-import it to EGL to ensure updated
contents are correctly flushed as EGL has no other API for it.
Hui what??? I'm not that deep into the EGL specification, but from the
kernel side that is utterly nonsense.
Could be that re-importing triggers something in userspace, but this
sounds strongly like a workaround to me which shouldn't be necessary.
That is my vague understanding, and what Weston implements. You can say
it's a bad userspace API design in EGL, but what else can we do?
Please open up a bug report with your EGL driver if that is really
necessary.
DMA-bufs shared using a file descriptor should be coherent when
written/read from a GPU or other hardware device. What is possible is
that you need to do something special for CPU access.
In other words once a DMA-buf is imported and available as
handle/texture/image inside EGL it doesn't needs to be flushed/synced
explicitly again.
Re-importing it adds quite a huge CPU overhead to both userspace as well
as the kernel.
However, in the particular case of Wayland, the shared dmabufs should
be accounted to the Wayland client process. OOM-killing the client
process will eventually free the dmabuf, also the Wayland server
references to it. Killing the Wayland server (compositor, display
server) OTOH is something that should not be done as long as there are
e.g. Wayland clients to be killed.
Unfortunately(?), Wayland clients do not have a reason to keep the
dmabuf fd open themselves, so they probably close it as soon as it has
been sent to a display server. So the process that should be OOM-killed
does not have an open fd for the dmabuf (but probably has something
else, but not an mmap for CPU). Buffer re-use in Wayland does not
require re-sending the dmabuf fd over IPC.
Correct. The reference to your memory is kept inside the drivers GEM handle.
That's one reason why we said that this approach here is not taking in
the whole picture.
Regards,
Christian.
(In general, dmabufs are never mmapped for CPU. They are accessed by
devices.)
Thanks,
pq
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel