Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5974215rwr; Mon, 24 Apr 2023 11:37:07 -0700 (PDT) X-Google-Smtp-Source: AKy350aLnwHpaleBhFPmrXJrddYsQz3D/GGr2/4sy7fqINRm059pLlUeiYHLd6eJfxyROdSVWKLj X-Received: by 2002:a05:6a00:1749:b0:63b:64f7:45a0 with SMTP id j9-20020a056a00174900b0063b64f745a0mr20525143pfc.12.1682361427568; Mon, 24 Apr 2023 11:37:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682361427; cv=none; d=google.com; s=arc-20160816; b=pbjljwVmfJ3yg8dTNKiekCMHBoiqKNnUw1QeLQruiNYSlPXWqXbQg2lKIbO8E3z8/a obzLv4au5d96YqonGKfgS7tRFLbuFV1fwOWGSfdSiWxeq2OcB706Wa/PDLFWRd5DVbSc blrNu4hW3zapKzrPcnIODm+WfSp7WipeQQxHX/qppBkKfhEoluS1zRecW14Mwph36CiZ KFsf9xAZKB1qQEqmv621SPxdIHG2k03GAAtzj2WcE3qm1fL0THGHLtsGe6hHfoRdHixu NSk0lWJPlyepTsBWD2Vhd1KiRPsitNlXLXrNesC/uv8FEUgj44MNLZe1dvcFFN48WbGf kXaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=KDrafg14DFfAommJqMVIc5LNl07QBXdjmZ0ArE+kbZM=; b=fv5LWAV+XW2wpyjjwP8ym+eQlsvsA0UltGdEGIpV5o0WNF3YoBgVfYNGt1mtDCUbOb nrWmJTkN9Wa13SZlNScdGUZNBDAzsi/WxfaLb0rjkFe9NFYGp5DT6wqQNLGh0nifC3uS d0q7W42ZpLLmGNBt3gji1yO7gbA2ORCVv7rULItoc1L6Zu/w122rzm44DDcfSryYszif ILBt3TG3F/FD/IU5uWhHiH9ZuGe078LW+YhG9qPx92qzuUJHOEvKZwOACe55yY7cyTT1 AV5u2ew55WlbL2fpOloU4zDDFMfzEeJOdov8tOTCZbm8W+/5ZhQX52IvmJqZ8QY27q10 25yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AL1mQRPI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d5-20020a63d705000000b0051f00f55bd8si11246194pgg.224.2023.04.24.11.36.54; Mon, 24 Apr 2023 11:37:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AL1mQRPI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231726AbjDXScp (ORCPT + 99 others); Mon, 24 Apr 2023 14:32:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229929AbjDXSci (ORCPT ); Mon, 24 Apr 2023 14:32:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C00244A4; Mon, 24 Apr 2023 11:32:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E0C8E61DAE; Mon, 24 Apr 2023 18:32:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6DC2C433EF; Mon, 24 Apr 2023 18:32:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682361155; bh=Qwb6xQXtIp9IK5K1XYNjKtQG2ZIwhMNhHPe94Eain8I=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=AL1mQRPIK32zEIp1g3UTreatnys6JEiIOElV8WxQ0HCWYrYOh9FUa/pV+J28wkIb0 kuYZuUJpavJkOZaHtCtWDI71bQfr8PqKub4qFn3x5yzC4y8fbdLxu7HbJwBzC+XQwm VrE7IOJkHHjP11gDLRWFy86EVLqVWwQrt/B4cpTsksi6B3BO3cBvv6mbtnfmE01ZgB TzxQElbzcDm36YDmuacquU8+DAzm2Bx6Sa8BvlgfPXGSzs47J+MRnxBY/ACBhDqqPE NaKy9ZqKj3mZAujGR2xqbrAlZIyDJXBbelkgz2XIH4N+SG2lVTYr08TXhvRv/t7uAi Q8Hr8qGO9TEdw== Message-ID: <679921ee-98d4-d6ef-5934-e009fd4b31fc@kernel.org> Date: Mon, 24 Apr 2023 13:32:28 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v3 29/65] clk: socfpga: gate: Add a determine_rate hook To: Maxime Ripard , Michael Turquette , Stephen Boyd , =?UTF-8?Q?Andreas_F=c3=a4rber?= , Manivannan Sadhasivam , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Max Filippov , Charles Keepax , Richard Fitzgerald , Maxime Coquelin , Alexandre Torgue , Luca Ceresoli , David Lechner , Sekhar Nori , Abel Vesa , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Matthias Brugger , Geert Uytterhoeven , Peter De Schrijver , Prashant Gaikwad , Thierry Reding , Jonathan Hunter , Ulf Hansson , Linus Walleij , David Airlie , Daniel Vetter , Vinod Koul , Kishon Vijay Abraham I , Alessandro Zummo , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Paul Cercueil , Orson Zhai , Baolin Wang , Chunyan Zhang Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, AngeloGioacchino Del Regno , linux-arm-kernel@lists.infradead.org, linux-actions@lists.infradead.org, patches@opensource.cirrus.com, linux-stm32@st-md-mailman.stormreply.com, linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-phy@lists.infradead.org, linux-rtc@vger.kernel.org, linux-sunxi@lists.linux.dev, alsa-devel@alsa-project.org, linux-mips@vger.kernel.org References: <20221018-clk-range-checks-fixes-v3-0-9a1358472d52@cerno.tech> <20221018-clk-range-checks-fixes-v3-29-9a1358472d52@cerno.tech> Content-Language: en-US From: Dinh Nguyen In-Reply-To: <20221018-clk-range-checks-fixes-v3-29-9a1358472d52@cerno.tech> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Maxime, On 4/4/23 05:11, Maxime Ripard wrote: > The SoCFGPA gate 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(). > > 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 > --- > drivers/clk/socfpga/clk-gate.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c > index 32ccda960f28..cbba8462a09e 100644 > --- a/drivers/clk/socfpga/clk-gate.c > +++ b/drivers/clk/socfpga/clk-gate.c > @@ -110,6 +110,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk, > > static struct clk_ops gateclk_ops = { > .recalc_rate = socfpga_clk_recalc_rate, > + .determine_rate = __clk_mux_determine_rate, > .get_parent = socfpga_clk_get_parent, > .set_parent = socfpga_clk_set_parent, > }; > @@ -166,7 +167,7 @@ void __init socfpga_gate_init(struct device_node *node) > > init.name = clk_name; > init.ops = ops; > - init.flags = 0; > + init.flags = CLK_SET_RATE_NO_REPARENT; > > init.num_parents = of_clk_parent_fill(node, parent_name, SOCFPGA_MAX_PARENTS); > if (init.num_parents < 2) { > This patch broke SoCFPGA boot serial port. The characters are mangled. Dinh