Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932881AbbENOiT (ORCPT ); Thu, 14 May 2015 10:38:19 -0400 Received: from mail-bn1bon0140.outbound.protection.outlook.com ([157.56.111.140]:42934 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753252AbbENOiM (ORCPT ); Thu, 14 May 2015 10:38:12 -0400 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; From: Dong Aisheng To: CC: , , , , , , , , , Subject: [PATCH v2 4/5] clk: core: add CLK_OPS_PARENT_ON flags to support clocks require parent on Date: Thu, 14 May 2015 21:29:02 +0800 Message-ID: <1431610143-21853-5-git-send-email-aisheng.dong@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431610143-21853-1-git-send-email-aisheng.dong@freescale.com> References: <1431610143-21853-1-git-send-email-aisheng.dong@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD002;1:Qd9X/jjl6j3fbD8njF6+DTfIxiWOue9811QdBjRHYkR97uIXYGvJ3/V6GxXVDM3dHmNcBuww8Flr4R9LH3VJcSJ+BptfwxMEKYIwRIZCb7k4mvw0qnOIBRlkgmXpT9c71lrntt6OqblLD0gARo1D0tb/PnzC0Ea5EiP6zDzLnJWXmvyVTc7ozz8piVDJN1ylPCzMRCYfLEDHabq9qSFbWSPnFMfkSELKfBd/Jgl72t4lENy/zPCEjZapKhs1rmoqwO818xI9SktCvhD5K/U4dGdW3eFHizzLrD2/9JXJQRvvDrh1OIMpddN2gYjXmBEr+t+TpXcTQ5Fzxt7dZJgyrg== X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(339900001)(199003)(189002)(189998001)(104016003)(107886002)(110136002)(19580395003)(5001960100002)(19580405001)(48376002)(50466002)(33646002)(77096005)(105606002)(50226001)(6806004)(87936001)(2950100001)(106466001)(36756003)(76176999)(85426001)(46102003)(50986999)(92566002)(62966003)(77156002)(86362001)(47776003)(229853001)(2351001)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR03MB1440;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;CY1PR03MB1440;2:+rCcvWJ1uHQ7apeQEw9ShaZmGRooRxiCPZFMpm2dPYoP2yAflQUOMEwxfVpwTNaK;2:iYwNtcX5+0hYbpH1dc5Fr1JKXkkUzUWL5rw31o9eOj4x7B7M3LKiQKCvKX7J+yHbgYhaDK1vxgdfGAArRDVT2j8op0mOGOE26uS2PxZOrfd8IwSQYTGjI8DvHTilkrk1oTeMgxxw9FACVhZsnAzjhtQncqJvfU0jnUy52K6G1dm1tvpkylJmitw10murzliuAyuAx+WAjkkYN9D+BGLpWSSWTx/Z5v0NMtqjZrXScQ8=;6:ky1F0eO/1B1E1Qce2Ndg5vh06XNQohSTbFc2xGDbCRs92jaEbO5WY1T+4EbCLQsb7kKqWVrOwCK1K5Rh8J4gQv7vKPWbIeYC8nkHNitI5UyZBIN1oUoJPIQnYJv84sIGbOpztIOXN6OM4y90gTQq64Q93pU1gXa/stRF6qmHpw75mXFgjeUvX25oTrvKqXATaUSJGJe0npjQSQ6sbt86ufmWHNpa1dCt8xceN4B2VrlhHrChHTMOphlqx85vSbfpxbdd5RfCOLhOyCh3U0ZFM44bFFHXMbGKHIu9BCWrju9z40EfVfL5FRpS5zEIZxQtrjL0KymYwD+CEW7mV+XEcQ==;3:LO+oY1gg4H2iPqfS+SPq5cS2MWVWf4iK6t111u0JjpoKZ9VAR1UYBZ6o5vJzrKH1KJzzGGmeTvYiEUzHU4eawUkMcJkI2yDlbejGVShwiZ+fxQpchcxOojBhHBrhZU4veb/IhrZFIWjuK9K+NmJEzDJQyUp8kTfr8Skt0+QSGj16VDMDFnrhFurWH0Jpfi9ozn6301gTpLV7Z3JxsICLFsBhEkqyoy8bBjXT75m9zI86Zz1Et99iMaRMldvJhFl3jd1cB/oKrJ//P4Vj0uC5yKLBQGxN47SUJS+t71K2BdU= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1440; 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:CY1PR03MB1440;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1440; X-Forefront-PRVS: 0576145E86 X-Microsoft-Exchange-Diagnostics: 1;CY1PR03MB1440;9:bQpXhJoey8J8GA8+xydBesnU4hKI0a8Tb6+jX4DfHeaOq/1EHMNIO7lH093RwnmSkrtu9CsgFcMdctOcU45EqytoKpsFxPuC9EmgC6cRb4zYfZ5upmu+INwL2unKDf+zzR172WSx8QZ8mCx92R17OrVS6L2f3UtqrPbNr5m0lGdIPRV1YqKNhxkuWmJ9+U6h7Yv9sdHcEYjgIxQBqF35ADrap+Bonfhf7E/7+7s9qCMHwxO0TdaHIN44wHE+lnJ9KT6VeDMMKykpk1MEaUl4cK02dbs0Wc0ab+qP8iRDGNImJ7odE7+d89USiyrkIwf+IxiuU6LvGQnqlHT+fwKGowTj1Atth35p98GsVUl2rD6qmrN4v/ky9ogQr4Lrc98xKZ9sJE8TZig9qwKECeFooftMLPdLlePe5NUHNcnePwo61ViQcq1QwqGtBcZx4LqdAHRNAcJG+ADLR8IlTk6jHAGwJIKF1iJtlScuaBGHBQtmiIRL0vEjeoLX5ROj3Buiv7MkWsSHSWeE53Qy9A6NlFPhcLzzW58HNVoDXFILHYyUi1tYADYx2tl2ldHvwN4996NY5pKYt9BALKbnI38OyEyDG6r8QrIQ5waV3Xa5+cwWSPsuxIAeBt2kaeEPxO4y+yfR0f9/OV4E8ZKVUnLH0Yo9gQnkzdYpG/oyt1PVV/0JXeah+mJjxh+6idcw5ReuX2Y3Tn4uP4Cub0FpXFRff3k7U8TD8kJjChc/UEGaQ1OZSgVyrYmvxIkr37N84zAe8jnxqYZeWzYyvpFWt1S14MrBMiKHcYzD7I3hqW3TS887HqCArcaFvRwrgOd4IjAFbi8wIM5DkIJFvJa6Xu7ZBtJSXwjDOhNoGrz2af7oO8h3Mtlm/Q+nV4iLotvCXCP8iUuHySCf0xvPHT2jgWdxmA== X-Microsoft-Exchange-Diagnostics: 1;CY1PR03MB1440;3:idC3q2ZoZwgy0rpigQMnes2vNlIPHnzqz5Zfvo4Af+A11xuBPXYZDRlOZXt2zdONgQowbMbhdHzHaC0YMnHlLoXVll0rph1CGoLiLAAQMjahevkkn9NcLHT7q9yPDaDiIIHUsd+bFEJ9Cb17wPWPTg==;10:HLBivluW9jDWVQbRqeYkjJWOn4e4w5nXp22dmtCU158P78Mn59AMbYvbBWGrearQfwjrHa30A75RpsJ/oDnIoIR/nhS3z1KgnBDy93vu+Ww=;6:FPtRS7LWOruwI5BrbYgUs5PsXYpQ3jwwWt1JrRAVgUMehA8y1m9IXjSHTLQ/aDHB X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2015 14:38:08.4029 (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.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR03MB1440 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2993 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 597d6d2..44a2f55 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -736,6 +736,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) @@ -760,6 +763,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 5378c2a..b37d9f3 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -31,6 +31,11 @@ #define CLK_GET_RATE_NOCACHE BIT(6) /* do not use the cached clk rate */ #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 */ +/* + * parent clock must be on across any operation including + * clock gate/ungate, rate change and re-parent + */ +#define CLK_OPS_PARENT_ON BIT(9) struct clk_hw; struct clk_core; -- 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/