From patchwork Mon Nov 12 14:00:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 1728381 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 24365DFE80 for ; Mon, 12 Nov 2012 14:06:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 154D49F0D9 for ; Mon, 12 Nov 2012 06:06:41 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-we0-f177.google.com (mail-we0-f177.google.com [74.125.82.177]) by gabe.freedesktop.org (Postfix) with ESMTP id D5C389F070 for ; Mon, 12 Nov 2012 06:00:53 -0800 (PST) Received: by mail-we0-f177.google.com with SMTP id u50so2715708wey.36 for ; Mon, 12 Nov 2012 06:00:53 -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=dsWR0o63EqeaxQS7cTgECP8iRexCvzRgwXj1PtOT6ss=; b=Nv9xAYq778q28vCfA/wWzHSQzwXaFSLbHtMhbyWIg99bcYL+jF8783C+TQYoGj4v3t pkKRgK/+3nQtPhN7vkOujJ8YMWAkqUKUKTWlVaz8LlDri9JPraqV04phafQT9tddcMED ZKl2yWxTCGDAffC6RvXPLM3riaOyrAcJbVyuVmFQIWxsn6DlMlHxrr6ED2BDA8d3udNW sk4kPF4CZieC1F/iVu3talWZrweKJ8W0P0Ro7b6D8FG4e7TBEFAEZwmafX0VvOWF5n8p chbfsq2eg8jGy3kY/B3NsdTgMT1MYKn44S+SkwEzQTFE2sNPbLtkJkmQgw2PztrVur+3 a9MA== Received: by 10.180.7.194 with SMTP id l2mr15164532wia.0.1352728853524; Mon, 12 Nov 2012 06:00:53 -0800 (PST) Received: from localhost (5ED48CEF.cm-7-5c.dynamic.ziggo.nl. [94.212.140.239]) by mx.google.com with ESMTPS id ey2sm11794877wib.9.2012.11.12.06.00.50 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 12 Nov 2012 06:00:52 -0800 (PST) Received: by localhost (sSMTP sendmail emulation); Mon, 12 Nov 2012 15:00:50 +0100 From: Maarten Lankhorst To: dri-devel@lists.freedesktop.org Subject: [PATCH 07/10] drm/ttm: cope with reserved buffers on swap list in ttm_bo_swapout Date: Mon, 12 Nov 2012 15:00:08 +0100 Message-Id: <1352728811-21860-7-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 Signed-off-by: Maarten Lankhorst --- drivers/gpu/drm/ttm/ttm_bo.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 1d77ad1..b9c26a5 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1761,16 +1761,7 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink) uint32_t swap_placement = (TTM_PL_FLAG_CACHED | TTM_PL_FLAG_SYSTEM); spin_lock(&glob->lru_lock); - while (ret == -EBUSY) { - if (unlikely(list_empty(&glob->swap_lru))) { - spin_unlock(&glob->lru_lock); - return -EBUSY; - } - - bo = list_first_entry(&glob->swap_lru, - struct ttm_buffer_object, swap); - kref_get(&bo->list_kref); - + list_for_each_entry(bo, &glob->swap_lru, swap) { /** * Reserve buffer. Since we unlock while sleeping, we need * to re-check that nobody removed us from the swap-list while @@ -1778,21 +1769,23 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink) */ ret = ttm_bo_reserve_locked(bo, false, true, false, 0); - if (unlikely(ret == -EBUSY)) { - spin_unlock(&glob->lru_lock); - ttm_bo_wait_unreserved(bo, false); - kref_put(&bo->list_kref, ttm_bo_release_list); - spin_lock(&glob->lru_lock); - } + if (!ret) + break; } + if (ret) { + spin_unlock(&glob->lru_lock); + return ret; + } + + kref_get(&bo->list_kref); + if (!list_empty(&bo->ddestroy)) { ret = ttm_bo_cleanup_refs_and_unlock(bo, false, false); kref_put(&bo->list_kref, ttm_bo_release_list); return ret; } - BUG_ON(ret != 0); put_count = ttm_bo_del_from_lru(bo); spin_unlock(&glob->lru_lock);