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: <0558282c-1471-84fb-d0f2-00e998db5cab@microchip.com>
Date:   Wed, 1 Jul 2020 09:47:40 +0000
From:   <Claudiu.Beznea@...rochip.com>
To:     <alexandre.belloni@...tlin.com>
CC:     <mturquette@...libre.com>, <sboyd@...nel.org>,
        <Nicolas.Ferre@...rochip.com>, <Ludovic.Desroches@...rochip.com>,
        <linux-kernel@...r.kernel.org>, <mturquette@...aro.org>,
        <bbrezillon@...nel.org>, <linux-clk@...r.kernel.org>,
        <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH 2/2] clk: at91: main: do not continue if oscillators
 already prepared



On 27.06.2020 00:03, Alexandre Belloni wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On 25/06/2020 13:09:28+0300, Claudiu Beznea wrote:
>> Return in clk_main_osc_prepare()/clk_main_rc_osc_prepare() if
>> oscillators are already enabled.
>>
>> Fixes: 27cb1c2083373 ("clk: at91: rework main clk implementation")
>> Fixes: 1bdf02326b71e ("clk: at91: make use of syscon/regmap internally")
> 
> Is this really a fix? What is the observed issue?
> 
>> Signed-off-by: Claudiu Beznea <claudiu.beznea@...rochip.com>
>> ---
>>  drivers/clk/at91/clk-main.c | 18 +++++++++---------
>>  1 file changed, 9 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c
>> index 37c22667e831..46b4d2131989 100644
>> --- a/drivers/clk/at91/clk-main.c
>> +++ b/drivers/clk/at91/clk-main.c
>> @@ -74,13 +74,11 @@ static int clk_main_osc_prepare(struct clk_hw *hw)
>>       regmap_read(regmap, AT91_CKGR_MOR, &tmp);
>>       tmp &= ~MOR_KEY_MASK;
>>
>> -     if (tmp & AT91_PMC_OSCBYPASS)
>> +     if (tmp & (AT91_PMC_OSCBYPASS | AT91_PMC_MOSCEN))
>>               return 0;
> 
> While this seems like a good optimization, it is also not correct.
> Having AT91_PMC_MOSCEN set doesn't mean that the clock is ready, you
> need to at least check MOSCS once.

I agree! This is may introduce issues. Thank you for reviewing it.

> 
>>
>> -     if (!(tmp & AT91_PMC_MOSCEN)) {
>> -             tmp |= AT91_PMC_MOSCEN | AT91_PMC_KEY;
>> -             regmap_write(regmap, AT91_CKGR_MOR, tmp);
>> -     }
>> +     tmp |= AT91_PMC_MOSCEN | AT91_PMC_KEY;
>> +     regmap_write(regmap, AT91_CKGR_MOR, tmp);
>>
>>       while (!clk_main_osc_ready(regmap))
>>               cpu_relax();
>> @@ -186,10 +184,12 @@ static int clk_main_rc_osc_prepare(struct clk_hw *hw)
>>
>>       regmap_read(regmap, AT91_CKGR_MOR, &mor);
>>
>> -     if (!(mor & AT91_PMC_MOSCRCEN))
>> -             regmap_update_bits(regmap, AT91_CKGR_MOR,
>> -                                MOR_KEY_MASK | AT91_PMC_MOSCRCEN,
>> -                                AT91_PMC_MOSCRCEN | AT91_PMC_KEY);
>> +     if (mor & AT91_PMC_MOSCRCEN)
>> +             return 0;
>> +
>> +     regmap_update_bits(regmap, AT91_CKGR_MOR,
>> +                        MOR_KEY_MASK | AT91_PMC_MOSCRCEN,
>> +                        AT91_PMC_MOSCRCEN | AT91_PMC_KEY);
>>
>>       while (!clk_main_rc_osc_ready(regmap))
>>               cpu_relax();
>> --
>> 2.7.4
>>
> 
> --
> Alexandre Belloni, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