From patchwork Tue Jun 18 13:58:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 11001777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 31A6114BB for ; Tue, 18 Jun 2019 13:58:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23A0628B35 for ; Tue, 18 Jun 2019 13:58:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1818B28AA7; Tue, 18 Jun 2019 13:58:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CCBD628B35 for ; Tue, 18 Jun 2019 13:58:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C9ECF6E1B4; Tue, 18 Jun 2019 13:58:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id CE6746E1B4 for ; Tue, 18 Jun 2019 13:58:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6EEECB0AA6; Tue, 18 Jun 2019 13:58:26 +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 246F81001DFF; Tue, 18 Jun 2019 13:58:26 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id A6CFB1753A; Tue, 18 Jun 2019 15:58:22 +0200 (CEST) From: Gerd Hoffmann To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 11/12] drm/virtio: rework virtio_gpu_object_create fencing even more. Date: Tue, 18 Jun 2019 15:58:19 +0200 Message-Id: <20190618135821.8644-12-kraxel@redhat.com> In-Reply-To: <20190618135821.8644-1-kraxel@redhat.com> References: <20190618135821.8644-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 18 Jun 2019 13:58:31 +0000 (UTC) X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , open list , Gerd Hoffmann , "open list:VIRTIO GPU DRIVER" MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Now with ttm initialization being out of the way we can simplify virtio_gpu_object_create fencing even more. No need to check whenever the command is still running after ttm_bo_init() returned. We have a fully initialized gem bo before we kick off the resource creation command, so we can simply add the fence to the bo's reservation object beforehand. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_object.c | 27 +++++++++---------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c index d0e328db0a55..4301456f087f 100644 --- a/drivers/gpu/drm/virtio/virtgpu_object.c +++ b/drivers/gpu/drm/virtio/virtgpu_object.c @@ -120,30 +120,21 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev, } bo->dumb = params->dumb; - if (params->virgl) { - virtio_gpu_cmd_resource_create_3d(vgdev, bo, params, fence); - } else { - virtio_gpu_cmd_create_resource(vgdev, bo, params, fence); - } - if (fence) { - struct virtio_gpu_fence_driver *drv = &vgdev->fence_drv; struct drm_gem_object *obj = &bo->base.base; struct ww_acquire_ctx ticket; - unsigned long irq_flags; - drm_gem_object_get(obj); ret = drm_gem_lock_reservations(&obj, 1, &ticket); - if (ret == 0) { - spin_lock_irqsave(&drv->lock, irq_flags); - if (!virtio_fence_signaled(&fence->f)) - /* virtio create command still in flight */ - reservation_object_add_excl_fence(obj->resv, - &fence->f); - spin_unlock_irqrestore(&drv->lock, irq_flags); - } + if (ret == 0) + reservation_object_add_excl_fence(obj->resv, + &fence->f); drm_gem_unlock_reservations(&obj, 1, &ticket); - drm_gem_object_put_unlocked(obj); + } + + if (params->virgl) { + virtio_gpu_cmd_resource_create_3d(vgdev, bo, params, fence); + } else { + virtio_gpu_cmd_create_resource(vgdev, bo, params, fence); } ret = virtio_gpu_object_attach(vgdev, bo, NULL);