From patchwork Fri Dec 16 19:25:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9478435 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 79464601C2 for ; Fri, 16 Dec 2016 19:31:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BEC028772 for ; Fri, 16 Dec 2016 19:31:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FBB9287DB; Fri, 16 Dec 2016 19:31:42 +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=unavailable 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 E652D28772 for ; Fri, 16 Dec 2016 19:31:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9EA8D6E137; Fri, 16 Dec 2016 19:31:40 +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 32A136ECDC; Fri, 16 Dec 2016 19:26:19 +0000 (UTC) Received: by mail-wj0-x244.google.com with SMTP id j10so15653037wjb.3; Fri, 16 Dec 2016 11:26:19 -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=dVrdUAvZ29aO85Yu1iQ/kthHakNF5+6WHlF4b7RVm6f1RzJMJDQ2b2XbyEyYmMg7or 0KonWmx8L8Irve+av5/twkdHvkJ29w/jENL+WnQwxhz6h+ETneZDyNgy7xdwv3Gqget9 m5erkeSvv47AJZuW/h+Q7yiOVvtmmKROKxf/uyo9BOjE/x4we0Yr13demUfwaItoPot8 ggzub0/90kNgR5G8qKUdqKEF4j9jliTCoB9c6gv0dodAuRLQ4KRhAFgvXqqMWpOp5tr8 sJfcdBsBCZ7kUFZS+tT9aoQiXwWIfppGTyk1++sSZQctFcE88+7xNNaxL+Nj0Dpn8gSU 2NyA== 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=D1IFd+1nNYETr9pe5cIGHzcPxxDOOXAVnRnBMCe0RswWa9aGul7HEwZOGU6vYkHv8Y 8Uk4KR396XTvtKp1n8s8E3i3tRJCr6rZ5ST7ZJeBCm5Iw8k7YNN2muBTPlmCDmQ3C2Sj /QsrVy0A3Hggf+tJHTOcM9A0zxngKpE55+rxWkLrjhm+7ilGBnGDswNAy8QT3L31Tp9o 4XPViXRb9X1tzrI7oOY6q1IGOuuDNeF0JRYWoeQxxWXnPyO+spmjv4FTZ8WQh7LpuHfH WzYMbXSZCKOlOlt6iPMpC+pCAdieACZwk8E7dRjWbKuhx+Ou5y1fjxsc2w0yI3Fi4/2Y Vk0Q== X-Gm-Message-State: AKaTC03QZNLwYhbNBh0F7u8hGMciuVsEJut+KxiAbQCM+yPS3Gy3/H+nNh7LRMNtvZaazA== X-Received: by 10.194.90.135 with SMTP id bw7mr3997216wjb.34.1481916377241; Fri, 16 Dec 2016 11:26:17 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id v2sm8125856wja.41.2016.12.16.11.26.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Dec 2016 11:26:16 -0800 (PST) From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 24/38] drm: Simplify drm_mm_clean() Date: Fri, 16 Dec 2016 19:25:36 +0000 Message-Id: <20161216192550.8352-25-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161216192550.8352-1-chris@chris-wilson.co.uk> References: <20161216192550.8352-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);