Revert "drm/virtio: drop prime import/export callbacks"
Subsystems (3)
PATCH 1/1 Revert "drm/virtio: drop prime import/export callbacks"
This patch does more harm than good, as it breaks both Xwayland and gnome-shell with X11.
Xwayland requires DRI3 & DRI3 requires PRIME.
X11 crash for obscure double-free reason which are hard to debug (starting X11 by hand doesn't trigger the crash).
I don't see an apparent problem implementing those stub prime functions, they may return an error at run-time, and it seems to be handled fine by GNOME at least.
Please consider a revert.
This reverts commit b318e3ff7ca065d6b107e424c85a63d7a6798a69.
--- drivers/gpu/drm/virtio/virtgpu_drv.c | 4 ++++ drivers/gpu/drm/virtio/virtgpu_drv.h | 4 ++++ drivers/gpu/drm/virtio/virtgpu_prime.c | 14 ++++++++++++++ 3 files changed, 22 insertions(+)
drivers/gpu/drm/virtio/virtgpu_drv.c +4 -0
@@ -205,10 +205,14 @@ static struct drm_driver driver = { #if defined(CONFIG_DEBUG_FS) .debugfs_init = virtio_gpu_debugfs_init, #endif + .prime_handle_to_fd = drm_gem_prime_handle_to_fd, + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_prime_export = drm_gem_prime_export, .gem_prime_import = drm_gem_prime_import, .gem_prime_pin = virtgpu_gem_prime_pin, .gem_prime_unpin = virtgpu_gem_prime_unpin, + .gem_prime_get_sg_table = virtgpu_gem_prime_get_sg_table, + .gem_prime_import_sg_table = virtgpu_gem_prime_import_sg_table, .gem_prime_vmap = virtgpu_gem_prime_vmap, .gem_prime_vunmap = virtgpu_gem_prime_vunmap, .gem_prime_mmap = virtgpu_gem_prime_mmap,
drivers/gpu/drm/virtio/virtgpu_drv.h +4 -0
@@ -354,6 +354,10 @@ int virtio_gpu_object_wait(struct virtio_gpu_object *bo, bool no_wait);/* virtgpu_prime.c */ int virtgpu_gem_prime_pin (struct drm_gem_object *obj);void virtgpu_gem_prime_unpin (struct drm_gem_object *obj); +struct sg_table *virtgpu_gem_prime_get_sg_table (struct drm_gem_object *obj); +struct drm_gem_object *virtgpu_gem_prime_import_sg_table ( +struct drm_device *dev,struct dma_buf_attachment *attach, +struct sg_table *sgt);void *virtgpu_gem_prime_vmap (struct drm_gem_object *obj);void virtgpu_gem_prime_vunmap (struct drm_gem_object *obj,void *vaddr); int virtgpu_gem_prime_mmap(struct drm_gem_object *obj,
drivers/gpu/drm/virtio/virtgpu_prime.c +14 -0
@@ -39,6 +39,20 @@ void virtgpu_gem_prime_unpin(struct drm_gem_object *obj)WARN_ONCE (1 ,"not implemented" ); } +struct sg_table *virtgpu_gem_prime_get_sg_table (struct drm_gem_object *obj) +{ +WARN_ONCE (1 ,"not implemented" ); +return ERR_PTR (-ENODEV ); +} + +struct drm_gem_object *virtgpu_gem_prime_import_sg_table ( +struct drm_device *dev,struct dma_buf_attachment *attach, +struct sg_table *table) +{ +WARN_ONCE (1 ,"not implemented" ); +return ERR_PTR (-ENODEV ); +} +void *virtgpu_gem_prime_vmap (struct drm_gem_object *obj) {struct virtio_gpu_object *bo =gem_to_virtio_gpu_obj (obj);
Signature · 6 lines
2.21.0.313.ge35b8cb8e2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 13 lines · Marc-André Lureau
This patch does more harm than good, as it breaks both Xwayland and gnome-shell with X11.
Xwayland requires DRI3 & DRI3 requires PRIME.
X11 crash for obscure double-free reason which are hard to debug (starting X11 by hand doesn't trigger the crash).
I don't see an apparent problem implementing those stub prime functions, they may return an error at run-time, and it seems to be handled fine by GNOME at least.
Quoted 7 lines
Please consider a revert.
This reverts commit
b318e3ff7ca065d6b107e424c85a63d7a6798a69.Cc Gerd Hoffmann <[email protected]>Cc Dave Airlie <[email protected]>Signed-off-by Marc-André Lureau <[email protected]>
The DRI3 code extensively uses prime_handle_to_fd and prime_fd_to_handle for self-import.
Fwiw the patch is:
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Chia-I Wu
reviewerQuoted 24 lines · Emil Velikov
Quoted 13 lines · Marc-André Lureau
This patch does more harm than good, as it breaks both Xwayland and gnome-shell with X11.
Xwayland requires DRI3 & DRI3 requires PRIME.
X11 crash for obscure double-free reason which are hard to debug (starting X11 by hand doesn't trigger the crash).
I don't see an apparent problem implementing those stub prime functions, they may return an error at run-time, and it seems to be handled fine by GNOME at least.
Quoted 7 lines
Please consider a revert.
This reverts commit
b318e3ff7ca065d6b107e424c85a63d7a6798a69.Cc Gerd Hoffmann <[email protected]>Cc Dave Airlie <[email protected]>Signed-off-by Marc-André Lureau <[email protected]>
Quoted 5 lines
The DRI3 code extensively uses
prime_handle_to_fdandprime_fd_to_handlefor self-import.Fwiw the patch is:
Reviewed-by Emil Velikov <[email protected]>
We also use Xwayland and will be helped by the revert.
I believe the cap was removed because the driver only supports self-import. But the driver only runs inside VMs where there is no(?) other dma-buf clients, and it handles runtime errors fine even if there are, I would also like to see this revert be considered.
Quoted 6 lines
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerHi,
Quoted 2 lines
Quoted 2 lines
The DRI3 code extensively uses
prime_handle_to_fdandprime_fd_to_handlefor self-import.
The callbacks are not used for self-import.
Quoted 3 lines
I believe the cap was removed because the driver only supports self-import. But the driver only runs inside VMs where there is no(?) other dma-buf clients,
There can be other dma-buf clients even in a VM.
cheers,
Gerd
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 8 lines · Gerd Hoffmann
Hi,
Quoted 2 lines
Quoted 2 lines
The DRI3 code extensively uses
prime_handle_to_fdandprime_fd_to_handlefor self-import.The callbacks are not used for self-import.
Userspace converts from it's own handles to a dmabuf fd and vice-versa. I assumed that's called self-import, is it not?
Can you please enlighten me?
Thanks
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerQuoted 11 lines · Emil Velikov
Quoted 8 lines · Gerd Hoffmann
Hi,
Quoted 2 lines
Quoted 2 lines
The DRI3 code extensively uses
prime_handle_to_fdandprime_fd_to_handlefor self-import.The callbacks are not used for self-import.
Userspace converts from it's own handles to a dmabuf fd and vice-versa. I assumed that's called self-import, is it not?
self-import is importing a dma-buf into the driver which created it.
drm_gem_prime.c has a shortcut for that, it'll just increase the gem reference count instead of going though a full-blown export/import.
The prime_handle_to_fd and prime_fd_to_handle callbacks are only needed for the non-self-import case, where the other driver needs/provides a scatter list.
cheers,
Gerd
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 14 lines · Gerd Hoffmann
Quoted 11 lines · Emil Velikov
Quoted 8 lines · Gerd Hoffmann
Hi,
Quoted 2 lines
Quoted 2 lines
The DRI3 code extensively uses
prime_handle_to_fdandprime_fd_to_handlefor self-import.The callbacks are not used for self-import.
Userspace converts from it's own handles to a dmabuf fd and vice-versa. I assumed that's called self-import, is it not?
Quoted 9 lines
self-import is importing a dma-buf into the driver which created it.
drm_gem_prime.chas a shortcut for that, it'll just increase the gem reference count instead of going though a full-blown export/import.The
prime_handle_to_fdandprime_fd_to_handlecallbacks are only needed for the non-self-import case, where the other driver needs/provides a scatter list.
Looking at kernel.org and drm-misc-next (as of a couple of hours ago) there is no drm_gem_prime.c file.
I would imagine you meant drm_prime.c.
Even then, the callbacks "prime_handle_to_fd" and "prime_fd_to_handle" are used by the ioctls themselves [1] [2].
There is no fall-back when the callbacks are missing - we error out with ENOSYS.
I assume that by "callbacks are only needed" you meant that we should fix the ioctls to use the callbacks only for the non-self-import case? If so, that should land first before pulling out the prime callbacks, right?
HTH
Emil
[1] https://cgit.freedesktop.org/drm/drm-misc/tree/drivers/gpu/drm/drm_prime.c?id=9158e3c31163488364c76bf6948507e7640d511f#n870
[2] https://cgit.freedesktop.org/drm/drm-misc/tree/drivers/gpu/drm/drm_prime.c?id=9158e3c31163488364c76bf6948507e7640d511f#n889
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerQuoted 4 lines · Emil Velikov
Quoted 2 lines · Gerd Hoffmann
On Tue, Apr 23, 2019 at 12:55:07PM +0100, Emil Velikov wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · Gerd Hoffmann
Quoted 7 lines
Hi,
Quoted 2 lines
Quoted 2 lines
The DRI3 code extensively uses
prime_handle_to_fdandprime_fd_to_handlefor self-import.The callbacks are not used for self-import.
Btw for drm-fixes I'm reverting this as it is a userspace regression.
I've dropped the warn prints in the revert, I think userspace should be fixed, and/or kernel space but without regression behaviour.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerQuoted 11 lines · Marc-André Lureau
This patch does more harm than good, as it breaks both Xwayland and gnome-shell with X11.
Xwayland requires DRI3 & DRI3 requires PRIME.
X11 crash for obscure double-free reason which are hard to debug (starting X11 by hand doesn't trigger the crash).
I don't see an apparent problem implementing those stub prime functions, they may return an error at run-time, and it seems to be handled fine by GNOME at least.
Well, problem is they are *not* handled fine, this is why the patch is there in the first place.
Problem case: gnome-shell (in wayland display server mode) fails to come up with a working desktop in case both a intel vgpu and an emulated display device are present in the system. Looks like wayland tries to render using the intel vgpu, then import the rendered buffers to the emulated display device (qxl or virtio-gpu), and it does not handle the failure.
I've tried to add a DRM_PRIME_CAP_LOCAL flag for self-import support:
https://patchwork.freedesktop.org/patch/297672/
But looks like Daniel Vetter (Cc'ed) thinks userspace is to blame here for not handling the import failure properly.
drivers/gpu/drm/virtio/virtgpu_prime.c void virtgpu_gem_prime_unpin(struct drm_gem_object *obj) · line 46
Quoted 5 lines
drivers/gpu/drm/virtio/virtgpu_prime.c +5
-0+struct sg_table *virtgpu_gem_prime_get_sg_table (struct drm_gem_object *obj) +{ +WARN_ONCE (1 ,"not implemented" ); +return ERR_PTR (-ENODEV ); +}
That is actually implemented meanwhile (branch drm-misc-next, will land in 5.2, commit "98f41dc3b3ee drm/virtio: implement prime export".
drivers/gpu/drm/virtio/virtgpu_prime.c void virtgpu_gem_prime_unpin(struct drm_gem_object *obj) · line 52
Quoted 5 lines
drivers/gpu/drm/virtio/virtgpu_prime.c +5
-0+struct drm_gem_object *virtgpu_gem_prime_import_sg_table ( +struct drm_device *dev,struct dma_buf_attachment *attach, +struct sg_table *table) +{ +WARN_ONCE (1 ,"not implemented" );
I don't think we should re-add this. Either drop this completely, or replace by a less noisy printk_once("can do self-import only").
cheers,
Gerd
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel