lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <07c7d2c0-f29b-4bf2-abf1-c640c39e6d7a@bootlin.com>
Date: Wed, 3 Dec 2025 15:10:07 +0100
From: Thomas Richard <thomas.richard@...tlin.com>
To: "Kumar, Udit" <u-kumar1@...com>, Nishanth Menon <nm@...com>,
 Tero Kristo <kristo@...nel.org>, Santosh Shilimkar <ssantosh@...nel.org>,
 Michael Turquette <mturquette@...libre.com>, Stephen Boyd <sboyd@...nel.org>
Cc: Gregory CLEMENT <gregory.clement@...tlin.com>,
 richard.genoud@...tlin.com, Prasanth Mantena <p-mantena@...com>,
 Abhash Kumar <a-kumar2@...com>,
 Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
 linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
 linux-clk@...r.kernel.org
Subject: Re: [PATCH RFC v2 3/4] clk: keystone: sci-clk: add restore_context()
 operation

Hi Udit,

On 12/3/25 8:50 AM, Kumar, Udit wrote:
> 
> On 11/27/2025 2:08 PM, Thomas Richard (TI.com) wrote:
>> Implement the restore_context() operation to restore the clock parent
>> state. The parent index is saved in sci_clk struct during set_parent().
>> 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().
>>
>> Signed-off-by: Thomas Richard (TI.com) <thomas.richard@...tlin.com>
>> ---
>>   drivers/clk/keystone/sci-clk.c | 25 ++++++++++++++++++++-----
>>   1 file changed, 20 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/
>> sci-clk.c
>> index a4b42811de55d..1e5dd01484d1c 100644
>> --- a/drivers/clk/keystone/sci-clk.c
>> +++ b/drivers/clk/keystone/sci-clk.c
>> @@ -47,6 +47,7 @@ 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
>>    */
>>   struct sci_clk {
>>       struct clk_hw hw;
>> @@ -58,6 +59,7 @@ struct sci_clk {
>>       struct list_head node;
>>       unsigned long cached_req;
>>       unsigned long cached_res;
>> +    u8 parent_id;
> 
> you may need to restore rate as well

will do in v3.

> 
> 
>>   };
>>     #define to_sci_clk(_hw) container_of(_hw, struct sci_clk, hw)
>> @@ -237,9 +239,9 @@ static u8 sci_clk_get_parent(struct clk_hw *hw)
>>           return 0;
>>       }
>>   -    parent_id = parent_id - clk->clk_id - 1;
>> +    clk->parent_id = (u8)(parent_id - clk->clk_id - 1);
>>   -    return (u8)parent_id;
>> +    return clk->parent_id;
>>   }
>>     /**
>> @@ -252,12 +254,24 @@ static u8 sci_clk_get_parent(struct clk_hw *hw)
>>   static int sci_clk_set_parent(struct clk_hw *hw, u8 index)
>>   {
>>       struct sci_clk *clk = to_sci_clk(hw);
>> +    int ret;
>>         clk->cached_req = 0;
>>   -    return clk->provider->ops->set_parent(clk->provider->sci, clk-
>> >dev_id,
>> -                          clk->clk_id,
>> -                          index + 1 + clk->clk_id);
>> +    ret = clk->provider->ops->set_parent(clk->provider->sci, clk-
>> >dev_id,
>> +                         clk->clk_id,
>> +                         index + 1 + clk->clk_id);
>> +    if (!ret)
>> +        clk->parent_id = index;
>> +
>> +    return ret;
>> +}
>> +
>> +static void sci_clk_restore_context(struct clk_hw *hw)
>> +{
>> +    struct sci_clk *clk = to_sci_clk(hw);
>> +
>> +    sci_clk_set_parent(hw, clk->parent_id);
> 
> You should restore,  if this is BOARD_CFG managed

restore_context() operation is called by clk_restore_context() for each
registered clock. And we call clk_restore_context() from ti_sci driver
only for BOARDCFG_MANAGED mode.

sci-clk driver cannot decide if clock context shall be restored or not.
Decision shall come from ti_sci as it knows the lpm mode.

Best Regards,
Thomas


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