Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 380c5c0d authored by Gerd Hoffmann's avatar Gerd Hoffmann Committed by Alistair Delva
Browse files

UPSTREAM: drm/virtio: make resource id workaround runtime switchable.



commit 3e93bc2a58aa241081e043ef9e6e86c42808499a upstream.

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

Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Reviewed-by: default avatarChia-I Wu <olvaffe@gmail.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20190822102614.18164-1-kraxel@redhat.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit d41f6cfd9aa7c3f01b44fc1ee15bac5589fd1b60)
Bug: 153580313
Signed-off-by: default avatarAlistair Delva <adelva@google.com>
Change-Id: If17d7c7303b9c4e9e03566a20386d46c3bf188b1
parent 5f6439cb
Loading
Loading
Loading
Loading
+24 −20
Original line number Diff line number Diff line
@@ -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;

	if (virtio_gpu_virglrenderer_workaround) {
		/*
	 * 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.
		 * 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++;
#endif

		*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
	if (!virtio_gpu_virglrenderer_workaround) {
		ida_free(&vgdev->resource_ida, id - 1);
#endif
	}
}

static void virtio_gpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)