2018-01-09 01:36:31

by Jia-Ju Bai

[permalink] [raw]
Subject: [PATCH v2] b43: Replace mdelay with usleep_range in b43_radio_2057_init_post

b43_radio_2057_init_post is not called in an interrupt handler
nor holding a spinlock.
The function mdelay in it can be replaced with usleep_range,
to reduce busy wait.

Signed-off-by: Jia-Ju Bai <[email protected]>
---
v2:
* Replace mdelay with usleep_range, instead of msleep in v1.
Thank Larry for good advice.
---
drivers/net/wireless/broadcom/b43/phy_n.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c b/drivers/net/wireless/broadcom/b43/phy_n.c
index a5557d7..f2a2f41 100644
--- a/drivers/net/wireless/broadcom/b43/phy_n.c
+++ b/drivers/net/wireless/broadcom/b43/phy_n.c
@@ -1031,7 +1031,7 @@ static void b43_radio_2057_init_post(struct b43_wldev *dev)

b43_radio_set(dev, R2057_RFPLL_MISC_CAL_RESETN, 0x78);
b43_radio_set(dev, R2057_XTAL_CONFIG2, 0x80);
- mdelay(2);
+ usleep_range(2000, 3000);
b43_radio_mask(dev, R2057_RFPLL_MISC_CAL_RESETN, ~0x78);
b43_radio_mask(dev, R2057_XTAL_CONFIG2, ~0x80);

--
1.7.9.5


2018-01-09 08:35:41

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v2] b43: Replace mdelay with usleep_range in b43_radio_2057_init_post

On Tue, Jan 09, 2018 at 09:40:06AM +0800, Jia-Ju Bai wrote:
> b43_radio_2057_init_post is not called in an interrupt handler
> nor holding a spinlock.
> The function mdelay in it can be replaced with usleep_range,
> to reduce busy wait.
>
> Signed-off-by: Jia-Ju Bai <[email protected]>
> ---
> v2:
> * Replace mdelay with usleep_range, instead of msleep in v1.
> Thank Larry for good advice.
> ---
> drivers/net/wireless/broadcom/b43/phy_n.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c b/drivers/net/wireless/broadcom/b43/phy_n.c
> index a5557d7..f2a2f41 100644
> --- a/drivers/net/wireless/broadcom/b43/phy_n.c
> +++ b/drivers/net/wireless/broadcom/b43/phy_n.c
> @@ -1031,7 +1031,7 @@ static void b43_radio_2057_init_post(struct b43_wldev *dev)
>
> b43_radio_set(dev, R2057_RFPLL_MISC_CAL_RESETN, 0x78);
> b43_radio_set(dev, R2057_XTAL_CONFIG2, 0x80);
> - mdelay(2);
> + usleep_range(2000, 3000);

Where did 3000 come from? Are you sure about that?

thanks,

greg k-h

2018-01-09 08:39:58

by Jia-Ju Bai

[permalink] [raw]
Subject: Re: [PATCH v2] b43: Replace mdelay with usleep_range in b43_radio_2057_init_post



On 2018/1/9 16:35, Greg KH wrote:
> On Tue, Jan 09, 2018 at 09:40:06AM +0800, Jia-Ju Bai wrote:
>> b43_radio_2057_init_post is not called in an interrupt handler
>> nor holding a spinlock.
>> The function mdelay in it can be replaced with usleep_range,
>> to reduce busy wait.
>>
>> Signed-off-by: Jia-Ju Bai <[email protected]>
>> ---
>> v2:
>> * Replace mdelay with usleep_range, instead of msleep in v1.
>> Thank Larry for good advice.
>> ---
>> drivers/net/wireless/broadcom/b43/phy_n.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c b/drivers/net/wireless/broadcom/b43/phy_n.c
>> index a5557d7..f2a2f41 100644
>> --- a/drivers/net/wireless/broadcom/b43/phy_n.c
>> +++ b/drivers/net/wireless/broadcom/b43/phy_n.c
>> @@ -1031,7 +1031,7 @@ static void b43_radio_2057_init_post(struct b43_wldev *dev)
>>
>> b43_radio_set(dev, R2057_RFPLL_MISC_CAL_RESETN, 0x78);
>> b43_radio_set(dev, R2057_XTAL_CONFIG2, 0x80);
>> - mdelay(2);
>> + usleep_range(2000, 3000);
> Where did 3000 come from? Are you sure about that?

I am not very sure, and I use it according to Larry's message:

> I had negative comments on one of those due to the possibility of
> msleep(2) extending as long as 20 msec. Until the author, or someone
> else, can test that this is OK, then the mdelay(2) can only be
> replaced with usleep_range(2000, 3000).

