Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932247AbbHSLSH (ORCPT ); Wed, 19 Aug 2015 07:18:07 -0400 Received: from mail-by2on0128.outbound.protection.outlook.com ([207.46.100.128]:48030 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753608AbbHSLSE (ORCPT ); Wed, 19 Aug 2015 07:18:04 -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; Date: Wed, 19 Aug 2015 19:07:04 +0800 From: Dong Aisheng To: Stephen Boyd CC: , , , , , , , , , Subject: Re: [PATCH V3 4/5] clk: core: add CLK_OPS_PARENT_ON flags to support clocks require parent on Message-ID: <20150819110703.GB30536@shlinux1.ap.freescale.net> References: <1438089585-30103-1-git-send-email-aisheng.dong@freescale.com> <1438089585-30103-5-git-send-email-aisheng.dong@freescale.com> <20150814010109.GW26614@codeaurora.org> <20150817124514.GA30536@shlinux1.ap.freescale.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20150817124514.GA30536@shlinux1.ap.freescale.net> User-Agent: Mutt/1.5.20 (2009-06-14) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11OLC003;1:XUDWb2G5cdDysGMi8l7wGjlN57LbcoL0Bv37v1XQsjv8TlUjAdiLSWbDiLM23SrKWw03uEICyqqkBCtePHmyv8+2c3DwSaqzNRVvLcOJ+RqdLxWA8lxTxV8ihCitBJ4hnvof+B6IJ1xz+zZSaG5eNqqlWKLyX3uNhvONay1HRwLEIZ78hGUy+A1dC6DBZR+2NbckkdONhLM3ByNcuDKiF7dVL0Iy2rYw1ie4KlRy6NMLGv5UY8Gu5ffAP3usXLCcAXdzu+GE+Y9lGVDPZpHq/Vbv38lDGIFqsgDxiHzuyjX8Y2K8TeshYukwsEfyZcOWNFw9w6hHKo/dyAd2qTDwbnA4dp+PkhoQRd9rZNSnufD0aCw1G3Y31nrFqWxOmXK/JegsygS2clKY0IC4cXOoGA== X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(3050300001)(339900001)(24454002)(189002)(199003)(77096005)(50466002)(86362001)(4001540100001)(189998001)(97756001)(93886004)(87936001)(4001350100001)(107886002)(5001860100001)(62966003)(69596002)(77156002)(97736004)(81156007)(47776003)(19580405001)(5003600100002)(2950100001)(105606002)(64706001)(5001960100002)(85426001)(6806004)(19580395003)(106466001)(46102003)(110136002)(76176999)(5001830100001)(104016003)(23726002)(50986999)(83506001)(92566002)(68736005)(54356999)(33656002)(46406003)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY1PR03MB1435;H:az84smr01.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY1PR03MB1435;2:ftuj/0JwttmXr0aKsKRAxjEsBAkhOZrqGxrqR6sePFMXMjY+vH8kz4F9Y1c9Rdqdxah1dGd7SqMhsDKLJ1QkjNBAydboAaCZ6adl8tk/vbGiwSyJ3lY1g23mPFzkC8ZBum5Ml8x6jFw+Nrt84YGpQaluxqPGPEXCWtQkuDf36xA=;3:6ePfqYqVgv/4Rb+gVDpmnMl6M9WIjCHjDMi5YgefHP4eHI/tR9ZzXymfByMYxjtHPvMNfAXD32D8ZRgko+Gkxxw5cqUWeRqUcnYlDygmejIYZsWJeJDIwY4Pp0AYVsmgSGlUV4l/jwbHabdc7ZNVxLV9xrJIj9S+8CBOmpdltAyx894z53AsQsD005TXayhgZedfJOc95f8Twz1la+bUVXST0vLxyVupDuY9oJQH2v4=;25:NUQW0aLQhTSdR83MU9KZkUIH57SyalZiwzVlj4VWPjUfS9XZQxFjagak/j8NzQlqM2usug7ScQDT3QbupPDD4vxLxkVovneOK8nQ79T3dPIq6aJs0S7k70LX5uzOpcfFy8hNASa519eKFmYdUxB9AUL37Z38F2bvhV/8xljWvlBMgDKIeNro05P9nAdJcHXebz32OGH5+mKb92OsmUGp5WIvp2LcqmJct8ohsjlWYuZwc52H12TesHOGdyydLmJpevSiw8d0f1h9v46Y2VPg8g== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1435; X-Microsoft-Exchange-Diagnostics: 1;BY1PR03MB1435;20:JlwZeCDNP46YTr0NLm8mdDR3IqxcWqKY3OdiXDI1k6rUC1If/+OT4fUAKmqj224cuubRzswp6qaH7jxr5bhHYWU8Fq1w6bc2MuQuPJHqWprFHEPHA2zFF+rQmpRY+Ut0pzQjIGQT72FdMBzA8pK47qVXOXK1GCeKeV59q6lPBKwW0AXWyB6up0N7+Fl8800RmtKoAxv+FikWg2hA19ZfAphCMVQsNEHCpyxzhX93BglK38qU1RCGDuBnvA15uZvXZ0PhJLLBEJMLs1ac7fYcFkdltM8zyLpNdtLv3b+U4CWhj+oTGIk+18apNYZX6GPWN0t7Az2MiKsni4doIFV8bI4zOuimZtIbx65zGCaSmbw=;4:wTLEDgt04SobmontZ9IbofI7IW0XVSQMGj7JZ2qdhT4AC+jigvGrYYkDmWCchojWrb7H6gaMFrX82RoC3IsS69mzz4eDXu9NRyojZbed9dRQIyH/0vo7zGwJ8N+Af2jRWGqbEd++CJQIZT0iKvPiBxzphJrQFIxPqDMaqy/qh5/SoAcLgqm9TmTyfqhWrlTJy8O/Chef3oZ9LEe3DYhS+IfBmhoTJhUU2zwk2ckg6XaOLs5w94ZG2fLzYAJWZZIVIz/pv1jVnqTjWz4+vd4Zoxm1ibPCRzJYwNR7PRb6gu6/gzBXCu/yR3dVShj8cHEW X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(8121501046)(5005006)(3002001);SRVR:BY1PR03MB1435;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1435; X-Forefront-PRVS: 0673F5BE31 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR03MB1435;23:81nQO9NJRTfncNnxXsBbYJi5k745kvuTFepC2NsA+?= =?us-ascii?Q?mJA+7Tr3aRjbRgVsHnEFNzKli1yqvgrhvOnbGsiuEl5oGVpQcLT6urHdwrIi?= =?us-ascii?Q?skOG9IS2gtrBaYndBrr6wSI5NTk7EjDq1vPsj7VdeDd70bfRWHCtyjVntLlK?= =?us-ascii?Q?jcWKkerAdbrclXqwfejChjFWX4e0Oblmvq7Fb8A8A/GxoNgyMvTvG4ZllwBT?= =?us-ascii?Q?ZK7RFq1UInYhWbs5YvxhQvSRntlJ9T4HktXVjpJgyiCRwkIavHXFjBN/rP0Y?= =?us-ascii?Q?vTKlhYcEqO7iO5vAcJF4q6KXO2joov91R3K9nmwoKvFjpHki8T8slDyEq8H1?= =?us-ascii?Q?GmNaBMOFg3e4a/xvl50FgIZRiNCE5n367qXg77mpXdp51E4OHQQq8iPTgqNn?= =?us-ascii?Q?nvWnBxZKGqOcPTJ+CyssOgbgKU5T/FQ4CaWEMyAZfhv7GaO0PMqbzaINLXwy?= =?us-ascii?Q?61o+caVcorLO0vkN0Hu7JZnDjovNx9HAQz/PfiIxW/WYVV8GJeSbQK3i3Uf8?= =?us-ascii?Q?5m40R5l/L6OGzo0PYdvv8nZr/4tXiwc/eW17UqO8zlAUxITTU2iwANFXqgYr?= =?us-ascii?Q?OWHqbttR+OBXpeey13WwI/o9HHx+aC1RGjEritpoIQGzGIe/HZFb86RSgT01?= =?us-ascii?Q?0zuvoDOEyyj02wW6xVBRiOqLkblouJIYHPyWIdziPV6INEkW5jxYP7diQIb7?= =?us-ascii?Q?W6fKd7SnMcWPtKzDfeULhkuSGe1Glq9KMDDzE+wJX4zI5G+sw2OnbHsBkqAH?= =?us-ascii?Q?Fq+Ftcn53QsnIdW1qX8Er31FmMaD70urytvq8I5oCtJ2+EPW4XGwc1vfF2yR?= =?us-ascii?Q?+BHjFSAGfFfG7x5o0UtAS6S49RNFbHWtzjC2FkpIXdXBieGHJeUJT7nD/Tg5?= =?us-ascii?Q?TxsQsTL1CrAsA3V3vo/cil2h8rOesbs1/SfTihrF4WoXXoq8M0qdezlxnoRz?= =?us-ascii?Q?Ttfkd217YE96puVcccGZVYtKHLf5byTApZ9Flac2EyFFuesJBQ70DvvYwPKT?= =?us-ascii?Q?ezB4fxsE/E2hOVIakwKbOCDRxscW2S+IFi00OQmmKbjKdHIIC+f1mWC4ieGT?= =?us-ascii?Q?HG1IL2c9tCMPDUHG0PG+CMdOf2RotlYaLKsMsTUtMsi2yjfgqfugB2U1cvzr?= =?us-ascii?Q?0uVot5aGEqMkV4+29qZXqS2KMenylG52DcyxrBSbkZ+ae9lkXDq+RA+9V9OT?= =?us-ascii?Q?UxkMquCiEnWbpSgpAk2SuCyX7XjaKCdRlmcBDr/xUCi6W3u6tN+S1UjAo1Uj?= =?us-ascii?Q?olYr3CC2FAE9+ZFcP6/8E9jRpcohDDKEqNiTaMggsn+eakhevcG/6du4XmJz?= =?us-ascii?B?dz09?= X-Microsoft-Exchange-Diagnostics: 1;BY1PR03MB1435;5:D+gnoDplYfafPqdHIPsPr9kVUBMG6zyafMkISPakHIjqWydxD4aUzwgwWQt++rFs+pf6ePKxabpDnvVeg0pja7Fnd12Kig0hGtN+362d53hg1GGT5JsqpQRFSDmuG0IwhInPK0o4408i2CHkXYCJwg==;24:tvcUdoVee4SJVH4qacdvuT0gS896YchUlpKV2G2M/hX/T8Rjxa+XUmSH6PLdv+7wfX6XxhS13iJO7I/y+TMM3Wy9L+5K42M20O6UwfEXYPU=;20:2Qp/yjspGR/7a0LMoq5fHEwoUfRGDWuLaL1GR4FHEreTjSUuokIZCy+mokDKcdgVerEojpHsNRzzBwo2Zf4ahw== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2015 11:17:58.8689 (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: BY1PR03MB1435 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6445 Lines: 146 On Mon, Aug 17, 2015 at 08:45:18PM +0800, Dong Aisheng wrote: > On Thu, Aug 13, 2015 at 06:01:09PM -0700, Stephen Boyd wrote: > > On 07/28, Dong Aisheng wrote: > > > 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 > > > --- > > > > Sorry, I still don't agree with this patch. There's no reason we > > should be turning on clocks during late init so that we can turn > > off clocks. > > Can't the reason be that it's fairly possible one clock is enabled > in HW while it's parent is disabled in initial clock tree state > and to enable parent clocks to disable itself is required by its special > HW characteristic? > > Dosen't it quite clear from HW point of view? > > > If there's some sort of problem in doing that we > > should figure it out and make it so that during late init we turn > > off clocks from the leaves of the tree to the root. > > > > Turning off clocks from the leaves to root probably may require clock core > to provide a way to keep the parent clock enabled once finding its child > is still on in HW (clk_core_is_enabled() returns true) but enable_count > is zero before late init. > > One possible solution may be leaving parent clocks on in HW during disable > once finding its child is on in HW and only decrease the parent's refcount, > and then replying on the later clk_disable_unused() to disable both child > and parent from leave to root. > e.g. clock A: parent, clock B: child of A > Initial state: clock B is enabled in HW while refcount is zero > Step1: Driver A enable clock A during probe > A: refcount becomes 1 HW state: enabled > Step2: Driver A disable clock A after probe > A: refcount becomes 0 HW state: enabled (only decrease refcount) > > Then Clock A will be the same state as B, HW enabled while refcount is zero( > means no users), the later clk_disable_unusersd() will disable them all > from leave to root. > > This is a workable solution but seems much more complicated than the exist > one in this patch which is only 5 lines of code changes. > > And the question is: > since we already have the support of CLK_OPS_PARENT_ON (required by > clock set_rate/re-parent), why we still need invent another complicated > mechanism to support avoiding enable parent clock only for clk_disable_unused()? > Is that really worthy? > And it's also less power efficiency than the one in the patch. > > > I agree that there's a problem here where we don't properly > > handle keeping children clocks on if a driver comes in and turns > > off a clock in the middle of the tree before late init. That's a > > real bug, and we should fix it. > > Sorry, i still can't understand it's a bug. > Can you help explain more? > > It looks to me like reasonable. > Enable/disable clock in driver is just one case, the initial clock tree may > also have such cases. > (Here i took the 'children clocks' you said as the one who's child clock is on > in HW while refcount is zero, fix me if wrong) > > And it seems not so quite make sense to not physically disable the clock > when there's already no child users(refcount becomes zero) and i don't > think the child clock's default enablement state in HW means a valid user > since it's just caused by misalignment between HW and SW clock tree during > kernel booting phase which is meaningless. > And that seems is why the clk_disable_unused() function exist for fixing > this state misalignment issue. > > > Mike Turquette has been doing > > some work to have a way to indicate that certain clocks should be > > kept on until client drivers grab them. > > Sorry i can't see how this help on my issue. > > > I think it will also make > > sure to up refcounts on parent clocks in the middle of the tree > > when it figures out that a child clock is enabled. Would that be > > all that we need to do to fix this problem? > > > > Then when will we down the refcounts on parent clocks and when to disable it? > The current clk_disable_unused() only handle HW clk enable/disable, no > refcount operations. > Not sure how this is going to fix my issues. > > And again, as i said above, i don't think it makes much sense to not disable > parent only if child is enabled in HW, unless there's more strong reasons. > > > Also, the subject of this patch and patch 5 are the same. Why? > > > > Sorry, mainly because the full feature of CLK_OPS_PARENT_ON is divided into > two patches for better review, their commit message is different. > patch 4 is adding support for clk_disable_unused() while patch 5 is for > clk_setrate/clk_reparent. > I could reform the subject if needed. > > Regards > Dong Aisheng > Hi Mike & Stephen, Any comments about this? Regards Dong Aisheng > > -- > > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, > > a Linux Foundation Collaborative Project -- 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/