From patchwork Fri Nov 30 12:12:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 1825281 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 870E1DF24C for ; Fri, 30 Nov 2012 12:17:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 880EDE6079 for ; Fri, 30 Nov 2012 04:17:24 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) by gabe.freedesktop.org (Postfix) with ESMTP id 7EACCE6079 for ; Fri, 30 Nov 2012 04:13:35 -0800 (PST) Received: by mail-wi0-f173.google.com with SMTP id hn17so5167939wib.12 for ; Fri, 30 Nov 2012 04:13:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=yXo2QJzSnR0cfxx06VdpC8EVwtjBhWD9TEjq3xpGvQ0=; b=czwjrZ+rooLA53ym78/m6rnsh8OVh1OE1T/VVdbTVmUcnLJPg8UpNEgq2LE8q7xFEd pQzpYiEliSSeQJujTX3ZyYYv/j4FBSLtIrfa4vGJ9Q37bGa0pj2blwKXUw3clXsFjErz tFsOUKkISm0nt5w8XuKvJVEXcZIRl3RP6AgrQRs2f8Z3TLNBDZ+cz0z9SNhvXtsVPbSJ Xuo8ItV5P1WisBnQauSrOSXgqI/IUNv7XSVrqZAVFk0zPlkFVJ6enrYa2wZ0XvkYaAMm oUvYaTuB7XzCagTLayuGnfhVLCzm/iu6YnTREIh0dO4cbLGRc0iqHLod5TllZpn0UHk3 l3rg== Received: by 10.216.29.211 with SMTP id i61mr410941wea.175.1354277614650; Fri, 30 Nov 2012 04:13:34 -0800 (PST) Received: from localhost (5ED48CEF.cm-7-5c.dynamic.ziggo.nl. [94.212.140.239]) by mx.google.com with ESMTPS id d9sm15473696wiw.0.2012.11.30.04.13.32 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 30 Nov 2012 04:13:34 -0800 (PST) Received: by localhost (sSMTP sendmail emulation); Fri, 30 Nov 2012 13:13:31 +0100 From: Maarten Lankhorst To: dri-devel@lists.freedesktop.org, thellstrom@vmware.com Subject: [PATCH 5/6] drm/nouveau: use ttm_bo_reserve_slowpath in validate_init Date: Fri, 30 Nov 2012 13:12:59 +0100 Message-Id: <1354277580-17958-5-git-send-email-maarten.lankhorst@canonical.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1354277580-17958-1-git-send-email-maarten.lankhorst@canonical.com> References: <50B8A254.904@canonical.com> <1354277580-17958-1-git-send-email-maarten.lankhorst@canonical.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Similar rationale to the identical commit in drm/ttm. Instead of only waiting for unreservation, we make sure we actually own the reservation, then retry to get the rest. Signed-off-by: Maarten Lankhorst --- drivers/gpu/drm/nouveau/nouveau_gem.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 7b9364b..6f58604 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -321,6 +321,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv, uint32_t sequence; int trycnt = 0; int ret, i; + struct nouveau_bo *res_bo = NULL; sequence = atomic_add_return(1, &drm->ttm.validate_sequence); retry: @@ -341,6 +342,11 @@ retry: return -ENOENT; } nvbo = gem->driver_private; + if (nvbo == res_bo) { + res_bo = NULL; + drm_gem_object_unreference_unlocked(gem); + continue; + } if (nvbo->reserved_by && nvbo->reserved_by == file_priv) { NV_ERROR(drm, "multiple instances of buffer %d on " @@ -353,15 +359,18 @@ retry: ret = ttm_bo_reserve(&nvbo->bo, true, false, true, sequence); if (ret) { validate_fini(op, NULL); - if (unlikely(ret == -EAGAIN)) - ret = ttm_bo_wait_unreserved(&nvbo->bo, true); - drm_gem_object_unreference_unlocked(gem); + if (unlikely(ret == -EAGAIN)) { + ret = ttm_bo_reserve_slowpath(&nvbo->bo, true, + sequence); + if (!ret) + res_bo = nvbo; + } if (unlikely(ret)) { + drm_gem_object_unreference_unlocked(gem); if (ret != -ERESTARTSYS) NV_ERROR(drm, "fail reserve\n"); return ret; } - goto retry; } b->user_priv = (uint64_t)(unsigned long)nvbo; @@ -383,6 +392,8 @@ retry: validate_fini(op, NULL); return -EINVAL; } + if (nvbo == res_bo) + goto retry; } return 0;