Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp1123179rwl; Fri, 4 Nov 2022 10:02:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4yylw3FUVz3NZ2U1LORlzrKluSaI0PLyDjm9DwlW45/iFQt8R3doqPk1ABMejTSOcVz/xf X-Received: by 2002:a17:902:cf08:b0:186:5e03:3040 with SMTP id i8-20020a170902cf0800b001865e033040mr36852492plg.20.1667581349922; Fri, 04 Nov 2022 10:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667581349; cv=none; d=google.com; s=arc-20160816; b=joUsvS8nQjDVza+IngAQoFyfMj+Zga5ureRtAvsIC/OIFQC/Dk5VKaPHk+xqoV3ybv 4HexRbnc5SVO+5KKUBsQnMUEKw1jx4s8c/vVWwvAxu2pf+4ewfaBdCG9HinppWmcqTJp smlAY6KYiuES/RaMZ+0iDnWSEWix6u9u3kKHUvhup/iHXwCe4Md/iUxM2QrebjBuwG4n /5sm/i1z02dAfO1m68s/Y5pTaqcYXSLfhpfBRdzb132kuoDl6hK+XtwFUmQ0a3cDuCKT xVTsmigYt2nUSiuESllD35SdzEu5pOtgsL+vFz2yWm+ZwRIYtLO8upmS/rl5PGIjhGAA k6jw== 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 :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=zI7RcZiPaTDKMltPgs4ZCXXOEkuyhKs5pu9RAgGaQCM=; b=ES+s0cAS0Zhfuf5mGdEojxOAWnTEni9Kpg+SpjL63ea77jEqCPYjv8XSw+ZbMYhqlD yZ4V/WYDsVUGqSbtiQum7/9PQUxIMNtS0XNiGBX9Mi9NNyHjG8A9wVGLcwlSK5d3s++d 1+nnKDpcW5/cD9ardQ6gvO/xyaByWsOf7i0uCuANQV5ECvCNixNuRIWb71tB98Y2yzT9 zP1gGaf6K+KnkfRkUNZ9pKsHZ8JjJw0+Mw1qv2ez8f6UETDIkdlZgJSadVBuSmrCdebQ eBadJH5gfI2Fm63FSxcVRh446eGdHNidP6Gemg8X9pMBODkOKWifRB1oZpFa0Vm8TWgS HZ4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lechnology.com header.s=default header.b=WDBX+cAn; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d3-20020a170902728300b00186bc66d2cdsi11892pll.75.2022.11.04.10.02.10; Fri, 04 Nov 2022 10:02:29 -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=fail header.i=@lechnology.com header.s=default header.b=WDBX+cAn; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231130AbiKDQqX (ORCPT + 96 others); Fri, 4 Nov 2022 12:46:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229756AbiKDQqV (ORCPT ); Fri, 4 Nov 2022 12:46:21 -0400 Received: from vern.gendns.com (vern.gendns.com [98.142.107.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EE1231EF9; Fri, 4 Nov 2022 09:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=zI7RcZiPaTDKMltPgs4ZCXXOEkuyhKs5pu9RAgGaQCM=; b=WDBX+cAnoxNFA2qROraJWPqwl6 sawOBGcwqy0cJOAIrVpjLZZ+Gx2IKKPpzlq32XA8dIyrUdyxFM7DDARo5oPRviL3HJfndmG8Y/6DX JszwjA1qIBE963R9b+AbWyWXzot3CnWQfj8Q3yBrd7GtzWZM+7HpOT38Y0pygwUoqjt9E5drTi3PA iwRZOCwQqQ0SXdmD9XyBdaTbR1R3prwAqmXw5Hw/1of8Akd3I0gnrXsFcDHUGIRQzdA3pfYYEcbWP RGvTglAlnqK66tcDfALPc+yDGWDJk2SuAVwnrNdyQUQOE9Eu+PrDksdtVsbsh6ynJyaP/aeQMp/TT YGTHedGw==; Received: from ip98-183-112-30.ok.ok.cox.net ([98.183.112.30]:45370 helo=[192.168.0.134]) by vern.gendns.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.95) (envelope-from ) id 1oqzpN-00ChtK-Ip; Fri, 04 Nov 2022 12:46:11 -0400 Message-ID: <4a91a4cf-acac-387f-19a5-e2ce144f3496@lechnology.com> Date: Fri, 4 Nov 2022 11:46:02 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v2 22/65] clk: davinci: da8xx-cfgchip: Add a determine_rate hook Content-Language: en-US To: Maxime Ripard , 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 , =?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 , Sascha Hauer , Mark Brown , Max Filippov , Geert Uytterhoeven Cc: 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 References: <20221018-clk-range-checks-fixes-v2-0-f6736dec138e@cerno.tech> <20221018-clk-range-checks-fixes-v2-22-f6736dec138e@cerno.tech> From: David Lechner In-Reply-To: <20221018-clk-range-checks-fixes-v2-22-f6736dec138e@cerno.tech> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS, SPF_PASS 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 On 11/4/22 8:17 AM, Maxime Ripard wrote: > The Davinci DA8xxx cfgchip "clk48" 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. The parent is defined in the device tree and is not expected to change at runtime, so if I am understanding the patch correctly, setting the CLK_SET_RATE_NO_REPARENT flag seems correct. > > Signed-off-by: Maxime Ripard > --- > drivers/clk/davinci/da8xx-cfgchip.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/clk/davinci/da8xx-cfgchip.c b/drivers/clk/davinci/da8xx-cfgchip.c > index c04276bc4051..4c1cc59bba53 100644 > --- a/drivers/clk/davinci/da8xx-cfgchip.c > +++ b/drivers/clk/davinci/da8xx-cfgchip.c > @@ -565,6 +565,7 @@ static u8 da8xx_usb1_clk48_get_parent(struct clk_hw *hw) > } > > static const struct clk_ops da8xx_usb1_clk48_ops = { > + .determine_rate = __clk_mux_determine_rate, > .set_parent = da8xx_usb1_clk48_set_parent, > .get_parent = da8xx_usb1_clk48_get_parent, > }; > @@ -589,6 +590,7 @@ da8xx_cfgchip_register_usb1_clk48(struct device *dev, > > init.name = "usb1_clk48"; > init.ops = &da8xx_usb1_clk48_ops; > + init.flags = CLK_SET_RATE_NO_REPARENT; > init.parent_names = parent_names; > init.num_parents = 2; > >