From patchwork Thu Dec 22 08:36:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9484471 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CA109601D2 for ; Thu, 22 Dec 2016 08:39:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6C2C277D9 for ; Thu, 22 Dec 2016 08:39:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA22B281C3; Thu, 22 Dec 2016 08:39:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 751A1277D9 for ; Thu, 22 Dec 2016 08:39:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DA2AF6F194; Thu, 22 Dec 2016 08:39:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wj0-x244.google.com (mail-wj0-x244.google.com [IPv6:2a00:1450:400c:c01::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2B8C26F16E; Thu, 22 Dec 2016 08:37:12 +0000 (UTC) Received: by mail-wj0-x244.google.com with SMTP id ez4so670552wjd.1; Thu, 22 Dec 2016 00:37:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=US4OhtVxElwTXXnukPXR/T4DhgjuK1i4kouI5hjyOok=; b=ZntuHZZMYw6Gm/moHjYGqJbylGJ1oOuGjhGML3S0/CgRYQPCobqDgi7KmM16NNO00d bPEwUBJkMgB/I5FW51AuqSDYLDV10YfUVCWpc1MBtgFo4mhtskL5iBwG4wO3N33LjNQO OV1AFj9lI9cwkcFZiG0RtXzlPLTw+2TNc1+DfNU5KsKaUch62UmGjHFYMiP5x6t9hBuc l3w75UMFyas2Pta+nRkkAXvRp62dJjYb2yPIgN7knmCMU9iUuY5em3ZMSLInQnR3/NQ6 V9sfdi6xkn1zt7+QCWlwCBNgjXtmQP515Gobb8u+lwckzo6fpHnQW/2kHTFtN3YKPsmw S8hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=US4OhtVxElwTXXnukPXR/T4DhgjuK1i4kouI5hjyOok=; b=BRHcbOxm3lRfzL3bRJ6RAgprIhIcM4yax+9m5CeWFWiUYuULfD/j/3fzJANU231/p7 VTSxSCsQGbxEVse0QJ2czfWV6cXz1IHOFAGvhNMFYRx57q3o/ydj6bfcTDcgTbVytzA4 G3jp5rEqQn1A0zqJDvL1Utqf2uwzmzWAPCFMOH9+yqQzJ4jyaea/39mBIt7EpzUHmEGd MOniHakM6yWGhYiMrwo/mQ/qq5LuYxw0Z8Bow3LL3eF9HuvZkSKy+Fo88by2vETu9jjk KLf4V7BYv35kQvQKsXP88MZvMNW93KCdhG1QN6m9XKtiH90zpPbskLEHg5yGC+bWjMb2 ysOA== X-Gm-Message-State: AIkVDXI+ia4tnhzH51x7YYbJs+1mIlpLAOeNpnj0F4ykSCSoq94PodE7pnxcBza4f8g/fQ== X-Received: by 10.194.222.202 with SMTP id qo10mr7986714wjc.115.1482395830382; Thu, 22 Dec 2016 00:37:10 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id di9sm34442318wjc.37.2016.12.22.00.37.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Dec 2016 00:37:09 -0800 (PST) From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 24/38] drm: Simplify drm_mm_clean() Date: Thu, 22 Dec 2016 08:36:27 +0000 Message-Id: <20161222083641.2691-25-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161222083641.2691-1-chris@chris-wilson.co.uk> References: <20161222083641.2691-1-chris@chris-wilson.co.uk> Cc: intel-gfx@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Since commit ea7b1dd44867 ("drm: mm: track free areas implicitly"), to test whether there are any nodes allocated within the range manager, we merely have to ask whether the node_list is empty. Signed-off-by: Chris Wilson Reviewed-by: Joonas Lahtinen --- drivers/gpu/drm/drm_mm.c | 19 +------------------ include/drm/drm_mm.h | 14 +++++++++++++- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c index 370cb8ee91c9..e0419cf09bbb 100644 --- a/drivers/gpu/drm/drm_mm.c +++ b/drivers/gpu/drm/drm_mm.c @@ -873,22 +873,6 @@ bool drm_mm_scan_remove_block(struct drm_mm_node *node) EXPORT_SYMBOL(drm_mm_scan_remove_block); /** - * drm_mm_clean - checks whether an allocator is clean - * @mm: drm_mm allocator to check - * - * Returns: - * True if the allocator is completely free, false if there's still a node - * allocated in it. - */ -bool drm_mm_clean(const struct drm_mm *mm) -{ - const struct list_head *head = drm_mm_nodes(mm); - - return (head->next->next == head); -} -EXPORT_SYMBOL(drm_mm_clean); - -/** * drm_mm_init - initialize a drm-mm allocator * @mm: the drm_mm structure to initialize * @start: start of the range managed by @mm @@ -928,10 +912,9 @@ EXPORT_SYMBOL(drm_mm_init); */ void drm_mm_takedown(struct drm_mm *mm) { - if (WARN(!list_empty(drm_mm_nodes(mm)), + if (WARN(!drm_mm_clean(mm), "Memory manager not clean during takedown.\n")) show_leaks(mm); - } EXPORT_SYMBOL(drm_mm_takedown); diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h index 7eeb98b5bf70..72e0c0ddf8d0 100644 --- a/include/drm/drm_mm.h +++ b/include/drm/drm_mm.h @@ -342,7 +342,19 @@ void drm_mm_remove_node(struct drm_mm_node *node); void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new); void drm_mm_init(struct drm_mm *mm, u64 start, u64 size); void drm_mm_takedown(struct drm_mm *mm); -bool drm_mm_clean(const struct drm_mm *mm); + +/** + * drm_mm_clean - checks whether an allocator is clean + * @mm: drm_mm allocator to check + * + * Returns: + * True if the allocator is completely free, false if there's still a node + * allocated in it. + */ +static inline bool drm_mm_clean(const struct drm_mm *mm) +{ + return list_empty(drm_mm_nodes(mm)); +} struct drm_mm_node * __drm_mm_interval_first(const struct drm_mm *mm, u64 start, u64 last);