From: Inochi Amaoto <inochiama@gmail.com>
To: Jerome Brunet <jbrunet@baylibre.com>, Icenowy Zheng <uwu@icenowy.me>
Cc: Rob Herring <robh@kernel.org>, Han Gao <gaohan@iscas.ac.cn>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Chen Wang <chen.wang@linux.dev>,
Inochi Amaoto <inochiama@gmail.com>, Yao Zi <me@ziyao.cc>,
Chen Wang <unicorn_wang@outlook.com>,
Han Gao <rabenda.cn@gmail.com>,
linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
sophgo@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 0/2] clk: sophgo: sg2042: Keep gates used by firmware enabled
Date: Thu, 3 Dec 2026 21:41:07 +0800 [thread overview]
Message-ID: <axFuDVOBT1fQRtDv@inochi.infowork> (raw)
In-Reply-To: <179624000421.3767986.8173736547788472972.b4-reply@b4>
On Wed, Dec 02, 2026 at 08:33:24PM +0100, Jerome Brunet wrote:
> On 2026-12-03 00:29 +0800, Icenowy Zheng wrote:
> > 在 2026-12-02三的 08:50 -0600,Rob Herring写道:
> > > On Fri, Nov 27, 2026 at 04:01:32PM +0100, Jerome Brunet wrote:
> > > > > On Milk-V Pioneer, firmware uses I2C0 for the EFI RTC and the serial
> > > > > flash for its own image and EFI variables. Both sit behind clock gates
> > > > > shared with devices Linux drives, so runtime PM on the Linux side can
> > > > > turn them off under the firmware, and GetTime() returns EFI_NOT_READY.
> > > > >
> > > > > Let firmware list such gates in protected-clocks on the clkgen node,
> > > > > and keep them enabled.
> > > > >
> > > > > qcom, the only current user of protected-clocks, does not register such
> > > > > clocks at all. That would break the I2C controllers Linux uses, as the
> > > > > DesignWare driver needs the clock rate, so here they stay registered and
> > > > > are only kept on. I'm not sure this fits the intended use; suggestions
> > > > > welcome.
> > > > >
> > > > > Tested on Milk-V Pioneer.
> > > > >
> > > > > Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
> > > > > ---
> > > > > Changes in v2:
> > > > > - Drop the EFI MMIO patch, Ard is taking it through the EFI tree
> > > > > - Use protected-clocks instead of scanning reserved nodes under /soc
> > > > > (Krzysztof)
> > > >
> > > > Hey Krzysztof,
> > > >
> > > > Using protected-clocks in the way proposed in this series would give it a different
> > > > behavior/meaning compared to what introduced it in Qcom:
> > > >
> > > > - Qualcomm skips registering listed clocks. A consumer requesting a listed ID gets NULL.
> > > > - SG2042 still registers listed gates and marks them CLK_IS_CRITICAL.
> > > > A consumer gets a valid clock handle, can read its rate, but releasing its enable
> > > > reference won’t turn off the hardware gate.
> > > >
> > > > Having different meaning for the same property is not ideal, is it ?
> > > > Eventually that might be something we could fold into the framework, but that can only
> > > > happen if the meaning is consistent.
> >
> > Well in fact the purpose isn't the same on QCOM and SG2042 here:
> >
> > - On Qualcomm platforms, all resources specified as "protected" in DT is
> > really protected by the TEE. If Linux even dare to touch these resources,
> > the TEE will consider this as tamper of TEE security and hang the system,
> > so these resources should never be touched by Linux.
> > - On SG2042, there's no security enforcement on these resources, and Linux
> > has the permission to access them. However this will render some part of
> > the EFI runtime service unavailable, so for the sake of EFI runtime service
> > availability these resources need to be kept on by Linux.
> >
> > These two behaviors are not possible to be unified, although the latter
> > isn't restricted to SG2042 and is common on EFI-booted embedded systems.
> >
> > Maybe a new name (instead of protected-*) could be chosen for the latter
> > behavior. Considering it would behaves like the `assigned-clock*` family
> > when in the clock framework, maybe something like `assigned-clock-on = <0>
> > /* doing nothing */, <1> /* keep the corresponding assigned-clocks entry on
> > */;` ?
>
>
> For sure, It'd prefer if a property had single meaning regardless of the SoC so
> not protected-clocks please.
>
> I thought this reminded me of something and we have been down that road before:
> https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/tree/drivers/clk/clk.c?h=clk-next#n5600
>
> So apparently there was good reason not to do this 10y ago but I don't have
> the history on it. I'll try to dig.
>
> --
> Jerome
>
Hi Jerome,
A new name could be a better option. My understanding is that the
protected-clocks is more like requirement from the firmware, so the
kernel must ignore it, whether it will hang the system or not.
The usage on SG2042 is more like a negotiation between the firmware
and kernel. The clock can be referenced by the kernel, but it is
still controlled by the firmware. Maybe we also need a new clock
flag to mark it. Mark it critial does not tell the kernel that it
is controlled by others like firmware.
Regards,
Inochi
next prev parent reply other threads:[~2026-12-03 13:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 18:18 [PATCH v2 0/2] clk: sophgo: sg2042: Keep gates used by firmware enabled Han Gao via B4 Relay
2026-11-21 18:18 ` Han Gao
2026-11-21 18:18 ` [PATCH v2 1/2] dt-bindings: clock: sophgo: Allow protected gate clocks on SG2042 Han Gao via B4 Relay
2026-11-21 18:18 ` Han Gao
2026-11-21 18:18 ` [PATCH v2 2/2] clk: sophgo: Keep SG2042 gates listed in protected-clocks enabled Han Gao via B4 Relay
2026-11-21 18:18 ` Han Gao
2026-11-21 23:48 ` Inochi Amaoto
2026-11-22 11:50 ` Jerome Brunet
2026-11-27 15:01 ` [PATCH v2 0/2] clk: sophgo: sg2042: Keep gates used by firmware enabled Jerome Brunet
2026-12-02 14:50 ` Rob Herring
2026-12-02 16:29 ` Icenowy Zheng
2026-12-02 19:33 ` Jerome Brunet
2026-12-03 10:02 ` Icenowy Zheng
2026-12-03 13:41 ` Inochi Amaoto [this message]
2026-12-03 18:06 ` Yao Zi
2026-12-03 18:34 ` Jerome Brunet
2026-12-04 20:25 ` Rob Herring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=axFuDVOBT1fQRtDv@inochi.infowork \
--to=inochiama@gmail.com \
--cc=bmasney+clk@redhat.com \
--cc=chen.wang@linux.dev \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gaohan@iscas.ac.cn \
--cc=jbrunet+clk@baylibre.com \
--cc=jbrunet@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=me@ziyao.cc \
--cc=rabenda.cn@gmail.com \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=sophgo@lists.linux.dev \
--cc=unicorn_wang@outlook.com \
--cc=uwu@icenowy.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.