From patchwork Thu Jan 24 16:45:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 14275 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id DD80F23F79 for ; Thu, 24 Jan 2013 16:46:15 +0000 (UTC) Received: from mail-vb0-f54.google.com (mail-vb0-f54.google.com [209.85.212.54]) by fiordland.canonical.com (Postfix) with ESMTP id 89B47A1958C for ; Thu, 24 Jan 2013 16:46:15 +0000 (UTC) Received: by mail-vb0-f54.google.com with SMTP id l1so2668417vba.27 for ; Thu, 24 Jan 2013 08:46:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:mime-version:content-type:x-gm-message-state; bh=9sJo1aBcL2fBa/G+TQhJaw8T8pofVHd5KeYkoCr/LfE=; b=gH/DkNjOSaNfg3FgTvUM/6rsih+o/ZR16xENMbOMyIBpOslimLFytGt8nw/iQn7Uh5 nPHvawD6Wf6lTbNmVWeGFidRH3kbaJjeeTKQV+BB2V/IHdmtt9lVZ19ex9BnisKPoQIh De2AQCg4Ryv192WibA7GmfRdjKBMp1j2WItpsv3xtJnRWZSIuZg9fjeVvHDFVTB6w/Rk UUWxUfBrUrwtBYAb0+EqMsiVg9Zj9IMDIudE0/UL/H7DVkmOnZPmAPWI9ZVudp7STO1c VEgEOCYltDDuh+Z44nCPWV3IBN/IilDOTLf2Uau9RWcH9MrCYe9goXiE5fCVpI6ru9ji S6wA== X-Received: by 10.220.39.69 with SMTP id f5mr2605962vce.45.1359045975036; Thu, 24 Jan 2013 08:46:15 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp74434veb; Thu, 24 Jan 2013 08:46:14 -0800 (PST) X-Received: by 10.14.173.196 with SMTP id v44mr3816921eel.29.1359045973899; Thu, 24 Jan 2013 08:46:13 -0800 (PST) Received: from eu1sys200aog119.obsmtp.com (eu1sys200aog119.obsmtp.com [207.126.144.147]) by mx.google.com with SMTP id f4si42606514eep.147.2013.01.24.08.46.10 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 24 Jan 2013 08:46:13 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.147 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.147; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.147 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) smtp.mail=ulf.hansson@stericsson.com Received: from beta.dmz-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob119.postini.com ([207.126.147.11]) with SMTP ID DSNKUQFlURKv6lXlexiRnSnsST+fQc37IuOd@postini.com; Thu, 24 Jan 2013 16:46:13 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id 99B6F3F; Thu, 24 Jan 2013 16:45:23 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 2C84692; Thu, 24 Jan 2013 11:02:39 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 5F2C324C07C; Thu, 24 Jan 2013 17:45:59 +0100 (CET) Received: from steludxu1397.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.83.0; Thu, 24 Jan 2013 17:46:07 +0100 From: Ulf Hansson To: , Mike Turquette Cc: Linus Walleij , Philippe Begnic , Ulf Hansson Subject: [PATCH 2/4] clk: Unprepare the unused prepared slow clocks at late init Date: Thu, 24 Jan 2013 17:45:54 +0100 Message-ID: <1359045956-30741-3-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1359045956-30741-1-git-send-email-ulf.hansson@stericsson.com> References: <1359045956-30741-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQltm9rgrHJV5kxZGrRGhse/SJmOz4aAlUga3GOXo0di3boypUM6ShlyqkBuO01mXMBCObB6 From: Ulf Hansson The unused ungated fast clocks are already being disabled from clk_disable_unused at late init. This patch extend this sequence to the slow unused prepared clocks to be unprepared. Unless the optional .is_prepared callback is implemented by a clk_hw the clk_disable_unused sequence will not unprepare any unused clocks, since it will fall back to use the software prepare counter. Signed-off-by: Ulf Hansson Acked-by: Linus Walleij --- drivers/clk/clk.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index deb259a..0944348 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -341,6 +341,29 @@ static inline int clk_debug_register(struct clk *clk) { return 0; } #endif /* caller must hold prepare_lock */ +static void clk_unprepare_unused_subtree(struct clk *clk) +{ + struct clk *child; + struct hlist_node *tmp; + + if (!clk) + return; + + hlist_for_each_entry(child, tmp, &clk->children, child_node) + clk_unprepare_unused_subtree(child); + + if (clk->prepare_count) + return; + + if (clk->flags & CLK_IGNORE_UNUSED) + return; + + if (__clk_is_prepared(clk)) + if (clk->ops->unprepare) + clk->ops->unprepare(clk->hw); +} + +/* caller must hold prepare_lock */ static void clk_disable_unused_subtree(struct clk *clk) { struct clk *child; @@ -393,6 +416,12 @@ static int clk_disable_unused(void) hlist_for_each_entry(clk, tmp, &clk_orphan_list, child_node) clk_disable_unused_subtree(clk); + hlist_for_each_entry(clk, tmp, &clk_root_list, child_node) + clk_unprepare_unused_subtree(clk); + + hlist_for_each_entry(clk, tmp, &clk_orphan_list, child_node) + clk_unprepare_unused_subtree(clk); + mutex_unlock(&prepare_lock); return 0;