Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3813757ybi; Tue, 18 Jun 2019 06:58:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyqNWcTTqfJtU/lmXN/o928ahBH4unm3UQbpg6NO+LGpW5hxc+kaEHHWJ9uTG0s6wHdGTk0 X-Received: by 2002:a17:902:bd94:: with SMTP id q20mr27802208pls.307.1560866334834; Tue, 18 Jun 2019 06:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560866334; cv=none; d=google.com; s=arc-20160816; b=fPsQwrlg8rRY/sGWtxdM29kGeEJvlOZ8Qec7oKVjbIEJGF4xM4BAR0MEfdgm82Qsul xZXmnNXb/BN6CuKmptTi1LbmgHSRxOeSnCg5dm/GFV9yf8mL7T+9UVvf5KSuajv+asl+ 00/W8/QKzCcSRwiJ6T/e/gTWJ7s8g5XnPeVg1EZNTkK/YlrgGGw5zalDtfR2SZ25IJ4j T9QpW9HDrN5AqbT/C0ggIr/LNfmNXLSM4CvZp292Qz+JF9v81nok98IKHttauv3BL2// eFDdg5iK/6fLNYVcwGzVU5i+oDJj6PqnpNFR0c4AuQ0g6LHSinGhVbsu8uFd921xjtdH Wirg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=ovH+BTbDAT6qg2jYWA8BgX9ikBQ/iRQDf/BFg+8VmlQ=; b=nznwsy8UXcCgs4DgdWxEcehdgo9NmEI6iyagcIlV3BfHb/CGiCHqhQCfoGtuyz9Vmv +zq/44L+RxwtL+AjAlfZn7/SZdIKF2mRVS2ZGFixnlvMEQxfZ2dFePVL/TPwvw+05rEQ 80FBLWcW6GoGgiFyOFXNTfyelZ7VZR2mn+Mdi6vKG6uLQKr+gs0ywPALas26ssPZQJAc 7EGFI0Zix5FtIRc6sLA347Z1CPIWKkn/72w5XWElK6x117J9zrZE5x99Q8ouOKv75Wvz LWGuJfxaHWcViAG2N5UM8eDyzpo25vmYwROqSROPr/iglgRUHJCnit7G+vgZnd/Ay6TH AWKg== 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 m5si12619226pls.18.2019.06.18.06.58.39; Tue, 18 Jun 2019 06:58:54 -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 S1729400AbfFRN60 (ORCPT + 99 others); Tue, 18 Jun 2019 09:58:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44000 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726689AbfFRN6Z (ORCPT ); Tue, 18 Jun 2019 09:58:25 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BA12E3003B36; Tue, 18 Jun 2019 13:58:24 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-33.ams2.redhat.com [10.36.116.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id E69C317B73; Tue, 18 Jun 2019 13:58:21 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 4454716E1A; Tue, 18 Jun 2019 15:58:21 +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 02/12] drm/virtio: switch virtio_gpu_wait_ioctl() to gem helper. Date: Tue, 18 Jun 2019 15:58:10 +0200 Message-Id: <20190618135821.8644-3-kraxel@redhat.com> In-Reply-To: <20190618135821.8644-1-kraxel@redhat.com> References: <20190618135821.8644-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 18 Jun 2019 13:58:24 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use drm_gem_reservation_object_wait() in virtio_gpu_wait_ioctl(). This also makes the ioctl run lockless. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel Vetter --- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index ac60be9b5c19..313c770ea2c5 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -464,23 +464,19 @@ static int virtio_gpu_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file) { struct drm_virtgpu_3d_wait *args = data; - struct drm_gem_object *gobj = NULL; - struct virtio_gpu_object *qobj = NULL; + struct drm_gem_object *obj; + long timeout = 15 * HZ; int ret; - bool nowait = false; - gobj = drm_gem_object_lookup(file, args->handle); - if (gobj == NULL) - return -ENOENT; + if (args->flags & VIRTGPU_WAIT_NOWAIT) { + obj = drm_gem_object_lookup(file, args->handle); + ret = reservation_object_test_signaled_rcu(obj->resv, true); + drm_gem_object_put_unlocked(obj); + return ret ? 0 : -EBUSY; + } - qobj = gem_to_virtio_gpu_obj(gobj); - - if (args->flags & VIRTGPU_WAIT_NOWAIT) - nowait = true; - ret = virtio_gpu_object_wait(qobj, nowait); - - drm_gem_object_put_unlocked(gobj); - return ret; + return drm_gem_reservation_object_wait(file, args->handle, + true, timeout); } static int virtio_gpu_get_caps_ioctl(struct drm_device *dev, -- 2.18.1