All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chia-I Wu <olvaffe@gmail.com>
To: Gurchetan Singh <gurchetansingh@chromium.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>,
	ML dri-devel <dri-devel@lists.freedesktop.org>,
	jbates@chromium.org
Subject: Re: [PATCH 3/5 v5] drm/virtio: track whether or not a context has been initiated
Date: Wed, 19 Feb 2020 10:30:20 -0800	[thread overview]
Message-ID: <CAPaKu7QDRJx0auB7eKvLTx17Wio28eXU1urhsVJSfeua28OYhg@mail.gmail.com> (raw)
In-Reply-To: <20200219175640.809-3-gurchetansingh@chromium.org>

Patch 1-4 are

Reviewed-by: Chia-I Wu <olvaffe@gmail.com>

I think we can drop patch 5 for now.


On Wed, Feb 19, 2020 at 9:56 AM Gurchetan Singh
<gurchetansingh@chromium.org> wrote:
>
> Use an atomic variable to track whether a context has been
> initiated.
>
> v5: Fix possible race and sleep via mutex (@olv)
>
> Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
> ---
>  drivers/gpu/drm/virtio/virtgpu_drv.h   | 2 ++
>  drivers/gpu/drm/virtio/virtgpu_ioctl.c | 8 ++++++++
>  drivers/gpu/drm/virtio/virtgpu_kms.c   | 3 +++
>  3 files changed, 13 insertions(+)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
> index 72c1d9b59dfe..0596d9618554 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_drv.h
> +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
> @@ -209,6 +209,8 @@ struct virtio_gpu_device {
>
>  struct virtio_gpu_fpriv {
>         uint32_t ctx_id;
> +       bool context_initiated;
ctx_id and context_initialized are named hw_res_handle and created
respectively in virtio_gpu_object.  I think we should use "hw",
"id"/"handle", "initialized"/"created" more consistently.

This is just a nitpick, and does not need to be a part of this series.

> +       struct mutex context_lock;
>  };
>
>  /* virtio_ioctl.c */
> diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> index de04f80f737d..c1a6cb4ec375 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> @@ -44,10 +44,18 @@ void virtio_gpu_create_context(struct drm_device *dev,
>         if (!vgdev->has_virgl_3d)
>                 return;
>
> +       mutex_lock(&vfpriv->context_lock);
> +       if (vfpriv->context_initiated)
> +               goto out_unlock;
> +
>         get_task_comm(dbgname, current);
>         virtio_gpu_cmd_context_create(vgdev, vfpriv->ctx_id,
>                                       strlen(dbgname), dbgname);
>         virtio_gpu_notify(vgdev);
> +       vfpriv->context_initiated = true;
> +
> +out_unlock:
> +       mutex_unlock(&vfpriv->context_lock);
>  }
>
>  static int virtio_gpu_map_ioctl(struct drm_device *dev, void *data,
> diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
> index f7e3712502ca..424729cb81d1 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_kms.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
> @@ -258,6 +258,8 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file)
>         if (!vfpriv)
>                 return -ENOMEM;
>
> +       mutex_init(&vfpriv->context_lock);
> +
>         handle = ida_alloc(&vgdev->ctx_id_ida, GFP_KERNEL);
>         if (handle < 0) {
>                 kfree(vfpriv);
> @@ -281,6 +283,7 @@ void virtio_gpu_driver_postclose(struct drm_device *dev, struct drm_file *file)
>         vfpriv = file->driver_priv;
>
>         virtio_gpu_context_destroy(vgdev, vfpriv->ctx_id);
> +       mutex_destroy(&vfpriv->context_lock);
>         kfree(vfpriv);
>         file->driver_priv = NULL;
>  }
> --
> 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 18:30 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 [this message]
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 ` [PATCH 5/5 v5] drm/virtio: add virtio_gpu_context_type Gurchetan Singh
2020-02-19 18:29   ` 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=CAPaKu7QDRJx0auB7eKvLTx17Wio28eXU1urhsVJSfeua28OYhg@mail.gmail.com \
    --to=olvaffe@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gurchetansingh@chromium.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.