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 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6DD13C4332F for ; Mon, 14 Nov 2022 08:56:40 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 96E171630; Mon, 14 Nov 2022 09:55:48 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 96E171630 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1668416198; bh=biZhgwn0BDv2SGfl/SETWF0oFZVJvXDkr1FCxZH6sTg=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=El3N5qNGhAkvdtYJR+HXLgxci/8XyUWE/X54JwlHkvqA0KOFLOR19tpfeMvrHRfnu AbaKhI2x58FBJ81OYw7t62WH8nhmMp7OcMXp/zPmCpe9SUt9owv25myk4EnPFHCOql DLdVK4B5tjxtR/zG5D51SmLmU7MC2ZMmrvQD7F6I= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 45E99F80549; Mon, 14 Nov 2022 09:55:48 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 51B18F8030F; Sun, 13 Nov 2022 23:35:59 +0100 (CET) Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2DECEF80085 for ; Sun, 13 Nov 2022 23:35:52 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2DECEF80085 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cxos6M6S" Received: by mail-qt1-x833.google.com with SMTP id l15so5919842qtv.4 for ; Sun, 13 Nov 2022 14:35:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2UWIwxNMt9Li5DI9V3Ue/+A2ETbpfwK4uJjlNth28Ps=; b=cxos6M6SEMWjz70hcYfwJn7Qy9x3ScQZdWjcWHcTUuPDd6QIkxHfs4TdC7er0cgTfw Zecl1ammtXTh3CRumNopuCdrO/B9HdufOATVFx7LmHWfcuepu8nGRPAXZimVwU33NdJY fSpdh/6V9x/8s+acnZlcPXnCq3SzIgJYAOJ+MdHag7DONXMIur05Qu2T29C+PPj+G5FS 51vaHNJTqtvQKEh0MKIsH8wIeeMtk/77Zn6zHSFYDKwwTYJrTvxOcJz1pI56sykta8ez ucf+QXApfLU7u3dxQYz1YwJFVAwCWBLrNvZsrMdMSVYHA3yVHW95iD4uAWPO1ebw8AQZ l5aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2UWIwxNMt9Li5DI9V3Ue/+A2ETbpfwK4uJjlNth28Ps=; b=KgkodQcyA1T98pOk+PM3Bto81AoioSz61MiiMybHwvd4ugeIY4sWTD/poDVGcMihyI kGcEPcvZGs7Wm/O/mC94+t9wbY7HIdA9A6vgwZI3ZFWmxYV5iRLNJhDsW7Q0ucAtPZut C74nlKyvDPoftstwwYYyT6S3XzTLNsRVhNis1Baz7LjPYodzSX2UQvdOAXU6X0Gy3oGy D44q/sbSaV/vylc2EJxSSCZ+LsmIwIUSpDXXWxaiXJWeFlm4Z4ThhmLffOs8v769N4Pt Ttg36L/XUVZVpvMj+ls9x00YtKahxyNmz+XbJf1VCZvAt4DuOVxE3oEA6g1AsQUyC+cu DwgA== X-Gm-Message-State: ANoB5pkjxqxzTxn241PUWwiu3nhrE8Zm/KjlY0aEd5lMEK7Tae+oqy8F +RhU8fm5AayB2ZX+GGTHM6M= X-Google-Smtp-Source: AA0mqf6n/LTjELlMgOPAUHKCZj998ajlsJmr6FJtHheLBD4DRKv0w+DZx/+jLTxZzLzeUXXjccj7Rg== X-Received: by 2002:a05:622a:4806:b0:3a4:f140:f707 with SMTP id fb6-20020a05622a480600b003a4f140f707mr10057169qtb.317.1668378951056; Sun, 13 Nov 2022 14:35:51 -0800 (PST) Received: from shaak (modemcable055.92-163-184.mc.videotron.ca. [184.163.92.55]) by smtp.gmail.com with ESMTPSA id bk8-20020a05620a1a0800b006f9f3c0c63csm5482646qkb.32.2022.11.13.14.35.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Nov 2022 14:35:50 -0800 (PST) Date: Sun, 13 Nov 2022 17:35:46 -0500 From: Liam Beguin To: Maxime Ripard Subject: Re: [PATCH v2 13/65] clk: lmk04832: clkout: Add a determine_rate hook Message-ID: References: <20221018-clk-range-checks-fixes-v2-0-f6736dec138e@cerno.tech> <20221018-clk-range-checks-fixes-v2-13-f6736dec138e@cerno.tech> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221018-clk-range-checks-fixes-v2-13-f6736dec138e@cerno.tech> X-Mailman-Approved-At: Mon, 14 Nov 2022 09:55:46 +0100 Cc: Ulf Hansson , Prashant Gaikwad , Alexandre Belloni , Liam Girdwood , Michael Turquette , Sekhar Nori , Alexandre Torgue , dri-devel@lists.freedesktop.org, Paul Cercueil , Max Filippov , Thierry Reding , linux-phy@lists.infradead.org, David Airlie , Fabio Estevam , linux-stm32@st-md-mailman.stormreply.com, Abel Vesa , Kishon Vijay Abraham I , Geert Uytterhoeven , Samuel Holland , Chunyan Zhang , Takashi Iwai , linux-tegra@vger.kernel.org, Jernej Skrabec , Jonathan Hunter , Chen-Yu Tsai , NXP Linux Team , Orson Zhai , linux-mips@vger.kernel.org, Luca Ceresoli , Linus Walleij , linux-rtc@vger.kernel.org, linux-clk@vger.kernel.org, Charles Keepax , Daniel Vetter , alsa-devel@alsa-project.org, Manivannan Sadhasivam , linux-kernel@vger.kernel.org, Sascha Hauer , linux-actions@lists.infradead.org, Richard Fitzgerald , Mark Brown , linux-mediatek@lists.infradead.org, Baolin Wang , Matthias Brugger , Pengutronix Kernel Team , linux-arm-kernel@lists.infradead.org, AngeloGioacchino Del Regno , Alessandro Zummo , linux-sunxi@lists.linux.dev, Stephen Boyd , patches@opensource.cirrus.com, Peter De Schrijver , Nicolas Ferre , Andreas =?iso-8859-1?Q?F=E4rber?= , linux-renesas-soc@vger.kernel.org, Dinh Nguyen , Vinod Koul , Maxime Coquelin , David Lechner , Shawn Guo , Claudiu Beznea X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Hi Maxime, On Fri, Nov 04, 2022 at 02:17:30PM +0100, Maxime Ripard wrote: > The LKM04832 "CLKOUT" clock implements a mux with a set_parent hook, but > doesn't provide a determine_rate implementation. > > This is a bit odd, since set_parent() is there to, as its name implies, > change the parent of a clock. However, the most likely candidate to > trigger that parent change is a call to clk_set_rate(), with > determine_rate() figuring out which parent is the best suited for a > given rate. > > The other trigger would be a call to clk_set_parent(), but it's far less > used, and it doesn't look like there's any obvious user for that clock. > > So, the set_parent hook is effectively unused, possibly because of an > oversight. However, it could also be an explicit decision by the > original author to avoid any reparenting but through an explicit call to > clk_set_parent(). This is correct, the set_parent hook is effectively unused at the moment. It was implemented as a way for consumers to select the parent themselves. The LMK04832 is used in JESD204 applications where devices need a device clock as well as a sysref clock. Since this is determined by the hardware layout, a devicetree option is used to select the inital state of the clkout mux. This is set at the end of lmk04832_register_clkout(). > The latter case would be equivalent to setting the flag > CLK_SET_RATE_NO_REPARENT, together with setting our determine_rate hook > to __clk_mux_determine_rate(). Indeed, if no determine_rate > implementation is provided, clk_round_rate() (through > clk_core_round_rate_nolock()) will call itself on the parent if > CLK_SET_RATE_PARENT is set, and will not change the clock rate > otherwise. __clk_mux_determine_rate() has the exact same behavior when > CLK_SET_RATE_NO_REPARENT is set. > > And if it was an oversight, then we are at least explicit about our > behavior now and it can be further refined down the line. > > Since the CLK_SET_RATE_NO_REPARENT flag was already set though, it seems > unlikely. > > Signed-off-by: Maxime Ripard Reviewed-by: Liam Beguin Cheers, Liam > --- > drivers/clk/clk-lmk04832.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/clk/clk-lmk04832.c b/drivers/clk/clk-lmk04832.c > index f416f8bc2898..f68bb0affdad 100644 > --- a/drivers/clk/clk-lmk04832.c > +++ b/drivers/clk/clk-lmk04832.c > @@ -1281,6 +1281,7 @@ static const struct clk_ops lmk04832_clkout_ops = { > .is_enabled = lmk04832_clkout_is_enabled, > .prepare = lmk04832_clkout_prepare, > .unprepare = lmk04832_clkout_unprepare, > + .determine_rate = __clk_mux_determine_rate, > .set_parent = lmk04832_clkout_set_parent, > .get_parent = lmk04832_clkout_get_parent, > }; > > -- > b4 0.11.0-dev-99e3a > 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BF23C43219 for ; Sun, 13 Nov 2022 22:35:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235524AbiKMWfy (ORCPT ); Sun, 13 Nov 2022 17:35:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235422AbiKMWfx (ORCPT ); Sun, 13 Nov 2022 17:35:53 -0500 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F39DEFAE8; Sun, 13 Nov 2022 14:35:51 -0800 (PST) Received: by mail-qt1-x834.google.com with SMTP id z6so5920259qtv.5; Sun, 13 Nov 2022 14:35:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2UWIwxNMt9Li5DI9V3Ue/+A2ETbpfwK4uJjlNth28Ps=; b=cxos6M6SEMWjz70hcYfwJn7Qy9x3ScQZdWjcWHcTUuPDd6QIkxHfs4TdC7er0cgTfw Zecl1ammtXTh3CRumNopuCdrO/B9HdufOATVFx7LmHWfcuepu8nGRPAXZimVwU33NdJY fSpdh/6V9x/8s+acnZlcPXnCq3SzIgJYAOJ+MdHag7DONXMIur05Qu2T29C+PPj+G5FS 51vaHNJTqtvQKEh0MKIsH8wIeeMtk/77Zn6zHSFYDKwwTYJrTvxOcJz1pI56sykta8ez ucf+QXApfLU7u3dxQYz1YwJFVAwCWBLrNvZsrMdMSVYHA3yVHW95iD4uAWPO1ebw8AQZ l5aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2UWIwxNMt9Li5DI9V3Ue/+A2ETbpfwK4uJjlNth28Ps=; b=SHRhf3ePzGWd2eW9o9v+lLAbpwPN7fWPliNSTLPdEJVI8OUpdhq+2LJvaqTPeCPqKz CrppKsATY3mnE6/gta6JICDXpkV9Y33NMBK9Ca7vs7N/+xKUbiS0ieC1HYcC0a//cVCP oNa9Z9bWMh8n2aOTOEsRH8t7Zo9WSZuK9PzIVFwg6Zt0J1Rw1EDYmVU2zDRaUmSaWB2x D17rHqKQMx96kAHzJAg2FvHsOwVVkxQrD53OInAaDVpPOuUogvseS6VwsvO22Xhqfb2c P5zkdlS3Zy2Q9lTSiXP67q6Z3c42pbHEw/iBOQWfdiy5WrlLh+cIy0eiQDW7S1VKSB9g CAeg== X-Gm-Message-State: ANoB5plYYsDjhGWuYBBunRQ6lPH15hkZM5ooD9D9wfAN6nL5cgD4UCZJ NlSb4wLRqKefJDbi6lbchjI= X-Google-Smtp-Source: AA0mqf6n/LTjELlMgOPAUHKCZj998ajlsJmr6FJtHheLBD4DRKv0w+DZx/+jLTxZzLzeUXXjccj7Rg== X-Received: by 2002:a05:622a:4806:b0:3a4:f140:f707 with SMTP id fb6-20020a05622a480600b003a4f140f707mr10057169qtb.317.1668378951056; Sun, 13 Nov 2022 14:35:51 -0800 (PST) Received: from shaak (modemcable055.92-163-184.mc.videotron.ca. [184.163.92.55]) by smtp.gmail.com with ESMTPSA id bk8-20020a05620a1a0800b006f9f3c0c63csm5482646qkb.32.2022.11.13.14.35.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Nov 2022 14:35:50 -0800 (PST) Date: Sun, 13 Nov 2022 17:35:46 -0500 From: Liam Beguin To: Maxime Ripard Cc: Stephen Boyd , Maxime Coquelin , Chen-Yu Tsai , Daniel Vetter , Nicolas Ferre , Thierry Reding , Jaroslav Kysela , Shawn Guo , Fabio Estevam , Ulf Hansson , Claudiu Beznea , Michael Turquette , Dinh Nguyen , Paul Cercueil , Chunyan Zhang , Manivannan Sadhasivam , Andreas =?iso-8859-1?Q?F=E4rber?= , Jonathan Hunter , Abel Vesa , Charles Keepax , Alessandro Zummo , Peter De Schrijver , Orson Zhai , Alexandre Torgue , Prashant Gaikwad , Liam Girdwood , Alexandre Belloni , Samuel Holland , Matthias Brugger , Richard Fitzgerald , Vinod Koul , NXP Linux Team , Sekhar Nori , Kishon Vijay Abraham I , Linus Walleij , Takashi Iwai , David Airlie , Luca Ceresoli , Jernej Skrabec , Pengutronix Kernel Team , Baolin Wang , David Lechner , Sascha Hauer , Mark Brown , Max Filippov , Geert Uytterhoeven , linux-stm32@st-md-mailman.stormreply.com, alsa-devel@alsa-project.org, linux-mediatek@lists.infradead.org, linux-phy@lists.infradead.org, linux-mips@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-actions@lists.infradead.org, linux-clk@vger.kernel.org, AngeloGioacchino Del Regno , patches@opensource.cirrus.com, linux-tegra@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: Re: [PATCH v2 13/65] clk: lmk04832: clkout: Add a determine_rate hook Message-ID: References: <20221018-clk-range-checks-fixes-v2-0-f6736dec138e@cerno.tech> <20221018-clk-range-checks-fixes-v2-13-f6736dec138e@cerno.tech> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221018-clk-range-checks-fixes-v2-13-f6736dec138e@cerno.tech> Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org Hi Maxime, On Fri, Nov 04, 2022 at 02:17:30PM +0100, Maxime Ripard wrote: > The LKM04832 "CLKOUT" clock implements a mux with a set_parent hook, but > doesn't provide a determine_rate implementation. > > This is a bit odd, since set_parent() is there to, as its name implies, > change the parent of a clock. However, the most likely candidate to > trigger that parent change is a call to clk_set_rate(), with > determine_rate() figuring out which parent is the best suited for a > given rate. > > The other trigger would be a call to clk_set_parent(), but it's far less > used, and it doesn't look like there's any obvious user for that clock. > > So, the set_parent hook is effectively unused, possibly because of an > oversight. However, it could also be an explicit decision by the > original author to avoid any reparenting but through an explicit call to > clk_set_parent(). This is correct, the set_parent hook is effectively unused at the moment. It was implemented as a way for consumers to select the parent themselves. The LMK04832 is used in JESD204 applications where devices need a device clock as well as a sysref clock. Since this is determined by the hardware layout, a devicetree option is used to select the inital state of the clkout mux. This is set at the end of lmk04832_register_clkout(). > The latter case would be equivalent to setting the flag > CLK_SET_RATE_NO_REPARENT, together with setting our determine_rate hook > to __clk_mux_determine_rate(). Indeed, if no determine_rate > implementation is provided, clk_round_rate() (through > clk_core_round_rate_nolock()) will call itself on the parent if > CLK_SET_RATE_PARENT is set, and will not change the clock rate > otherwise. __clk_mux_determine_rate() has the exact same behavior when > CLK_SET_RATE_NO_REPARENT is set. > > And if it was an oversight, then we are at least explicit about our > behavior now and it can be further refined down the line. > > Since the CLK_SET_RATE_NO_REPARENT flag was already set though, it seems > unlikely. > > Signed-off-by: Maxime Ripard Reviewed-by: Liam Beguin Cheers, Liam > --- > drivers/clk/clk-lmk04832.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/clk/clk-lmk04832.c b/drivers/clk/clk-lmk04832.c > index f416f8bc2898..f68bb0affdad 100644 > --- a/drivers/clk/clk-lmk04832.c > +++ b/drivers/clk/clk-lmk04832.c > @@ -1281,6 +1281,7 @@ static const struct clk_ops lmk04832_clkout_ops = { > .is_enabled = lmk04832_clkout_is_enabled, > .prepare = lmk04832_clkout_prepare, > .unprepare = lmk04832_clkout_unprepare, > + .determine_rate = __clk_mux_determine_rate, > .set_parent = lmk04832_clkout_set_parent, > .get_parent = lmk04832_clkout_get_parent, > }; > > -- > b4 0.11.0-dev-99e3a > 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id AD07BC433FE for ; Sun, 13 Nov 2022 22:35:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc: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=etFzBHV219N4XpLUyo5IkkCmEgsvFLqMyCiMESY0nyk=; b=JcCoCWgd3NjEzh iOKNKYkKCI0+yohe4jyrEn2cit2fb/ZaqCQ5XGHJolTtjq2Ye8WIEIV7U02PlJRT7Dy0eOc0fK/CU fgNezkCl7JXF2RsTivawOu7Msn6dn2dZxPa2pFMXQP3vpm5uPo3tlC9LfbINQml+GNnepkSEANSZL B5mmVma/c7VzGSoXxRBRulXLGnvIy2TkjuTUTWPr4tzYasEJFWTG7IdCH4tLiReCXWpLubY6vCjnb a7wa5uiT7Rgi8gpf0rYwMAj+ZwoNaUvRm+XHE0Jl0OyCUujwvIdQr7lub42TUT+mjkx3nrm6Stg7b kHyzyiFpWcU7uycFt7eQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ouLa2-00Eglu-3k; Sun, 13 Nov 2022 22:35:58 +0000 Received: from mail-qt1-x836.google.com ([2607:f8b0:4864:20::836]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ouLZx-00Egij-N8; Sun, 13 Nov 2022 22:35:55 +0000 Received: by mail-qt1-x836.google.com with SMTP id e15so5932959qts.1; Sun, 13 Nov 2022 14:35:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2UWIwxNMt9Li5DI9V3Ue/+A2ETbpfwK4uJjlNth28Ps=; b=cxos6M6SEMWjz70hcYfwJn7Qy9x3ScQZdWjcWHcTUuPDd6QIkxHfs4TdC7er0cgTfw Zecl1ammtXTh3CRumNopuCdrO/B9HdufOATVFx7LmHWfcuepu8nGRPAXZimVwU33NdJY fSpdh/6V9x/8s+acnZlcPXnCq3SzIgJYAOJ+MdHag7DONXMIur05Qu2T29C+PPj+G5FS 51vaHNJTqtvQKEh0MKIsH8wIeeMtk/77Zn6zHSFYDKwwTYJrTvxOcJz1pI56sykta8ez ucf+QXApfLU7u3dxQYz1YwJFVAwCWBLrNvZsrMdMSVYHA3yVHW95iD4uAWPO1ebw8AQZ l5aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2UWIwxNMt9Li5DI9V3Ue/+A2ETbpfwK4uJjlNth28Ps=; b=27ni8QBuW9LkP3cC/fp2wEn2EzTeKXADSx+ZxXctpBZaz0eC8XyzE6UxtV9L2pFTVJ DQytlV5gh0XaJ6L/3NvHJxYK3rWCvsuCh5MqPb77uJja44z2VR0z90ngnYFYfnEQSAHP jouZtZz6QLUqkgfLA3oZ+dEe/Flx5I9yQ3u03EbpptA9Ra6iUt4mHcLkzFMbkJR2cLIn P6mCYtWWa1M6WV8QL3fpfY4tvApuwYF0HPVUGDW/RziMzdhdN7UOIeHM/tBMQcGIgj8r TZMqN7RGlymalsAHX+YjTzqVHln8zbIm3G9Er34msw2rpfrzxzy2+K/C3lDQdVHB1MCN qqAQ== X-Gm-Message-State: ANoB5pkSo1m/76wRaENU7Dms+INrcXiEBlO83j2ciMzcVQbKrPsHN5Qn vE7SnqorKO8HR7pGiAf4jjU= X-Google-Smtp-Source: AA0mqf6n/LTjELlMgOPAUHKCZj998ajlsJmr6FJtHheLBD4DRKv0w+DZx/+jLTxZzLzeUXXjccj7Rg== X-Received: by 2002:a05:622a:4806:b0:3a4:f140:f707 with SMTP id fb6-20020a05622a480600b003a4f140f707mr10057169qtb.317.1668378951056; Sun, 13 Nov 2022 14:35:51 -0800 (PST) Received: from shaak (modemcable055.92-163-184.mc.videotron.ca. [184.163.92.55]) by smtp.gmail.com with ESMTPSA id bk8-20020a05620a1a0800b006f9f3c0c63csm5482646qkb.32.2022.11.13.14.35.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Nov 2022 14:35:50 -0800 (PST) Date: Sun, 13 Nov 2022 17:35:46 -0500 From: Liam Beguin To: Maxime Ripard Cc: Stephen Boyd , Maxime Coquelin , Chen-Yu Tsai , Daniel Vetter , Nicolas Ferre , Thierry Reding , Jaroslav Kysela , Shawn Guo , Fabio Estevam , Ulf Hansson , Claudiu Beznea , Michael Turquette , Dinh Nguyen , Paul Cercueil , Chunyan Zhang , Manivannan Sadhasivam , Andreas =?iso-8859-1?Q?F=E4rber?= , Jonathan Hunter , Abel Vesa , Charles Keepax , Alessandro Zummo , Peter De Schrijver , Orson Zhai , Alexandre Torgue , Prashant Gaikwad , Liam Girdwood , Alexandre Belloni , Samuel Holland , Matthias Brugger , Richard Fitzgerald , Vinod Koul , NXP Linux Team , Sekhar Nori , Kishon Vijay Abraham I , Linus Walleij , Takashi Iwai , David Airlie , Luca Ceresoli , Jernej Skrabec , Pengutronix Kernel Team , Baolin Wang , David Lechner , Sascha Hauer , Mark Brown , Max Filippov , Geert Uytterhoeven , linux-stm32@st-md-mailman.stormreply.com, alsa-devel@alsa-project.org, linux-mediatek@lists.infradead.org, linux-phy@lists.infradead.org, linux-mips@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-actions@lists.infradead.org, linux-clk@vger.kernel.org, AngeloGioacchino Del Regno , patches@opensource.cirrus.com, linux-tegra@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: Re: [PATCH v2 13/65] clk: lmk04832: clkout: Add a determine_rate hook Message-ID: References: <20221018-clk-range-checks-fixes-v2-0-f6736dec138e@cerno.tech> <20221018-clk-range-checks-fixes-v2-13-f6736dec138e@cerno.tech> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221018-clk-range-checks-fixes-v2-13-f6736dec138e@cerno.tech> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221113_143553_809421_5D5B5304 X-CRM114-Status: GOOD ( 31.96 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Hi Maxime, On Fri, Nov 04, 2022 at 02:17:30PM +0100, Maxime Ripard wrote: > The LKM04832 "CLKOUT" clock implements a mux with a set_parent hook, but > doesn't provide a determine_rate implementation. > > This is a bit odd, since set_parent() is there to, as its name implies, > change the parent of a clock. However, the most likely candidate to > trigger that parent change is a call to clk_set_rate(), with > determine_rate() figuring out which parent is the best suited for a > given rate. > > The other trigger would be a call to clk_set_parent(), but it's far less > used, and it doesn't look like there's any obvious user for that clock. > > So, the set_parent hook is effectively unused, possibly because of an > oversight. However, it could also be an explicit decision by the > original author to avoid any reparenting but through an explicit call to > clk_set_parent(). This is correct, the set_parent hook is effectively unused at the moment. It was implemented as a way for consumers to select the parent themselves. The LMK04832 is used in JESD204 applications where devices need a device clock as well as a sysref clock. Since this is determined by the hardware layout, a devicetree option is used to select the inital state of the clkout mux. This is set at the end of lmk04832_register_clkout(). > The latter case would be equivalent to setting the flag > CLK_SET_RATE_NO_REPARENT, together with setting our determine_rate hook > to __clk_mux_determine_rate(). Indeed, if no determine_rate > implementation is provided, clk_round_rate() (through > clk_core_round_rate_nolock()) will call itself on the parent if > CLK_SET_RATE_PARENT is set, and will not change the clock rate > otherwise. __clk_mux_determine_rate() has the exact same behavior when > CLK_SET_RATE_NO_REPARENT is set. > > And if it was an oversight, then we are at least explicit about our > behavior now and it can be further refined down the line. > > Since the CLK_SET_RATE_NO_REPARENT flag was already set though, it seems > unlikely. > > Signed-off-by: Maxime Ripard Reviewed-by: Liam Beguin Cheers, Liam > --- > drivers/clk/clk-lmk04832.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/clk/clk-lmk04832.c b/drivers/clk/clk-lmk04832.c > index f416f8bc2898..f68bb0affdad 100644 > --- a/drivers/clk/clk-lmk04832.c > +++ b/drivers/clk/clk-lmk04832.c > @@ -1281,6 +1281,7 @@ static const struct clk_ops lmk04832_clkout_ops = { > .is_enabled = lmk04832_clkout_is_enabled, > .prepare = lmk04832_clkout_prepare, > .unprepare = lmk04832_clkout_unprepare, > + .determine_rate = __clk_mux_determine_rate, > .set_parent = lmk04832_clkout_set_parent, > .get_parent = lmk04832_clkout_get_parent, > }; > > -- > b4 0.11.0-dev-99e3a > -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy 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 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 359BFC433FE for ; Mon, 14 Nov 2022 08:47:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A353310E281; Mon, 14 Nov 2022 08:47:26 +0000 (UTC) Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 029CF10E110 for ; Sun, 13 Nov 2022 22:35:51 +0000 (UTC) Received: by mail-qt1-x82b.google.com with SMTP id w4so5950169qts.0 for ; Sun, 13 Nov 2022 14:35:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2UWIwxNMt9Li5DI9V3Ue/+A2ETbpfwK4uJjlNth28Ps=; b=cxos6M6SEMWjz70hcYfwJn7Qy9x3ScQZdWjcWHcTUuPDd6QIkxHfs4TdC7er0cgTfw Zecl1ammtXTh3CRumNopuCdrO/B9HdufOATVFx7LmHWfcuepu8nGRPAXZimVwU33NdJY fSpdh/6V9x/8s+acnZlcPXnCq3SzIgJYAOJ+MdHag7DONXMIur05Qu2T29C+PPj+G5FS 51vaHNJTqtvQKEh0MKIsH8wIeeMtk/77Zn6zHSFYDKwwTYJrTvxOcJz1pI56sykta8ez ucf+QXApfLU7u3dxQYz1YwJFVAwCWBLrNvZsrMdMSVYHA3yVHW95iD4uAWPO1ebw8AQZ l5aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2UWIwxNMt9Li5DI9V3Ue/+A2ETbpfwK4uJjlNth28Ps=; b=REKW59RKo9XTsUkywodU9JDkfdDDeQIk31tZz6wnqqPhwhYRybuaCaZ9oXVn8MstWg fZnvIP+sbKvc+7rho0Ka5+VxBDOiDVSnmDkdweGUIVJqsvY/KuJIWSQyURQJ0ymydJzG 9MgqqeBiUvfcoFmGdgbEq7E5elqRWk9JIp3czgwuK3D7hiYH6WjEw+QAYXo2696ZXUqK U2SppqDU21Ud5ODnhLgte5E/E5bJg1phF9eQ0x2yH0iq1zezQ/vQePUdleV4f5poYaFY RQKbD7GFtWaMJOMPttVyB/ZdK4hrWihs8ddn9U4uSImBf9oE4bg5+V+9wdcSMfPkm/k5 kMgg== X-Gm-Message-State: ANoB5pmJt1FeFhaVafYEfH/btOzyc9jtS6KtEMrziy7S3IwVb2GlTcg7 sdhq0eDxTibN6TezcxVK0AQ= X-Google-Smtp-Source: AA0mqf6n/LTjELlMgOPAUHKCZj998ajlsJmr6FJtHheLBD4DRKv0w+DZx/+jLTxZzLzeUXXjccj7Rg== X-Received: by 2002:a05:622a:4806:b0:3a4:f140:f707 with SMTP id fb6-20020a05622a480600b003a4f140f707mr10057169qtb.317.1668378951056; Sun, 13 Nov 2022 14:35:51 -0800 (PST) Received: from shaak (modemcable055.92-163-184.mc.videotron.ca. [184.163.92.55]) by smtp.gmail.com with ESMTPSA id bk8-20020a05620a1a0800b006f9f3c0c63csm5482646qkb.32.2022.11.13.14.35.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Nov 2022 14:35:50 -0800 (PST) Date: Sun, 13 Nov 2022 17:35:46 -0500 From: Liam Beguin To: Maxime Ripard Subject: Re: [PATCH v2 13/65] clk: lmk04832: clkout: Add a determine_rate hook Message-ID: References: <20221018-clk-range-checks-fixes-v2-0-f6736dec138e@cerno.tech> <20221018-clk-range-checks-fixes-v2-13-f6736dec138e@cerno.tech> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221018-clk-range-checks-fixes-v2-13-f6736dec138e@cerno.tech> X-Mailman-Approved-At: Mon, 14 Nov 2022 08:47:13 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Prashant Gaikwad , Alexandre Belloni , Liam Girdwood , Michael Turquette , Sekhar Nori , Alexandre Torgue , dri-devel@lists.freedesktop.org, Jaroslav Kysela , Paul Cercueil , Max Filippov , Thierry Reding , linux-phy@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Abel Vesa , Kishon Vijay Abraham I , Geert Uytterhoeven , Samuel Holland , Chunyan Zhang , Takashi Iwai , linux-tegra@vger.kernel.org, Jernej Skrabec , Jonathan Hunter , Chen-Yu Tsai , NXP Linux Team , Orson Zhai , linux-mips@vger.kernel.org, Luca Ceresoli , linux-rtc@vger.kernel.org, linux-clk@vger.kernel.org, Charles Keepax , alsa-devel@alsa-project.org, Manivannan Sadhasivam , linux-kernel@vger.kernel.org, Sascha Hauer , linux-actions@lists.infradead.org, Richard Fitzgerald , Mark Brown , linux-mediatek@lists.infradead.org, Baolin Wang , Matthias Brugger , Pengutronix Kernel Team , linux-arm-kernel@lists.infradead.org, AngeloGioacchino Del Regno , Alessandro Zummo , linux-sunxi@lists.linux.dev, Stephen Boyd , patches@opensource.cirrus.com, Peter De Schrijver , Nicolas Ferre , Andreas =?iso-8859-1?Q?F=E4rber?= , linux-renesas-soc@vger.kernel.org, Dinh Nguyen , Vinod Koul , Maxime Coquelin , David Lechner , Shawn Guo , Claudiu Beznea Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Maxime, On Fri, Nov 04, 2022 at 02:17:30PM +0100, Maxime Ripard wrote: > The LKM04832 "CLKOUT" clock implements a mux with a set_parent hook, but > doesn't provide a determine_rate implementation. > > This is a bit odd, since set_parent() is there to, as its name implies, > change the parent of a clock. However, the most likely candidate to > trigger that parent change is a call to clk_set_rate(), with > determine_rate() figuring out which parent is the best suited for a > given rate. > > The other trigger would be a call to clk_set_parent(), but it's far less > used, and it doesn't look like there's any obvious user for that clock. > > So, the set_parent hook is effectively unused, possibly because of an > oversight. However, it could also be an explicit decision by the > original author to avoid any reparenting but through an explicit call to > clk_set_parent(). This is correct, the set_parent hook is effectively unused at the moment. It was implemented as a way for consumers to select the parent themselves. The LMK04832 is used in JESD204 applications where devices need a device clock as well as a sysref clock. Since this is determined by the hardware layout, a devicetree option is used to select the inital state of the clkout mux. This is set at the end of lmk04832_register_clkout(). > The latter case would be equivalent to setting the flag > CLK_SET_RATE_NO_REPARENT, together with setting our determine_rate hook > to __clk_mux_determine_rate(). Indeed, if no determine_rate > implementation is provided, clk_round_rate() (through > clk_core_round_rate_nolock()) will call itself on the parent if > CLK_SET_RATE_PARENT is set, and will not change the clock rate > otherwise. __clk_mux_determine_rate() has the exact same behavior when > CLK_SET_RATE_NO_REPARENT is set. > > And if it was an oversight, then we are at least explicit about our > behavior now and it can be further refined down the line. > > Since the CLK_SET_RATE_NO_REPARENT flag was already set though, it seems > unlikely. > > Signed-off-by: Maxime Ripard Reviewed-by: Liam Beguin Cheers, Liam > --- > drivers/clk/clk-lmk04832.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/clk/clk-lmk04832.c b/drivers/clk/clk-lmk04832.c > index f416f8bc2898..f68bb0affdad 100644 > --- a/drivers/clk/clk-lmk04832.c > +++ b/drivers/clk/clk-lmk04832.c > @@ -1281,6 +1281,7 @@ static const struct clk_ops lmk04832_clkout_ops = { > .is_enabled = lmk04832_clkout_is_enabled, > .prepare = lmk04832_clkout_prepare, > .unprepare = lmk04832_clkout_unprepare, > + .determine_rate = __clk_mux_determine_rate, > .set_parent = lmk04832_clkout_set_parent, > .get_parent = lmk04832_clkout_get_parent, > }; > > -- > b4 0.11.0-dev-99e3a >