From patchwork Mon Dec 10 09:17:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 1856541 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 8E2C8DFB79 for ; Mon, 10 Dec 2012 09:26:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8397AE60B3 for ; Mon, 10 Dec 2012 01:26:18 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by gabe.freedesktop.org (Postfix) with ESMTP id 21CDBE608B for ; Mon, 10 Dec 2012 01:17:39 -0800 (PST) Received: by mail-wi0-f179.google.com with SMTP id o1so802430wic.12 for ; Mon, 10 Dec 2012 01:17:39 -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=pTO2ok+PudT+TudRSwlwIAnjfOWjd6C2yGO99DuiFiE=; b=Z860ug0YhJntC3gFH1xYgw/qlx4pnR1fmbUhiTiqa2XaV1BPbTv2xm/0wTRm5QLkxn JUKOASQMHusqBgY1OhX21FvvakWXC2iQNyoCRarxu3t4AQTXd2fHjsh5Gc58tHCl6Dmo ZVSb1LzIk28aexGr+YYBdS3yUAcLZPqoAAGfEtZ6GZx5O0Ql0XuLiYxZT6Mb06k048Ud elNN5h+vXf1tufgGPbXuSh1Og2ax4jZNoVY89SkCltgbMVRmEHM9yhhUdupHjI0ZxVhh 2V5c41i5/E+h5o5Z0Q9cdYTZp/KOm6MKvpaeyoe7cuAvTv7XU9XNiatIygZhZ0QWbVKh 0XQw== Received: by 10.216.93.147 with SMTP id l19mr4936904wef.173.1355131059233; Mon, 10 Dec 2012 01:17:39 -0800 (PST) Received: from localhost (5ED48CEF.cm-7-5c.dynamic.ziggo.nl. [94.212.140.239]) by mx.google.com with ESMTPS id y3sm9233877wix.6.2012.12.10.01.17.33 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 10 Dec 2012 01:17:34 -0800 (PST) Received: by localhost (sSMTP sendmail emulation); Mon, 10 Dec 2012 10:17:32 +0100 From: Maarten Lankhorst To: dri-devel@lists.freedesktop.org, thellstrom@vmware.com Subject: [PATCH 6/7] drm/nouveau: use ttm_bo_reserve_slowpath in validate_init, v2 Date: Mon, 10 Dec 2012 10:17:00 +0100 Message-Id: <1355131021-11611-6-git-send-email-maarten.lankhorst@canonical.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1355131021-11611-1-git-send-email-maarten.lankhorst@canonical.com> References: <1355131021-11611-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. Changes since v1: - Increase the seqno before calling ttm_bo_reserve_slowpath Signed-off-by: Maarten Lankhorst --- drivers/gpu/drm/nouveau/nouveau_gem.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index f2bd59e..afcba1a 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -321,9 +321,10 @@ 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; -retry: sequence = atomic_add_return(1, &drm->ttm.validate_sequence); +retry: if (++trycnt > 100000) { NV_ERROR(drm, "%s failed and gave up.\n", __func__); return -EINVAL; @@ -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,19 @@ 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)) { + sequence = atomic_add_return(1, &drm->ttm.validate_sequence); + 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 +393,8 @@ retry: validate_fini(op, NULL); return -EINVAL; } + if (nvbo == res_bo) + goto retry; } return 0;