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] [thread-next>] [day] [month] [year] [list]
Message-ID: <DM6PR11MB31314A9FCC12CBCA581052E7E7D00@DM6PR11MB3131.namprd11.prod.outlook.com>
Date:   Tue, 27 Nov 2018 17:44:02 +0000
From:   Ryan Lee <RyanS.Lee@...imintegrated.com>
To:     Grant Grundler <grundler@...omium.org>
CC:     Liam Girdwood <lgirdwood@...il.com>,
        "broonie@...nel.org" <broonie@...nel.org>,
        "perex@...ex.cz" <perex@...ex.cz>,
        "tiwai@...e.com" <tiwai@...e.com>,
        Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>,
        Benson Leung <bleung@...omium.org>,
        "alsa-devel@...a-project.org" <alsa-devel@...a-project.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] ASoC: max98373: Added max98373_reset for stable amp reset

Grant,
Thanks for your feedback. Please find my answers inline.
>-----Original Message-----
>From: Grant Grundler <grundler@...omium.org>
>Sent: Monday, November 26, 2018 6:25 PM
>To: Ryan Lee <RyanS.Lee@...imintegrated.com>
>Cc: Liam Girdwood <lgirdwood@...il.com>; broonie@...nel.org;
>perex@...ex.cz; tiwai@...e.com; Grant Grundler
><grundler@...omium.org>; Kuninori Morimoto
><kuninori.morimoto.gx@...esas.com>; Benson Leung
><bleung@...omium.org>; alsa-devel@...a-project.org; LKML <linux-
>kernel@...r.kernel.org>
>Subject: Re: [PATCH] ASoC: max98373: Added max98373_reset for stable amp
>reset
>
>EXTERNAL EMAIL
>
>
>
>Hi Ryan!
>
>Just some questions inline - in general I like the reset function.
>
>On Mon, Nov 26, 2018 at 10:46 AM Ryan Lee
><RyanS.Lee@...imintegrated.com> wrote:
>>
>> Signed-off-by: Ryan Lee <ryans.lee@...imintegrated.com>
>> ---
>>  Changes : Created max98373_reset function to minimize code duplication.
>>            Changed regmap_write to regmap_update_bits. Other bits except LSB
>need to be masked.
>>            Added reset verification step to make sure software reset is
>completed well. Software reset is done in 10ms in normal case.
>>            Revision ID is available when the amp is in the idle state which means
>software reset is completed.
>>            Software reset will be performed maximum 3 times to avoid amp reset
>failure. Generally it is done in the first trial.
>>            sleep time after software reset is increased + 30ms for every retrial.
>Maximum possible msleep time is 100 ms (initial 10 ms + 30 ms * 3 times).
>
>Why is the sleep time increased after each SW reset?
>What is the failure case that you've seen which would benefit from this?
Generally 10ms is enough time for amp software reset but I wanted to add more guard time for the retrial because it is already failed once.
I have not seen a failure issue with 10ms delay on my test setup but I wanted to make it more conservative.
Let me remove this.

>
>>
>>  sound/soc/codecs/max98373.c | 41
>> +++++++++++++++++++++++++++++++++++------
>>  1 file changed, 35 insertions(+), 6 deletions(-)
>>
>> diff --git a/sound/soc/codecs/max98373.c b/sound/soc/codecs/max98373.c
>> index a09d013..55af7f02 100644
>> --- a/sound/soc/codecs/max98373.c
>> +++ b/sound/soc/codecs/max98373.c
>> @@ -724,14 +724,45 @@ static struct snd_soc_dai_driver max98373_dai[] =
>{
>>         }
>>  };
>>
>> +static void max98373_reset(struct max98373_priv *max98373, struct
>> +device *dev) {
>> +       int ret, reg, count, delay;
>> +
>> +       count = 0;
>> +       while (true) {
>> +               /* Software Reset */
>> +               ret = regmap_update_bits(max98373->regmap,
>> +                       MAX98373_R2000_SW_RESET,
>> +                       MAX98373_SOFT_RESET,
>> +                       MAX98373_SOFT_RESET);
>> +               if (ret)
>> +                       dev_err(dev, "Reset command failed.
>> + (ret:%d)\n", ret);
>> +
>> +               delay = 10000 + (count * 30000);
>> +               usleep_range(delay, delay + 1000);
>> +
>> +               /* Software Reset Verification */
>> +               ret = regmap_read(max98373->regmap,
>> +                       MAX98373_R21FF_REV_ID, &reg);
>> +               if (!ret) {
>> +                       dev_info(dev, "Reset completed (retry:%d)\n", count);
>> +                       break;
>
>Instead of break, can the code return here?
>"break" implies something else will happen after the while loop exits
>- there isn't.
Okay. I will fix it. Thanks for the comment.

>
>> +               }
>> +
>> +               if (++count > 3)        {
>> +                       dev_err(dev, "Reset failed. (ret:%d)\n", ret);
>> +                       break;
>> +               }
>> +               usleep_range(10000, 11000);
>
>Why is there a second delay after reading MAX98373_R21FF_REV_ID?
>Is this really necessary?
It is not very necessary. I just wanted to make it more conservative because this delay is applied only when reset is failed.

>
>If the second usleep_range() isn't needed, it would be better/clearer
>to make code loop on "while (count < 4)".   And then outside the while
>loop, use dev_err() to share what the failure was.
OK. Let me fix it.

>
>> +       }
>> +}
>> +
>>  static int max98373_probe(struct snd_soc_component *component)  {
>>         struct max98373_priv *max98373 =
>> snd_soc_component_get_drvdata(component);
>>
>>         /* Software Reset */
>> -       regmap_write(max98373->regmap,
>> -               MAX98373_R2000_SW_RESET, MAX98373_SOFT_RESET);
>> -       usleep_range(10000, 11000);
>> +       max98373_reset(max98373, component->dev);
>>
>>         /* IV default slot configuration */
>>         regmap_write(max98373->regmap, @@ -818,9 +849,7 @@ static int
>> max98373_resume(struct device *dev)  {
>>         struct max98373_priv *max98373 = dev_get_drvdata(dev);
>>
>> -       regmap_write(max98373->regmap,
>> -               MAX98373_R2000_SW_RESET, MAX98373_SOFT_RESET);
>> -       usleep_range(10000, 11000);
>> +       max98373_reset(max98373, dev);
>>         regcache_cache_only(max98373->regmap, false);
>>         regcache_sync(max98373->regmap);
>>         return 0;
>> --
>> 2.7.4
>>
>
>cheers,
>grant

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