Thanks,
Jia-Ju Bai

2018-01-09 09:07:35

by Arend Van Spriel

[permalink] [raw]
Subject: Re: [PATCH v2] b43: Replace mdelay with usleep_range in b43_radio_2057_init_post

On 1/9/2018 9:39 AM, Jia-Ju Bai wrote:
>
>
> On 2018/1/9 16:35, Greg KH wrote:
>> On Tue, Jan 09, 2018 at 09:40:06AM +0800, Jia-Ju Bai wrote:
>>> b43_radio_2057_init_post is not called in an interrupt handler
>>> nor holding a spinlock.
>>> The function mdelay in it can be replaced with usleep_range,
>>> to reduce busy wait.
>>>
>>> Signed-off-by: Jia-Ju Bai <[email protected]>
>>> ---
>>> v2:
>>> * Replace mdelay with usleep_range, instead of msleep in v1.
>>> Thank Larry for good advice.
>>> ---
>>> drivers/net/wireless/broadcom/b43/phy_n.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c
>>> b/drivers/net/wireless/broadcom/b43/phy_n.c
>>> index a5557d7..f2a2f41 100644
>>> --- a/drivers/net/wireless/broadcom/b43/phy_n.c
>>> +++ b/drivers/net/wireless/broadcom/b43/phy_n.c
>>> @@ -1031,7 +1031,7 @@ static void b43_radio_2057_init_post(struct
>>> b43_wldev *dev)
>>> b43_radio_set(dev, R2057_RFPLL_MISC_CAL_RESETN, 0x78);
>>> b43_radio_set(dev, R2057_XTAL_CONFIG2, 0x80);
>>> - mdelay(2);
>>> + usleep_range(2000, 3000);
>> Where did 3000 come from? Are you sure about that?
>
> I am not very sure, and I use it according to Larry's message:

Hi Jia-Ju Bai,

The duration here is for settling the registers so hardware can pick it
up. Right after this they are written again. Now this is during
initialization of the radio so not time critical, but probably anything
in the range of 2000..3000 would also have been fine.

Regards,
Arend

2018-01-09 09:48:30

by Jia-Ju Bai

[permalink] [raw]
Subject: Re: [PATCH v2] b43: Replace mdelay with usleep_range in b43_radio_2057_init_post



On 2018/1/9 17:07, Arend van Spriel wrote:
> On 1/9/2018 9:39 AM, Jia-Ju Bai wrote:
>>
>>
>> On 2018/1/9 16:35, Greg KH wrote:
>>> On Tue, Jan 09, 2018 at 09:40:06AM +0800, Jia-Ju Bai wrote:
>>>> b43_radio_2057_init_post is not called in an interrupt handler
>>>> nor holding a spinlock.
>>>> The function mdelay in it can be replaced with usleep_range,
>>>> to reduce busy wait.
>>>>
>>>> Signed-off-by: Jia-Ju Bai <[email protected]>
>>>> ---
>>>> v2:
>>>> * Replace mdelay with usleep_range, instead of msleep in v1.
>>>> Thank Larry for good advice.
>>>> ---
>>>> drivers/net/wireless/broadcom/b43/phy_n.c | 2 +-
>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c
>>>> b/drivers/net/wireless/broadcom/b43/phy_n.c
>>>> index a5557d7..f2a2f41 100644
>>>> --- a/drivers/net/wireless/broadcom/b43/phy_n.c
>>>> +++ b/drivers/net/wireless/broadcom/b43/phy_n.c
>>>> @@ -1031,7 +1031,7 @@ static void b43_radio_2057_init_post(struct
>>>> b43_wldev *dev)
>>>> b43_radio_set(dev, R2057_RFPLL_MISC_CAL_RESETN, 0x78);
>>>> b43_radio_set(dev, R2057_XTAL_CONFIG2, 0x80);
>>>> - mdelay(2);
>>>> + usleep_range(2000, 3000);
>>> Where did 3000 come from? Are you sure about that?
>>
>> I am not very sure, and I use it according to Larry's message:
>
> Hi Jia-Ju Bai,
>
> The duration here is for settling the registers so hardware can pick
> it up. Right after this they are written again. Now this is during
> initialization of the radio so not time critical, but probably
> anything in the range of 2000..3000 would also have been fine.

Hi Arend,

Thanks for your detailed explanation :)
So I think usleep_range(2000, 3000) is okay.


Thanks,
Jia-Ju Bai

2018-01-09 11:12:04

by Arend Van Spriel

[permalink] [raw]
Subject: Re: [PATCH v2] b43: Replace mdelay with usleep_range in b43_radio_2057_init_post

