From patchwork Mon Nov 12 14:00:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 1728331 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 5CD813FCDE for ; Mon, 12 Nov 2012 14:01:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 499BA9F070 for ; Mon, 12 Nov 2012 06:01:44 -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 402489EB32 for ; Mon, 12 Nov 2012 06:00:24 -0800 (PST) Received: by mail-we0-f177.google.com with SMTP id u50so2715708wey.36 for ; Mon, 12 Nov 2012 06:00:23 -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=z3MHxsRlrL5k9HdC61J0NjhvVTtcXxGLpj/NuJbGSBg=; b=RThr1K/uE1HxQ9CXVUczbtHfpKIbSekTemrjOPgiTWtKZhTRjN3ajVs6vJ6OTyFhq/ OvkfQwOEb7wysLIZta4KYVROeYiLZv2kp7D6BkO0liTXnKjF8cxr4mLkOOqz/rN9QCAk bP+Ou1K5gIQaWLfgSPNGZSktZjZGyZhaZNOeh+nfS8wij5tLOzEu0+7u9NaZgR89OTKU /TNj/30CrOPPQL0TYeVRn7mi0pqCuZuHj1z3+Dr0WSdW2aSyFaE28ErTi35TZOXZLX5P DpwpIZ5Mb+VkF0COyT1VDcd+1WO4EJ4L4/JqmAhPMIgH35voIQ5pkRtxVfLS8hEmQc0v S7vA== Received: by 10.216.198.198 with SMTP id v48mr6689384wen.192.1352728823864; Mon, 12 Nov 2012 06:00:23 -0800 (PST) Received: from localhost (5ED48CEF.cm-7-5c.dynamic.ziggo.nl. [94.212.140.239]) by mx.google.com with ESMTPS id i6sm14663309wix.5.2012.11.12.06.00.21 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 12 Nov 2012 06:00:22 -0800 (PST) Received: by localhost (sSMTP sendmail emulation); Mon, 12 Nov 2012 15:00:20 +0100 From: Maarten Lankhorst To: dri-devel@lists.freedesktop.org Subject: [PATCH 02/10] drm/ttm: remove ttm_bo_cleanup_memtype_use Date: Mon, 12 Nov 2012 15:00:03 +0100 Message-Id: <1352728811-21860-2-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 move to release_list instead Signed-off-by: Maarten Lankhorst --- drivers/gpu/drm/ttm/ttm_bo.c | 47 +++++++++++++------------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 9c48e8f..74d6e7c 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -143,12 +143,20 @@ static void ttm_bo_release_list(struct kref *list_kref) BUG_ON(atomic_read(&bo->kref.refcount)); BUG_ON(atomic_read(&bo->cpu_writers)); BUG_ON(bo->sync_obj != NULL); - BUG_ON(bo->mem.mm_node != NULL); BUG_ON(!list_empty(&bo->lru)); BUG_ON(!list_empty(&bo->ddestroy)); - if (bo->ttm) + if (bo->bdev->driver->move_notify) + bo->bdev->driver->move_notify(bo, NULL); + + if (bo->ttm) { + ttm_tt_unbind(bo->ttm); ttm_tt_destroy(bo->ttm); + bo->ttm = NULL; + } + ttm_bo_mem_put(bo, &bo->mem); + BUG_ON(bo->mem.mm_node != NULL); + atomic_dec(&bo->glob->bo_count); if (bo->destroy) bo->destroy(bo); @@ -466,35 +474,6 @@ out_err: return ret; } -/** - * Call bo::reserved. - * Will release GPU memory type usage on destruction. - * This is the place to put in driver specific hooks to release - * driver private resources. - * Will release the bo::reserved lock. - */ - -static void ttm_bo_cleanup_memtype_use(struct ttm_buffer_object *bo) -{ - if (bo->bdev->driver->move_notify) - bo->bdev->driver->move_notify(bo, NULL); - - if (bo->ttm) { - ttm_tt_unbind(bo->ttm); - ttm_tt_destroy(bo->ttm); - bo->ttm = NULL; - } - ttm_bo_mem_put(bo, &bo->mem); - - atomic_set(&bo->reserved, 0); - - /* - * Make processes trying to reserve really pick it up. - */ - smp_mb__after_atomic_dec(); - wake_up_all(&bo->event_queue); -} - static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo) { struct ttm_bo_device *bdev = bo->bdev; @@ -523,8 +502,9 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo) spin_unlock(&bdev->fence_lock); put_count = ttm_bo_del_from_lru(bo); + atomic_set(&bo->reserved, 0); + wake_up_all(&bo->event_queue); spin_unlock(&glob->lru_lock); - ttm_bo_cleanup_memtype_use(bo); ttm_bo_list_ref_sub(bo, put_count, true); @@ -619,8 +599,9 @@ retry_reserve: list_del_init(&bo->ddestroy); ++put_count; + atomic_set(&bo->reserved, 0); + wake_up_all(&bo->event_queue); spin_unlock(&glob->lru_lock); - ttm_bo_cleanup_memtype_use(bo); ttm_bo_list_ref_sub(bo, put_count, true);