All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/2] drm/virtio: Don't attach GEM to a non-created context in gem_object_open()
@ 2025-03-26  1:49 Dmitry Osipenko
  2025-03-26  1:49 ` [PATCH v1 2/2] drm/virtio: Fix missed dmabuf unpinning in error path of prepare_fb() Dmitry Osipenko
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Osipenko @ 2025-03-26  1:49 UTC (permalink / raw)
  To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu,
	Vivek Kasireddy, Pierre-Eric Pelloux-Prayer
  Cc: dri-devel, virtualization, linux-kernel, kernel

The vfpriv->ctx_id is always initialized to a non-zero value. Check whether
context was created before attaching GEM to this context ID. This left
unnoticed previously because host silently skips attachment if context
doesn't exist, still we shouldn't do that for consistency.

Fixes: 086b9f27f0ab ("drm/virtio: Don't create a context with default param if context_init is supported")
Cc: <stable@vger.kernel.org> # v6.14+
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
---
 drivers/gpu/drm/virtio/virtgpu_gem.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c b/drivers/gpu/drm/virtio/virtgpu_gem.c
index dde8fc1a3689..90c99d83c4cf 100644
--- a/drivers/gpu/drm/virtio/virtgpu_gem.c
+++ b/drivers/gpu/drm/virtio/virtgpu_gem.c
@@ -115,13 +115,14 @@ int virtio_gpu_gem_object_open(struct drm_gem_object *obj,
 	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);
+	if (vfpriv->context_created) {
+		objs = virtio_gpu_array_alloc(1);
+		if (!objs)
+			return -ENOMEM;
+		virtio_gpu_array_add_obj(objs, obj);
 
-	if (vfpriv->ctx_id)
 		virtio_gpu_cmd_context_attach_resource(vgdev, vfpriv->ctx_id, objs);
+	}
 
 out_notify:
 	virtio_gpu_notify(vgdev);
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-03-28  1:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-26  1:49 [PATCH v1 1/2] drm/virtio: Don't attach GEM to a non-created context in gem_object_open() Dmitry Osipenko
2025-03-26  1:49 ` [PATCH v1 2/2] drm/virtio: Fix missed dmabuf unpinning in error path of prepare_fb() Dmitry Osipenko
2025-03-26  5:14   ` Kasireddy, Vivek
2025-03-26 11:54     ` Dmitry Osipenko
2025-03-27  7:14       ` Kasireddy, Vivek
2025-03-28  1:35         ` Dmitry Osipenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.