linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bcma: Replace mdelay with usleep_range in bcma_pmu_resources_init
@ 2018-01-26  9:13 Jia-Ju Bai
  2018-01-26 16:13 ` Kalle Valo
  2018-01-26 16:26 ` Larry Finger
  0 siblings, 2 replies; 5+ messages in thread
From: Jia-Ju Bai @ 2018-01-26  9:13 UTC (permalink / raw)
  To: zajec5, hauke; +Cc: linux-wireless, linux-kernel, Jia-Ju Bai

After checking all possible call chains to bcma_pmu_resources_init() here,
my tool finds that this function is never called in atomic context,
namely never in an interrupt handler or holding a spinlock.
Thus mdelay can be replaced with usleep_range to avoid busy wait.

This is found by a static analysis tool named DCNS written by myself.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 drivers/bcma/driver_chipcommon_pmu.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bcma/driver_chipcommon_pmu.c b/drivers/bcma/driver_chipcommon_pmu.c
index f1eb4d3..478948c 100644
--- a/drivers/bcma/driver_chipcommon_pmu.c
+++ b/drivers/bcma/driver_chipcommon_pmu.c
@@ -203,7 +203,7 @@ static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
 	 * Add some delay; allow resources to come up and settle.
 	 * Delay is required for SoC (early init).
 	 */
-	mdelay(2);
+	usleep_range(1500, 2000);
 }
 
 /* Disable to allow reading SPROM. Don't know the adventages of enabling it. */
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] bcma: Replace mdelay with usleep_range in bcma_pmu_resources_init
  2018-01-26  9:13 [PATCH] bcma: Replace mdelay with usleep_range in bcma_pmu_resources_init Jia-Ju Bai
@ 2018-01-26 16:13 ` Kalle Valo
  2018-01-26 16:27   ` Larry Finger
  2018-01-26 16:26 ` Larry Finger
  1 sibling, 1 reply; 5+ messages in thread
From: Kalle Valo @ 2018-01-26 16:13 UTC (permalink / raw)
  To: Jia-Ju Bai; +Cc: zajec5, hauke, linux-wireless, linux-kernel

Jia-Ju Bai <baijiaju1990@gmail.com> writes:

> After checking all possible call chains to bcma_pmu_resources_init() here,
> my tool finds that this function is never called in atomic context,
> namely never in an interrupt handler or holding a spinlock.
> Thus mdelay can be replaced with usleep_range to avoid busy wait.
>
> This is found by a static analysis tool named DCNS written by myself.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
>  drivers/bcma/driver_chipcommon_pmu.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/bcma/driver_chipcommon_pmu.c b/drivers/bcma/driver_chipcommon_pmu.c
> index f1eb4d3..478948c 100644
> --- a/drivers/bcma/driver_chipcommon_pmu.c
> +++ b/drivers/bcma/driver_chipcommon_pmu.c
> @@ -203,7 +203,7 @@ static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
>  	 * Add some delay; allow resources to come up and settle.
>  	 * Delay is required for SoC (early init).
>  	 */
> -	mdelay(2);
> +	usleep_range(1500, 2000);

I would like to have an ack from someone familiar with bcma before I
apply this.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] bcma: Replace mdelay with usleep_range in bcma_pmu_resources_init
  2018-01-26  9:13 [PATCH] bcma: Replace mdelay with usleep_range in bcma_pmu_resources_init Jia-Ju Bai
  2018-01-26 16:13 ` Kalle Valo
@ 2018-01-26 16:26 ` Larry Finger
  2018-01-26 16:33   ` Jia-Ju Bai
  1 sibling, 1 reply; 5+ messages in thread
From: Larry Finger @ 2018-01-26 16:26 UTC (permalink / raw)
  To: Jia-Ju Bai, zajec5, hauke; +Cc: linux-wireless, linux-kernel

On 01/26/2018 03:13 AM, Jia-Ju Bai wrote:
> After checking all possible call chains to bcma_pmu_resources_init() here,
> my tool finds that this function is never called in atomic context,
> namely never in an interrupt handler or holding a spinlock.
> Thus mdelay can be replaced with usleep_range to avoid busy wait.
> 
> This is found by a static analysis tool named DCNS written by myself.
> 
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
>   drivers/bcma/driver_chipcommon_pmu.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/bcma/driver_chipcommon_pmu.c b/drivers/bcma/driver_chipcommon_pmu.c
> index f1eb4d3..478948c 100644
> --- a/drivers/bcma/driver_chipcommon_pmu.c
> +++ b/drivers/bcma/driver_chipcommon_pmu.c
> @@ -203,7 +203,7 @@ static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
>   	 * Add some delay; allow resources to come up and settle.
>   	 * Delay is required for SoC (early init).
>   	 */
> -	mdelay(2);
> +	usleep_range(1500, 2000);

