All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gurchetan Singh <gurchetansingh@chromium.org>
To: dri-devel@lists.freedesktop.org
Cc: Gurchetan Singh <gurchetansingh@chromium.org>,
	kraxel@redhat.com, jbates@chromium.org
Subject: [PATCH 5/5 v5] drm/virtio: add virtio_gpu_context_type
Date: Wed, 19 Feb 2020 09:56:40 -0800	[thread overview]
Message-ID: <20200219175640.809-5-gurchetansingh@chromium.org> (raw)
In-Reply-To: <20200219175640.809-1-gurchetansingh@chromium.org>

We'll have to do something like this eventually, and this
conveys we want a Virgl context by default.

Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
---
 drivers/gpu/drm/virtio/virtgpu_ioctl.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index 2c182922ec78..c3358eedd3ab 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
@@ -33,8 +33,14 @@
 
 #include "virtgpu_drv.h"
 
+/* TODO: add more context types */
+enum virtio_gpu_context_type {
+	virtio_gpu_virgl_context,
+};
+
 static void virtio_gpu_create_context(struct drm_device *dev,
-				      struct drm_file *file)
+				      struct drm_file *file,
+				      enum virtio_gpu_context_type type)
 {
 	struct virtio_gpu_device *vgdev = dev->dev_private;
 	struct virtio_gpu_fpriv *vfpriv = file->driver_priv;
@@ -44,6 +50,11 @@ static void virtio_gpu_create_context(struct drm_device *dev,
 	if (!vgdev->has_virgl_3d)
 		return;
 
+	if (type != virtio_gpu_virgl_context) {
+		DRM_ERROR("Unsupported context type: %u\n", type);
+		return;
+	}
+
 	mutex_lock(&vfpriv->context_lock);
 	if (vfpriv->context_initiated)
 		goto out_unlock;
@@ -98,7 +109,7 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
 
 	exbuf->fence_fd = -1;
 
-	virtio_gpu_create_context(dev, file);
+	virtio_gpu_create_context(dev, file, virtio_gpu_virgl_context);
 	if (exbuf->flags & VIRTGPU_EXECBUF_FENCE_FD_IN) {
 		struct dma_fence *in_fence;
 
@@ -250,7 +261,7 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data,
 			return -EINVAL;
 	}
 
-	virtio_gpu_create_context(dev, file);
+	virtio_gpu_create_context(dev, file, virtio_gpu_virgl_context);
 	params.format = rc->format;
 	params.width = rc->width;
 	params.height = rc->height;
@@ -324,7 +335,7 @@ static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev,
 	if (vgdev->has_virgl_3d == false)
 		return -ENOSYS;
 
-	virtio_gpu_create_context(dev, file);
+	virtio_gpu_create_context(dev, file, virtio_gpu_virgl_context);
 	objs = virtio_gpu_array_from_handles(file, &args->bo_handle, 1);
 	if (objs == NULL)
 		return -ENOENT;
@@ -373,7 +384,7 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data,
 			 args->box.w, args->box.h, args->box.x, args->box.y,
 			 objs, NULL);
 	} else {
-		virtio_gpu_create_context(dev, file);
+		virtio_gpu_create_context(dev, file, virtio_gpu_virgl_context);
 		ret = virtio_gpu_array_lock_resv(objs);
 		if (ret != 0)
 			goto err_put_free;
@@ -474,7 +485,7 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev,
 	spin_unlock(&vgdev->display_info_lock);
 
 	/* not in cache - need to talk to hw */
-	virtio_gpu_create_context(dev, file);
+	virtio_gpu_create_context(dev, file, virtio_gpu_virgl_context);
 	virtio_gpu_cmd_get_capset(vgdev, found_valid, args->cap_set_ver,
 				  &cache_ent);
 	virtio_gpu_notify(vgdev);
-- 
2.25.0.265.gbab2e86ba0-goog

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2020-02-19 17:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-19 17:56 [PATCH 1/5 v5] drm/virtio: use consistent names for drm_files Gurchetan Singh
2020-02-19 17:56 ` [PATCH 2/5 v5] drm/virtio: factor out context create hyercall Gurchetan Singh
2020-02-19 18:10   ` Emil Velikov
2020-02-19 17:56 ` [PATCH 3/5 v5] drm/virtio: track whether or not a context has been initiated Gurchetan Singh
2020-02-19 18:12   ` Emil Velikov
2020-02-19 18:30   ` Chia-I Wu
2020-02-19 17:56 ` [PATCH 4/5 v5] drm/virtio: enqueue virtio_gpu_create_context after the first 3D ioctl Gurchetan Singh
2020-02-19 18:28   ` Emil Velikov
2020-02-19 17:56 ` Gurchetan Singh [this message]
2020-02-19 18:29   ` [PATCH 5/5 v5] drm/virtio: add virtio_gpu_context_type Emil Velikov
2020-02-19 18:06 ` [PATCH 1/5 v5] drm/virtio: use consistent names for drm_files Emil Velikov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200219175640.809-5-gurchetansingh@chromium.org \
    --to=gurchetansingh@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jbates@chromium.org \
    --cc=kraxel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.