From patchwork Tue Dec 18 23:16:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13647 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 E5E3623E19 for ; Tue, 18 Dec 2012 23:16:45 +0000 (UTC) Received: from mail-ie0-f169.google.com (mail-ie0-f169.google.com [209.85.223.169]) by fiordland.canonical.com (Postfix) with ESMTP id 7E68BA1866E for ; Tue, 18 Dec 2012 23:16:45 +0000 (UTC) Received: by mail-ie0-f169.google.com with SMTP id c14so1833859ieb.28 for ; Tue, 18 Dec 2012 15:16:45 -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=kPRCtvcTbgaoqJq4sNAcIvMfAt43XbjTdYhHXhHkKwY=; b=JZvCkbxqGTgMY1+ysE/MTxmt6DRABTTY6k8wi+FtI1EDNM0yNbZFSPcSMbrPq5vOwx 0tNa0dWWvk4IBkIyjnZceJ8qBR9NG36JQnLVEwKMeIBE7ScilRqCEEmkPmt+x6zy8LlC RHc9Ej5NNB9qEYwvzu1URRmEAQcbAwdaqsPqKfxUW8YtTVxRrlaIZykmiJvR68DTvJR2 VlyCurkg6ijLMc3NphTWYGLmveXyNRlERiVgTEQs1SFRsmAB7P4ghkkT2CS8/INOABV2 qOwtiX1+4Hv/EpdjLNN+KLFm6fK4fl6rmINxnvVBoSKI1dwcBg6BhUzQiJComVSW7Low n/ZA== X-Received: by 10.50.12.138 with SMTP id y10mr5152161igb.58.1355872604904; Tue, 18 Dec 2012 15:16:44 -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.50.67.115 with SMTP id m19csp197639igt; Tue, 18 Dec 2012 15:16:44 -0800 (PST) X-Received: by 10.14.207.195 with SMTP id n43mr8817160eeo.38.1355872603975; Tue, 18 Dec 2012 15:16:43 -0800 (PST) Received: from eu1sys200aog114.obsmtp.com (eu1sys200aog114.obsmtp.com [207.126.144.137]) by mx.google.com with SMTP id j49si7853199eep.105.2012.12.18.15.16.40 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Dec 2012 15:16:43 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.137 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.137; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.137 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-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob114.postini.com ([207.126.147.11]) with SMTP ID DSNKUND5WK73qxXWQBIBQMrrk27BcNP8d4eG@postini.com; Tue, 18 Dec 2012 23:16:43 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2655CB2; Tue, 18 Dec 2012 23:16:39 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D3DEE591D; Tue, 18 Dec 2012 23:16:37 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 4B8F224C2E5; Wed, 19 Dec 2012 00:16:39 +0100 (CET) Received: from steludxu1397.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Wed, 19 Dec 2012 00:16:38 +0100 From: Ulf Hansson To: , Mike Turquette Cc: Linus Walleij , Philippe Begnic , Ulf Hansson Subject: [PATCH 2/3] clk: Unprepare the unused prepared slow clocks at late init Date: Wed, 19 Dec 2012 00:16:22 +0100 Message-ID: <1355872583-20928-3-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1355872583-20928-1-git-send-email-ulf.hansson@stericsson.com> References: <1355872583-20928-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQkaANj/PcNp0Lpad1Xpexn+dK4z5LF0zVmNk/OZMQp1ZfrVPpUwie+s1tylsICQtVUgu9fX 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 --- drivers/clk/clk.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 5adf2bb..2c4c2a1 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -199,6 +199,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; @@ -251,6 +274,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;