From patchwork Wed Jul 9 12:30:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 4515191 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2057E9F1C4 for ; Wed, 9 Jul 2014 12:30:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 58A0620357 for ; Wed, 9 Jul 2014 12:30:28 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8C63C2015E for ; Wed, 9 Jul 2014 12:30:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EF4458A0B7; Wed, 9 Jul 2014 05:30:26 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by gabe.freedesktop.org (Postfix) with ESMTP id AE0578A0B7 for ; Wed, 9 Jul 2014 05:30:25 -0700 (PDT) Received: from lillypilly.canonical.com ([91.189.89.62]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1X4r0y-000522-1b; Wed, 09 Jul 2014 12:30:24 +0000 Received: by lillypilly.canonical.com (Postfix, from userid 3489) id DADD426C297D; Wed, 9 Jul 2014 12:30:23 +0000 (UTC) Subject: [PATCH 14/17] drm/nouveau: use rcu in nouveau_gem_ioctl_cpu_prep To: airlied@linux.ie From: Maarten Lankhorst Date: Wed, 09 Jul 2014 14:30:23 +0200 Message-ID: <20140709123023.11354.45654.stgit@patser> In-Reply-To: <20140709093124.11354.3774.stgit@patser> References: <20140709093124.11354.3774.stgit@patser> User-Agent: StGit/0.15 MIME-Version: 1.0 Cc: thellstrom@vmware.com, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, bskeggs@redhat.com, alexander.deucher@amd.com, christian.koenig@amd.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With the conversion to the reservation api this should be safe. Signed-off-by: Maarten Lankhorst --- drivers/gpu/drm/nouveau/nouveau_gem.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 4beaa897adad..c2ca894f6507 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -863,33 +863,29 @@ nouveau_gem_ioctl_cpu_prep(struct drm_device *dev, void *data, struct drm_gem_object *gem; struct nouveau_bo *nvbo; bool no_wait = !!(req->flags & NOUVEAU_GEM_CPU_PREP_NOWAIT); + bool write = !!(req->flags & NOUVEAU_GEM_CPU_PREP_WRITE); int ret; - struct nouveau_fence *fence = NULL; gem = drm_gem_object_lookup(dev, file_priv, req->handle); if (!gem) return -ENOENT; nvbo = nouveau_gem_object(gem); - ret = ttm_bo_reserve(&nvbo->bo, true, false, false, 0); - if (!ret) { - ret = ttm_bo_wait(&nvbo->bo, true, true, true); - if (!no_wait && ret) { - struct fence *excl; - - excl = reservation_object_get_excl(nvbo->bo.resv); - fence = nouveau_fence_ref((struct nouveau_fence *)excl); - } + if (no_wait) + ret = reservation_object_test_signaled_rcu(nvbo->bo.resv, write) ? 0 : -EBUSY; + else { + long lret; - ttm_bo_unreserve(&nvbo->bo); + lret = reservation_object_wait_timeout_rcu(nvbo->bo.resv, write, true, 30 * HZ); + if (!lret) + ret = -EBUSY; + else if (lret > 0) + ret = 0; + else + ret = lret; } drm_gem_object_unreference_unlocked(gem); - if (fence) { - ret = nouveau_fence_wait(fence, true, no_wait); - nouveau_fence_unref(&fence); - } - return ret; }