Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755184AbbHQM4Q (ORCPT ); Mon, 17 Aug 2015 08:56:16 -0400 Received: from mail-by2on0131.outbound.protection.outlook.com ([207.46.100.131]:37280 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751673AbbHQM4N (ORCPT ); Mon, 17 Aug 2015 08:56:13 -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: Mon, 17 Aug 2015 20:45:18 +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: <20150817124514.GA30536@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> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20150814010109.GW26614@codeaurora.org> User-Agent: Mutt/1.5.20 (2009-06-14) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD055;1:5uOi2f5kIh7BWTe+8T9aqbKKRumBIBuENVjEsslj5QpuItO7Tc2ykhiownI/L/OoEUKnmXIicc34O7XfDk2Qa/qiw9YmgWElUgHPj6zVoV2HvDVBA/AC3Rguw41H2aRZ6+pkS8TUsLh/9xzSjlAqUzPEkEpreB9HBm9wjCv0jhfjW/OlQKD6D7b1B/3WP5PJ+P8nR9gXB433DL0NYjH83u602uPnzoLZlzUQyAYG5wK1tPmY5ZucsKZkTVdRhdR3lhrcOBiLNVHyLwBhyh9tVQY6WXzC4g/anV3GWO091kst8Q1vEikVF0XF/g/TJ6PeJe09+eO6hfFUlVWq7z7xQ2DzwB5GY52Af4sJloUdjhLWuZtqVbLdFtkkTNqGq+vyt4apwyCulRxuceLi8ZLWZg== 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)(76176999)(105606002)(5003600100002)(69596002)(5001960100002)(4001540100001)(97736004)(85426001)(92566002)(81156007)(97756001)(106466001)(5001830100001)(4001350100001)(5001860100001)(19580405001)(46406003)(50986999)(19580395003)(6806004)(54356999)(2950100001)(68736005)(77096005)(46102003)(189998001)(104016003)(87936001)(50466002)(77156002)(83506001)(110136002)(23726002)(107886002)(33656002)(62966003)(47776003)(64706001)(86362001)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY1PR0301MB1207;H:az84smr01.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1207;2:VG+7bJ8H/rCj6NOSogpscvkFdF/Cslk3cLVXeO1aK83dfv9cHtGH/It7vuJj7jVA2i+vTB13W30c3IiSqNLBICAMAzQYlI/NkOL/odhJHaOh/e4PquTIYoEqan5FNuMbrAFPoEbTXsqxs80RdDm/VDbMXjSNWp1X8iKPtjUbifM=;3:elPxbsCRKdDhNB4km6UdMWnlwgdKXWceWLJ+5DCa8ChWABSNcS8Qf7jM+C+C38wndiXXX9FtrvQwix74QysnuxtWo4isA0LyBsOiFuIXfekMwEtXqk0xDInEVNTLvlqM4iX3Jk8nG1HIfSg2FB6j9phD+Gg39/CRsVVXJ0B/SN4LWqlhlEuhrm+jnrikxXHKh6Ky0g9cwqlJYvMEXRJaXyj1pD3aQWk7Uw2s/mAqkKg=;25:ytg0i53Z3PE1tylYRNImXQA6V6kL99AFc8d614hnqZITDplJ+4bl0nL4zKJOYg1bmp8Nhvp2kzAdUHbmUq+a8pq0/PPADQRFQ46F/uan/rHsRsJLt2QUEM5iFitmdjtL6Yvpob9K/Ybqikmf4EhWNNQ34qNpYpqeiyYXuy1huXcimhHZdeAmwnY5bv2D2sVXRhzZOlmAbhSsDyDxkc8+zQ5UgVJzWHS0qn0Ay/jS4xN70ZVcmjvgiNWk/jNWCeUnLjXyoamElV9aBZcApNRTFw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0301MB1207;UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0301MB1318; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1207;20:73/qvgizJUkNlzX3+Nqafo3KAU0LrfcrdIYDxVqb4/PA4Rk5fh2MW6UQPmbrUSSe23Xv6sRGjJ/1U02BeCfLAyeCXj1HUOXxmMIG39sMmvGumrL5/L6WUiQsRTaH35CZYLnrn1d6C+J9Ja4Qta1brTIaNZwXukf7Gl99E79s+k3HYnojZ7zznQVDZDhYce+llrQHOYQwb30/3kUmjC5t4nP7UiPTh6S3HFktUMjMJxkSEL6kdjuzLdH7WKPTu9rJTZ9K5H9gL5soH7lfHl1RLmql3Nhs1oKp+kvNwY0LnKQvgqPsvqwPEzminzfTkBHOjHWapUxAi/JZEF+1NdUnsNN5wfi6ZW6OGDxFRAioEAw=;4:gAEeTnotPiYhHZPMdNqdWhCmcT3kdoMsv+UkzZNtwltiDiXZSvTpVAiwaF7YJEcg635Jxt1MEiY/VmgSlY1uC9kZpwJve8e4q8/SxMCbUBEbl2JQrGm5PZTS7FGeKr2DpevHI/SGgZZTu6TiCkPZMRho070kAzhKPCyRqTmJmZsOp2Pedn/Ar4nBJ9lPFW6QIGaGvcQqitGd5yu7sZ9+q1JyJ2+TavnuLuN2x6pXEB6vQY0dc7Uji1qClvQiCAYdHaewudMvjedQKhS6X6Jgxjs+QBTByynGU/Bx6UAHQpX1Dbaf3uDuu/9WIdCIGrg0U8tinLlls00/OGXT/3XbaA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(8121501046)(3002001);SRVR:BY1PR0301MB1207;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0301MB1207; X-Forefront-PRVS: 0671F32598 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0301MB1207;23:oj9wVXILtXUTrrXp4iPrXFvdkh/3AfwO36aMtdb?= =?us-ascii?Q?enzJB+c345AxcGn3vVPgX4D18OcUcAzPhuS8FSM8lizoLEqCsAnCzfvoobCh?= =?us-ascii?Q?sXOX26Z/dChQootZVD0iqgmTm6bY+FT2w1CMEtCMc/ulT2UnORbOk61JzYRy?= =?us-ascii?Q?WUc/nJOLHz4b+j3l0dcYukgRsBqCnf+rLICF7CJXpXMmezd5juv9UJOjK1iT?= =?us-ascii?Q?TIIeguYZtvOxBjtLqPr1Fu+my2FX1A7ruOVjwbOwDdOvXJcwz/NhDxmoaB5U?= =?us-ascii?Q?/By9DgnIcS6bNTP+GlZ6OucWTPl5rNfUvqeD0r5GVL53L4o7e2t//LhTx31W?= =?us-ascii?Q?+kMg78uWD5Jm7CzMbIxRrN4ibWhWgkdhPg4pdkrAkCRZkL3PKMYPDDqWqp9g?= =?us-ascii?Q?TmuaimsZ6L+70pBJ870oHlyQ2wUo3xXgUxguvO6fgyplL+zUffXOW2Gzc4d8?= =?us-ascii?Q?8NNlIMLo14MtMJLb0g70wJgq6b24bT+UBs4hB3ikbRSARzCUhWDDkuukrYlS?= =?us-ascii?Q?8arxHJ5okp0HtXhDnxNfOgHiVq7Ae4/tgvgBXWNNekH59EJk9t7dF0ZVGrvu?= =?us-ascii?Q?H9fSsE+5llh6kh2PwaBb13etdrsEplWvU7fNvtP7aKJp+2BWF9IyDPz3ZoLi?= =?us-ascii?Q?i5G9xBjcNu1njpL4lYPvUquUoWZXFveUJ9CNj+FN0GfI6ECoCxvbt/AEGnqk?= =?us-ascii?Q?LGLAOxTIh99O5aqECtxqV7/5PQUFksImuCICzdZ3wllPkUNDRcC/0vbs91lW?= =?us-ascii?Q?c3AkviDXn2eoHyWwBDqXnzS0VctTVd1pyTdm2SnsWKgPI81P2T4CX2qWpTyZ?= =?us-ascii?Q?+EAU37gS21ms6/wTHCj+ZBz2IRcbQ4Bk/6BsKQwYDB2p01ZuNr0r8QWNDWUN?= =?us-ascii?Q?3CcHLBG8v0JwiA1MfgaBb7hNIJtcw9TwEmvuQ+W9Kl+LCuPv6CFPEVWrrm5I?= =?us-ascii?Q?xyRHZvCtbQm09d71mBiq/FQE5WO8Ho9D4CY1CfhLu98SX5Ku6UobefXgboes?= =?us-ascii?Q?efnqHX8eNq4M/7+X2XwfTmXrVLGirSTn+kol3Up6flqec1SjaklyG6YsziQc?= =?us-ascii?Q?20cqPt1HZG2+C6TDtKkxxKMPxmvbnfQovnDA826unSO4RGIBvMKbcHTBuM42?= =?us-ascii?Q?AbhDaxCAwvYBMsG0IAWwjimz3n9HI/BetVX5HIlQcDCbqIVJ/cH8AtypvvKu?= =?us-ascii?Q?JbtNnBlbVxJQqQkHG26hjMtlBsm8crYA9e63rhjBgksclddjlTwy6s2fQqOF?= =?us-ascii?Q?J2z5zE7SOIEnBh4SlwWCNzeC0UUf6IojpegGOquPb?= X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1207;5:FreMUm2G2dP+2pwnLUM4mSmKFvJHPN2NmEM4vk6LTSc2QMH05pnkX3ROLqxNxLGVQWz6Rk69HVQ6F9T2bxBSeKCXj5ZgViIhdYQ7hHE8MVFebVUw04Duzj8BFU76SynVrK+VqQ8xQduVytZbh7Us9A==;24:QB33fcKopjziV8ZLLYudJOEtJxRJRLz8rMGh+/+UQakXNRTbbdd6YWn/C2CAN8aYAwpb9OYZduaDggjd9InmPMu3Ud5UZ77j+6kjb87TEdY=;20:MvmMb9T6Cs3K7Xv1f/1CMT76qFUht48eVM8RkKaTS+ui2RFIhu6A503Vlwb2VUNFUd1dbeJgQ6lihLOBMizTCQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2015 12:55:59.0232 (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: BY1PR0301MB1207 X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1318;2:MkEfYVwlcIL8bBOi3DL7SoaIKMBxOU330tG7apl8mfyikYzavg8h7GTDv2OvtfCuZqgkuTYgjZZfBbgQ1b+2Gbz3xvUrXD/31Ro3jZoNXYndZ4HqzK20SvknTsvqQC4uSmT2wrTkHpFJeLnQKkfEaOEX1+2ltdLFigpsbRy40zg=;3:UbVXaa2AqR/YdeuqOOY1CRNwYA6KcMuHPyt+EydPkCC0alPBmtH1eA0VJJlNEsMZmQRqV8e58Cj1TRAcSO/heKetYAd/EuIbDpA4O1838JiwcYEVlV0XRCeOmkgwqnmepSe/88iqkFSxEZ3o7uEnyyEDvYg8ufU+v4gbNHj1g6AqZKTPxiGyXCEeiKLmOXrLL0kvfOFRHwlPFeFdpvENBxb0ADt/w7UuC5XuNkJ3R8g=;25:twsO3vQCgWv7Bz6S/En6W7jpaFHer5w8x0+AKg+DQptAuCwZ4blqUYarvmmLwm/Iyyzt0fuHoQlZs6Ri03/konm9jWYra4PegNMzvMIrN0Lq+2gkg3M0AW/GkOyAic+j0bRFcBHz5eIa4SYim9gzWhHAuFmwS12SpXvrLy6vmG2PDj+98z6Lv8AUQgXKYfruoMwpvC+4NR48pW6N7WDCj1rcr/Y2cYkhAJuJIikqHc5D3BZxyN/inoBzhmBv6mF+VgW4P/OUzbwndry3pi0ktA==;23:Toeb+JcpWPGCuUSmuxvHGJb5tSzi2RAw3kAoS0aHV1WcbXk7dLThMiPJjmEHn/kOXp5ar8bpmzv8HEaCcd7yhqasIQzCJ3HU6RkeIpuNOd23a/XRWZ2ZWsEC09JW+6xi4wZ+slKMt+eKGOjG/bszHK0Tjhyn8vGSIuMNl1Nj5Tre0NQ3ljGJayJYu1ebt4N+ X-OriginatorOrg: freescale.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6050 Lines: 137 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 > -- > 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/