Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp961666rwl; Fri, 24 Mar 2023 04:34:36 -0700 (PDT) X-Google-Smtp-Source: AKy350Y9uQLAY1bLElq3qSdKvZDTtoTY23eY6yQgO5ymlfCbZV1bQ8Rs4V3WuEKtdqJNDoCeZonj X-Received: by 2002:aa7:c609:0:b0:4aa:a280:55b5 with SMTP id h9-20020aa7c609000000b004aaa28055b5mr2258676edq.20.1679657676507; Fri, 24 Mar 2023 04:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679657676; cv=none; d=google.com; s=arc-20160816; b=hgNdTKaPazZzZVGiLszuB04U7jaPV6CRAJ8D3w4q45OhS2Kx1YIsKlIiMoX6gYrH9x ZoJ3l7S7xNUIHTFwOax7ke8T6b32yw+FCKI+r0QcaP5CacBbzXBgUlct5WCNlei8JpRC JteWW7PZpu8Q/C2DYagD+j5erUdrJVvrkZP4s4j+qkkg2I1kJ4yVnbMTDrAVbjVL9UsP LALBUd+cKtyPORATbEbvKxEGZkiizjq7gzG87gopnHroUmvHqK1S5MRUxIu28JN89oaB P7NWPlvbFMZHXR1MnbF8hIiucc5564fLSFv8X0gy6l5s9cTkfqHY8Wqx5dWFLiL43Lc0 uSMQ== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=jnhC/DvfTlyZcOnZuUe9LuHIarcRp2uTbbPObwOvLtk=; b=yFD6zYdfcDjYm7MO8uHb5iMfi0BEpiJZagjBMDpDITAcvnWlzJaP4RH4378R1o4sdq BRN2rZ5kLDaGzFtlvPTZZn86c/SrHej4wHke94CsOPs03EYxyPaO/zYCIQrpXNtnhjcO DfNtwA5Ds7H4c9uXc2XQqOSzkO9ZgZGsL8F6Pvi3mW8npitcB+jqoUv7/wAjahL+hWeC k8T6t9hNizY+OomUFxyL2YdV3HaJwRySwdYknYxaBpuIZX6qEhfiQXtD44l5e/1VmvFB HLH9fqMgAN+dnMWVPG3qUjEzjC9GjWnN/eOVwSfey9nsrsuArMqpHjil4IDMHy5gL5qK Tltw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=RINbDJrD; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=G4KWdAq5; 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 f3-20020a05640214c300b004af7e6911e7si21172955edx.528.2023.03.24.04.34.11; Fri, 24 Mar 2023 04:34:36 -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=@cerno.tech header.s=fm3 header.b=RINbDJrD; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=G4KWdAq5; 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 S229997AbjCXLUL (ORCPT + 99 others); Fri, 24 Mar 2023 07:20:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230380AbjCXLUK (ORCPT ); Fri, 24 Mar 2023 07:20:10 -0400 Received: from new2-smtp.messagingengine.com (new2-smtp.messagingengine.com [66.111.4.224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9218225972; Fri, 24 Mar 2023 04:20:08 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailnew.nyi.internal (Postfix) with ESMTP id 02E8758211D; Fri, 24 Mar 2023 07:20:06 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 24 Mar 2023 07:20:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-type: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=fm3; t=1679656805; x=1679664005; bh=jn hC/DvfTlyZcOnZuUe9LuHIarcRp2uTbbPObwOvLtk=; b=RINbDJrDavr91qApxS 4BIapnsTSMpJsQcMuiekOJ4buZfgO1V5bxZUX92x96X+70RG5pM597H6X6A8ze2Q J3K3HTIk9bh/ZbHNJcL4cY9CXoNlp9BFd+TTAQzaGhbL4Q/xS5FNx1TElQW6xvG7 0pWgXxxHWJn2xo8oKO6WZBtJ8/apSTxWaFgzT4XANpTX/yFywGqPfreFSFA+SxYy DVWfFOmgiUFFAwcBCuUS5l1GOHRlbwP6IKA226oMHwgNZfpxX+vE/kqqplzGKxN6 3CA6w8YfKEc956VkNbvyMcVk4fjXMyE6jZ/K83ddG+CzpHvsr07jRCCCdY737Omz uzeA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type: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=fm2; t=1679656805; x=1679664005; bh=jnhC/DvfTlyZc OnZuUe9LuHIarcRp2uTbbPObwOvLtk=; b=G4KWdAq5u3yOdbhwSK/77/yGH7IQB 2xysJ+4DHASMDHD4DpUNSh0qiUQ7PoZ0HeB31FPCqa3ypIcHnjDyiqx4+OASl4vt YII+0RiTBeUGCTuHiRp/2zrlkY7JsRYyob4hyT9jfvFspEvX+TWDxi6HeqVtkkkI EIEz+43mJMF3TccMFqhY9/s2d2q0Bnzb5506eHVsiiRibRjc0JM/OyGd5+joNcoL b2y+9ja4sW5wabUkTzlsQiAxcTUWRGjZRPmuIIWmJFWEdsTq0+X56oaR8GkrkVqB dX4i5J533jmuMxkiG1iqzEHijtLWz0ghQXTKvlKaafFgHLlEw3jiDRZ4g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdegiedgvdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeetfefffefgkedtfefgledugfdtjeefjedvtddtkeetieffjedvgfehheff hfevudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 24 Mar 2023 07:20:01 -0400 (EDT) Date: Fri, 24 Mar 2023 12:19:59 +0100 From: Maxime Ripard To: Aidan MacDonald Cc: Stephen Boyd , Paul Cercueil , 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: <20230324111959.frjf4neopbs67ugd@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> <20221107085417.xrsh6xy3ouwdkp4z@houat> <20221109110045.j24vwkaq3s4yzoy3@houat> <06a293adc75990ed3e297b076fc38d8a.sboyd@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ygvujwxxgbycerm7" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 --ygvujwxxgbycerm7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Thu, Mar 23, 2023 at 03:35:30PM +0000, Aidan MacDonald wrote: >=20 > Stephen Boyd writes: >=20 > > Quoting Maxime Ripard (2022-11-09 03:00:45) > >> On Mon, Nov 07, 2022 at 08:57:22PM +0000, Aidan MacDonald wrote: > >> > > >> > Maxime Ripard writes: > >> > > >> > > Hi, > >> > > > >> > > On Fri, Nov 04, 2022 at 05:35:29PM +0000, Aidan MacDonald wrote: > >> > > >> > Assigning the parent clock in the DT works once, at boot, but going = off > >> > what you wrote in the commit message, if the clock driver has a > >> > .determine_rate() implementation that *can* reparent clocks then it > >> > probably *will* reparent them, and the DT assignment will be lost. > >> > >> Yes, indeed, but assigned-clock-parents never provided any sort of > >> guarantee on whether or not the clock was allowed to reparent or not. > >> It's just a one-off thing, right before probe, and a clk_set_parent() > >> call at probe will override that just fine. > >> > >> Just like assigned-clock-rates isn't permanent. > >> > >> > What I'm suggesting is a runtime constraint that the clock subsystem > >> > would enforce, and actively prevent drivers from changing the parent. > >> > Either explicitly with clk_set_parent() or due to .determine_rate(). > >> > > >> > That way you could write a .determine_rate() implementation that *ca= n* > >> > select a better parent, but if the DT applies a constraint to fix the > >> > clock to a particular parent, the clock subsystem will force that pa= rent > >> > to be used so you can be sure the clock is never reparented by accid= ent. > >> > >> Yeah, that sounds like a good idea, and CLK_SET_RATE_NO_REPARENT isn't > >> too far off from this, it's just ignored by clk_set_parent() for now. I > >> guess we could rename CLK_SET_RATE_NO_REPARENT to CLK_NO_REPARENT, make > >> clk_set_parent handle it, and set that flag whenever > >> assigned-clock-parents is set on a clock. > >> > >> It's out of scope for this series though, and I certainly don't want to > >> deal with all the regressions it might create :) > >> > > > > This sounds like a new dt binding that says the assigned parent should > > never change. It sounds sort of like gpio hogs. A clock-hogs binding? >=20 > Ideally we want the clock driver to be able to reparent clocks freely > to get the best rate. But we also need some control over that to stop > consumers from being reparented in undesired ways. Eg. you might want > to make sure the GPU gets its own PLL so it can be reclocked easily, > and putting another device on the GPU's PLL could prevent that. >=20 > The only way to achieve this today is (1) never do any reparenting in > the clock driver; and (2) use assigned-clock-parents in the DT to set > up the entire clock tree manually. >=20 > Maxime said that (2) is basically wrong -- if assigned-clock-parents > provides no guarantee on what the OS does "after boot" then the OS is > pretty much free to ignore it. I didn't really say it's wrong, just that it never provided the guarantee you expect it to provide. I can't really say whether it's an issue or not on your platform. It's mostly unrelated to this series though, none of these patches affect that behavior in one way or the other. > My suggestion: add a per-clock bitmap to keep track of which parents > are allowed. Any operation that would select a parent clock not on the > whitelist should fail. Automatic reparenting should only select from > clocks on the whitelist. And we need new DT bindings for controlling > the whitelist, for example: >=20 > clock-parents-0 =3D <&clk1>, <&pll_c>; > clock-parents-1 =3D <&clk2>, <&pll_a>, <&pll_b>; >=20 > This means that clk1 can only have pll_c as a parent, while clk2 can > have pll_a or pll_b as parents. By default every clock will be able > to use any parent, so a list is only needed if the machine needs a > more restrictive policy. >=20 > assigned-clock-parents should disable automatic reparenting, but allow > explicit clk_set_parent(). This will allow clock drivers to start doing > reparenting without breaking old DTs. I'm generally not a fan of putting all these policies in the device tree. Do you have an example where it wouldn't be possible to do exactly this from the driver itself? Maxime --ygvujwxxgbycerm7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZB2HXwAKCRDj7w1vZxhR xSbnAQCJvmVlpJgunPtELVTvf4BU6vbdciJ5jecqJV2UslBqNAEA3GtvUaTD5e0p e0nSvm2EbCQGLtQFj+xVrIWIaKTMYAc= =GgBk -----END PGP SIGNATURE----- --ygvujwxxgbycerm7--