Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755503AbbG1Oar (ORCPT ); Tue, 28 Jul 2015 10:30:47 -0400 Received: from mail-by2on0112.outbound.protection.outlook.com ([207.46.100.112]:23911 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932191AbbG1O36 (ORCPT ); Tue, 28 Jul 2015 10:29:58 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; From: Dong Aisheng To: CC: , , , , , , , , , Subject: [PATCH V3 4/5] clk: core: add CLK_OPS_PARENT_ON flags to support clocks require parent on Date: Tue, 28 Jul 2015 21:19:44 +0800 Message-ID: <1438089585-30103-5-git-send-email-aisheng.dong@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1438089585-30103-1-git-send-email-aisheng.dong@freescale.com> References: <1438089585-30103-1-git-send-email-aisheng.dong@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD008;1:LrpAsFr69AtyJCMlKK7krW/8oSSs6x7uQaPPb38i60cccpsVK6IuLdoemE70WmRsL/F9BztNRHP+gTsRx63hTjUpuJThCpheM7C1uHfumm4nXmZ2w4WMgsaHdtuj/G+aF/LZrmWRgutHZyo9HuMzyGSo80poy1E97bEOoN6pg2RE4/hHEweWb8AQlv36DWkUvhJZRR+ZK8GQZH6KCAsJ2kmOr6n/Ir7gmb7dezzGXRToKwIYwRliJb5aCnQzNRjjjPbVuqPhiKcfwRzwouMpSTI6kTpCUMBe5oChjt/c+eo15WAKxGYlGq4LDgOFr8G1qhuC1/IGjxziRAP3HE3jOw== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(46102003)(6806004)(86362001)(87936001)(19580405001)(19580395003)(85426001)(47776003)(48376002)(2950100001)(50226001)(50986999)(76176999)(229853001)(92566002)(5001920100001)(110136002)(5001960100002)(2351001)(62966003)(36756003)(77156002)(105606002)(33646002)(189998001)(104016003)(107886002)(106466001)(77096005)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR03MB1437;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;CY1PR03MB1437;2:Tl6wd1VhoqvaYQvN6UE8ygddEt9CKcCxqCYWxUvQcyWAj9sMhkMl3/nnbbK0OAq+BfSkhxlKO77A5IcyiMuhWXPbreSgoAb5En4S/W3FyuiE2snDEYoSJvoGoUoQp7d3c49e5iDSAwR5mm2IKUuuBdBd6I5zg9m47fnQtTJTEuA=;3:yXREV+9367x+VLHqLP8s2h4EtKkhTWE9RLhC8tECKeDV5qlFKlgMhRIfzuAcj/IgwPN5LwmblsORsOVS6buVl5c4AOglP3GRP22kRLtsRpL8y9YTrXgwLbg6HylI4nXxuV7CAMxjOsoioYfVESBe9/8paBo6wpopCiUd3wAL9J053fx2eKT24gfwmtZrxg1uUL1El5MsVdUm8KfRPkQs0MC3LsHCSGHx0u7gcP3dKNQ=;25:ZluHELILDJXuiid7ekKKxpocYIknTw9zVQmFpvlqU3VPF+6rZzWIfUrEuKFVYDDk40h3SGVJgKnwFm1qsC1bhOOxivlEGo4U5RltN3XfZacXTQb5NhUqFVos/ppw0OF9c9bmdhV4L86DOASWDftvNMViGNSE1YVJgW2iC1etZGYlHuIjqfEWT6o8ir/IwCDxs4qpSP91zQj52S5q8rjI8G4OLXYX0Blr5dc2JugN1B2freG7pALOhT3Bm/Z8h42bCZ4DgJFD6pYJn4orGbb/qA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1437; X-Microsoft-Exchange-Diagnostics: 1;CY1PR03MB1437;20:Lxo+GYC5OPsK4GSd/afLm0OoX2zeWPKTGej4BmM3KY7ULqTyqkCcBPoYkA4pF5XS4wU/+oFpQVZqZJ8J7DSQxFEbMCxeK1ss96QL6DYv/+iIxQTdvunj9Y8UuRFUia/aNIUQWiee8p3OwiwuHWCQaMm6tHMInbKEKgu8YHKzIOK4QEFnbzHSk9kqBNiTjlDbmZ4yzjZT6lUqqCOh1UYP9XdvkJbg3i2BKtT3XlGY0OWOwB2rdR0TCTNrdQqcv258N6SMubuiSRmFdpQssnHwo2MUYXADRyT7M/s9g9iT/lc6SJV2Z/dw0Aq6rUpVMwgP/RcHzP8lvi0lh+xs/mIxAIBUOOSYOrT4cUpAtmkgnak=;4:KS80E2jWwxlDXuK6xLxKyf1wm908ixjXABaPJw2I0mZXp+MHnCZ6+JR6mLzDuwAahd4+NDvEp8/ZzCXcqHJwyzf6RvLoaL/GrRZY8UIt1PMsvUgYqxSJkS0KYDzJLhMVWnNmfMBQe7OBSpdlDhrtHaIXnNsixIl4AqCgIkotxnqQaF5CPbxonL5Z+jVUco3Tw7g17skPt33YJYQdqlJHss2XVO56NXntMZHf64cCf83mn/65P5aMQFhbnYDtVFIvohvAJoqSPDLP/DBp4JxYizdvi+R7PNhIEmHRcxioBsI= CY1PR03MB1437: X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:CY1PR03MB1437;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1437; X-Forefront-PRVS: 06515DA04B X-Microsoft-Exchange-Diagnostics: 1;CY1PR03MB1437;23:3GcsB2IsSgWFtbFG41zr32+OHczcecPppBbv3SlL9HYvI++EzWR5guOYdqwx5HD/CFjRVvI4XiRPi+RMWI1VJNp3mBBn2aemLMfgqhJNTrV4PoYIObfpMhH8DNl02oe/MlfykIXVvdNzKCFeJR7e1VhJo3qUDiMRBD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M96JX26cI=;20:sv9rSfOHs6Hzdb1pgj6UlETMLDhS9mgBv2qqQjgllwny+LVbiyrThMoIT/ovVBqH6E3McNgyRYT9h9xhh40ehQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2015 14:29:56.5788 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR03MB1437 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2991 Lines: 77 On Freescale i.MX7D platform, all clocks operations, including enable/disable, rate change and re-parent, requires its parent clock on. Current clock core can not support it well. This patch introduce a new flag CLK_OPS_PARENT_ON to handle this special case in clock core that enable its parent clock firstly for each operation and disable it later after operation complete. This patch fixes disaling clocks while its parent is off. This is a special case that is caused by a state mis-align between HW and SW in clock tree during booting. Usually in uboot, we may enable all clocks in HW by default. And during kernel booting time, the parent clock could be disabled in its driver probe due to calling clk_prepare_enable and clk_disable_unprepare. Because it's child clock is only enabled in HW while its SW usecount in clock tree is still 0, so clk_disable of parent clock will gate the parent clock in both HW and SW usecount ultimately. Then there will be a clock is on in HW while its parent is disabled. Later when clock core does clk_disable_unused, this clock disable will cause system hang due to the limitation of operation requiring its parent clock on. Cc: Mike Turquette Cc: Stephen Boyd Signed-off-by: Dong Aisheng --- drivers/clk/clk.c | 5 +++++ include/linux/clk-provider.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index ac158c4..cf31dc4 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -754,6 +754,9 @@ static void clk_disable_unused_subtree(struct clk_core *core) hlist_for_each_entry(child, &core->children, child_node) clk_disable_unused_subtree(child); + if (core->flags & CLK_OPS_PARENT_ON) + clk_core_prepare_enable(core->parent); + flags = clk_enable_lock(); if (core->enable_count) @@ -778,6 +781,8 @@ static void clk_disable_unused_subtree(struct clk_core *core) unlock_out: clk_enable_unlock(flags); + if (core->flags & CLK_OPS_PARENT_ON) + clk_core_disable_unprepare(core->parent); } static bool clk_ignore_unused; diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 06a56e5..006fafb 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -31,6 +31,11 @@ #define CLK_SET_RATE_NO_REPARENT BIT(7) /* don't re-parent on rate change */ #define CLK_GET_ACCURACY_NOCACHE BIT(8) /* do not use the cached clk accuracy */ #define CLK_RECALC_NEW_RATES BIT(9) /* recalc rates after notifications */ +/* + * parent clock must be on across any operation including + * clock gate/ungate, rate change and re-parent + */ +#define CLK_OPS_PARENT_ON BIT(10) struct clk; struct clk_hw; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/