From patchwork Fri Nov 30 08:05:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 1823881 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id C8CA83FC23 for ; Fri, 30 Nov 2012 08:22:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8828BE60CF for ; Fri, 30 Nov 2012 00:22:24 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by gabe.freedesktop.org (Postfix) with ESMTP id 0F964E66F3 for ; Fri, 30 Nov 2012 00:05:24 -0800 (PST) Received: from 5ed48cef.cm-7-5c.dynamic.ziggo.nl ([94.212.140.239] helo=[192.168.1.128]) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1TeLb8-00014n-FQ; Fri, 30 Nov 2012 08:05:22 +0000 Message-ID: <50B868C1.8000703@canonical.com> Date: Fri, 30 Nov 2012 09:05:21 +0100 From: Maarten Lankhorst User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Thomas Hellstrom Subject: [PATCH] drm/ttm: do not check if list is empty in ttm_bo_force_list_clean, v2 Cc: dri-devel@lists.freedesktop.org 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: , 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 Just use the return error from ttm_mem_evict_first instead. Changes since v1: - Add warning if list is not empty, nothing else we can do here. Signed-off-by: Maarten Lankhorst Reviewed-by: Thomas Hellstrom --- drivers/gpu/drm/ttm/ttm_bo.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 8ab23ae..9028327 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1323,25 +1323,25 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, struct ttm_bo_global *glob = bdev->glob; int ret; - /* - * Can't use standard list traversal since we're unlocking. - */ - - spin_lock(&glob->lru_lock); - while (!list_empty(&man->lru)) { - spin_unlock(&glob->lru_lock); + do { ret = ttm_mem_evict_first(bdev, mem_type, false, false); - if (ret) { - if (allow_errors) { - return ret; - } else { - pr_err("Cleanup eviction failed\n"); - } + if (ret && ret != -EBUSY && !allow_errors) { + pr_err("Cleanup eviction failed with %i\n", ret); + ret = 0; } + } while (!ret); + + if (likely(ret == -EBUSY)) { + /* + * lru list should be empty, verify this is the case. + */ spin_lock(&glob->lru_lock); + WARN_ON(!list_empty(&man->lru)); + if (list_empty(&man->lru) || !allow_errors) + ret = 0; + spin_unlock(&glob->lru_lock); } - spin_unlock(&glob->lru_lock); - return 0; + return ret; } int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)