From patchwork Mon Aug 20 14:36:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 1349371 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 9A9123FC33 for ; Mon, 20 Aug 2012 14:36:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7EF4E9EEEE for ; Mon, 20 Aug 2012 07:36:34 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from kiwano.canonical.com (kiwano.canonical.com [91.189.89.52]) by gabe.freedesktop.org (Postfix) with ESMTP id 51C0E9E7E8 for ; Mon, 20 Aug 2012 07:36:23 -0700 (PDT) Received: from lillypilly.canonical.com ([91.189.89.62]) by kiwano.canonical.com with esmtp (Exim 4.76 #1 (Debian)) id 1T3T5a-0007EU-IQ for ; Mon, 20 Aug 2012 14:36:22 +0000 Received: by lillypilly.canonical.com (Postfix, from userid 3489) id C8C7626C2804; Mon, 20 Aug 2012 14:36:21 +0000 (UTC) Subject: [PATCH] drm/ttm: cleanup ttm_execbuf_util.c slightly more To: dri-devel@lists.freedesktop.org From: Maarten Lankhorst Date: Mon, 20 Aug 2012 16:36:12 +0200 Message-ID: <20120820143612.21905.68138.stgit@patser.local> User-Agent: StGit/0.15 MIME-Version: 1.0 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 The removed member is unneeded, an extra pass is done after all buffers have been reserved. The behavior stays the same even without the removed member, but this makes the code slightly more readable. Depends on previous 2 execbuf-util patches. Signed-off-by: Maarten Lankhorst --- drivers/gpu/drm/ttm/ttm_execbuf_util.c | 69 +++++++++++--------------------- 1 file changed, 24 insertions(+), 45 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_execbuf_util.c b/drivers/gpu/drm/ttm/ttm_execbuf_util.c index 4e7b596..a545bc9 100644 --- a/drivers/gpu/drm/ttm/ttm_execbuf_util.c +++ b/drivers/gpu/drm/ttm/ttm_execbuf_util.c @@ -32,7 +32,7 @@ #include #include -static void ttm_eu_backoff_reservation_locked(struct list_head *list) +static void ttm_eu_backoff_reservation_locked(struct list_head *list, bool removed) { struct ttm_validate_buffer *entry; @@ -41,43 +41,13 @@ static void ttm_eu_backoff_reservation_locked(struct list_head *list) if (!entry->reserved) continue; - if (entry->removed) { - ttm_bo_add_to_lru(bo); - entry->removed = false; - - } entry->reserved = false; - atomic_set(&bo->reserved, 0); - wake_up_all(&bo->event_queue); - } -} - -static void ttm_eu_del_from_lru_locked(struct list_head *list) -{ - struct ttm_validate_buffer *entry; - - list_for_each_entry(entry, list, head) { - struct ttm_buffer_object *bo = entry->bo; - if (!entry->reserved) - continue; - if (!entry->removed) { - entry->put_count = ttm_bo_del_from_lru(bo); - entry->removed = true; - } - } -} - -static void ttm_eu_list_ref_sub(struct list_head *list) -{ - struct ttm_validate_buffer *entry; - - list_for_each_entry(entry, list, head) { - struct ttm_buffer_object *bo = entry->bo; - - if (entry->put_count) { - ttm_bo_list_ref_sub(bo, entry->put_count, true); - entry->put_count = 0; + if (removed) { + ttm_bo_unreserve_locked(bo); + } else { + atomic_set(&bo->reserved, 0); + wake_up_all(&bo->event_queue); } } } @@ -93,7 +63,7 @@ void ttm_eu_backoff_reservation(struct list_head *list) entry = list_first_entry(list, struct ttm_validate_buffer, head); glob = entry->bo->glob; spin_lock(&glob->lru_lock); - ttm_eu_backoff_reservation_locked(list); + ttm_eu_backoff_reservation_locked(list, true); spin_unlock(&glob->lru_lock); } EXPORT_SYMBOL(ttm_eu_backoff_reservation); @@ -122,8 +92,6 @@ int ttm_eu_reserve_buffers(struct list_head *list) list_for_each_entry(entry, list, head) { entry->reserved = false; - entry->put_count = 0; - entry->removed = false; } entry = list_first_entry(list, struct ttm_validate_buffer, head); @@ -141,26 +109,37 @@ retry: case 0: break; case -EAGAIN: - ttm_eu_backoff_reservation_locked(list); + ttm_eu_backoff_reservation_locked(list, false); spin_unlock(&glob->lru_lock); - ttm_eu_list_ref_sub(list); ret = ttm_bo_wait_unreserved(bo, true); if (unlikely(ret != 0)) return ret; goto retry; default: - ttm_eu_backoff_reservation_locked(list); + ttm_eu_backoff_reservation_locked(list, false); spin_unlock(&glob->lru_lock); - ttm_eu_list_ref_sub(list); return ret; } entry->reserved = true; } - ttm_eu_del_from_lru_locked(list); + list_for_each_entry(entry, list, head) { + struct ttm_buffer_object *bo = entry->bo; + + entry->put_count = ttm_bo_del_from_lru(bo); + } + spin_unlock(&glob->lru_lock); - ttm_eu_list_ref_sub(list); + + list_for_each_entry(entry, list, head) { + struct ttm_buffer_object *bo = entry->bo; + + if (entry->put_count) { + ttm_bo_list_ref_sub(bo, entry->put_count, true); + entry->put_count = 0; + } + } return 0; } diff --git a/include/drm/ttm/ttm_execbuf_util.h b/include/drm/ttm/ttm_execbuf_util.h index 26cc7f9..0ef7c95 100644 --- a/include/drm/ttm/ttm_execbuf_util.h +++ b/include/drm/ttm/ttm_execbuf_util.h @@ -42,7 +42,6 @@ * @new_sync_obj_arg: New sync_obj_arg for @bo, to be used once * adding a new sync object. * @reserved: Indicates whether @bo has been reserved for validation. - * @removed: Indicates whether @bo has been removed from lru lists. * @put_count: Number of outstanding references on bo::list_kref. * @old_sync_obj: Pointer to a sync object about to be unreferenced */ @@ -52,7 +51,6 @@ struct ttm_validate_buffer { struct ttm_buffer_object *bo; void *new_sync_obj_arg; bool reserved; - bool removed; int put_count; void *old_sync_obj; };