Re: [PATCH v3 11/11] PCI: imx6: Replace calls to udelay() with usleep_range()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am Sonntag, den 31.03.2019, 21:25 -0700 schrieb Andrey Smirnov:
> In both cases udelay() is called in non-atomic context, so there's
> really no need to use it there. Change the code to use usleep_range()
> instead.
> 
> > Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
> ---
>  drivers/pci/controller/dwc/pci-imx6.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> index c9431a8a7ca1..3f13022991ec 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -167,7 +167,7 @@ static int pcie_phy_poll_ack(struct imx6_pcie *imx6_pcie, bool exp_val)
>  		if (val == exp_val)
>  			return 0;
>  
> -		udelay(1);
> +		usleep_range(10, 100);

I'm not sure we want to change this. This is dragging out the timeout
considerably while the really short delay, together with the low number
of max loop iterations suggests that the condition is usually met very
quickly.

Maybe this would even want a change in the other direction by replacing
the udelay with a cpu_relax to speed up the condition detection and
stall the CPU in device memory loads, instead of having it spin in a
tight inner loop.

>  	} while (wait_counter < max_iterations);
>  
>  	return -ETIMEDOUT;
> @@ -449,7 +449,7 @@ static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie)
>  		 * reset time is too short, cannot meet the requirement.
>  		 * add one ~10us delay here.
>  		 */
> -		udelay(10);
> +		usleep_range(10, 100);

This one looks good.

Regards,
Lucas

>  		regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
>  				   IMX6Q_GPR1_PCIE_REF_CLK_EN, 1 << 16);
>  		break;



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux