2018-01-26 16:34:52

by Jia-Ju Bai

[permalink] [raw]
Subject: [PATCH v2] bcma: Replace mdelay with usleep_range in bcma_pmu_resources_init

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 <[email protected]>
---
v2:
* Use usleep_range(2000, 2500), instead of (1500, 2000) in v1.

---
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(2000, 2500);
}

/* Disable to allow reading SPROM. Don't know the adventages of enabling it. */
--
1.7.9.5



2018-01-26 18:48:22

by Larry Finger

[permalink] [raw]
Subject: Re: [PATCH v2] bcma: Replace mdelay with usleep_range in bcma_pmu_resources_init

On 01/26/2018 10:38 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 <[email protected]>
> ---
> v2:
> * Use usleep_range(2000, 2500), instead of (1500, 2000) in v1.
>
> ---
> 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(2000, 2500);

I have no means of testing this patch, but it should be OK.

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


> }
>
> /* Disable to allow reading SPROM. Don't know the adventages of enabling it. */
>


2018-02-27 13:53:46

by Kalle Valo

[permalink] [raw]
Subject: Re: [v2] bcma: Replace mdelay with usleep_range in bcma_pmu_resources_init

Jia-Ju Bai <[email protected]> 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 <[email protected]>
> Acked-by: Larry Finger <[email protected]>

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

8100091d0248 bcma: Replace mdelay with usleep_range in bcma_pmu_resources_init

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

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