From patchwork Thu Dec 22 08:36:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9484495 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 39A8F601D3 for ; Thu, 22 Dec 2016 08:41:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35BFA281C3 for ; Thu, 22 Dec 2016 08:41:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2AC8128285; Thu, 22 Dec 2016 08:41:47 +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 BC5D6277D9 for ; Thu, 22 Dec 2016 08:41:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 677036F1A3; Thu, 22 Dec 2016 08:41:26 +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 2C2036F16E; Thu, 22 Dec 2016 08:36:50 +0000 (UTC) Received: by mail-wj0-x244.google.com with SMTP id j10so35199979wjb.3; Thu, 22 Dec 2016 00:36:50 -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=Ni5Jd1DMccSXtROxzgjgXvmQtndolRiK8scm1cvOxF4=; b=SVC5ImKlyIr7RKyD+fUjF3LdXdPOyTyZIx9nkDraDEh2bc9FC2U/6dj2N03nRC1CBy 3ItyDypbA4YS/h+7UXBmpYdZj1Z/PXMFm2yt4+BwbU3PXIapzRVYDytGiUUGKzkQg3kX W4C/T+GotyWky02VuIgAOYGC3jKc12bw7lxcofc1TtQZXzbAELiSPco2//fb8MrzM5n+ qcw6mwKhCiAB2C1YsmDCvhxLIRkvOic1n98H1qF41uLc2J5RZLcLHF4r7yUJp4ZkJEAe qA0YgaQqSrEufwRqq/V8ItS4Fglae7Ql3adnZVR/TTpsMsIWLmLggugH8fZH24jMa2OW oVUA== 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=Ni5Jd1DMccSXtROxzgjgXvmQtndolRiK8scm1cvOxF4=; b=ctXnd/ok+FT2qPvEJY6h1dnfGaWoThMi8dAYOPsI/Ph2dl4gRiI4pHzjXzvzQquKCN lI+HdMPq6f3hc8AFi4Z+SW4LIJBqZhuKCLZzhf3K/j6/cYBilW+/LWyxKNzkpOCNw5qv Aipoger1OTZTmHzisSDidCDP2ZkLKPkmpJgTHfeQx7hu4tdRUJ8CX3ZJKpKvKbMkPYIV pU6j2HVKq1ZqrNlMQg8+s3aZSGHVPz5wdPh9Qf4uWfKGTIXn7mrgE85BEP2hwP/wrJZY kSGZ5JG52cF3sZVcYnETo1TgUAc/83a944/sGdFLCqVXT0qzZU7VDb76itdlss5HYdyO S2qg== X-Gm-Message-State: AIkVDXIwm4CP/GhG91WzzeyUiMQd/rrBuueGVygrSj6dvJKDw8nzfKxXfmwkBrYwoxAHxA== X-Received: by 10.194.55.104 with SMTP id r8mr7820198wjp.137.1482395808092; Thu, 22 Dec 2016 00:36:48 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id di9sm34442318wjc.37.2016.12.22.00.36.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Dec 2016 00:36:47 -0800 (PST) From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 02/38] drm: Use drm_mm_nodes() as shorthand for the list of nodes under struct drm_mm Date: Thu, 22 Dec 2016 08:36:05 +0000 Message-Id: <20161222083641.2691-3-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: Daniel Vetter , 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 Fairly commonly we want to inspect the node list on the struct drm_mm, which is buried within an embedded node. Bring it to the surface with a bit of syntatic sugar. Note this was intended to be split from commit ad579002c8ec ("drm: Add drm_mm_for_each_node_safe()") before being applied, but my timing sucks. Signed-off-by: Chris Wilson Reviewed-by: Joonas Lahtinen Cc: Daniel Vetter --- drivers/gpu/drm/drm_mm.c | 8 ++++---- include/drm/drm_mm.h | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c index 7573661302a4..4257c86cc305 100644 --- a/drivers/gpu/drm/drm_mm.c +++ b/drivers/gpu/drm/drm_mm.c @@ -138,7 +138,7 @@ static void show_leaks(struct drm_mm *mm) if (!buf) return; - list_for_each_entry(node, __drm_mm_nodes(mm), node_list) { + list_for_each_entry(node, drm_mm_nodes(mm), node_list) { struct stack_trace trace = { .entries = entries, .max_entries = STACKDEPTH @@ -320,7 +320,7 @@ int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node) if (hole->start < end) return -ENOSPC; } else { - hole = list_entry(__drm_mm_nodes(mm), typeof(*hole), node_list); + hole = list_entry(drm_mm_nodes(mm), typeof(*hole), node_list); } hole = list_last_entry(&hole->node_list, typeof(*hole), node_list); @@ -883,7 +883,7 @@ EXPORT_SYMBOL(drm_mm_scan_remove_block); */ bool drm_mm_clean(const struct drm_mm *mm) { - const struct list_head *head = __drm_mm_nodes(mm); + const struct list_head *head = drm_mm_nodes(mm); return (head->next->next == head); } @@ -929,7 +929,7 @@ EXPORT_SYMBOL(drm_mm_init); */ void drm_mm_takedown(struct drm_mm *mm) { - if (WARN(!list_empty(__drm_mm_nodes(mm)), + if (WARN(!list_empty(drm_mm_nodes(mm)), "Memory manager not clean during takedown.\n")) show_leaks(mm); diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h index 5c7f15875b6a..f6a68ed5ecaf 100644 --- a/include/drm/drm_mm.h +++ b/include/drm/drm_mm.h @@ -180,7 +180,19 @@ static inline u64 drm_mm_hole_node_end(const struct drm_mm_node *hole_node) return __drm_mm_hole_node_end(hole_node); } -#define __drm_mm_nodes(mm) (&(mm)->head_node.node_list) +/** + * drm_mm_nodes - list of nodes under the drm_mm range manager + * @mm: the struct drm_mm range manger + * + * As the drm_mm range manager hides its node_list deep with its + * structure, extracting it looks painful and repetitive. This is + * not expected to be used outside of the drm_mm_for_each_node() + * macros and similar internal functions. + * + * Returns: + * The node list, may be empty. + */ +#define drm_mm_nodes(mm) (&(mm)->head_node.node_list) /** * drm_mm_for_each_node - iterator to walk over all allocated nodes @@ -191,7 +203,7 @@ static inline u64 drm_mm_hole_node_end(const struct drm_mm_node *hole_node) * with list_for_each, so not save against removal of elements. */ #define drm_mm_for_each_node(entry, mm) \ - list_for_each_entry(entry, __drm_mm_nodes(mm), node_list) + list_for_each_entry(entry, drm_mm_nodes(mm), node_list) /** * drm_mm_for_each_node_safe - iterator to walk over all allocated nodes @@ -203,7 +215,7 @@ static inline u64 drm_mm_hole_node_end(const struct drm_mm_node *hole_node) * with list_for_each_safe, so save against removal of elements. */ #define drm_mm_for_each_node_safe(entry, next, mm) \ - list_for_each_entry_safe(entry, next, __drm_mm_nodes(mm), node_list) + list_for_each_entry_safe(entry, next, drm_mm_nodes(mm), node_list) #define __drm_mm_for_each_hole(entry, mm, hole_start, hole_end, backwards) \ for (entry = list_entry((backwards) ? (mm)->hole_stack.prev : (mm)->hole_stack.next, struct drm_mm_node, hole_stack); \