Linux-RTC Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] rtc: goldfish: Enable interrupt in set_alarm() when necessary
@ 2020-06-20 12:04 Huacai Chen
  2020-07-03  3:00 ` Huacai Chen
  2020-07-16  9:16 ` Alexandre Belloni
  0 siblings, 2 replies; 5+ messages in thread
From: Huacai Chen @ 2020-06-20 12:04 UTC (permalink / raw)
  To: Miodrag Dinic, Alessandro Zummo, Alexandre Belloni
  Cc: linux-rtc, Fuxin Zhang, Huacai Chen, Jiaxun Yang, Huacai Chen

When use goldfish rtc, the "hwclock" command fails with "select() to
/dev/rtc to wait for clock tick timed out". This is because "hwclock"
need the set_alarm() hook to enable interrupt when alrm->enabled is
true. This operation is missing in goldfish rtc (but other rtc drivers,
such as cmos rtc, enable interrupt here), so add it.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 drivers/rtc/rtc-goldfish.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/rtc/rtc-goldfish.c b/drivers/rtc/rtc-goldfish.c
index 1a3420e..d5083b0 100644
--- a/drivers/rtc/rtc-goldfish.c
+++ b/drivers/rtc/rtc-goldfish.c
@@ -73,6 +73,7 @@ static int goldfish_rtc_set_alarm(struct device *dev,
 		rtc_alarm64 = rtc_tm_to_time64(&alrm->time) * NSEC_PER_SEC;
 		writel((rtc_alarm64 >> 32), base + TIMER_ALARM_HIGH);
 		writel(rtc_alarm64, base + TIMER_ALARM_LOW);
+		writel(1, base + TIMER_IRQ_ENABLED);
 	} else {
 		/*
 		 * if this function was called with enabled=0
-- 
2.7.0


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

* Re: [PATCH] rtc: goldfish: Enable interrupt in set_alarm() when necessary
  2020-06-20 12:04 [PATCH] rtc: goldfish: Enable interrupt in set_alarm() when necessary Huacai Chen
@ 2020-07-03  3:00 ` Huacai Chen
  2020-07-09  9:39   ` Huacai Chen
  2020-07-16  9:16 ` Alexandre Belloni
  1 sibling, 1 reply; 5+ messages in thread
From: Huacai Chen @ 2020-07-03  3:00 UTC (permalink / raw)
  To: Miodrag Dinic, Alessandro Zummo, Alexandre Belloni
  Cc: linux-rtc, Fuxin Zhang, Jiaxun Yang

Ping?

On Sat, Jun 20, 2020 at 8:03 PM Huacai Chen <chenhc@lemote.com> wrote:
>
> When use goldfish rtc, the "hwclock" command fails with "select() to
> /dev/rtc to wait for clock tick timed out". This is because "hwclock"
> need the set_alarm() hook to enable interrupt when alrm->enabled is
> true. This operation is missing in goldfish rtc (but other rtc drivers,
> such as cmos rtc, enable interrupt here), so add it.
>
> Signed-off-by: Huacai Chen <chenhc@lemote.com>
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
>  drivers/rtc/rtc-goldfish.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/rtc/rtc-goldfish.c b/drivers/rtc/rtc-goldfish.c
> index 1a3420e..d5083b0 100644
> --- a/drivers/rtc/rtc-goldfish.c
> +++ b/drivers/rtc/rtc-goldfish.c
> @@ -73,6 +73,7 @@ static int goldfish_rtc_set_alarm(struct device *dev,
>                 rtc_alarm64 = rtc_tm_to_time64(&alrm->time) * NSEC_PER_SEC;
>                 writel((rtc_alarm64 >> 32), base + TIMER_ALARM_HIGH);
>                 writel(rtc_alarm64, base + TIMER_ALARM_LOW);
> +               writel(1, base + TIMER_IRQ_ENABLED);
>         } else {
>                 /*
>                  * if this function was called with enabled=0
> --
> 2.7.0
>

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

* Re: [PATCH] rtc: goldfish: Enable interrupt in set_alarm() when necessary
  2020-07-03  3:00 ` Huacai Chen
@ 2020-07-09  9:39   ` Huacai Chen
  2020-07-09 10:30     ` Miodrag Dinic
  0 siblings, 1 reply; 5+ messages in thread
From: Huacai Chen @ 2020-07-09  9:39 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni, miodrag.dinic
  Cc: linux-rtc, Fuxin Zhang, Jiaxun Yang

Hi, Midorag,

Maybe miodrag.dinic@syrmia.com is your new email address? Please
review this patch.
And Alessandro, Alexandre, could you please help to review this patch?

Huacai

On Fri, Jul 3, 2020 at 11:00 AM Huacai Chen <chenhuacai@gmail.com> wrote:
>
> Ping?
>
> On Sat, Jun 20, 2020 at 8:03 PM Huacai Chen <chenhc@lemote.com> wrote:
> >
> > When use goldfish rtc, the "hwclock" command fails with "select() to
> > /dev/rtc to wait for clock tick timed out". This is because "hwclock"
> > need the set_alarm() hook to enable interrupt when alrm->enabled is
> > true. This operation is missing in goldfish rtc (but other rtc drivers,
> > such as cmos rtc, enable interrupt here), so add it.
> >
> > Signed-off-by: Huacai Chen <chenhc@lemote.com>
> > Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> > ---
> >  drivers/rtc/rtc-goldfish.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/rtc/rtc-goldfish.c b/drivers/rtc/rtc-goldfish.c
> > index 1a3420e..d5083b0 100644
> > --- a/drivers/rtc/rtc-goldfish.c
> > +++ b/drivers/rtc/rtc-goldfish.c
> > @@ -73,6 +73,7 @@ static int goldfish_rtc_set_alarm(struct device *dev,
> >                 rtc_alarm64 = rtc_tm_to_time64(&alrm->time) * NSEC_PER_SEC;
> >                 writel((rtc_alarm64 >> 32), base + TIMER_ALARM_HIGH);
> >                 writel(rtc_alarm64, base + TIMER_ALARM_LOW);
> > +               writel(1, base + TIMER_IRQ_ENABLED);
> >         } else {
> >                 /*
> >                  * if this function was called with enabled=0
> > --
> > 2.7.0
> >

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

* RE: [PATCH] rtc: goldfish: Enable interrupt in set_alarm() when necessary
  2020-07-09  9:39   ` Huacai Chen
@ 2020-07-09 10:30     ` Miodrag Dinic
  0 siblings, 0 replies; 5+ messages in thread
From: Miodrag Dinic @ 2020-07-09 10:30 UTC (permalink / raw)
  To: Huacai Chen, Alessandro Zummo, Alexandre Belloni
  Cc: linux-rtc, Fuxin Zhang, Jiaxun Yang, Aleksandar Markovic,
	Petar Jovanovic

Hi Huacai,

Yes, this is my new address. However I haven't been involved in kernel/QEMU community for a while now.
The patch itself looks OK to me, if you made sure the RTC device emulation on the QEMU side is now also inspecting the TIMER_IRQ_ENABLED setting.

OK I see now that you have committed upstream to QEMU the Goldfish RTC device, good job with that.
https://github.com/qemu/qemu/blame/971b2a1e5b1a8cc8f597ac5d7016908f9fa880de/hw/rtc/goldfish_rtc.c

You can add my "reviewed-by".

Glad to see that the "goldfish" project is still alive out there.

Kind regards,
Miodrag

-----Original Message-----
From: Huacai Chen <chenhuacai@gmail.com> 
Sent: Thursday, July 9, 2020 11:40 AM
To: Alessandro Zummo <a.zummo@towertech.it>; Alexandre Belloni <alexandre.belloni@bootlin.com>; Miodrag Dinic <Miodrag.Dinic@syrmia.com>
Cc: linux-rtc@vger.kernel.org; Fuxin Zhang <zhangfx@lemote.com>; Jiaxun Yang <jiaxun.yang@flygoat.com>
Subject: Re: [PATCH] rtc: goldfish: Enable interrupt in set_alarm() when necessary

Hi, Midorag,

Maybe miodrag.dinic@syrmia.com is your new email address? Please review this patch.
And Alessandro, Alexandre, could you please help to review this patch?

Huacai

On Fri, Jul 3, 2020 at 11:00 AM Huacai Chen <chenhuacai@gmail.com> wrote:
>
> Ping?
>
> On Sat, Jun 20, 2020 at 8:03 PM Huacai Chen <chenhc@lemote.com> wrote:
> >
> > When use goldfish rtc, the "hwclock" command fails with "select() to 
> > /dev/rtc to wait for clock tick timed out". This is because "hwclock"
> > need the set_alarm() hook to enable interrupt when alrm->enabled is 
> > true. This operation is missing in goldfish rtc (but other rtc 
> > drivers, such as cmos rtc, enable interrupt here), so add it.
> >
> > Signed-off-by: Huacai Chen <chenhc@lemote.com>
> > Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> > ---
> >  drivers/rtc/rtc-goldfish.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/rtc/rtc-goldfish.c b/drivers/rtc/rtc-goldfish.c 
> > index 1a3420e..d5083b0 100644
> > --- a/drivers/rtc/rtc-goldfish.c
> > +++ b/drivers/rtc/rtc-goldfish.c
> > @@ -73,6 +73,7 @@ static int goldfish_rtc_set_alarm(struct device *dev,
> >                 rtc_alarm64 = rtc_tm_to_time64(&alrm->time) * NSEC_PER_SEC;
> >                 writel((rtc_alarm64 >> 32), base + TIMER_ALARM_HIGH);
> >                 writel(rtc_alarm64, base + TIMER_ALARM_LOW);
> > +               writel(1, base + TIMER_IRQ_ENABLED);
> >         } else {
> >                 /*
> >                  * if this function was called with enabled=0
> > --
> > 2.7.0
> >

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

* Re: [PATCH] rtc: goldfish: Enable interrupt in set_alarm() when necessary
  2020-06-20 12:04 [PATCH] rtc: goldfish: Enable interrupt in set_alarm() when necessary Huacai Chen
  2020-07-03  3:00 ` Huacai Chen
@ 2020-07-16  9:16 ` Alexandre Belloni
  1 sibling, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2020-07-16  9:16 UTC (permalink / raw)
  To: Huacai Chen, Miodrag Dinic, Alessandro Zummo
  Cc: Alexandre Belloni, Huacai Chen, linux-rtc, Jiaxun Yang, Fuxin Zhang

On Sat, 20 Jun 2020 20:04:43 +0800, Huacai Chen wrote:
> When use goldfish rtc, the "hwclock" command fails with "select() to
> /dev/rtc to wait for clock tick timed out". This is because "hwclock"
> need the set_alarm() hook to enable interrupt when alrm->enabled is
> true. This operation is missing in goldfish rtc (but other rtc drivers,
> such as cmos rtc, enable interrupt here), so add it.

Applied, thanks!

[1/1] rtc: goldfish: Enable interrupt in set_alarm() when necessary
      commit: 22f8d5a1bf230cf8567a4121fc3789babb46336d

Best regards,
-- 
Alexandre Belloni <alexandre.belloni@bootlin.com>

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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-20 12:04 [PATCH] rtc: goldfish: Enable interrupt in set_alarm() when necessary Huacai Chen
2020-07-03  3:00 ` Huacai Chen
2020-07-09  9:39   ` Huacai Chen
2020-07-09 10:30     ` Miodrag Dinic
2020-07-16  9:16 ` Alexandre Belloni

Linux-RTC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rtc/0 linux-rtc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rtc linux-rtc/ https://lore.kernel.org/linux-rtc \
		linux-rtc@vger.kernel.org
	public-inbox-index linux-rtc

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rtc


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git