[PATCH v1 1/1] pwrap: mediatek: fix wait time out issue

zhiyong.tao zhiyong.tao at mediatek.com
Sun Apr 17 18:29:26 PDT 2022


On Tue, 2022-03-29 at 16:44 +0200, Matthias Brugger wrote:
> 
> On 29/03/2022 13:58, Zhiyong Tao wrote:
> > From: "Zhiyong.Tao" <zhiyong.tao at mediatek.com>
> > 
> > add sleep delay before read "jiffies"
> > 
> > Signed-off-by: Zhiyong.Tao <zhiyong.tao at mediatek.com>
> > ---
> >   drivers/soc/mediatek/mtk-pmic-wrap.c | 8 ++++++--
> >   1 file changed, 6 insertions(+), 2 deletions(-)
> >   mode change 100644 => 100755 drivers/soc/mediatek/mtk-pmic-wrap.c
> > 
> > diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c
> > b/drivers/soc/mediatek/mtk-pmic-wrap.c
> > old mode 100644
> > new mode 100755
> > index 952bc554f443..ac7139a67e87
> > --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
> > +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
> > @@ -12,6 +12,7 @@
> >   #include <linux/platform_device.h>
> >   #include <linux/regmap.h>
> >   #include <linux/reset.h>
> > +#include <linux/delay.h>
> >   
> >   #define PWRAP_MT8135_BRIDGE_IORD_ARB_EN		0x4
> >   #define PWRAP_MT8135_BRIDGE_WACS3_EN		0x10
> > @@ -1197,10 +1198,13 @@ static int pwrap_wait_for_state(struct
> > pmic_wrapper *wrp,
> >   	timeout = jiffies + usecs_to_jiffies(10000);
> >   
> >   	do {
> > -		if (time_after(jiffies, timeout))
> > -			return fp(wrp) ? 0 : -ETIMEDOUT;
> >   		if (fp(wrp))
> >   			return 0;
> > +
> > +		usleep_range(10, 11);
> > +
> 
> You need to explain this change. Why is it needed, are you sure it
> does not 
> break other platforms etc.
> 
> I can guess why you need that patch here. In any case in the code you
> provide, 
> it would make sense to move the first if out of the do loop and only
> after this 
> wait 10 us before reading again. Right now the code does usleep only
> after every 
> other read.
> 
> Regards,
> Matthias
> 
Hi Mattias,

we confirm the delay time with our pwrap designer.
we should add the 10us delay before reading again.
The patch is accord with all platforms pwrap design.
we will explain this in next version.

Thanks.
> > +		if (time_after(jiffies, timeout))
> > +			return fp(wrp) ? 0 : -ETIMEDOUT;
> >   	} while (1);
> >   }
> >   


More information about the Linux-mediatek mailing list