From patchwork Fri May 23 10:59:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter De Schrijver X-Patchwork-Id: 4231731 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0DB2DBF90B for ; Fri, 23 May 2014 11:11:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 19173201ED for ; Fri, 23 May 2014 11:11:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2ED4A201E7 for ; Fri, 23 May 2014 11:11:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WnnKO-0001rN-0I; Fri, 23 May 2014 11:07:56 +0000 Received: from hqemgate15.nvidia.com ([216.228.121.64]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WnnCo-00005b-Ff for linux-arm-kernel@lists.infradead.org; Fri, 23 May 2014 11:00:07 +0000 Received: from hqnvupgp08.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Fri, 23 May 2014 03:58:55 -0700 Received: from hqemhub01.nvidia.com ([172.20.12.94]) by hqnvupgp08.nvidia.com (PGP Universal service); Fri, 23 May 2014 03:54:46 -0700 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Fri, 23 May 2014 03:54:46 -0700 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by hqemhub01.nvidia.com (172.20.150.30) with Microsoft SMTP Server id 8.3.342.0; Fri, 23 May 2014 03:59:42 -0700 Received: from sc-daphne.nvidia.com (Not Verified[172.20.232.60]) by hqnvemgw02.nvidia.com with MailMarshal (v7,1,2,5326) id ; Fri, 23 May 2014 03:59:42 -0700 Received: from tbergstrom-lnx.nvidia.com (tbergstrom-lnx.nvidia.com [10.21.24.170]) by sc-daphne.nvidia.com (8.13.8+Sun/8.8.8) with ESMTP id s4NAxdiF002026; Fri, 23 May 2014 03:59:39 -0700 (PDT) From: Peter De Schrijver To: Peter De Schrijver Subject: [RFC PATCH] clk: flatten clk tree in debugfs Date: Fri, 23 May 2014 13:59:32 +0300 Message-ID: <1400842772-4862-1-git-send-email-pdeschrijver@nvidia.com> X-Mailer: git-send-email 1.7.7.rc0.72.g4b5ea.dirty X-NVConfidentiality: public MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140523_040006_607170_BF5D920F X-CRM114-Status: GOOD ( 18.26 ) X-Spam-Score: -0.7 (/) Cc: linux-tegra@vger.kernel.org, Mike Turquette , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch flattens the clk tree in CCF debugfs. Instead of representing the clocks and their hierarchy as a directory structure under /sys/kernel/debug/clk, each clock gets a single directory directly under /sys/kernel/debug/clk. While this may seem strange, here's way I think this is the right thing to do: 1) a directory structure cannot be 'snapshotted' atomically, therefore it's not in general possible to get a consistent view of the clocktree, because clocks can be reparented at any time. This was solved by adding clk_dump and clk_summary, which do guarantee an atomic snapshot of the tree. Therefore I think the directory structure doesn't add any value. 2) When writing userspace programs which use the files in the clock directories (eg. for testing purposes), it's impossible to know for sure where a certain clock will be, because it might have been reparented by the time you figured out the path from clk_dump. This makes writing such programs more difficult than it should be. So because the directory structure doesn't give any information we don't already provide by other means and it makes certain usecases more difficult than the should be, I think we should move to a flat directory containing one subdir per clock. Signed-off-by: Peter De Schrijver --- drivers/clk/clk.c | 54 +++------------------------------------------------- 1 files changed, 4 insertions(+), 50 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index dff0373..53c6b4f 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -306,7 +306,7 @@ static int clk_debug_create_subtree(struct clk *clk, struct dentry *pdentry) goto out; hlist_for_each_entry(child, &clk->children, child_node) - clk_debug_create_subtree(child, clk->dentry); + clk_debug_create_subtree(child, pdentry); ret = 0; out: @@ -326,29 +326,20 @@ out: */ static int clk_debug_register(struct clk *clk) { - struct clk *parent; struct dentry *pdentry; int ret = 0; if (!inited) goto out; - parent = clk->parent; - /* * Check to see if a clk is a root clk. Also check that it is * safe to add this clk to debugfs */ - if (!parent) - if (clk->flags & CLK_IS_ROOT) - pdentry = rootdir; - else - pdentry = orphandir; + if (clk->flags & CLK_IS_ROOT) + pdentry = rootdir; else - if (parent->dentry) - pdentry = parent->dentry; - else - goto out; + pdentry = orphandir; ret = clk_debug_create_subtree(clk, pdentry); @@ -372,39 +363,6 @@ static void clk_debug_unregister(struct clk *clk) } /** - * clk_debug_reparent - reparent clk node in the debugfs clk tree - * @clk: the clk being reparented - * @new_parent: the new clk parent, may be NULL - * - * Rename clk entry in the debugfs clk tree if debugfs has been - * initialized. Otherwise it bails out early since the debugfs clk tree - * will be created lazily by clk_debug_init as part of a late_initcall. - * - * Caller must hold prepare_lock. - */ -static void clk_debug_reparent(struct clk *clk, struct clk *new_parent) -{ - struct dentry *d; - struct dentry *new_parent_d; - - if (!inited) - return; - - if (new_parent) - new_parent_d = new_parent->dentry; - else - new_parent_d = orphandir; - - d = debugfs_rename(clk->dentry->d_parent, clk->dentry, - new_parent_d, clk->name); - if (d) - clk->dentry = d; - else - pr_debug("%s: failed to rename debugfs entry for %s\n", - __func__, clk->name); -} - -/** * clk_debug_init - lazily create the debugfs clk tree visualization * * clks are often initialized very early during boot before memory can @@ -1277,9 +1235,6 @@ static void __clk_set_parent_after(struct clk *clk, struct clk *parent, clk_disable(old_parent); __clk_unprepare(old_parent); } - - /* update debugfs with new clk tree topology */ - clk_debug_reparent(clk, parent); } static int __clk_set_parent(struct clk *clk, struct clk *parent, u8 p_index) @@ -1685,7 +1640,6 @@ out: void __clk_reparent(struct clk *clk, struct clk *new_parent) { clk_reparent(clk, new_parent); - clk_debug_reparent(clk, new_parent); __clk_recalc_accuracies(clk); __clk_recalc_rates(clk, POST_RATE_CHANGE); }