From patchwork Mon Nov 12 14:00:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 1728341 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 1807E3FCDE for ; Mon, 12 Nov 2012 14:02:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0AF789F0E2 for ; Mon, 12 Nov 2012 06:02:41 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com [209.85.212.169]) by gabe.freedesktop.org (Postfix) with ESMTP id BF9CD9F01D for ; Mon, 12 Nov 2012 06:00:31 -0800 (PST) Received: by mail-wi0-f169.google.com with SMTP id x18so461617wia.0 for ; Mon, 12 Nov 2012 06:00:30 -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=pHf+gOCTjIIb5EXH0vGK6NZolAw7tUbWzuujyCXkXVM=; b=UCnuSjGz09gsJdwYYAQ6YCsU9JoRlxRMPMYBATdfK0XVOimY7KUOR3LThihZ4a89U7 Y4i2iFAW89ZMIAy+yQ+huv/FGawqqZxaFvzzuuidxPddB0/Ud4R5/acwoNdBty25bJ4H jXewAGb6792Pz2Q3Ug+JBMQr1ufvbII05rnrkGWjYXihGbgA1jOU98zUFk2bvVWyMWcq e6DmdsZJU4ZvVPENz7L8I0j9puouWt8ri78d5gb8KjbExR7SPQpa0P7vOwrYu71Zu6lv j/UQMvhMvk2t4qI1ftV85Wd9Y7wu85uyl2JEZugrcruJm5HQl3/O5Vyi5F5n8xWSHAde Rd5w== Received: by 10.180.24.193 with SMTP id w1mr15084646wif.22.1352728830791; Mon, 12 Nov 2012 06:00:30 -0800 (PST) Received: from localhost (5ED48CEF.cm-7-5c.dynamic.ziggo.nl. [94.212.140.239]) by mx.google.com with ESMTPS id hf10sm15062225wib.0.2012.11.12.06.00.24 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 12 Nov 2012 06:00:29 -0800 (PST) Received: by localhost (sSMTP sendmail emulation); Mon, 12 Nov 2012 15:00:23 +0100 From: Maarten Lankhorst To: dri-devel@lists.freedesktop.org Subject: [PATCH 03/10] drm/ttm: do not check if list is empty in ttm_bo_force_list_clean Date: Mon, 12 Nov 2012 15:00:04 +0100 Message-Id: <1352728811-21860-3-git-send-email-maarten.lankhorst@canonical.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1352728811-21860-1-git-send-email-maarten.lankhorst@canonical.com> References: <1352728811-21860-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 Just use the return error from ttm_mem_evict_first instead. Signed-off-by: Maarten Lankhorst --- drivers/gpu/drm/ttm/ttm_bo.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 74d6e7c..a3383a7 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1302,29 +1302,18 @@ EXPORT_SYMBOL(ttm_bo_create); static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, unsigned mem_type, bool allow_errors) { - struct ttm_mem_type_manager *man = &bdev->man[mem_type]; - struct ttm_bo_global *glob = bdev->glob; - int ret; - - /* - * Can't use standard list traversal since we're unlocking. - */ + int ret = 0; - spin_lock(&glob->lru_lock); - while (!list_empty(&man->lru)) { - spin_unlock(&glob->lru_lock); + while (!ret) { ret = ttm_mem_evict_first(bdev, mem_type, false, false, false); - if (ret) { - if (allow_errors) { - return ret; - } else { - pr_err("Cleanup eviction failed\n"); - } + if (ret == -EBUSY) + return 0; + else if (ret && !allow_errors) { + pr_err("Cleanup eviction failed\n"); + ret = 0; } - spin_lock(&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)