From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795348255; b=AUePIerTnquF7hW/DDMT7ePR1au4F15o0s4Vun4cn97asy3JKm5e6BxllMadkTPTuuFv De3gFQNxSn1S9hdZVzK1M8BCwxL3iaxyn1Pv2a/jIICbMEmmPni0/76BnExpMtNLgdVi7 afIZBfLPPt4IT75EFd2ZdvqbcQljMIWId8PLOB0WbCMMmz2qS2FhOIkYrLY9L7BJYOxwG 5Nm/SLCRP7Y1ttxn/vzfrAwibD43bDDNRRDC+DMzF5hoKM3IzIP7+sgG7DIdm8XC3C3DD iOe4+zvmumiVQkeSJIz5hhssytP4EEmdj8h/irJwZQobn5ym2WJ/4SxSzr1mFk5kpVg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795348255; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: MIME-Version:Content-Type:Content-Transfer-Encoding:Subject:From:To: Cc:In-Reply-To:References:Date:Message-Id:X-Mailer: X-Developer-Signature:X-Developer-Key; bh=cB68K9VszL8x8rzgkP/c3kcIxRgyD3G47ftVYkV0bxo=; b=1UGy1H5EpxKLnLY8qXZbJslUGRaZfrOgH8OtTg11es3pD3++WYSx933jvyYkKIhEBdd+ fXNwT5jzPQPaYYF6g4oUU6D0ILluZuSG3aDuOo7skqupRvu9iFlM0WiFI5R2F/jD8+v0I 9NMunCdPjLIk/0BqLon1lN+IKQdcH/mr3zhGpHrJIldj/ytcR7bAwamF2+HdlyEa2qawC RwR3mHajsvUaQrch0SoNIT4rGz7lp9CtAJlgDTK6vjltO0igcfbEHpUHtrO+aZxCbLVHz GtVML1UxTB8EXYT6W8JnJG2Yhcgw+IeCqmGVq34KLcjpK1fLQt0PZ0yc0ce/1+xyn3g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass header.d=baylibre.com header.i=@baylibre.com header.a=rsa-sha256 header.s=google header.b=BXTr1Cpc; arc=none smtp.remote-ip=209.85.221.47 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 719CF606A331 for ; Sun, 22 Nov 2026 11:50:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 719CF606A331 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.a=rsa-sha256 header.s=google header.b=BXTr1Cpc Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-4a5024b3c28so2040364f8f.0 for ; Sun, 22 Nov 2026 03:50:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1795348253; x=1795953053; darn=vger.kernel.org; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:content-type:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=cB68K9VszL8x8rzgkP/c3kcIxRgyD3G47ftVYkV0bxo=; b=BXTr1Cpcmy5ZiD6nkwYf1A1L9ZCyVYQHqcj/Y58abuAg0pgE+RhWyVUsieT75cDdvA yXOVqq9c9hQTpcmTAl3ScYgP2+pzG94AUnd7Uu4iGgq3E3TMY3RPgcYFU8CIhyOXkAtQ 6QXhqoI2wKBNCHgXsMWP+XUqvnAlFEPs5i+BUSiOmf60BkH8bKtqwa8wsOG0qCTCUyKR PxWNmxMZi9bt3P9i5qg5gwa1pMbvEjvVgMNHP4YDTedsiWQiXKi35IBNUoW+1g8DA+rM 3l+Y3vBncVdAEAdSfwwYN38uSr/9Qvu50bGdHuTrC4i2USUQZeZDuVTuAPEeaNczUs7c a8Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795348253; x=1795953053; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:content-type:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=cB68K9VszL8x8rzgkP/c3kcIxRgyD3G47ftVYkV0bxo=; b=iFmu2mmnry03kh7D6drgNgjaEKZsek4X4UNA6OB+EoTNe7iDBnrY4D/vd6zOF6gbh4 +mDVuUKK0JgpoXab4zfOtlqYsn2grP+cLHcpJd+IOIdYDO7lyHcBy0vUlKpNZeHzfMiE 32JutgNFBrirY1SY6Cjtp64CHVVI1zYb4sbQaN9lN8AzC5SvZ48hMGDHTIHOQZSe0K18 yrbIBQnNoshvTl5+jDDOGoigGpqFcv2K2KSJ8k9004L9u0rDGQooQdqQNyODRRuokgEb yl4fShWoEl9uQhD5fKi5OhO8hewYq1ckPBe9WOHBxnfdUxvyea7kCe+/K2YP/fOXbGnJ +pWw== X-Forwarded-Encrypted: i=1; AL+hErH71T1JXFDPXLt9EyBDyDf9kXlfVOMn0ltpeFpTm1q0M/M6EIbvfwg290AsxfOc2Ex41mcBsTifOl4LolI=@vger.kernel.org X-Gm-Message-State: APuU4Z+cQ6ILaJ8+fFnXfWVHW8nPXXCG8ZRn+amKGGrj+AO6UKUTNaPO 6ht0fESwWQGH1IjouZJZ09T3PIlilHq56ElIwHxTDdAs635Jub7z7OzjYJA1Bt1VjsU= X-Gm-Gg: AZFdTZcGwuva0qgAa2tMYML0lXVoTbce+aHQ2AnyvVFfQ5+TzHrKY5G6XYkDlh/sFgg /rYBEFFZW6DflFsWae7iagHuSLSYBDu0LyuUp6sEMY5BtEPy0fdisDcngu7NvsLSYlOyoUbOIvk BEeJAnfUKBPlL9CSxeptzI7gRX69BheOtqiFzTffFHlqfpTPoxeA8zmK4ei9ggIwqtn9CNwwyy4 wl46x04xLKneFUYzPrEL8mjrspLeaI5x18/0nKLjeWkX+zMfPSLVzIA6LTXx5fGytCKUVBZPZpf 8T9K/DMp0UoFaL51f9ehGK2b/aRVUsq6KWbxsslRV01yWuNE53T0mUoTspPzDhya9M6qkw/YqXP zizXacyK9oHNdyh+wOHjJa5WQeH0m3dUKz+1ySz/SOQl6E2x/P01DMxHamU/o7qV/qhyq/DcATJ A++pz4LKfh+kpeBPcK2B4Mmxx3bPn53CFf8zldzBZIMjW1THXFl81cbdahNRxOTVaou001zq+NY qde5iQp7qYp205Jd8NyYL07hhMSsfxkHNZ/WDTzbLjYzxPmtSGscmvPZMpNDc6HeNajaMvU9n0O hYr1toIyT05eGVBmrgn+fyou5M4QmB+p8vrXnGWIRgPo2/2P X-Received: by 2002:a05:600c:4f81:b0:4bb:5e8c:13bc with SMTP id 5b1f17b1804b1-4bb88805902mr173405365e9.7.1795348252406; Sun, 22 Nov 2026 03:50:52 -0800 (PST) Received: from localhost (82-67-6-57.subs.proxad.net. [82.67.6.57]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb884b39b6sm224616505e9.12.2026.11.22.03.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 03:50:51 -0800 (PST) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: Re: [PATCH v2 2/2] clk: sophgo: Keep SG2042 gates listed in protected-clocks enabled From: Jerome Brunet To: Inochi Amaoto Cc: gaohan@iscas.ac.cn, Stephen Boyd , Brian Masney , Jerome Brunet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Yao Zi , Chen Wang , Han Gao , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, sophgo@lists.linux.dev, linux-kernel@vger.kernel.org, Jerome Brunet In-Reply-To: References: <20261122-b4-sg2042-efi-rtc-v2-0-6d087e03e4e8@iscas.ac.cn> <20261122-b4-sg2042-efi-rtc-v2-2-6d087e03e4e8@iscas.ac.cn> Date: Sun, 22 Nov 2026 12:50:50 +0100 Message-Id: <179534825090.2640804.3856644920774930042.b4-reply@b4> X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3068; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=IdvAZSlfVMHZbcbQ9G6YqRxqWmYmrg7EOTVCXlS1rG0=; b=owGbwMvMwCW2VtK+WnvWU3HG02pJDNlM16Wzti9b2Wcj+sZr/8Q3E4TmvSufv1fHe5WQhkfj0 X8WB/JlOkpZGMS4GGTFFFlquKvF30lqfZk1Xec2zBxWJpAhDFycAjCRHVMZ/sf6PNWvYa1VURFr F0ydaZ7j9G934ovvrXmKRy+Hcz3l+cfwP++79vPLcQoXdE3O1TXcuHF2/95D0RMVjNUXfO+d4nf BlwMA X-Developer-Key: i=jbrunet@baylibre.com; a=openpgp; fpr=F29F26CF27BAE1A9719AE6BDC3C92AAF3E60AED9 On 2026-11-22 07:48 +0800, Inochi Amaoto wrote: > On Sun, Nov 22, 2026 at 02:18:05AM +0800, Han Gao via B4 Relay wrote: > > From: Han Gao > > > > On Milk-V Pioneer, EFI runtime services use I2C0 and the serial flash, > > while Linux drives other devices behind the same gates. When those > > devices runtime-suspend, the gates are turned off under the firmware. > > > > Mark gates listed in protected-clocks as critical. Unlike qcom, still > > register them, since Linux devices use them too. > > > > Suggested-by: Yao Zi > > Signed-off-by: Han Gao > > --- > > drivers/clk/sophgo/clk-sg2042-clkgen.c | 16 ++++++++++++++-- > > 1 file changed, 14 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/clk/sophgo/clk-sg2042-clkgen.c b/drivers/clk/sophgo/clk-sg2042-clkgen.c > > index 6abc2c973c49..65ab18f701e1 100644 > > --- a/drivers/clk/sophgo/clk-sg2042-clkgen.c > > +++ b/drivers/clk/sophgo/clk-sg2042-clkgen.c > > @@ -840,6 +840,18 @@ static int sg2042_clk_register_divs(struct device *dev, > > return ret; > > } > > > > +static unsigned long sg2042_gate_flags(struct device *dev, > > + const struct sg2042_gate_clock *gate) > > +{ > > + u32 id; > > + > > + of_property_for_each_u32(dev->of_node, "protected-clocks", id) > > + if (id == gate->id) If you are going to do it this way, restricting to gates looks like a pitfall that would difficult to anticipate from the DT side. > > + return gate->hw.init->flags | CLK_IS_CRITICAL; > > + > > + return gate->hw.init->flags; > > +} > > + > > I have a question on this: since a procteded clock should not be touched > by a driver. Is this logic necessary? I guess this is a shared clock > topology between the kernel and the firmare? > > Regards, > Inochi It depends what the intent is with protected-clocks here. This apparently starte as a qcom specific flag and it might, unfortunately, be a bit confusing with CCF existing concept of clock protection. CCF concept of protected (or exlusive) clock is basically a clock that do not tolerate rate change or glitch, resulting from a direct rate change of the clock from another consumer or one of its parents. Essentially, all the tree leading to the related clock gets locked. This is accessed with the consumer API clk_rate_exclusive_get/put(). CLK_IS_CRITICAL is special case where the clock is locked and protected by the provider, even in the absence of a consumer. Consumer can still get the clock, enable or disable it but it won't ever result in the HW actually turning the clock off. clk_set_rate() will error out if the request would result in a disallowed glitch. Apparently Qcom use of the flag is to skip the registration of clock, presumably because they've got something else controlling the clock. An alternative to this is register the clock with RO ops and NO_CACHE, this way CCF still expose the clock but does not touch it and you can still get it in drivers if need be. -- Jerome