All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: Phil Reid <preid@electromag.com.au>,
	f.fainelli@gmail.com, andrew@lunn.ch,
	vivien.didelot@savoirfairelinux.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: dsa: b53: Replace mdelay with msleep in b53_switch_reset_gpio
Date: Wed, 11 Apr 2018 15:14:34 +0800	[thread overview]
Message-ID: <7c9dffb7-d55a-98f5-4024-7e2f0c704a56@gmail.com> (raw)
In-Reply-To: <11d079ab-3c07-a10d-c321-f873c53e9690@electromag.com.au>



On 2018/4/11 13:30, Phil Reid wrote:
> On 11/04/2018 09:51, Jia-Ju Bai wrote:
>> b53_switch_reset_gpio() is never called in atomic context.
>>
>> The call chain ending up at b53_switch_reset_gpio() is:
>> [1] b53_switch_reset_gpio() <- b53_switch_reset() <-
>>     b53_reset_switch() <- b53_setup()
>>
>> b53_switch_reset_gpio() is set as ".setup" in struct dsa_switch_ops.
>> This function is not called in atomic context.
>>
>> Despite never getting called from atomic context, 
>> b53_switch_reset_gpio()
>> calls mdelay() to busily wait.
>> This is not necessary and can be replaced with msleep() to
>> avoid busy waiting.
>>
>> This is found by a static analysis tool named DCNS written by myself.
>> And I also manually check it.
>>
>> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
>> ---
>>   drivers/net/dsa/b53/b53_common.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/dsa/b53/b53_common.c 
>> b/drivers/net/dsa/b53/b53_common.c
>> index 274f367..e070ff6 100644
>> --- a/drivers/net/dsa/b53/b53_common.c
>> +++ b/drivers/net/dsa/b53/b53_common.c
>> @@ -597,10 +597,10 @@ static void b53_switch_reset_gpio(struct 
>> b53_device *dev)
>>       /* Reset sequence: RESET low(50ms)->high(20ms)
>>        */
>>       gpio_set_value(gpio, 0);
>> -    mdelay(50);
>> +    msleep(50);
>>         gpio_set_value(gpio, 1);
>> -    mdelay(20);
>> +    msleep(20);
>>         dev->current_page = 0xff;
>>   }
>>
> Would that also imply gpio_set_value could be gpio_set_value_cansleep?
>

Yes, I think gpio_set_value_cansleep() is okay here?
Do I need to send a V2 patch to replace gpio_set_value()?


Best wishes,
Jia-Ju Bai

  reply	other threads:[~2018-04-11  7:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-11  1:51 [PATCH] net: dsa: b53: Replace mdelay with msleep in b53_switch_reset_gpio Jia-Ju Bai
2018-04-11  5:30 ` Phil Reid
2018-04-11  7:14   ` Jia-Ju Bai [this message]
2018-04-11 16:19     ` Florian Fainelli
2018-04-12  1:49       ` Jia-Ju Bai

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=7c9dffb7-d55a-98f5-4024-7e2f0c704a56@gmail.com \
    --to=baijiaju1990@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=preid@electromag.com.au \
    --cc=vivien.didelot@savoirfairelinux.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 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.