From patchwork Tue Jul 28 13:19:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dong Aisheng X-Patchwork-Id: 6886521 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 60024C05AC for ; Tue, 28 Jul 2015 14:33:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6B07D20666 for ; Tue, 28 Jul 2015 14:33:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6A2C6203B1 for ; Tue, 28 Jul 2015 14:33:31 +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 1ZK5un-0005z1-L8; Tue, 28 Jul 2015 14:31:33 +0000 Received: from mail-bl2on0102.outbound.protection.outlook.com ([65.55.169.102] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZK5ta-0003bN-Rj for linux-arm-kernel@lists.infradead.org; Tue, 28 Jul 2015 14:30:22 +0000 Received: from CH1PR03CA006.namprd03.prod.outlook.com (10.255.156.151) by CY1PR03MB1437.namprd03.prod.outlook.com (10.163.17.147) with Microsoft SMTP Server (TLS) id 15.1.225.19; Tue, 28 Jul 2015 14:29:56 +0000 Received: from BL2FFO11FD008.protection.gbl (10.255.156.132) by CH1PR03CA006.outlook.office365.com (10.255.156.151) with Microsoft SMTP Server (TLS) id 15.1.201.16 via Frontend Transport; Tue, 28 Jul 2015 14:29:56 +0000 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; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD008.mail.protection.outlook.com (10.173.161.4) with Microsoft SMTP Server (TLS) id 15.1.231.11 via Frontend Transport; Tue, 28 Jul 2015 14:29:56 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t6SETZDK010845; Tue, 28 Jul 2015 07:29:52 -0700 From: Dong Aisheng To: 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 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+RMWI1V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LpMUjayWibAnUoQ7T1L8oUsBWsqUZ8/Y9tSyGZT1sYmOLo18zmRV73Fb8J12x0+hHkLCGa1Wommx9YM96JX26cI=; 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150728_073019_457769_9ED94DF7 X-CRM114-Status: GOOD ( 18.90 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ranjani.Vaidyanathan@freescale.com, b20596@freescale.com, mturquette@linaro.org, shawnguo@kernel.org, sboyd@codeaurora.org, linux-kernel@vger.kernel.org, r64343@freescale.com, b20788@freescale.com, b29396@freescale.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 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;