From patchwork Mon Nov 12 14:00:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 1728391 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 93BBCDFE80 for ; Mon, 12 Nov 2012 14:07:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8608A9F0D9 for ; Mon, 12 Nov 2012 06:07:32 -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 8ECEB9F064 for ; Mon, 12 Nov 2012 06:01:02 -0800 (PST) Received: by mail-we0-f177.google.com with SMTP id u50so2715708wey.36 for ; Mon, 12 Nov 2012 06:01:02 -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=TkaxWvG9r0ThpQtcUG8P2YsUVSiIWS/BzcVJdn4Xsbg=; b=0nMCNczknTBVMy8wR3r5q7PzhFhsmPPtHed0ye2jWYNc/iMw8aijcfXJd7D8rac/dM Nzghn3CVGyrfV3qOgl3j9C+w7OkLrEhcag8L96Ckzpngg+2xJ7bnRe4PJosih8GlZ968 LW9A/+FOmCXXir14GsoVRszmcZ2z2t0/phjr5y3hpWaN5n3aC2SbP5smAtj39zciEHFa RZ7wETOY8jOnLdQceIqBa9bNLY98foM8ZlXIlhu4Tq0r/uy/NVmixfg9H1jVxsma47xl FG90oAm47vIxdW6iiXuiS0mwsMAz3CVhKmrSx/g2amq94ry1qS/DOO6Os1WwLp1Z8N+Z ogWw== Received: by 10.180.79.37 with SMTP id g5mr15103162wix.7.1352728862247; Mon, 12 Nov 2012 06:01:02 -0800 (PST) Received: from localhost (5ED48CEF.cm-7-5c.dynamic.ziggo.nl. [94.212.140.239]) by mx.google.com with ESMTPS id gk9sm14667396wib.4.2012.11.12.06.00.54 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 12 Nov 2012 06:01:01 -0800 (PST) Received: by localhost (sSMTP sendmail emulation); Mon, 12 Nov 2012 15:00:53 +0100 From: Maarten Lankhorst To: dri-devel@lists.freedesktop.org Subject: [PATCH 08/10] drm/ttm: cope with reserved buffers on lru list in ttm_mem_evict_first Date: Mon, 12 Nov 2012 15:00:09 +0100 Message-Id: <1352728811-21860-8-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 | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index b9c26a5..a760178 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -779,26 +779,21 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev, struct ttm_bo_global *glob = bdev->glob; struct ttm_mem_type_manager *man = &bdev->man[mem_type]; struct ttm_buffer_object *bo; - int ret, put_count = 0; + int ret = -EBUSY, put_count = 0; spin_lock(&glob->lru_lock); - if (list_empty(&man->lru)) { - spin_unlock(&glob->lru_lock); - return -EBUSY; + list_for_each_entry(bo, &man->lru, lru) { + ret = ttm_bo_reserve_locked(bo, false, true, false, 0); + if (!ret) + break; } - bo = list_first_entry(&man->lru, struct ttm_buffer_object, lru); - kref_get(&bo->list_kref); - - ret = ttm_bo_reserve_locked(bo, false, true, false, 0); - - if (WARN_ON_ONCE(ret == -EBUSY)) { + if (ret) { spin_unlock(&glob->lru_lock); - - kref_put(&bo->list_kref, ttm_bo_release_list); return ret; } + kref_get(&bo->list_kref); if (!list_empty(&bo->ddestroy)) { ret = ttm_bo_cleanup_refs_and_unlock(bo, interruptible, no_wait_gpu);