Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp821860ybl; Thu, 22 Aug 2019 05:31:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5v80Zw3SzRLerJsY+a/HGDVnEYfuQxomEM41zmxnj7xOqCFCuMEqbzxYMdpeH0SpgRJMT X-Received: by 2002:a17:902:d911:: with SMTP id c17mr938245plz.70.1566477118581; Thu, 22 Aug 2019 05:31:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566477118; cv=none; d=google.com; s=arc-20160816; b=Iq6ftYCD2WNKPqVyf0UsNz4dHOLqGGVY0weLkB/ugPeEEhTAOMkneDykFhJl9emb28 3LemnEYuZDeyPrGr0Hi7BW6B4giQCfj5PIq/pkcyZpYhcVOQUIDUHu4Ko9mqylf7mAI3 h7Gdt/J13Fz+aqVqE7TV7tgBGpKUe9BRP47A8iMJXSbCzu26GMUUq70AbTBGFcGCJNjr kS46Slb3nkajKhi/dFIpk8FMJmT3NVcILLOzbVa+zC7o2N6IiYx8+F+rsLBnz8ovndhw efkvdCH7brzX1P5jdkWqPWC4eRt8VzpG7o0GXz1T0AxUElpImAOR+oYmiogijNxnO9ZU feng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=E8esgeI5cS6cfTPmslaRz2xrpccaH7/9oUCohGFi7xs=; b=uj7mrf2b7SfIaf3Dizo3/Woe7j6ctGZf9nfD1Nx/p4QVvLdGxTgInU7xbwO0Y0aoTw Py/3LascT6VkXZUECAHekUfvkggu2FTRuFIGaBnBnb2MKJuBrgsh7+Xc2EMpyG6ivWbA 8wRsRqAJCcPnsFbGf3PIY+ya5wNvH7t79QyTwJwm94IdmSjbc3YKMdHsFrN9WcCtv3Vi b7eP8jvEfN4UzxRfrwfJHULGCVYy0VAQZljitYqW7qkWnDI7HuARasoUgojOtfJdFMw/ LmwjCXqcaX4D0OLzoBxfHg+rpqt221u1dfjFlzyS2VRex51JSBWsFY3MWh2AK7or5UqT hRXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r9si17230869plo.104.2019.08.22.05.31.43; Thu, 22 Aug 2019 05:31:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387576AbfHVK0T (ORCPT + 99 others); Thu, 22 Aug 2019 06:26:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34162 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730918AbfHVK0T (ORCPT ); Thu, 22 Aug 2019 06:26:19 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8B9607F75C; Thu, 22 Aug 2019 10:26:18 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-60.ams2.redhat.com [10.36.116.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id A15426012C; Thu, 22 Aug 2019 10:26:15 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C817516E32; Thu, 22 Aug 2019 12:26:14 +0200 (CEST) From: Gerd Hoffmann To: dri-devel@lists.freedesktop.org Cc: Gerd Hoffmann , David Airlie , Daniel Vetter , virtualization@lists.linux-foundation.org (open list:VIRTIO GPU DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] drm/virtio: make resource id workaround runtime switchable. Date: Thu, 22 Aug 2019 12:26:14 +0200 Message-Id: <20190822102614.18164-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Thu, 22 Aug 2019 10:26:18 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Also update the comment with a reference to the virglrenderer fix. Signed-off-by: Gerd Hoffmann --- 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