On 1/9/2018 10:47 AM, Jia-Ju Bai wrote:
>
>
> On 2018/1/9 17:07, Arend van Spriel wrote:
>> On 1/9/2018 9:39 AM, Jia-Ju Bai wrote:
>>>
>>>
>>> On 2018/1/9 16:35, Greg KH wrote:
>>>> On Tue, Jan 09, 2018 at 09:40:06AM +0800, Jia-Ju Bai wrote:
>>>>> b43_radio_2057_init_post is not called in an interrupt handler
>>>>> nor holding a spinlock.
>>>>> The function mdelay in it can be replaced with usleep_range,
>>>>> to reduce busy wait.
>>>>>
>>>>> Signed-off-by: Jia-Ju Bai <[email protected]>
>>>>> ---
>>>>> v2:
>>>>> * Replace mdelay with usleep_range, instead of msleep in v1.
>>>>> Thank Larry for good advice.
>>>>> ---
>>>>> drivers/net/wireless/broadcom/b43/phy_n.c | 2 +-
>>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c
>>>>> b/drivers/net/wireless/broadcom/b43/phy_n.c
>>>>> index a5557d7..f2a2f41 100644
>>>>> --- a/drivers/net/wireless/broadcom/b43/phy_n.c
>>>>> +++ b/drivers/net/wireless/broadcom/b43/phy_n.c
>>>>> @@ -1031,7 +1031,7 @@ static void b43_radio_2057_init_post(struct
>>>>> b43_wldev *dev)
>>>>> b43_radio_set(dev, R2057_RFPLL_MISC_CAL_RESETN, 0x78);
>>>>> b43_radio_set(dev, R2057_XTAL_CONFIG2, 0x80);
>>>>> - mdelay(2);
>>>>> + usleep_range(2000, 3000);
>>>> Where did 3000 come from? Are you sure about that?
>>>
>>> I am not very sure, and I use it according to Larry's message:
>>
>> Hi Jia-Ju Bai,
>>
>> The duration here is for settling the registers so hardware can pick
>> it up. Right after this they are written again. Now this is during
>> initialization of the radio so not time critical, but probably
>> anything in the range of 2000..3000 would also have been fine.
>
> Hi Arend,
>
> Thanks for your detailed explanation :)
> So I think usleep_range(2000, 3000) is okay.

Sure.

Regards,
Arend

2018-01-09 16:50:03

by Larry Finger

[permalink] [raw]
Subject: Re: [PATCH v2] b43: Replace mdelay with usleep_range in b43_radio_2057_init_post

On 01/08/2018 07:40 PM, Jia-Ju Bai wrote:
> b43_radio_2057_init_post is not called in an interrupt handler
> nor holding a spinlock.
> The function mdelay in it can be replaced with usleep_range,
> to reduce busy wait.
>
> Signed-off-by: Jia-Ju Bai <[email protected]>
> ---
> v2:
> * Replace mdelay with usleep_range, instead of msleep in v1.
> Thank Larry for good advice.
> ---

I agree that a sleep of 2-3 ms should be OK here.

Acked-by: Larry Finger <[email protected]>

Larry

> drivers/net/wireless/broadcom/b43/phy_n.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c b/drivers/net/wireless/broadcom/b43/phy_n.c
> index a5557d7..f2a2f41 100644
> --- a/drivers/net/wireless/broadcom/b43/phy_n.c
> +++ b/drivers/net/wireless/broadcom/b43/phy_n.c
> @@ -1031,7 +1031,7 @@ static void b43_radio_2057_init_post(struct b43_wldev *dev)
>
> b43_radio_set(dev, R2057_RFPLL_MISC_CAL_RESETN, 0x78);
> b43_radio_set(dev, R2057_XTAL_CONFIG2, 0x80);
> - mdelay(2);
> + usleep_range(2000, 3000);
> b43_radio_mask(dev, R2057_RFPLL_MISC_CAL_RESETN, ~0x78);
> b43_radio_mask(dev, R2057_XTAL_CONFIG2, ~0x80);
>
>

2018-01-11 19:54:33

by Kalle Valo

[permalink] [raw]
Subject: Re: [v2] b43: Replace mdelay with usleep_range in b43_radio_2057_init_post

Jia-Ju Bai <[email protected]> wrote:

> b43_radio_2057_init_post is not called in an interrupt handler
> nor holding a spinlock.
> The function mdelay in it can be replaced with usleep_range,
> to reduce busy wait.
>
> Signed-off-by: Jia-Ju Bai <[email protected]>
> Acked-by: Larry Finger <[email protected]>

Patch applied to wireless-drivers-next.git, thanks.

4330b53e9662 b43: Replace mdelay with usleep_range in b43_radio_2057_init_post

--
https://patchwork.kernel.org/patch/10150845/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches