From: Thomas Richard <thomas.richard@bootlin.com>
To: Nishanth Menon <nm@ti.com>
Cc: Tero Kristo <kristo@kernel.org>,
Santosh Shilimkar <ssantosh@kernel.org>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Gregory CLEMENT <gregory.clement@bootlin.com>,
richard.genoud@bootlin.com, Udit Kumar <u-kumar1@ti.com>,
Abhash Kumar <a-kumar2@ti.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
Dhruva Gole <d-gole@ti.com>, Kendall Willis <k-willis@ti.com>
Subject: Re: [PATCH v6 3/4] clk: keystone: sci-clk: add restore_context() operation
Date: Tue, 5 May 2026 17:14:31 +0200 [thread overview]
Message-ID: <676912d8-a957-48dc-9182-5a6a1162b3f4@bootlin.com> (raw)
In-Reply-To: <20260505114249.y7svb7jf7w64zflo@concerned>
On 5/5/26 1:42 PM, Nishanth Menon wrote:
> On 14:21-20260427, Thomas Richard (TI) wrote:
>> Implement the restore_context() operation to restore the clock rate and the
>> clock parent state. The clock rate is saved in sci_clk struct during
>> set_rate() and recalc_rate() operations. The parent index is saved in
>> sci_clk struct during set_parent() operation. During clock registration,
>> the core retrieves each clock’s parent using get_parent() operation to
>> ensure the internal clock tree reflects the actual hardware state,
>> including any configurations made by the bootloader. So we also save the
>> parent index in get_parent().
>>
>> Reviewed-by: Dhruva Gole <d-gole@ti.com>
>> Reviewed-by: Kendall Willis <k-willis@ti.com>
>> Signed-off-by: Thomas Richard (TI) <thomas.richard@bootlin.com>
>> ---
>> drivers/clk/keystone/sci-clk.c | 44 ++++++++++++++++++++++++++++++++++--------
>> 1 file changed, 36 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c
>> index 9d5071223f4c..b090edf5f82e 100644
>> --- a/drivers/clk/keystone/sci-clk.c
>> +++ b/drivers/clk/keystone/sci-clk.c
>> @@ -47,6 +47,8 @@ struct sci_clk_provider {
>> * @node: Link for handling clocks probed via DT
>> * @cached_req: Cached requested freq for determine rate calls
>> * @cached_res: Cached result freq for determine rate calls
>> + * @parent_id: Parent index for this clock
>> + * @rate: Clock rate
>> */
>> struct sci_clk {
>> struct clk_hw hw;
>> @@ -58,6 +60,8 @@ struct sci_clk {
>> struct list_head node;
>> unsigned long cached_req;
>> unsigned long cached_res;
>> + u8 parent_id;
>> + unsigned long rate;
>> };
>>
>> #define to_sci_clk(_hw) container_of(_hw, struct sci_clk, hw)
>> @@ -150,6 +154,8 @@ static unsigned long sci_clk_recalc_rate(struct clk_hw *hw,
>> return 0;
>> }
>>
>> + clk->rate = freq;
>> +
>> return freq;
>> }
>>
>> @@ -210,10 +216,15 @@ static int sci_clk_set_rate(struct clk_hw *hw, unsigned long rate,
>> unsigned long parent_rate)
>> {
>> struct sci_clk *clk = to_sci_clk(hw);
>> + int ret;
>>
>> - return clk->provider->ops->set_freq(clk->provider->sci, clk->dev_id,
>> - clk->clk_id, rate / 10 * 9, rate,
>> - rate / 10 * 11);
>> + ret = clk->provider->ops->set_freq(clk->provider->sci, clk->dev_id,
>> + clk->clk_id, rate / 10 * 9, rate,
>> + rate / 10 * 11);
>> + if (!ret)
>> + clk->rate = rate;
>> +
>> + return ret;
>> }
>>
>> /**
>> @@ -237,9 +248,9 @@ static u8 sci_clk_get_parent(struct clk_hw *hw)
>> return 0;
>
> What happens if get_parent() fails during clock registration? Looking at
> sci_clk_get_parent(), if the firmware call fails, parent_id will be a
> valid value of 0? and in restore, we'd attempt to restore it back? I
> think that is wrong.
Okay. I'll use an integer for parent_id, so I can also store
get_parent()'s return code in case of error. And in restore_context() I
call set_parent() only if num_parents > 1 and parent_id >= 0.
Best Regards,
Thomas
next prev parent reply other threads:[~2026-05-05 15:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 12:21 [PATCH v6 0/4] firmware: ti_sci: Introduce BOARDCFG_MANAGED mode for Jacinto family Thomas Richard (TI)
2026-04-27 12:21 ` [PATCH v6 1/4] firmware: ti_sci: add BOARDCFG_MANAGED mode support Thomas Richard (TI)
2026-04-27 12:21 ` [PATCH v6 2/4] firmware: ti_sci: add support for restoring IRQs during resume Thomas Richard (TI)
2026-05-05 11:32 ` Nishanth Menon
2026-05-05 13:16 ` Thomas Richard
2026-05-05 13:20 ` Nishanth Menon
2026-04-27 12:21 ` [PATCH v6 3/4] clk: keystone: sci-clk: add restore_context() operation Thomas Richard (TI)
2026-04-27 15:08 ` Brian Masney
2026-04-29 3:57 ` Stephen Boyd
2026-05-05 11:42 ` Nishanth Menon
2026-05-05 15:14 ` Thomas Richard [this message]
2026-04-27 12:21 ` [PATCH v6 4/4] firmware: ti_sci: add support for restoring clock context during resume Thomas Richard (TI)
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=676912d8-a957-48dc-9182-5a6a1162b3f4@bootlin.com \
--to=thomas.richard@bootlin.com \
--cc=a-kumar2@ti.com \
--cc=d-gole@ti.com \
--cc=gregory.clement@bootlin.com \
--cc=k-willis@ti.com \
--cc=kristo@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=nm@ti.com \
--cc=richard.genoud@bootlin.com \
--cc=sboyd@kernel.org \
--cc=ssantosh@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=u-kumar1@ti.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox