From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31A71185E for ; Thu, 10 Nov 2022 11:29:19 +0000 (UTC) Received: by mail-pf1-f170.google.com with SMTP id m6so1797603pfb.0 for ; Thu, 10 Nov 2022 03:29:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=dZWp2kHBH7BxTK24vYMYaWuh8ES61v4HZQKkOxWH97c=; b=nm5AzPUP/c5SxnOWRF0E8OOs8vIUdOgDjB6wYkEQYpfYDRuGKSxS+CBIeuds7UEokj CAc3O4M3Lzp0CmH9uvJ+chSuCz2e7UtgkMxDMXFmH0EFBdC81NQcL56cIa/e5fTzyvWS kSegvkcOyKB6FEauX3mSzkzzDIAUq5r5SATzN3WmVSBqg1jyg/gg0kYs06KdBSG3zxV/ fvTxGa1dt18Ruz+5BEtQasGBTHQrEp0wpReAHWWGdK+pWMVHzmdtTwn3mkonTWk309ZV x5RN6EKVnoWzvPKijsEeJPqRTGi+5rLHTCBxYP1D5lgzLbOuhL8arV0ezTVKJRNayIhr L9Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dZWp2kHBH7BxTK24vYMYaWuh8ES61v4HZQKkOxWH97c=; b=R0rYctutDK4blXgC/TOOtem0bWh7Bi+zL/z7UAU0n0p7PJYe9SF9plUdSt5SLwlwmj CI66mQzXyQ1BXw4XxKdIrf3RTvP/oRbCrWomdVCwruGDMVX5ZA1J8pJrjEtVBE6HmvLd aDtx3kuAbTwCtunm6DneIb1V+/J2RYIigMZFB0HGg2RmlZbzif7LYhEfuizlYB4w5v2R vzJWfUyO/cRcyF/ERilc09XefSn+L06qKhiKWzOLriSGvcmAntAONvqUvzE5zajUSBxx az2vhrP6OtUZj5mI2nVMLemLMlPefA/ku4eSN7i6L9KOFAoin6iYN6FuwgYTPcl4qdmH qPXw== X-Gm-Message-State: ACrzQf2OSIiEY4AetR8lyCvbEpOcEXidBSeM1CmAdRVIW5/feQqOq2og MtQ889urUmCneOeIITofCI6cbqd+z75j4I4dfpixMw== X-Google-Smtp-Source: AMsMyM4cuzpOD/TX9hqFyYyupcC8P3vPeFAFlSRm0wZ2MgnRUbZnV+cRg9A/mVHt7wBrkUdmfz48YahbcXukazUMnzc= X-Received: by 2002:a63:4204:0:b0:442:ee11:4894 with SMTP id p4-20020a634204000000b00442ee114894mr2372631pga.595.1668079758533; Thu, 10 Nov 2022 03:29:18 -0800 (PST) Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20221018-clk-range-checks-fixes-v2-0-f6736dec138e@cerno.tech> <20221018-clk-range-checks-fixes-v2-35-f6736dec138e@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v2-35-f6736dec138e@cerno.tech> From: Ulf Hansson Date: Thu, 10 Nov 2022 12:28:41 +0100 Message-ID: Subject: Re: [PATCH v2 35/65] clk: ux500: sysctrl: Add a determine_rate hook To: Maxime Ripard Cc: Stephen Boyd , Maxime Coquelin , Chen-Yu Tsai , Daniel Vetter , Nicolas Ferre , Thierry Reding , Jaroslav Kysela , Shawn Guo , Fabio Estevam , Claudiu Beznea , Michael Turquette , Dinh Nguyen , Paul Cercueil , Chunyan Zhang , Manivannan Sadhasivam , =?UTF-8?Q?Andreas_F=C3=A4rber?= , 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 Content-Type: text/plain; charset="UTF-8" On Fri, 4 Nov 2022 at 14:32, Maxime Ripard wrote: > > The UX500 sysctrl "set_parent" clocks implement 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. If I recall correctly, that is the use case we did target for these types of clocks. See sound/soc/ux500/ux500_ab85xx.c, for example. Maybe there are some additional pieces missing from the old down stream kernel, I don't have full picture, sorry. Anyway, if I am not wrong, this was about supporting a low-power audio use case, which requires us to switch the parent clock (to avoid wasting energy). > > 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(). Yes, this was the reason. As a matter of fact, I don't even recall that re-parenting was possible through clk_set_rate() when this clock driver was introduced. But, I might be wrong, it's quite a while ago. > > 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. > > Signed-off-by: Maxime Ripard Seems reasonable to me! Reviewed-by: Ulf Hansson Kind regards Uffe > --- > drivers/clk/ux500/clk-sysctrl.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/ux500/clk-sysctrl.c b/drivers/clk/ux500/clk-sysctrl.c > index 702f2f8b43fa..d36336665b6d 100644 > --- a/drivers/clk/ux500/clk-sysctrl.c > +++ b/drivers/clk/ux500/clk-sysctrl.c > @@ -110,6 +110,7 @@ static const struct clk_ops clk_sysctrl_gate_fixed_rate_ops = { > }; > > static const struct clk_ops clk_sysctrl_set_parent_ops = { > + .determine_rate = __clk_mux_determine_rate, > .set_parent = clk_sysctrl_set_parent, > .get_parent = clk_sysctrl_get_parent, > }; > @@ -220,6 +221,7 @@ struct clk *clk_reg_sysctrl_set_parent(struct device *dev, > unsigned long flags) > { > return clk_reg_sysctrl(dev, name, parent_names, num_parents, > - reg_sel, reg_mask, reg_bits, 0, 0, flags, > + reg_sel, reg_mask, reg_bits, 0, 0, > + flags | CLK_SET_RATE_NO_REPARENT, > &clk_sysctrl_set_parent_ops); > } > > -- > 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 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 B1C80C4332F for ; Thu, 10 Nov 2022 11:29:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 21CA110E6D3; Thu, 10 Nov 2022 11:29:23 +0000 (UTC) Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1110C10E6D3 for ; Thu, 10 Nov 2022 11:29:19 +0000 (UTC) Received: by mail-pg1-x52b.google.com with SMTP id f63so1541944pgc.2 for ; Thu, 10 Nov 2022 03:29:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=dZWp2kHBH7BxTK24vYMYaWuh8ES61v4HZQKkOxWH97c=; b=nm5AzPUP/c5SxnOWRF0E8OOs8vIUdOgDjB6wYkEQYpfYDRuGKSxS+CBIeuds7UEokj CAc3O4M3Lzp0CmH9uvJ+chSuCz2e7UtgkMxDMXFmH0EFBdC81NQcL56cIa/e5fTzyvWS kSegvkcOyKB6FEauX3mSzkzzDIAUq5r5SATzN3WmVSBqg1jyg/gg0kYs06KdBSG3zxV/ fvTxGa1dt18Ruz+5BEtQasGBTHQrEp0wpReAHWWGdK+pWMVHzmdtTwn3mkonTWk309ZV x5RN6EKVnoWzvPKijsEeJPqRTGi+5rLHTCBxYP1D5lgzLbOuhL8arV0ezTVKJRNayIhr L9Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dZWp2kHBH7BxTK24vYMYaWuh8ES61v4HZQKkOxWH97c=; b=rLdASt1yj8rNYYuK7LvckskpJYQ+jBs2yeqE0LsBmNo6ww87CjBwBUg2YF7Wu+5yqj ZuGfVU9A4xesEnasOi2LUzyLxDx9xo+JKhYXlyH7HWibwUhjCssw/6Dj1S4LN4fPHhBW +zs63PH3vdzQj2CiDA315QDriELpMEHl25zizehzKGopSBfWdW7iax9pV/1xVJCdhNJN c/SiCNYwE5AJsYdFbXcAnRGhV75cDYEK8yxcqJUHvEy6l15jGpc4WCUc46zlu0Uj+a7S o6mWDdeQ5bKv5/l8LmyR0CgN1OaFq3d0PAqCzPMzAhmSEbFuAEW3r7p57uzAHn/9VKKY eLOQ== X-Gm-Message-State: ACrzQf1Gwa1QJ0J0TmCQLl04ASOf6vbTlhUXFdIGV+uupf8QN25ePgoo WHGsc/PMHhj8k0D17aMWkHjOMO0YRW1/GSuFClRTvQ== X-Google-Smtp-Source: AMsMyM4cuzpOD/TX9hqFyYyupcC8P3vPeFAFlSRm0wZ2MgnRUbZnV+cRg9A/mVHt7wBrkUdmfz48YahbcXukazUMnzc= X-Received: by 2002:a63:4204:0:b0:442:ee11:4894 with SMTP id p4-20020a634204000000b00442ee114894mr2372631pga.595.1668079758533; Thu, 10 Nov 2022 03:29:18 -0800 (PST) MIME-Version: 1.0 References: <20221018-clk-range-checks-fixes-v2-0-f6736dec138e@cerno.tech> <20221018-clk-range-checks-fixes-v2-35-f6736dec138e@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v2-35-f6736dec138e@cerno.tech> From: Ulf Hansson Date: Thu, 10 Nov 2022 12:28:41 +0100 Message-ID: Subject: Re: [PATCH v2 35/65] clk: ux500: sysctrl: Add a determine_rate hook To: Maxime Ripard Content-Type: text/plain; charset="UTF-8" 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: Alexandre Belloni , Prashant Gaikwad , Geert Uytterhoeven , 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 , 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 , =?UTF-8?Q?Andreas_F=C3=A4rber?= , 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" On Fri, 4 Nov 2022 at 14:32, Maxime Ripard wrote: > > The UX500 sysctrl "set_parent" clocks implement 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. If I recall correctly, that is the use case we did target for these types of clocks. See sound/soc/ux500/ux500_ab85xx.c, for example. Maybe there are some additional pieces missing from the old down stream kernel, I don't have full picture, sorry. Anyway, if I am not wrong, this was about supporting a low-power audio use case, which requires us to switch the parent clock (to avoid wasting energy). > > 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(). Yes, this was the reason. As a matter of fact, I don't even recall that re-parenting was possible through clk_set_rate() when this clock driver was introduced. But, I might be wrong, it's quite a while ago. > > 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. > > Signed-off-by: Maxime Ripard Seems reasonable to me! Reviewed-by: Ulf Hansson Kind regards Uffe > --- > drivers/clk/ux500/clk-sysctrl.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/ux500/clk-sysctrl.c b/drivers/clk/ux500/clk-sysctrl.c > index 702f2f8b43fa..d36336665b6d 100644 > --- a/drivers/clk/ux500/clk-sysctrl.c > +++ b/drivers/clk/ux500/clk-sysctrl.c > @@ -110,6 +110,7 @@ static const struct clk_ops clk_sysctrl_gate_fixed_rate_ops = { > }; > > static const struct clk_ops clk_sysctrl_set_parent_ops = { > + .determine_rate = __clk_mux_determine_rate, > .set_parent = clk_sysctrl_set_parent, > .get_parent = clk_sysctrl_get_parent, > }; > @@ -220,6 +221,7 @@ struct clk *clk_reg_sysctrl_set_parent(struct device *dev, > unsigned long flags) > { > return clk_reg_sysctrl(dev, name, parent_names, num_parents, > - reg_sel, reg_mask, reg_bits, 0, 0, flags, > + reg_sel, reg_mask, reg_bits, 0, 0, > + flags | CLK_SET_RATE_NO_REPARENT, > &clk_sysctrl_set_parent_ops); > } > > -- > 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 8E98BC4332F for ; Thu, 10 Nov 2022 11:46:44 +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:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bqxXkdVOQLrDMyysUCavwW2uySY2kilwcpui9knaEd8=; b=avHbu3KvEVAj+P Qfm2WBO941ImnQ/ThQyqwAS1TtViNTE5bUxbPPPtjAtrHeyApDP+ANXtO9Q31j/+4lkBatRwxy8Nh s4xc1I7f2b6q9CbxntU4XiFjaYaoh03WVxP902irQMAGIIRUuI5MpA+yLDR0DjFph2j/2nOzl3m0T uXw4rOFec7Fq8h0hlB/sAu/tVvdQK7m7GHF3X6UOLxkp5hpgUOkNSgf/z8kfFT40y6qhfqHvSHMHA 37eOsGrDbmbSF4R+LuF5dDdACJBr3r2T72u7tzmtLmGUaRh8al8foqhfmdzxyNAo21nVMraAccP7v LsPLAUB0bhQYpmqmwp8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ot615-005UTR-Jr; Thu, 10 Nov 2022 11:46:43 +0000 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ot5kG-005MYs-LL for linux-phy@lists.infradead.org; Thu, 10 Nov 2022 11:29:22 +0000 Received: by mail-pg1-x529.google.com with SMTP id s196so1538176pgs.3 for ; Thu, 10 Nov 2022 03:29:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=dZWp2kHBH7BxTK24vYMYaWuh8ES61v4HZQKkOxWH97c=; b=nm5AzPUP/c5SxnOWRF0E8OOs8vIUdOgDjB6wYkEQYpfYDRuGKSxS+CBIeuds7UEokj CAc3O4M3Lzp0CmH9uvJ+chSuCz2e7UtgkMxDMXFmH0EFBdC81NQcL56cIa/e5fTzyvWS kSegvkcOyKB6FEauX3mSzkzzDIAUq5r5SATzN3WmVSBqg1jyg/gg0kYs06KdBSG3zxV/ fvTxGa1dt18Ruz+5BEtQasGBTHQrEp0wpReAHWWGdK+pWMVHzmdtTwn3mkonTWk309ZV x5RN6EKVnoWzvPKijsEeJPqRTGi+5rLHTCBxYP1D5lgzLbOuhL8arV0ezTVKJRNayIhr L9Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dZWp2kHBH7BxTK24vYMYaWuh8ES61v4HZQKkOxWH97c=; b=2rljy4JtvK9hjfpKfgmiv/MdbGuNVky2oLk6ywV7uvFefhS7hSnVZ8c2WSBpXLqCk4 zs3vS3AT2UK9RHwlsKV+Ou31vTNSZpTC9oxk26PaJPXvUKpUIVaX3ZPO4zXmXV2tlauo ruJ299LbQGPyQNW0vZbMMauEEkSf7Bs04nIwPdKhkMInOXfY7OBMIXLep0aVukZUfAPO 224rtnMcGdoj6tQeP11TGHoX552RDiep/5ilwgzyYudaa1F+WqQptxNkdJR7Xn9HNW88 EUwGva4rOhtRyLL/xNsCE2K2P6UDYtfcdSBd36m09y0O3jak6Q3PSZggRmRafWeAXwfq mlag== X-Gm-Message-State: ACrzQf1o+hlIf699zUkYU7I7+L1UDWY7u+dYr+GIIeOxgwPOgQr3+Fj4 rsPhoxaHgV3tuIvXqNB0wk8ZqagcUWL68GuQWeLmhg== X-Google-Smtp-Source: AMsMyM4cuzpOD/TX9hqFyYyupcC8P3vPeFAFlSRm0wZ2MgnRUbZnV+cRg9A/mVHt7wBrkUdmfz48YahbcXukazUMnzc= X-Received: by 2002:a63:4204:0:b0:442:ee11:4894 with SMTP id p4-20020a634204000000b00442ee114894mr2372631pga.595.1668079758533; Thu, 10 Nov 2022 03:29:18 -0800 (PST) MIME-Version: 1.0 References: <20221018-clk-range-checks-fixes-v2-0-f6736dec138e@cerno.tech> <20221018-clk-range-checks-fixes-v2-35-f6736dec138e@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v2-35-f6736dec138e@cerno.tech> From: Ulf Hansson Date: Thu, 10 Nov 2022 12:28:41 +0100 Message-ID: Subject: Re: [PATCH v2 35/65] clk: ux500: sysctrl: Add a determine_rate hook To: Maxime Ripard Cc: Stephen Boyd , Maxime Coquelin , Chen-Yu Tsai , Daniel Vetter , Nicolas Ferre , Thierry Reding , Jaroslav Kysela , Shawn Guo , Fabio Estevam , Claudiu Beznea , Michael Turquette , Dinh Nguyen , Paul Cercueil , Chunyan Zhang , Manivannan Sadhasivam , =?UTF-8?Q?Andreas_F=C3=A4rber?= , 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221110_032920_829743_DB4768B2 X-CRM114-Status: GOOD ( 34.47 ) 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 On Fri, 4 Nov 2022 at 14:32, Maxime Ripard wrote: > > The UX500 sysctrl "set_parent" clocks implement 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. If I recall correctly, that is the use case we did target for these types of clocks. See sound/soc/ux500/ux500_ab85xx.c, for example. Maybe there are some additional pieces missing from the old down stream kernel, I don't have full picture, sorry. Anyway, if I am not wrong, this was about supporting a low-power audio use case, which requires us to switch the parent clock (to avoid wasting energy). > > 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(). Yes, this was the reason. As a matter of fact, I don't even recall that re-parenting was possible through clk_set_rate() when this clock driver was introduced. But, I might be wrong, it's quite a while ago. > > 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. > > Signed-off-by: Maxime Ripard Seems reasonable to me! Reviewed-by: Ulf Hansson Kind regards Uffe > --- > drivers/clk/ux500/clk-sysctrl.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/ux500/clk-sysctrl.c b/drivers/clk/ux500/clk-sysctrl.c > index 702f2f8b43fa..d36336665b6d 100644 > --- a/drivers/clk/ux500/clk-sysctrl.c > +++ b/drivers/clk/ux500/clk-sysctrl.c > @@ -110,6 +110,7 @@ static const struct clk_ops clk_sysctrl_gate_fixed_rate_ops = { > }; > > static const struct clk_ops clk_sysctrl_set_parent_ops = { > + .determine_rate = __clk_mux_determine_rate, > .set_parent = clk_sysctrl_set_parent, > .get_parent = clk_sysctrl_get_parent, > }; > @@ -220,6 +221,7 @@ struct clk *clk_reg_sysctrl_set_parent(struct device *dev, > unsigned long flags) > { > return clk_reg_sysctrl(dev, name, parent_names, num_parents, > - reg_sel, reg_mask, reg_bits, 0, 0, flags, > + reg_sel, reg_mask, reg_bits, 0, 0, > + flags | CLK_SET_RATE_NO_REPARENT, > &clk_sysctrl_set_parent_ops); > } > > -- > 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 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 D5E5DC433FE for ; Thu, 10 Nov 2022 19:07:13 +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 BEE5182C; Thu, 10 Nov 2022 20:06:21 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BEE5182C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1668107231; bh=H5FKZPxGHJoooX31l+qryyFtW/DY08k6T4D3JxGzA6A=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ELVqjML+1USzVaq1iKcDIAAUokOthvcLcn3E/SHaLktVtlhuKXzjbOINawKHykYTm 9sIEQvYevtOxnouZCCLj4fh4SJDfX2n3vhR3pdEriaoZ7OYnMrmBltaxvULukJ5aW2 4/GEEt6mSjw/BIXok+CPb7VXGNyctUGnVGQ0B3wQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7E579F80163; Thu, 10 Nov 2022 20:06:21 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 621F5F8021D; Thu, 10 Nov 2022 12:29:28 +0100 (CET) Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) (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 84ECCF80114 for ; Thu, 10 Nov 2022 12:29:21 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 84ECCF80114 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nm5AzPUP" Received: by mail-pg1-x531.google.com with SMTP id h193so1514798pgc.10 for ; Thu, 10 Nov 2022 03:29:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=dZWp2kHBH7BxTK24vYMYaWuh8ES61v4HZQKkOxWH97c=; b=nm5AzPUP/c5SxnOWRF0E8OOs8vIUdOgDjB6wYkEQYpfYDRuGKSxS+CBIeuds7UEokj CAc3O4M3Lzp0CmH9uvJ+chSuCz2e7UtgkMxDMXFmH0EFBdC81NQcL56cIa/e5fTzyvWS kSegvkcOyKB6FEauX3mSzkzzDIAUq5r5SATzN3WmVSBqg1jyg/gg0kYs06KdBSG3zxV/ fvTxGa1dt18Ruz+5BEtQasGBTHQrEp0wpReAHWWGdK+pWMVHzmdtTwn3mkonTWk309ZV x5RN6EKVnoWzvPKijsEeJPqRTGi+5rLHTCBxYP1D5lgzLbOuhL8arV0ezTVKJRNayIhr L9Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dZWp2kHBH7BxTK24vYMYaWuh8ES61v4HZQKkOxWH97c=; b=ghlGCfiI+jefoKlKXltnOOgRW8mTuO0vdnAAUXNjEqtOJificDztIUTjU/ZhB+Ngt6 JQVbPrAH1nhwgNzQ5b3e0357Yt3FGnQ3arer7X30wcfi3pVlEB3kP6uVv4lClVTyocab pyOmAzXO00i9q+Vl37EoQX9UXnHRBMFYn6f+RLkiF/MTQ565teaKfcUSRNXtd0AaaHwu 4bSv18ssuKRbzAcMihyYIcH70higSQF6JBEhPsY48IIJiPKH9B4Zbx7K/BbOj6eAHrGf THOo1VBEtqPX3m7yGCT8MGCpQyYiJzC+3SxcCjyTzpPcHtLP2BXRG4J/9pbPgmYObnsz llmQ== X-Gm-Message-State: ACrzQf1f1+Iynx+FkZLcMPS10V5svFKG3FIQpEDbDsg4BJCGWz8Kv7Qq OcoZ3vdtiKwU1UM90x/RT6GP1bswiP1eBD2D7egy4Q== X-Google-Smtp-Source: AMsMyM4cuzpOD/TX9hqFyYyupcC8P3vPeFAFlSRm0wZ2MgnRUbZnV+cRg9A/mVHt7wBrkUdmfz48YahbcXukazUMnzc= X-Received: by 2002:a63:4204:0:b0:442:ee11:4894 with SMTP id p4-20020a634204000000b00442ee114894mr2372631pga.595.1668079758533; Thu, 10 Nov 2022 03:29:18 -0800 (PST) MIME-Version: 1.0 References: <20221018-clk-range-checks-fixes-v2-0-f6736dec138e@cerno.tech> <20221018-clk-range-checks-fixes-v2-35-f6736dec138e@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v2-35-f6736dec138e@cerno.tech> From: Ulf Hansson Date: Thu, 10 Nov 2022 12:28:41 +0100 Message-ID: Subject: Re: [PATCH v2 35/65] clk: ux500: sysctrl: Add a determine_rate hook To: Maxime Ripard Content-Type: text/plain; charset="UTF-8" X-Mailman-Approved-At: Thu, 10 Nov 2022 20:06:20 +0100 Cc: Alexandre Belloni , Prashant Gaikwad , Geert Uytterhoeven , 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 , 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 , =?UTF-8?Q?Andreas_F=C3=A4rber?= , 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" On Fri, 4 Nov 2022 at 14:32, Maxime Ripard wrote: > > The UX500 sysctrl "set_parent" clocks implement 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. If I recall correctly, that is the use case we did target for these types of clocks. See sound/soc/ux500/ux500_ab85xx.c, for example. Maybe there are some additional pieces missing from the old down stream kernel, I don't have full picture, sorry. Anyway, if I am not wrong, this was about supporting a low-power audio use case, which requires us to switch the parent clock (to avoid wasting energy). > > 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(). Yes, this was the reason. As a matter of fact, I don't even recall that re-parenting was possible through clk_set_rate() when this clock driver was introduced. But, I might be wrong, it's quite a while ago. > > 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. > > Signed-off-by: Maxime Ripard Seems reasonable to me! Reviewed-by: Ulf Hansson Kind regards Uffe > --- > drivers/clk/ux500/clk-sysctrl.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/ux500/clk-sysctrl.c b/drivers/clk/ux500/clk-sysctrl.c > index 702f2f8b43fa..d36336665b6d 100644 > --- a/drivers/clk/ux500/clk-sysctrl.c > +++ b/drivers/clk/ux500/clk-sysctrl.c > @@ -110,6 +110,7 @@ static const struct clk_ops clk_sysctrl_gate_fixed_rate_ops = { > }; > > static const struct clk_ops clk_sysctrl_set_parent_ops = { > + .determine_rate = __clk_mux_determine_rate, > .set_parent = clk_sysctrl_set_parent, > .get_parent = clk_sysctrl_get_parent, > }; > @@ -220,6 +221,7 @@ struct clk *clk_reg_sysctrl_set_parent(struct device *dev, > unsigned long flags) > { > return clk_reg_sysctrl(dev, name, parent_names, num_parents, > - reg_sel, reg_mask, reg_bits, 0, 0, flags, > + reg_sel, reg_mask, reg_bits, 0, 0, > + flags | CLK_SET_RATE_NO_REPARENT, > &clk_sysctrl_set_parent_ops); > } > > -- > b4 0.11.0-dev-99e3a