* Re: [PATCH] rtc: snvs: improve timeout handling in snvs_rtc_enable()
@ 2012-08-18 13:14 Lothar Waßmann
2015-05-10 21:42 ` [rtc-linux] " Alexandre Belloni
0 siblings, 1 reply; 2+ messages in thread
From: Lothar Waßmann @ 2012-08-18 13:14 UTC (permalink / raw)
To: Shawn Guo
Cc: rtc-linux, Andrew Morton, Alessandro Zummo, Kim Phillips,
Sascha Hauer, Stephen Boyd, linux-arm-kernel
Shawn Guo writes:
> On Sat, Aug 18, 2012 at 10:10:08AM +0200, Lothar Waßmann wrote:
> > If snvs_rtc_enable() happens to be descheduled for a period longer
> > than the timout period, a timeout may be indicated even if the RTC
> > status has changed meanwhile. Force a status read at the end of the
> > timeout period to prevent bogus timeout errors.
> >
> >
> > Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
> > ---
> > drivers/rtc/rtc-snvs.c | 22 +++++++++++++---------
> > 1 files changed, 13 insertions(+), 9 deletions(-)
> >
> > Compile tested only due to lack of HW.
>
> Tested-by: Shawn Guo <shawn.guo@linaro.org>
>
> A small nitpick below.
>
> >
> > diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c
> > index 912f116..dc921b2 100644
> > --- a/drivers/rtc/rtc-snvs.c
> > +++ b/drivers/rtc/rtc-snvs.c
> > @@ -81,6 +81,13 @@ static void rtc_write_sync_lp(void __iomem *ioaddr)
> > }
> > }
> >
> > +static int snvs_rtc_enable_done(int enable, void __iomem *addr)
>
> Can we rename parameter "addr" to "ioaddr" and put it before "enable",
> also change "enable" to bool?
>
OK. The resulting assembler code of the patch below is identical to
the previous version of this patch.
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Tested-by: Shawn Guo <shawn.guo@linaro.org>
---
drivers/rtc/rtc-snvs.c | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c
index 912f116..a757cb9 100644
--- a/drivers/rtc/rtc-snvs.c
+++ b/drivers/rtc/rtc-snvs.c
@@ -81,6 +81,13 @@ static void rtc_write_sync_lp(void __iomem *ioaddr)
}
}
+static int snvs_rtc_enable_done(void __iomem *ioaddr, bool enable)
+{
+ u32 lpcr = readl(ioaddr + SNVS_LPCR);
+
+ return enable ^ !(lpcr & SNVS_LPCR_SRTC_ENV);
+}
+
static int snvs_rtc_enable(struct snvs_rtc_data *data, bool enable)
{
unsigned long timeout = jiffies + msecs_to_jiffies(1);
@@ -99,18 +106,15 @@ static int snvs_rtc_enable(struct snvs_rtc_data *data, bool enable)
spin_unlock_irqrestore(&data->lock, flags);
while (1) {
- lpcr = readl(data->ioaddr + SNVS_LPCR);
+ if (snvs_rtc_enable_done(data->ioaddr, enable))
+ break;
- if (enable) {
- if (lpcr & SNVS_LPCR_SRTC_ENV)
- break;
- } else {
- if (!(lpcr & SNVS_LPCR_SRTC_ENV))
+ if (time_after(jiffies, timeout)) {
+ if (snvs_rtc_enable_done(data->ioaddr, enable))
break;
+ else
+ return -ETIMEDOUT;
}
-
- if (time_after(jiffies, timeout))
- return -ETIMEDOUT;
}
return 0;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [rtc-linux] Re: [PATCH] rtc: snvs: improve timeout handling in snvs_rtc_enable()
2012-08-18 13:14 [PATCH] rtc: snvs: improve timeout handling in snvs_rtc_enable() Lothar Waßmann
@ 2015-05-10 21:42 ` Alexandre Belloni
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2015-05-10 21:42 UTC (permalink / raw)
To: Lothar Waßmann, Shawn Guo
Cc: rtc-linux, Andrew Morton, Alessandro Zummo, Kim Phillips,
Sascha Hauer, Stephen Boyd, linux-arm-kernel
Hi Shawn, Lothar,
On 18/08/2012 at 15:14:04 +0200, Lothar Wa=C3=9Fmann wrote :
> Shawn Guo writes:
> > On Sat, Aug 18, 2012 at 10:10:08AM +0200, Lothar Wa=C3=9Fmann wrote:
> > > If snvs_rtc_enable() happens to be descheduled for a period longer
> > > than the timout period, a timeout may be indicated even if the RTC
> > > status has changed meanwhile. Force a status read at the end of the
> > > timeout period to prevent bogus timeout errors.
> > >=20
> > >=20
> > > Signed-off-by: Lothar Wa=C3=9Fmann <LW@KARO-electronics.de>
> > > ---
> > > drivers/rtc/rtc-snvs.c | 22 +++++++++++++---------
> > > 1 files changed, 13 insertions(+), 9 deletions(-)
> > >=20
> > > Compile tested only due to lack of HW.
> >=20
> > Tested-by: Shawn Guo <shawn.guo@linaro.org>
> >=20
It seems that patch never made it mainline. Can you check if it is still
needed?
> > A small nitpick below.
> >=20
> > >=20
> > > diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c
> > > index 912f116..dc921b2 100644
> > > --- a/drivers/rtc/rtc-snvs.c
> > > +++ b/drivers/rtc/rtc-snvs.c
> > > @@ -81,6 +81,13 @@ static void rtc_write_sync_lp(void __iomem *ioaddr=
)
> > > }
> > > }
> > > =20
> > > +static int snvs_rtc_enable_done(int enable, void __iomem *addr)
> >=20
> > Can we rename parameter "addr" to "ioaddr" and put it before "enable",
> > also change "enable" to bool?
> >=20
> OK. The resulting assembler code of the patch below is identical to
> the previous version of this patch.
>=20
>=20
> Signed-off-by: Lothar Wa=C3=9Fmann <LW@KARO-electronics.de>
> Tested-by: Shawn Guo <shawn.guo@linaro.org>
> ---
> drivers/rtc/rtc-snvs.c | 22 +++++++++++++---------
> 1 files changed, 13 insertions(+), 9 deletions(-)
>=20
> diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c
> index 912f116..a757cb9 100644
> --- a/drivers/rtc/rtc-snvs.c
> +++ b/drivers/rtc/rtc-snvs.c
> @@ -81,6 +81,13 @@ static void rtc_write_sync_lp(void __iomem *ioaddr)
> }
> }
> =20
> +static int snvs_rtc_enable_done(void __iomem *ioaddr, bool enable)
> +{
> + u32 lpcr =3D readl(ioaddr + SNVS_LPCR);
> +
> + return enable ^ !(lpcr & SNVS_LPCR_SRTC_ENV);
> +}
> +
> static int snvs_rtc_enable(struct snvs_rtc_data *data, bool enable)
> {
> unsigned long timeout =3D jiffies + msecs_to_jiffies(1);
> @@ -99,18 +106,15 @@ static int snvs_rtc_enable(struct snvs_rtc_data *dat=
a, bool enable)
> spin_unlock_irqrestore(&data->lock, flags);
> =20
> while (1) {
> - lpcr =3D readl(data->ioaddr + SNVS_LPCR);
> + if (snvs_rtc_enable_done(data->ioaddr, enable))
> + break;
> =20
> - if (enable) {
> - if (lpcr & SNVS_LPCR_SRTC_ENV)
> - break;
> - } else {
> - if (!(lpcr & SNVS_LPCR_SRTC_ENV))
> + if (time_after(jiffies, timeout)) {
> + if (snvs_rtc_enable_done(data->ioaddr, enable))
> break;
> + else
> + return -ETIMEDOUT;
> }
> -
> - if (time_after(jiffies, timeout))
> - return -ETIMEDOUT;
> }
> =20
> return 0;
--=20
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--=20
--=20
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "=
rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-05-10 21:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-18 13:14 [PATCH] rtc: snvs: improve timeout handling in snvs_rtc_enable() Lothar Waßmann
2015-05-10 21:42 ` [rtc-linux] " Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox