Skip to contentSkip to conversation

drm/virtio: make sure context is created in gem open

PATCH In review Chia-I Wu 3 participants 3 messages Jan 7, 2021 – Jan 12, 2021

Subsystems (3)
lore
Share & tools
lore

Chia-I Wu

author reviewer
#0 lore raw

PATCH 1/1 drm/virtio: make sure context is created in gem open

The context might still be missing when DRM_IOCTL_PRIME_FD_TO_HANDLE is the first ioctl on the drm_file.

Fixes 72b48ae800da ("drm/virtio: enqueue virtio_gpu_create_context after the first 3D ioctl")
Cc Gurchetan Singh <[email protected]>
Cc Gerd Hoffmann <[email protected]>
---
 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 c30c75ee83fc..8502400b2f9c 100644
@@ -39,9 +39,6 @@ static int virtio_gpu_gem_create(struct drm_file *file,
 	int ret;
 	u32 handle;
 
-	if (vgdev->has_virgl_3d)
-		virtio_gpu_create_context(dev, file);
-
 	ret = virtio_gpu_object_create(vgdev, params, &obj, NULL);
 	if (ret < 0)
 		return ret;
@@ -119,6 +116,11 @@ int virtio_gpu_gem_object_open(struct drm_gem_object *obj,
 	if (!vgdev->has_virgl_3d)
 		goto out_notify;
 
+	/* 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);
+
 	objs = virtio_gpu_array_alloc(1);
 	if (!objs)
 		return -ENOMEM;
Signature · 6 lines
2.29.2.729.g45daf8777d-goog

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 40 lines · Chia-I Wu

The context might still be missing when DRM_IOCTL_PRIME_FD_TO_HANDLE is the first ioctl on the drm_file.

Fixes 72b48ae800da ("drm/virtio: enqueue virtio_gpu_create_context after

the first 3D ioctl")

Cc Gurchetan Singh <[email protected]>
Cc Gerd Hoffmann <[email protected]>
---
 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 c30c75ee83fc..8502400b2f9c 100644
@@ -39,9 +39,6 @@ static int virtio_gpu_gem_create(struct drm_file *file,
        int ret;
        u32 handle;
 
-       if (vgdev->has_virgl_3d)
-               virtio_gpu_create_context(dev, file);
-
        ret = virtio_gpu_object_create(vgdev, params, &obj, NULL);
        if (ret < 0)
                return ret;
@@ -119,6 +116,11 @@ int virtio_gpu_gem_object_open(struct drm_gem_object
 *obj,
        if (!vgdev->has_virgl_3d)
                goto out_notify;
 
+       /* 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);
+
        objs = virtio_gpu_array_alloc(1);
        if (!objs)
                return -ENOMEM;
Quoted 4 lines

--
2.29.2.729.g45daf8777d-goog

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by on v1 1/1
#2 lore raw
In reply to Chia-I Wu
Quoted 7 lines · Chia-I Wu

The context might still be missing when DRM_IOCTL_PRIME_FD_TO_HANDLE is the first ioctl on the drm_file.

Fixes 72b48ae800da ("drm/virtio: enqueue virtio_gpu_create_context after the first 3D ioctl")
Cc Gurchetan Singh <[email protected]>
Cc Gerd Hoffmann <[email protected]>
Quoted 37 lines

---
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 c30c75ee83fc..8502400b2f9c 100644
@@ -39,9 +39,6 @@ static int virtio_gpu_gem_create(struct drm_file *file,
 	int ret;
 	u32 handle;
 
-	if (vgdev->has_virgl_3d)
-		virtio_gpu_create_context(dev, file);
-
 	ret = virtio_gpu_object_create(vgdev, params, &obj, NULL);
 	if (ret < 0)
 		return ret;
@@ -119,6 +116,11 @@ int virtio_gpu_gem_object_open(struct drm_gem_object *obj,
 	if (!vgdev->has_virgl_3d)
 		goto out_notify;
 
+	/* 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);
+
 	objs = virtio_gpu_array_alloc(1);
 	if (!objs)
 		return -ENOMEM;
Signature · 6 lines
2.29.2.729.g45daf8777d-goog

_______________________________________________
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