Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751940AbdFZDH5 (ORCPT ); Sun, 25 Jun 2017 23:07:57 -0400 Received: from mail-he1eur01on0085.outbound.protection.outlook.com ([104.47.0.85]:18499 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751525AbdFZDHs (ORCPT ); Sun, 25 Jun 2017 23:07:48 -0400 From: "A.s. Dong" To: Dong Aisheng , Stephen Boyd CC: "linux-clk@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "mturquette@baylibre.com" , "shawnguo@kernel.org" , "Anson Huang" , Jacky Bai Subject: RE: [PATCH 1/9] clk: clk-divider: add CLK_DIVIDER_ZERO_GATE clk support Thread-Topic: [PATCH 1/9] clk: clk-divider: add CLK_DIVIDER_ZERO_GATE clk support Thread-Index: AQHSzYN3F+RbVHbrJkqp4dYX0fhP6KItMq8AgAB7yYCACQke8A== Date: Mon, 26 Jun 2017 03:07:44 +0000 Message-ID: References: <1494856763-6543-1-git-send-email-aisheng.dong@nxp.com> <1494856763-6543-2-git-send-email-aisheng.dong@nxp.com> <20170620014512.GL4493@codeaurora.org> <20170620090815.GA6805@b29396-OptiPlex-7040> In-Reply-To: <20170620090815.GA6805@b29396-OptiPlex-7040> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=nxp.com; x-originating-ip: [199.59.231.64] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;AM3PR04MB1315;7:Wi02kKM6NhrDDrfpLugN2NCFRzpdBWJ8o/F3zE3yygPMAZt/gw4pq48ftSthOrF3ex3SRjwpdbqSVdnU4jfxAQ/c/kv3ffc+6zQMo71thPu6bpS2J8x7EHeEakE7M6esK1T70LpRV03QNNTychCH1deAUtfauAKFm+oK2njVmvtRMZrgMJJHvFZS+Axq+gykTenkUYBDdTqm24eYJRWwclcd34vY3guP5R/rY8nikKcl06AzxUOCMMnD+dSWz4JKXkgpuZ0lPtZjtxLIxBUuruNLKPEPEUuJejB/kxKOC7EUC7h4ScPWHE9MHtBnX5x6yEz6LolcZjK87wRE1f54/Kp1mSjmn/Hdim33+qydrYl0+Deat9F46sshqnJhPGo5HYUWIQ83X4vWl8DbLpWFpG3N5rSdTd0HNDsqWuL9qZZ9XlYMZ7oMpYhUCEA4+1yWcFs1wjLixRFyNG+Hj/VhjnXsz+Dy+FxxIJd92DmGQk7fKCAICDrOypkmDadN9aT7Epyf6l47CPtZ33gGWo9I8e47lmCuSi95hZTjhHH8aEagz8XOSBWD7XOCoiiWM5V2HKTouiqI/MO2QvCxs9yMR/MUXv+qfVPODMM4JxuQTBMQysbmsconMQ7/JNNPza+J+sXdeDGMN0UiTNX4RTBcc9OVl8D6r3CqzYCSZ5+9g4c0kW05ieR2XVW3/giVyBaHaLiR42jxGc+/FV/7EuMUMcX3qA7RzApA9irqFMRtN2gGgjRDcttLLpnenZw+Lp32UrPuPw2Qj2TtdzQPNpr/i8UVb+imCKSYun/E1XLDKgQ= x-forefront-antispam-report: SFV:SKI;SCL:-1SFV:NSPM;SFS:(10009020)(6009001)(39840400002)(39860400002)(39410400002)(39450400003)(39400400002)(39850400002)(377454003)(199003)(13464003)(24454002)(189002)(5250100002)(4326008)(3280700002)(3660700001)(74316002)(189998001)(6506006)(2906002)(478600001)(6436002)(14454004)(66066001)(25786009)(76176999)(5660300001)(50986999)(229853002)(2950100002)(86362001)(966005)(93886004)(9686003)(6246003)(53936002)(54906002)(6116002)(3846002)(102836003)(7736002)(38730400002)(7696004)(53546010)(6306002)(39060400002)(54356999)(8936002)(55016002)(33656002)(81166006)(99286003)(8676002)(305945005)(2900100001)(422495003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM3PR04MB1315;H:AM3PR04MB306.eurprd04.prod.outlook.com;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;A:1;MX:1;LANG:en; x-ms-office365-filtering-correlation-id: 5c96b015-6b85-497c-9d03-08d4bc4083f5 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254075)(300000503095)(300135400095)(48565401081)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506067)(300135500095);SRVR:AM3PR04MB1315; x-ms-traffictypediagnostic: AM3PR04MB1315: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(133145235818549)(236129657087228)(9452136761055)(258649278758335)(247924648384137); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123555025)(20161123564025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:AM3PR04MB1315;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:AM3PR04MB1315; x-forefront-prvs: 0350D7A55D spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Jun 2017 03:07:44.1431 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR04MB1315 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v5Q38QG4020422 Content-Length: 3596 Lines: 100 Hi Stephen, > -----Original Message----- > From: Dong Aisheng [mailto:dongas86@gmail.com] > Sent: Tuesday, June 20, 2017 5:08 PM > To: Stephen Boyd > Cc: A.s. Dong; linux-clk@vger.kernel.org; linux-kernel@vger.kernel.org; > linux-arm-kernel@lists.infradead.org; mturquette@baylibre.com; > shawnguo@kernel.org; Anson Huang; Jacky Bai > Subject: Re: [PATCH 1/9] clk: clk-divider: add CLK_DIVIDER_ZERO_GATE clk > support > > Hi Stephen, > > On Mon, Jun 19, 2017 at 06:45:12PM -0700, Stephen Boyd wrote: > > On 05/15, Dong Aisheng wrote: > > > --- > > > drivers/clk/clk-divider.c | 2 ++ > > > include/linux/clk-provider.h | 4 ++++ > > > 2 files changed, 6 insertions(+) > > > > > > diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c > > > index 96386ff..f78ba7a 100644 > > > --- a/drivers/clk/clk-divider.c > > > +++ b/drivers/clk/clk-divider.c > > > @@ -125,6 +125,8 @@ unsigned long divider_recalc_rate(struct clk_hw > > > *hw, unsigned long parent_rate, > > > > > > div = _get_div(table, val, flags, divider->width); > > > if (!div) { > > > + if (flags & CLK_DIVIDER_ZERO_GATE) > > > + return 0; > > > WARN(!(flags & CLK_DIVIDER_ALLOW_ZERO), > > > > Why not use the CLK_DIVIDER_ALLOW_ZERO flag? A clk being off doesn't > > mean the rate is 0. The divider is just disabled, so we would consider > > the rate as whatever the parent is, which is what this code does > > before this patch. Similarly, we don't do anything about gate clocks > > and return a rate of 0 when they're disabled. > > > > The semantic of CLK_DIVIDER_ALLOW_ZERO seems a bit different. > > See below definition: > * CLK_DIVIDER_ALLOW_ZERO - Allow zero divisors. For dividers which have > * CLK_DIVIDER_ONE_BASED set, it is possible to end up with a zero > divisor. > * Some hardware implementations gracefully handle this case and allow > a > * zero divisor by not modifying their input clock > * (divide by one / bypass). > > zero divisor is simply as divide by one or bypass which is supported by > hardware. > > But it's not true for this hardware. > > If we consider the rate as whatever the parent is if divider is zero, we > may got an issue like below: > e.g. > Assuming spll_bus_clk divider is 0x0 and it may be enabled by users > directly without setting a rate first. > > Then the clock tree looks like: > ... > spll_pfd0 1 1 500210526 0 0 > spll_pfd_sel 1 1 500210526 0 0 > spll_sel 1 1 500210526 0 0 > spll_bus_clk 1 1 500210526 0 0 > > But the spll_bus_clk clock rate actually is wrong and it's even not > enabled, not like CLK_DIVIDER_ALLOW_ZERO which zero divider means simply > bypass. > > So for this case, we probably can't simply assume zero divider rate as its > parent, it is actually set to 0 in hw, although it's something like gate, > but a bit different from gate as the normal gate does not affect divider > where you can keep the rate. > > How would you suggest for this? > Any suggestions? Regards Dong Aisheng > Regards > Dong Aisheng > > > > "%s: Zero divisor and CLK_DIVIDER_ALLOW_ZERO not set\n", > > > clk_hw_get_name(hw)); > > > > -- > > 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-clk" > > in the body of a message to majordomo@vger.kernel.org More majordomo > > info at http://vger.kernel.org/majordomo-info.html