Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1401660rwb; Mon, 7 Nov 2022 00:57:42 -0800 (PST) X-Google-Smtp-Source: AMsMyM4QihdPvXj/G5ULCAIoLrhnCI69xVg+NWIh0uzdGAXyhKiQgfpE4bzyAasodmWI2UAdrrLZ X-Received: by 2002:a63:2ad8:0:b0:46e:bb8e:b343 with SMTP id q207-20020a632ad8000000b0046ebb8eb343mr42037582pgq.408.1667811462197; Mon, 07 Nov 2022 00:57:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667811462; cv=none; d=google.com; s=arc-20160816; b=lxFCRGZQ+ZI6szd0t8wu4jFsm3xGoViBcwFpHjMlwgzrovCzQaPx3avlEEjZ0W9XQd kaPQAao6+vX5Uww7IsyU3Cd+Mc5X2gE6i22JtjOc91vEeD2IolG5nAgsFXcZjdv+qRqR DicurGzVChhqMYlEa3NCjDBzitYLCO15TwhCn6hJfLnTsU4AmCtReKL94R3z2Cpi1lnY pBQY0FEv85vQ9OLar8UcfepdCfNU5M4OQFJIMBcfIDZTUhBJnbkSLIWsTH0oJ7Vv92gW i8Rn3QR/sqA6zkKCmOl6z81vya/RKj7OKQNnalk1ISKulrUV/1+gjoDtuN0kQvBtFfmk w1bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:feedback-id:dkim-signature:dkim-signature; bh=DpobGsjjO6+ObD0CgLx0PfBT5w/ojqtKffWwUQfBXkA=; b=MIxeyDtbtV+zq11k9UKOEAG4ztkOqGZmZc0qOnPTOPHNL+MV5C7NVBJXIX+DY82rkP kh/S9HsurGeAz96DvJfI6GxmXy0Eaig80N99hn6KSlq9XTKeNwN1BNnGevcAVrByWoDB QaFc8ra66Mo8pcBT+0UY1MzxLyVfpqi0tat8L6I0OD841njP/vYv+Mi4o5PsgUqsjdTy K5XRbXsIQbSqU9mu06OSMAfAZ21mlQBExB2G8WMGydmghiTt2F5AYzYfAQ6VKP1vbCyr wDV/QzHEve7xN3nAlwu7Ll6446RU3xgCBTAcBPNeAb39DFXy5WPIcPs/5CtR+mU54p7V oR3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=aL7x6Ved; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=awf3lMuG; 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=cerno.tech Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 79-20020a630052000000b0046fcd2ffc76si9567240pga.772.2022.11.07.00.57.29; Mon, 07 Nov 2022 00:57:42 -0800 (PST) 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=@cerno.tech header.s=fm2 header.b=aL7x6Ved; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=awf3lMuG; 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=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231324AbiKGIy1 (ORCPT + 96 others); Mon, 7 Nov 2022 03:54:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231448AbiKGIyX (ORCPT ); Mon, 7 Nov 2022 03:54:23 -0500 Received: from new4-smtp.messagingengine.com (new4-smtp.messagingengine.com [66.111.4.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FAFABE3A; Mon, 7 Nov 2022 00:54:22 -0800 (PST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id CBDFB580981; Mon, 7 Nov 2022 03:54:21 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Mon, 07 Nov 2022 03:54:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1667811261; x= 1667818461; bh=DpobGsjjO6+ObD0CgLx0PfBT5w/ojqtKffWwUQfBXkA=; b=a L7x6VeduJt+1Hu5h1m6xZv3p7hN365kpXqH5SuShvo3zwCzJIKsm96bEmylPDRnr vKihkUHqJ+opr8d5eypGD34fQlnFGyxPjZz8U+6RxuJq36EaUEjtGGOHxWFWJmsR xF8mQxK/zVQWtqPsaAi62pWa+AWIoU2BQQvgaXR8zkOkphgUl8UR2UNnuFhq1pY6 BBMhiWDZbMK+qFDNXAtIYmad+XRLYmN1xRyV+Cdif96MtdkOqfkm8tHhatycY5y4 6hqoUGqXVWC6P521j5IjRmmgaDJ6w3DWXYznabMX8M7Hgb9gEW6XKEk3hW0kJ2QI +2VDPHajg+fFKI1/fw4zg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1667811261; x= 1667818461; bh=DpobGsjjO6+ObD0CgLx0PfBT5w/ojqtKffWwUQfBXkA=; b=a wf3lMuGSE0c+KKuKS9VUt+n1OzUMiXhyTIxQLBDjWgJq5Rasjs/0LinZ+VNNis3Q alYUFBZQZ1o6/Q54VwJt3hqIwUHR2Sqily3v9eJVSTlP+Hu2fMStre5KXTVYz4tY up+dWJV8xLSoFiZUgzmweb/bZBcB/fFtJnk3gDOGBjofi4mAWNWAPpiPA0jEfPrm qZYWyDNc5qSMORFII98iU3MY0TQmveTRjRLYGwUC3eXJUsRYRr3v7if3WJeSkO6I j3g07rByjglyFc5HGmp7F1QOFNm/ObUDgojleoszz+DZFx1tbTqcAVeOKkORWZom ZIRqMfyKz+fN8PnA+frdQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrvdejgdduvdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggugfgjsehtqhertddttddunecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepleelfeeileelteetfedvieekfeefffevhfdtvefgheevudevheejvddv ieeltdeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 7 Nov 2022 03:54:18 -0500 (EST) Date: Mon, 7 Nov 2022 09:54:17 +0100 From: Maxime Ripard To: Aidan MacDonald Cc: Paul Cercueil , 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 , Chunyan Zhang , Manivannan Sadhasivam , Andreas =?utf-8?Q?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 Subject: Re: [PATCH v2 56/65] clk: ingenic: cgu: Switch to determine_rate Message-ID: <20221107085417.xrsh6xy3ouwdkp4z@houat> References: <20221018-clk-range-checks-fixes-v2-0-f6736dec138e@cerno.tech> <20221018-clk-range-checks-fixes-v2-56-f6736dec138e@cerno.tech> <80VTKR.CE8RVN8M3ZYK3@crapouillou.net> <20221104145946.orsyrhiqvypisl5j@houat> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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 Hi, On Fri, Nov 04, 2022 at 05:35:29PM +0000, Aidan MacDonald wrote: >=20 > Maxime Ripard writes: >=20 > > Hi Paul, > > > > On Fri, Nov 04, 2022 at 02:31:20PM +0000, Paul Cercueil wrote: > >> Le ven. 4 nov. 2022 =E0 14:18:13 +0100, Maxime Ripard a > >> =E9crit : > >> > The Ingenic CGU clocks 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 impli= es, > >> > 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 clo= ck. > >> > > >> > 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 cal= l to > >> > clk_set_parent(). > >> > > >> > The driver does implement round_rate() though, which means that we c= an > >> > change the rate of the clock, but we will never get to change the > >> > parent. > >> > > >> > However, It's hard to tell whether it's been done on purpose or not. > >> > > >> > Since we'll start mandating a determine_rate() implementation, let's > >> > convert the round_rate() implementation to a determine_rate(), which > >> > will also make the current behavior explicit. And if it was an > >> > oversight, the clock behaviour can be adjusted later on. > >> > >> So it's partly on purpose, partly because I didn't know about > >> .determine_rate. > >> > >> There's nothing odd about having a lonely .set_parent callback; in my = case > >> the clocks are parented from the device tree. > >> > >> Having the clocks driver trigger a parent change when requesting a rate > >> change sounds very dangerous, IMHO. My MMC controller can be parented = to the > >> external 48 MHz oscillator, and if the card requests 50 MHz, it could = switch > >> to one of the PLLs. That works as long as the PLLs don't change rate, = but if > >> one is configured as driving the CPU clock, it becomes messy. > >> The thing is, the clocks driver has no way to know whether or not it is > >> "safe" to use a designated parent. > >> > >> For that reason, in practice, I never actually want to have a clock > >> re-parented - it's almost always a bad idea vs. sticking to the parent= clock > >> configured in the DTS. > > > > Yeah, and this is totally fine. But we need to be explicit about it. The > > determine_rate implementation I did in all the patches is an exact > > equivalent to the round_rate one if there was one. We will never ask to > > change the parent. > > > > Given what you just said, I would suggest to set the > > CLK_SET_RATE_NO_REPARENT flag as well. > > Ideally there should be a way for drivers and the device tree to > say, "clock X must be driven by clock Y", but the clock framework > would be allowed to re-parent clocks freely as long as it doesn't > violate any DT or driver constraints. I'm not really sure what you mean there, sorry. Isn't it what assigned-clock-parents/clk_set_parent() at probe, plus a determine_rate implementation that would affect best_parent_hw would already provide? > That way allowing reparenting doesn't need to be an all-or-nothing > thing, and it doesn't need to be decided at the clock driver level > with special flags. Like I said, the default implementation is already working to what you suggested if I understood properly. However, this has never been tested for any of the drivers in that series so I don't want to introduce (and debug ;)) regressions in all those drivers that were not setting any constraint but never actually tested their reparenting code. So that series is strictly equivalent to what you had before, it's just explicit now. If you find that some other decision make sense for your driver in particular cases, feel free to change it. I barely know most of these platforms, so I won't be able to make that decision (and test it) unfortunately. Maxime