linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] drm/virtio: make resource id workaround runtime switchable.
@ 2019-08-22 10:26 Gerd Hoffmann
  2019-08-26 22:06 ` Chia-I Wu
  0 siblings, 1 reply; 2+ messages in thread
From: Gerd Hoffmann @ 2019-08-22 10:26 UTC (permalink / raw)
  To: dri-devel
  Cc: Gerd Hoffmann, David Airlie, Daniel Vetter,
	open list:VIRTIO GPU DRIVER, open list

Also update the comment with a reference to the virglrenderer fix.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/gpu/drm/virtio/virtgpu_object.c | 44 ++++++++++++++-----------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c
index b2da31310d24..e98aaa00578d 100644
--- a/drivers/gpu/drm/virtio/virtgpu_object.c
+++ b/drivers/gpu/drm/virtio/virtgpu_object.c
@@ -27,34 +27,38 @@
 
 #include "virtgpu_drv.h"
 
+static int virtio_gpu_virglrenderer_workaround = 1;
+module_param_named(virglhack, virtio_gpu_virglrenderer_workaround, int, 0400);
+
 static int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev,
 				       uint32_t *resid)
 {
-#if 0
-	int handle = ida_alloc(&vgdev->resource_ida, GFP_KERNEL);
-
-	if (handle < 0)
-		return handle;
-#else
-	static int handle;
-
-	/*
-	 * FIXME: dirty hack to avoid re-using IDs, virglrenderer
-	 * can't deal with that.  Needs fixing in virglrenderer, also
-	 * should figure a better way to handle that in the guest.
-	 */
-	handle++;
-#endif
-
-	*resid = handle + 1;
+	if (virtio_gpu_virglrenderer_workaround) {
+		/*
+		 * Hack to avoid re-using resource IDs.
+		 *
+		 * virglrenderer versions up to (and including) 0.7.0
+		 * can't deal with that.  virglrenderer commit
+		 * "f91a9dd35715 Fix unlinking resources from hash
+		 * table." (Feb 2019) fixes the bug.
+		 */
+		static int handle;
+		handle++;
+		*resid = handle + 1;
+	} else {
+		int handle = ida_alloc(&vgdev->resource_ida, GFP_KERNEL);
+		if (handle < 0)
+			return handle;
+		*resid = handle + 1;
+	}
 	return 0;
 }
 
 static void virtio_gpu_resource_id_put(struct virtio_gpu_device *vgdev, uint32_t id)
 {
-#if 0
-	ida_free(&vgdev->resource_ida, id - 1);
-#endif
+	if (!virtio_gpu_virglrenderer_workaround) {
+		ida_free(&vgdev->resource_ida, id - 1);
+	}
 }
 
 static void virtio_gpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)
-- 
2.18.1


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

* Re: [PATCH v2] drm/virtio: make resource id workaround runtime switchable.
  2019-08-22 10:26 [PATCH v2] drm/virtio: make resource id workaround runtime switchable Gerd Hoffmann
@ 2019-08-26 22:06 ` Chia-I Wu
  0 siblings, 0 replies; 2+ messages in thread
From: Chia-I Wu @ 2019-08-26 22:06 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: ML dri-devel, David Airlie, open list, open list:VIRTIO GPU DRIVER

On Thu, Aug 22, 2019 at 3:26 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> Also update the comment with a reference to the virglrenderer fix.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
> ---
>  drivers/gpu/drm/virtio/virtgpu_object.c | 44 ++++++++++++++-----------
>  1 file changed, 24 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c
> index b2da31310d24..e98aaa00578d 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_object.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_object.c
> @@ -27,34 +27,38 @@
>
>  #include "virtgpu_drv.h"
>
> +static int virtio_gpu_virglrenderer_workaround = 1;
> +module_param_named(virglhack, virtio_gpu_virglrenderer_workaround, int, 0400);
> +
>  static int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev,
>                                        uint32_t *resid)
>  {
> -#if 0
> -       int handle = ida_alloc(&vgdev->resource_ida, GFP_KERNEL);
> -
> -       if (handle < 0)
> -               return handle;
> -#else
> -       static int handle;
> -
> -       /*
> -        * FIXME: dirty hack to avoid re-using IDs, virglrenderer
> -        * can't deal with that.  Needs fixing in virglrenderer, also
> -        * should figure a better way to handle that in the guest.
> -        */
> -       handle++;
> -#endif
> -
> -       *resid = handle + 1;
> +       if (virtio_gpu_virglrenderer_workaround) {
> +               /*
> +                * Hack to avoid re-using resource IDs.
> +                *
> +                * virglrenderer versions up to (and including) 0.7.0
> +                * can't deal with that.  virglrenderer commit
> +                * "f91a9dd35715 Fix unlinking resources from hash
> +                * table." (Feb 2019) fixes the bug.
> +                */
> +               static int handle;
> +               handle++;
> +               *resid = handle + 1;
> +       } else {
> +               int handle = ida_alloc(&vgdev->resource_ida, GFP_KERNEL);
> +               if (handle < 0)
> +                       return handle;
> +               *resid = handle + 1;
> +       }
>         return 0;
>  }
>
>  static void virtio_gpu_resource_id_put(struct virtio_gpu_device *vgdev, uint32_t id)
>  {
> -#if 0
> -       ida_free(&vgdev->resource_ida, id - 1);
> -#endif
> +       if (!virtio_gpu_virglrenderer_workaround) {
> +               ida_free(&vgdev->resource_ida, id - 1);
> +       }
>  }
>
>  static void virtio_gpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)
> --
> 2.18.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2019-08-26 22:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-22 10:26 [PATCH v2] drm/virtio: make resource id workaround runtime switchable Gerd Hoffmann
2019-08-26 22:06 ` Chia-I Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).