I have no idea how critical this delay might be, but it would be safer to never 
make the sleep be shorter than the original delay. Using (2000, 2500) would be a 
better choice of arguments for usleep_range().

NACK

Larry

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] bcma: Replace mdelay with usleep_range in bcma_pmu_resources_init
  2018-01-26 16:13 ` Kalle Valo
@ 2018-01-26 16:27   ` Larry Finger
  0 siblings, 0 replies; 5+ messages in thread
From: Larry Finger @ 2018-01-26 16:27 UTC (permalink / raw)
  To: Kalle Valo, Jia-Ju Bai; +Cc: zajec5, hauke, linux-wireless, linux-kernel

On 01/26/2018 10:13 AM, Kalle Valo wrote:
> Jia-Ju Bai <baijiaju1990@gmail.com> writes:
> 
>> After checking all possible call chains to bcma_pmu_resources_init() here,
>> my tool finds that this function is never called in atomic context,
>> namely never in an interrupt handler or holding a spinlock.
>> Thus mdelay can be replaced with usleep_range to avoid busy wait.
>>
>> This is found by a static analysis tool named DCNS written by myself.
>>
>> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
>> ---
>>   drivers/bcma/driver_chipcommon_pmu.c |    2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/bcma/driver_chipcommon_pmu.c b/drivers/bcma/driver_chipcommon_pmu.c
>> index f1eb4d3..478948c 100644
>> --- a/drivers/bcma/driver_chipcommon_pmu.c
>> +++ b/drivers/bcma/driver_chipcommon_pmu.c
>> @@ -203,7 +203,7 @@ static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
>>   	 * Add some delay; allow resources to come up and settle.
>>   	 * Delay is required for SoC (early init).
>>   	 */
>> -	mdelay(2);
>> +	usleep_range(1500, 2000);
> 
> I would like to have an ack from someone familiar with bcma before I
> apply this.

No ack for this one.

Larry

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] bcma: Replace mdelay with usleep_range in bcma_pmu_resources_init
  2018-01-26 16:26 ` Larry Finger
@ 2018-01-26 16:33   ` Jia-Ju Bai
  0 siblings, 0 replies; 5+ messages in thread
From: Jia-Ju Bai @ 2018-01-26 16:33 UTC (permalink / raw)
  To: Larry Finger, zajec5, hauke; +Cc: linux-wireless, linux-kernel



On 2018/1/27 0:26, Larry Finger wrote:
> On 01/26/2018 03:13 AM, Jia-Ju Bai wrote:
>> After checking all possible call chains to bcma_pmu_resources_init() 
>> here,
>> my tool finds that this function is never called in atomic context,
>> namely never in an interrupt handler or holding a spinlock.
>> Thus mdelay can be replaced with usleep_range to avoid busy wait.
>>
>> This is found by a static analysis tool named DCNS written by myself.
>>
>> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
>> ---
>>   drivers/bcma/driver_chipcommon_pmu.c |    2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/bcma/driver_chipcommon_pmu.c 
>> b/drivers/bcma/driver_chipcommon_pmu.c
>> index f1eb4d3..478948c 100644
>> --- a/drivers/bcma/driver_chipcommon_pmu.c
>> +++ b/drivers/bcma/driver_chipcommon_pmu.c
>> @@ -203,7 +203,7 @@ static void bcma_pmu_resources_init(struct 
>> bcma_drv_cc *cc)
>>        * Add some delay; allow resources to come up and settle.
>>        * Delay is required for SoC (early init).
>>        */
>> -    mdelay(2);
>> +    usleep_range(1500, 2000);
>
> I have no idea how critical this delay might be, but it would be safer 
> to never make the sleep be shorter than the original delay. Using 
> (2000, 2500) would be a better choice of arguments for usleep_range().

Okay, I have used usleep_range(2000, 2500) and sent patch v2.


Thanks,
Jia-Ju Bai

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-01-26 16:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-26  9:13 [PATCH] bcma: Replace mdelay with usleep_range in bcma_pmu_resources_init Jia-Ju Bai
2018-01-26 16:13 ` Kalle Valo
2018-01-26 16:27   ` Larry Finger
2018-01-26 16:26 ` Larry Finger
2018-01-26 16:33   ` Jia-Ju Bai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).