From patchwork Wed Apr 20 09:34:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dong Aisheng X-Patchwork-Id: 8887621 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 437E59F1D3 for ; Wed, 20 Apr 2016 09:44:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 582D520172 for ; Wed, 20 Apr 2016 09:44:21 +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 5A99420114 for ; Wed, 20 Apr 2016 09:44:20 +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 1asoew-0005y5-Ug; Wed, 20 Apr 2016 09:42:58 +0000 Received: from mail-bl2on0098.outbound.protection.outlook.com ([65.55.169.98] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1asoea-0005RC-MY for linux-arm-kernel@lists.infradead.org; Wed, 20 Apr 2016 09:42:38 +0000 Received: from BLUPR0301CA0005.namprd03.prod.outlook.com (10.162.113.143) by DM2PR0301MB0717.namprd03.prod.outlook.com (10.160.97.13) with Microsoft SMTP Server (TLS) id 15.1.466.19; Wed, 20 Apr 2016 09:42:14 +0000 Received: from BN1BFFO11FD023.protection.gbl (2a01:111:f400:7c10::1:101) by BLUPR0301CA0005.outlook.office365.com (2a01:111:e400:5259::15) with Microsoft SMTP Server (TLS) id 15.1.466.19 via Frontend Transport; Wed, 20 Apr 2016 09:42:13 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.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 BN1BFFO11FD023.mail.protection.outlook.com (10.58.144.86) with Microsoft SMTP Server (TLS) id 15.1.472.8 via Frontend Transport; Wed, 20 Apr 2016 09:42:13 +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 u3K9g0iS016915; Wed, 20 Apr 2016 02:42:10 -0700 From: Dong Aisheng To: Subject: [RESEND PATCH 3/8] clk: core: support clocks which requires parents on (part 1) Date: Wed, 20 Apr 2016 17:34:35 +0800 Message-ID: <1461144880-8724-4-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461144880-8724-1-git-send-email-aisheng.dong@nxp.com> References: <1461144880-8724-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131056189335589874; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(86362001)(5008740100001)(6806005)(4326007)(106466001)(48376002)(110136002)(5003940100001)(81166005)(50466002)(104016004)(87936001)(586003)(36756003)(1096002)(1220700001)(105606002)(33646002)(11100500001)(189998001)(2351001)(85426001)(92566002)(77096005)(50226001)(2906002)(50986999)(2950100001)(229853001)(19580395003)(76176999)(19580405001)(7059030)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0301MB0717; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD023; 1:/vL0fybjZU0LdZWxduJk4xxHLg5p9I6Kri0DEULgVnv43aUecOBOc0aE98P76wC4NCE4GJY9Bo9/f75k5euLAPppEIdCNhX3qM9bkxHfyQ0hUz4Lm7+BigaI9Thuq9e6fuUbPcZGyBhnpLzKpM+aMKbFM8ZZlKjaeVFFbZYSqfuR7sXRAGkzTpOl1RQG8SgauYiyzObMfPNKwbs2TyxN4WVGqSIqsDXCBkanear67c6LkzOVMEm59DcUqGBcZ1KqR0hXsmRDzGROI799C7otTCGWz3KH19mkmDUMfSeo47hY2GHJwPVh8F37Dhc4/gpaCKSLSPQ1wbt1HrG9t0DScrScLKdKxJCPD8GRVI1i6mOBe68dBLl6Fbx6wTaaIuJEU6F22njsqsSmZj3cXbhKr0RrMeJtbe7OkOM7N7JTtoO7X18BmwyPB17qQc1eU72b52Rd9S9LFXWyfCFdwaMDoSRBLCVG711US2H+t1+pkPzrC4YkHCxzvQLmroElVOm6DTKa8Luy9uEZDTiPKDshtZ5u0rtTKAX4WfEAtnqtJCN+4VvZ4CLUZ+rBvfJt68X09+D9O2yl5liMeYVCL6+x33vUARQ0ylUXJkaWtU1zZ6P9fRCfl46pFz9RUFm0wPi8SDBzNAq/UbZttjdcOGor/htbO0kjacuiXqb5GT30NCvYAK2dY4QQFqv6AAOkbt47 MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 3b4a171d-dcb4-4f06-d3f2-08d369000d6d X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0717; 2:ijutWmsDKfdTUUPZf0TPXAgbpe8q1KUiVsRQcYO5ZYA4pPgI+OpkI23GaGxP4VT/G+aNFKWujL6OuQBgV8etOgBzKZ1O4/0ZQMdI4cGj045IFDo8THW8VTQ5C/bQhWkCiSEwaAlk2sgmMZ4JUjYsWdoQcNYyG4t894i7SCKY5QXZ3hqWyZ1mWpz/t6+9xuJB; 3:+jLTOhR7FzBMMifrlN+9CkgA0PidVDLN/7FLZHSui0uLifTUOtFStvPhraB9Uu0XgGGg50JbFhi3tpbFfcQXyo5zc8VNah2mlwNXQ4XbVaj6nwI11PHJsI6GBi0Hce/NpQ/bq9pzkzqqgO5tc/cZElZsmjPn0UGo3B24nXfRTPfh5tjr+5IbhvitQkd3ReZfQXE7ES7tMFuiAy+VPL0JqODWNfqx6PFkTchx//q+BbI=; 25:nulFsC1T5RRcOZ8vd2y0g6U56cNbYEWmVminFsZ1racCI/88KKDX7ZV90833AjPJ7+yiCq6iBc2NPX1NMifQe/bC9oLFh/3xbsK/0SVQR2YfAYTOglWDGSpnacyLJnhSHe5Dlr4JJ3UxGzr7HNgEHabMr77NUejbOkWjIJ+FFBehd1cz6TGeW4CIMhRTcVskdFsJCQlFlaZpKK4PD68sJE6KQUMQPffgYYNmY2ciFJCYz3qhNsSZ3QC+36P/RZ/RwGuCw/bF5O2+DLKMg8sEr9cQNkN4Udvu8n0vrjEQ3Gv8H/617h8if4ELaVaXlX15+n6KpXDYnEP8KJ6bz0VGWw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0717; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13018025)(13017025)(5005006)(13015025)(13024025)(8121501046)(13023025)(10201501046)(3002001)(6055026); SRVR:DM2PR0301MB0717; BCL:0; PCL:0; RULEID:(400006); SRVR:DM2PR0301MB0717; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0717; 4:8njOMdEoWPIw96fpzDLlLjrRYMWkXX2oHpJHpzM/2fXKkjd2tiz5nWgeHN3vxmNNtN0ba9IwZovCUAPECNUwUB51ZbLoikkIc2os8tjYenAzunS5Bm7HQ6QfE0+SV+C085wjbgMPRzJlNjjUdeKjFrAmtXL5f+fdQ1X8cVlrqQQ8j224sy5pgP9TMu5UetyNgEZ6RbjI+xjuykKX2s6J/eXXwp7oBeNbWM2NgkA6VwGAeHoqvP9VoDN9bJ91KopUA+AaEZZQqeQj7W1OKWmBvEctGx5UKvaNc/+U/nBZt28NSb4wvIJQqfLsI18PBqWCL9vsGCY7KjqzuIu+GxBDxbUtExRD4BOYSs2YE200Y2tQoWIDbs9/nozZ35ow99S0abYJP50fz0uswrqTFjTgQBkFOVX9ujMWUYufulSX/cZYqpBweWA3vpl16ED7fRfcoZhgTTW0zqiKSGSMmbSjoBx2L8HnXKoe2exl/pXq2Bw= X-Forefront-PRVS: 0918748D70 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR0301MB0717; 23:zWx4khL4/ilxU4XCoNQ/DWbisMIMJZ6L4EduLbJ?= =?us-ascii?Q?d2neCiaU7XJmyHzVUJkNeN0/RebCKhbJS1kU25KQ2OtvkR6umg+0teD+8zrA?= =?us-ascii?Q?psxRhyWJUH+GL7XbNYhfs9GjN2QsA3hMU5zkvfSsdbBPCMo/Osvh6k8+1DYo?= =?us-ascii?Q?0LsfBkiblgz8JXK4TNZJAEtPux034HjBR2IeQ1SD88/0L7EoYI6Q8tdtQGJU?= =?us-ascii?Q?Fb77Rm2mzS0YwqNJioPhmqKF79x0bME5Dl22p6F24NwXiDWdwqplRpQTgOSv?= =?us-ascii?Q?GqKPk6ixtBvUqznaHf1xPIq9//8ckIDqhieShjAPko3PR/1MXNciI/jV/Mvi?= =?us-ascii?Q?557rv5WyZ5O1bsOnmcqsIrus6qpeerCRvK2wQX625rnJ2QlEkQ8guYD2oFqy?= =?us-ascii?Q?2umCIFth1IeYF4ibeza5hi50taZbd9dxInRrsFapUV19CQAso87CHTOBxb4D?= =?us-ascii?Q?GBx384LjTOWHRr6S4wUqv0beog27OMvAF5OPISRPvbHqTUF5Z7fX8Rja8j46?= =?us-ascii?Q?7H77d3CkE39n8lHhSIykii1YT58mxwZm3HUGLQQ/dvc83cqzYGwiQ/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/s7WrltKFc2hk7KGaSS/snWrXI4NTu9yKcdpNmoOm55jcR4LPNizPkwygjsVw6IW8G+9mFFdtfUhkVv3nx9+AcDDMGASCK2nwh+jJGmmsfZ1/9pdQznKhyOSi7cu0xa25WozlOtwCxzXckiKACkEJjIxoemh4/D0fh31I= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2016 09:42:13.3717 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB0717 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160420_024237_156105_EB39701A X-CRM114-Status: GOOD ( 17.36 ) 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: aisheng.dong@nxp.com, anson.huang@nxp.com, mturquette@baylibre.com, sboyd@codeaurora.org, linux-kernel@vger.kernel.org, shawnguo@kernel.org, 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.2 required=5.0 tests=BAD_ENC_HEADER,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. The patch part 1 fixes the possible disabling clocks while its parent is off during kernel booting phase in clk_disable_unused_subtree(). Before the completion of kernel booting, clock tree is still not built completely, there may be a case that the child clock is on but its parent is off which could be caused by either HW initial reset state or bootloader initialization. Taking bootloader as an example, 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 child clock is still on in HW but its parent is already off. Later in clk_disable_unused(), this clock disable accessing while its parent off will cause system hang due to the limitation of HW which must require its parent on. This patch simply enables the parent clock first before disabling if flag CLK_OPS_PARENT_ON is set in clk_disable_unused_subtree(). This is a simple solution and only affects booting time. After kernel booting up the clock tree is already created, there will be no case that child is off but its parent is off. So no need do this checking for normal clk_disable() later. Cc: Michael Turquette Cc: Stephen Boyd Cc: Shawn Guo Signed-off-by: Dong Aisheng --- drivers/clk/clk.c | 5 +++++ include/linux/clk-provider.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 9f944d4..1f054d1a 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -765,6 +765,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) @@ -789,6 +792,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 15628644..c878f9c 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -33,6 +33,8 @@ #define CLK_RECALC_NEW_RATES BIT(9) /* recalc rates after notifications */ #define CLK_SET_RATE_UNGATE BIT(10) /* clock needs to run to set rate */ #define CLK_IS_CRITICAL BIT(11) /* do not gate, ever */ +/* parents need on during gate/ungate, set rate and re-parent */ +#define CLK_OPS_PARENT_ON BIT(12) struct clk; struct clk_hw;