Skip to contentSkip to conversation

rtc: goldfish: Enable interrupt in set_alarm() when necessary

PATCH Applied Huacai Chen 4 participants 5 messages Jun 20, 2020 – Jul 16, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: goldfish: Enable interrupt in set_alarm() when necessary

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.

---
 drivers/rtc/rtc-goldfish.c | 1 +
 1 file changed, 1 insertion(+)
drivers/rtc/rtc-goldfish.c +1 -0
index 1a3420e..d5083b0 100644
@@ -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
Signature · 1 line
2.7.0
#1 lore raw

Ping?

Quoted 28 lines · 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.

---
 drivers/rtc/rtc-goldfish.c | 1 +
 1 file changed, 1 insertion(+)
drivers/rtc/rtc-goldfish.c +1 -1
index 1a3420e..d5083b0 100644
@@ -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

#2 lore raw

Hi, Midorag,

Maybe [email protected] is your new email address? Please review this patch.
And Alessandro, Alexandre, could you please help to review this patch?

Huacai

Quoted 32 lines · Huacai Chen

Ping?

Quoted 28 lines · 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.

---
 drivers/rtc/rtc-goldfish.c | 1 +
 1 file changed, 1 insertion(+)
drivers/rtc/rtc-goldfish.c +1 -1
index 1a3420e..d5083b0 100644
@@ -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

#3 lore raw

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 <[email protected]>
Sent: Thursday, July 9, 2020 11:40 AM
To: Alessandro Zummo <[email protected]>; Alexandre Belloni <[email protected]>; Miodrag Dinic <[email protected]>
Cc: [email protected]; Fuxin Zhang <[email protected]>; Jiaxun Yang <[email protected]>
Subject: Re: [PATCH] rtc: goldfish: Enable interrupt in set_alarm() when necessary

Hi, Midorag,

Maybe [email protected] is your new email address? Please review this patch. And Alessandro, Alexandre, could you please help to review this patch?

Huacai

Quoted 32 lines · Huacai Chen

Ping?

Quoted 28 lines · 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.

---
 drivers/rtc/rtc-goldfish.c | 1 +
 1 file changed, 1 insertion(+)
drivers/rtc/rtc-goldfish.c +1 -1
index 1a3420e..d5083b0 100644
@@ -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

maintainer Applied
#4 lore raw
In reply to Huacai Chen
Quoted 5 lines · 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.

Applied, thanks!

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

      commit: 22f8d5a1bf230cf8567a4121fc3789babb46336d

Best regards,

Signature · 1 line
Alexandre Belloni <[email protected]>