Skip to contentSkip to conversation

drm/virtio: Don't create a context with default param if context_init is supported

PATCH Applied Dmitry Osipenko 2 participants 4 messages Oct 20, 2024 – Nov 19, 2024

Subsystems (4)
lore
Share & tools
lore

Dmitry Osipenko

author maintainer
#0 lore raw

PATCH 1/1 drm/virtio: Don't create a context with default param if context_init is supported

From: Pierre-Eric Pelloux-Prayer <[email protected]>

Xorg context creation fails for native contexts that use VIRTGPU_CONTEXT_INIT because context is already initialized implicitly when dumb buffer is created. Fix it by not creating default vrend context if context_init is supported.

---
 drivers/gpu/drm/virtio/virtgpu_gem.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/virtio/virtgpu_gem.c +5 -3
index 7db48d17ee3a..67f557e058b4 100644
@@ -127,15 +127,17 @@ int virtio_gpu_gem_object_open(struct drm_gem_object *obj,
 	/* the context might still be missing when the first ioctl is
 	 * DRM_IOCTL_MODE_CREATE_DUMB or DRM_IOCTL_PRIME_FD_TO_HANDLE
 	 */
-	virtio_gpu_create_context(obj->dev, file);
+	if (!vgdev->has_context_init)
+		virtio_gpu_create_context(obj->dev, file);
 
 	objs = virtio_gpu_array_alloc(1);
 	if (!objs)
 		return -ENOMEM;
 	virtio_gpu_array_add_obj(objs, obj);
 
-	virtio_gpu_cmd_context_attach_resource(vgdev, vfpriv->ctx_id,
-					       objs);
+	if (vfpriv->ctx_id)
+		virtio_gpu_cmd_context_attach_resource(vgdev, vfpriv->ctx_id, objs);
+
 out_notify:
 	virtio_gpu_notify(vgdev);
 	return 0;
Signature · 1 line
2.47.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Dmitry Osipenko

From: Pierre-Eric Pelloux-Prayer <[email protected]>

Xorg context creation fails for native contexts that use VIRTGPU_CONTEXT_INIT because context is already initialized implicitly when dumb buffer is created. Fix it by not creating default vrend context if context_init is supported.

Quoted 32 lines
---
 drivers/gpu/drm/virtio/virtgpu_gem.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/virtio/virtgpu_gem.c +5 -4
index 7db48d17ee3a..67f557e058b4 100644
@@ -127,15 +127,17 @@ int virtio_gpu_gem_object_open(struct drm_gem_object *obj,
        /* the context might still be missing when the first ioctl is
         * DRM_IOCTL_MODE_CREATE_DUMB or DRM_IOCTL_PRIME_FD_TO_HANDLE
         */
-       virtio_gpu_create_context(obj->dev, file);
+       if (!vgdev->has_context_init)
+               virtio_gpu_create_context(obj->dev, file);
 
        objs = virtio_gpu_array_alloc(1);
        if (!objs)
                return -ENOMEM;
        virtio_gpu_array_add_obj(objs, obj);
 
-       virtio_gpu_cmd_context_attach_resource(vgdev, vfpriv->ctx_id,
-                                              objs);
+       if (vfpriv->ctx_id)
+               virtio_gpu_cmd_context_attach_resource(vgdev, vfpriv->ctx_id, objs);
+
 out_notify:
        virtio_gpu_notify(vgdev);
        return 0;
--

2.47.0

author maintainer
#2 lore raw
In reply to Dmitry Osipenko
Quoted 7 lines · Dmitry Osipenko

From: Pierre-Eric Pelloux-Prayer <[email protected]>

Xorg context creation fails for native contexts that use VIRTGPU_CONTEXT_INIT because context is already initialized implicitly when dumb buffer is created. Fix it by not creating default vrend context if context_init is supported.

Quoted 5 lines
---
 drivers/gpu/drm/virtio/virtgpu_gem.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

I'll apply this patch tomorrow if nobody has more comments to add.

Signature · 2 lines
Best regards,
Dmitry
author maintainer Applied
#3 lore raw
In reply to Dmitry Osipenko
Quoted 7 lines · Dmitry Osipenko

From: Pierre-Eric Pelloux-Prayer <[email protected]>

Xorg context creation fails for native contexts that use VIRTGPU_CONTEXT_INIT because context is already initialized implicitly when dumb buffer is created. Fix it by not creating default vrend context if context_init is supported.

Quoted 5 lines
---
 drivers/gpu/drm/virtio/virtgpu_gem.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Applied to misc-next

Signature · 2 lines
Best regards,
Dmitry