From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BC6FC43381 for ; Tue, 19 Mar 2019 10:19:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DEDB520828 for ; Tue, 19 Mar 2019 10:19:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726703AbfCSKTM (ORCPT ); Tue, 19 Mar 2019 06:19:12 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:35185 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726573AbfCSKTM (ORCPT ); Tue, 19 Mar 2019 06:19:12 -0400 Received: from litschi.hi.pengutronix.de ([2001:67c:670:100:feaa:14ff:fe6a:8db5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1h6Bps-0005UV-El; Tue, 19 Mar 2019 11:19:08 +0100 Date: Tue, 19 Mar 2019 11:19:07 +0100 From: Michael Tretter To: Jolly Shah Cc: Stephen Boyd , "linux-arm-kernel@lists.infradead.org" , "linux-clk@vger.kernel.org" , "kernel@pengutronix.de" , Michael Turquette , Michal Simek Subject: Re: [PATCH 1/5] clk: zynqmp: fix check for fractional clock Message-ID: <20190319111907.753f7820@litschi.hi.pengutronix.de> In-Reply-To: References: <20190312110016.29174-1-m.tretter@pengutronix.de> <20190312110016.29174-2-m.tretter@pengutronix.de> <155240936160.20095.7716704029189456788@swboyd.mtv.corp.google.com> <20190312182546.24e46c5c@litschi.hi.pengutronix.de> <155249424471.20095.16028115604342624987@swboyd.mtv.corp.google.com> <20190314093836.6a70abc7@litschi.hi.pengutronix.de> Organization: Pengutronix X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2001:67c:670:100:feaa:14ff:fe6a:8db5 X-SA-Exim-Mail-From: m.tretter@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-clk@vger.kernel.org Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org On Tue, 19 Mar 2019 00:56:31 +0000, Jolly Shah wrote: > > -----Original Message----- > > From: Michael Tretter > > Sent: Thursday, March 14, 2019 1:39 AM > > To: Stephen Boyd > > Cc: linux-arm-kernel@lists.infradead.org; linux-clk@vger.kernel.org; > > kernel@pengutronix.de; Michael Turquette ; > > Michal Simek ; Jolly Shah > > Subject: Re: [PATCH 1/5] clk: zynqmp: fix check for fractional clock > > > > On Wed, 13 Mar 2019 09:24:04 -0700, Stephen Boyd wrote: > > > Quoting Michael Tretter (2019-03-12 10:25:46) > > > > On Tue, 12 Mar 2019 09:49:21 -0700, Stephen Boyd wrote: > > > > > Quoting Michael Tretter (2019-03-12 04:00:12) > > > > > > CLK_FRAC is not set in the divider->flags, but in the hw->flags. > > > > > > > > > > > > The firmware sets CLK_FRAC for fractional clocks in the clkflag field. > > > > > > When registering the devider, these clkflags are copied to hw->flags. > > > > > > > > > > > > Moreover, divider->flags field is a u8 type, but CLK_FRAG is BIT(13). So > > > > > > this check would never work. > > > > > > > > > > > > Signed-off-by: Michael Tretter > > > > > > --- > > > > > > drivers/clk/zynqmp/divider.c | 2 +- > > > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > > > > > diff --git a/drivers/clk/zynqmp/divider.c b/drivers/clk/zynqmp/divider.c > > > > > > index a371c66e72ef..fc70950c1e24 100644 > > > > > > --- a/drivers/clk/zynqmp/divider.c > > > > > > +++ b/drivers/clk/zynqmp/divider.c > > > > > > @@ -117,7 +117,7 @@ static long > > zynqmp_clk_divider_round_rate(struct clk_hw *hw, > > > > > > bestdiv = zynqmp_divider_get_val(*prate, rate); > > > > > > > > > > > > if ((clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) && > > > > > > - (divider->flags & CLK_FRAC)) > > > > > > + (clk_hw_get_flags(hw) & CLK_FRAC)) > > > > > > > > > > CLK_FRAC shouldn't be set in the struct clk_hw::core::flags field. It's > > > > > not a clk framework flag so it shouldn't go there. Please fix the user > > > > > of this flag to place the CLK_FRAC flag somewhere else. Even adding it > > > > > into divider::flags is not a good idea because that numberspace is for > > > > > dividers, and this flag seems to be zynqmp driver specific, so maybe > > > > > just add a bool to the zynqmp_clk_divider? > > > > > > > > > > > > > Thanks. The driver sets the clk_hw::core::flags based on a response > > > > from the ATF and this response includes this flag with other clk > > > > frameworks flags. I can test for the flag when registering the clock > > > > and set another flag or a bool for the zynqmp_clk_divider and will do > > > > so in v2. > > > > > > Cool. Thanks! > > > > > > > > > > > However, this merely sounds like a workaround for an issue in the ATF, > > > > which should not define and use this flag in the first place. > > > > > > > > > > What is ATF doing with these flags? Hopefully ATF and the Linux kernel > > > aren't using the same numberspace to describe these things. For example, > > > I would be concerned if ATF was looking at the CLK_SET_RATE_PARENT flag > > > and passing that value from firmware to the kernel, blindly assuming > > > that the kernel wouldn't change those numbers to be something else. > > > Obviously that type of kernel change would be invasive but it's not an > > > ABI that we've ever published so we're free to do these sorts of things. > > > > You mean that the ATF defines macros like > > > > #define CLK_SET_RATE_GATE BIT(0) /* must be gated across rate > > change */ > > #define CLK_SET_PARENT_GATE BIT(1) /* must be gated across re- > > parent */ > > #define CLK_SET_RATE_PARENT BIT(2) /* propagate rate change up > > one level */ > > > > in plat/xilinx/zynqmp/pm_service/pm_api_clock.h, sets the flags in the > > response to the Linux driver, and the Linux driver copies the flags > > that it got from the ATF to clk_hw::core::flags like > > > > init.flags = nodes->flag; > > > > where nodes is the response from the ATF? That's exactly what is happening. > > > > So instead of only translating CLK_FRAC, the driver should actually > > translate all flags in the ATF response to proper clk framework flags > > instead of blindly copying them, right? > > Except CLK_FRAC, all flags are defined same as clk framework. I think > we should add custom flags field and pass zynqmp specific flags there. Using the same flags in the ATF and the common clk framework works now, because they have the same value. However, the flags are not actually the same, because the flags that the driver gets from the ATF are defined in the ATF and the flags that the driver passes to the common clk framework are defined in the common clk framework. If the flags in the common clk framework are changed (which is admittedly unlikely), the ZynqMP clock driver will break, because it still assumes that the common clk framework uses the same flags as defined in the ATF. Therefore, the driver should actually decouple the flags by defining its own flags that correspond to the flags as defined by the ATF (i.e. platform specific flags) and convert these flags into flags for the common clk framework when registering the clocks. The problem is that two things that have the same value are not necessarily the same thing. Michael > > Thanks, > Jolly Shah > > > > > Michael > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DDCFC43381 for ; Tue, 19 Mar 2019 10:19:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2E29520828 for ; Tue, 19 Mar 2019 10:19:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NASvufDb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E29520828 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hPrt54InxTJJXlbad1Vrg61/Ymb5wm0yqpOlfSzmpzg=; b=NASvufDb00NK8C m+05ZNLdaJAWdRokrYBjYtGcaFm2cNNDhHeZ0evte6wXcn1NdoswYUq2rM+yRsU2Eh29FBilxfnZc WoQ3ipzqY6LMOuX1oFkZDs4LedWueXyKSKKWEq6x3mkhWgax6GbOsb5Bz+wRu6e3JPVITYlLWcZyo hUI1PRWTZ+Mg+c4O+oMmfLNLweedzBMCkazv43eR484bStLgtUNGmEBZES2w4V+GLzrlHsimWyr85 3r97wkUFknTrjoES0cBLRufJsdwQSdlaMtdvnFBDUegRdqUy/bR3ttx9rjpH2iQjd5iAutwka3+K/ 4e+61KkmcW4G5myalNSg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6Bq4-0003AL-Qk; Tue, 19 Mar 2019 10:19:20 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6Bpx-00030q-R9 for linux-arm-kernel@lists.infradead.org; Tue, 19 Mar 2019 10:19:16 +0000 Received: from litschi.hi.pengutronix.de ([2001:67c:670:100:feaa:14ff:fe6a:8db5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1h6Bps-0005UV-El; Tue, 19 Mar 2019 11:19:08 +0100 Date: Tue, 19 Mar 2019 11:19:07 +0100 From: Michael Tretter To: Jolly Shah Subject: Re: [PATCH 1/5] clk: zynqmp: fix check for fractional clock Message-ID: <20190319111907.753f7820@litschi.hi.pengutronix.de> In-Reply-To: References: <20190312110016.29174-1-m.tretter@pengutronix.de> <20190312110016.29174-2-m.tretter@pengutronix.de> <155240936160.20095.7716704029189456788@swboyd.mtv.corp.google.com> <20190312182546.24e46c5c@litschi.hi.pengutronix.de> <155249424471.20095.16028115604342624987@swboyd.mtv.corp.google.com> <20190314093836.6a70abc7@litschi.hi.pengutronix.de> Organization: Pengutronix X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:feaa:14ff:fe6a:8db5 X-SA-Exim-Mail-From: m.tretter@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190319_031914_069106_1EF83220 X-CRM114-Status: GOOD ( 40.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stephen Boyd , Michael Turquette , Michal Simek , "kernel@pengutronix.de" , "linux-clk@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 19 Mar 2019 00:56:31 +0000, Jolly Shah wrote: > > -----Original Message----- > > From: Michael Tretter > > Sent: Thursday, March 14, 2019 1:39 AM > > To: Stephen Boyd > > Cc: linux-arm-kernel@lists.infradead.org; linux-clk@vger.kernel.org; > > kernel@pengutronix.de; Michael Turquette ; > > Michal Simek ; Jolly Shah > > Subject: Re: [PATCH 1/5] clk: zynqmp: fix check for fractional clock > > > > On Wed, 13 Mar 2019 09:24:04 -0700, Stephen Boyd wrote: > > > Quoting Michael Tretter (2019-03-12 10:25:46) > > > > On Tue, 12 Mar 2019 09:49:21 -0700, Stephen Boyd wrote: > > > > > Quoting Michael Tretter (2019-03-12 04:00:12) > > > > > > CLK_FRAC is not set in the divider->flags, but in the hw->flags. > > > > > > > > > > > > The firmware sets CLK_FRAC for fractional clocks in the clkflag field. > > > > > > When registering the devider, these clkflags are copied to hw->flags. > > > > > > > > > > > > Moreover, divider->flags field is a u8 type, but CLK_FRAG is BIT(13). So > > > > > > this check would never work. > > > > > > > > > > > > Signed-off-by: Michael Tretter > > > > > > --- > > > > > > drivers/clk/zynqmp/divider.c | 2 +- > > > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > > > > > diff --git a/drivers/clk/zynqmp/divider.c b/drivers/clk/zynqmp/divider.c > > > > > > index a371c66e72ef..fc70950c1e24 100644 > > > > > > --- a/drivers/clk/zynqmp/divider.c > > > > > > +++ b/drivers/clk/zynqmp/divider.c > > > > > > @@ -117,7 +117,7 @@ static long > > zynqmp_clk_divider_round_rate(struct clk_hw *hw, > > > > > > bestdiv = zynqmp_divider_get_val(*prate, rate); > > > > > > > > > > > > if ((clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) && > > > > > > - (divider->flags & CLK_FRAC)) > > > > > > + (clk_hw_get_flags(hw) & CLK_FRAC)) > > > > > > > > > > CLK_FRAC shouldn't be set in the struct clk_hw::core::flags field. It's > > > > > not a clk framework flag so it shouldn't go there. Please fix the user > > > > > of this flag to place the CLK_FRAC flag somewhere else. Even adding it > > > > > into divider::flags is not a good idea because that numberspace is for > > > > > dividers, and this flag seems to be zynqmp driver specific, so maybe > > > > > just add a bool to the zynqmp_clk_divider? > > > > > > > > > > > > > Thanks. The driver sets the clk_hw::core::flags based on a response > > > > from the ATF and this response includes this flag with other clk > > > > frameworks flags. I can test for the flag when registering the clock > > > > and set another flag or a bool for the zynqmp_clk_divider and will do > > > > so in v2. > > > > > > Cool. Thanks! > > > > > > > > > > > However, this merely sounds like a workaround for an issue in the ATF, > > > > which should not define and use this flag in the first place. > > > > > > > > > > What is ATF doing with these flags? Hopefully ATF and the Linux kernel > > > aren't using the same numberspace to describe these things. For example, > > > I would be concerned if ATF was looking at the CLK_SET_RATE_PARENT flag > > > and passing that value from firmware to the kernel, blindly assuming > > > that the kernel wouldn't change those numbers to be something else. > > > Obviously that type of kernel change would be invasive but it's not an > > > ABI that we've ever published so we're free to do these sorts of things. > > > > You mean that the ATF defines macros like > > > > #define CLK_SET_RATE_GATE BIT(0) /* must be gated across rate > > change */ > > #define CLK_SET_PARENT_GATE BIT(1) /* must be gated across re- > > parent */ > > #define CLK_SET_RATE_PARENT BIT(2) /* propagate rate change up > > one level */ > > > > in plat/xilinx/zynqmp/pm_service/pm_api_clock.h, sets the flags in the > > response to the Linux driver, and the Linux driver copies the flags > > that it got from the ATF to clk_hw::core::flags like > > > > init.flags = nodes->flag; > > > > where nodes is the response from the ATF? That's exactly what is happening. > > > > So instead of only translating CLK_FRAC, the driver should actually > > translate all flags in the ATF response to proper clk framework flags > > instead of blindly copying them, right? > > Except CLK_FRAC, all flags are defined same as clk framework. I think > we should add custom flags field and pass zynqmp specific flags there. Using the same flags in the ATF and the common clk framework works now, because they have the same value. However, the flags are not actually the same, because the flags that the driver gets from the ATF are defined in the ATF and the flags that the driver passes to the common clk framework are defined in the common clk framework. If the flags in the common clk framework are changed (which is admittedly unlikely), the ZynqMP clock driver will break, because it still assumes that the common clk framework uses the same flags as defined in the ATF. Therefore, the driver should actually decouple the flags by defining its own flags that correspond to the flags as defined by the ATF (i.e. platform specific flags) and convert these flags into flags for the common clk framework when registering the clocks. The problem is that two things that have the same value are not necessarily the same thing. Michael > > Thanks, > Jolly Shah > > > > > Michael > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel