* [PATCH 0/8] clocksource/drivers/timer-goldfish: Fix bugs and add DT support
@ 2026-11-05 16:16 Kuan-Wei Chiu
2026-11-05 16:16 ` [PATCH 1/8] clocksource/drivers/timer-goldfish: Fix latch corruption with spinlock Kuan-Wei Chiu
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Kuan-Wei Chiu @ 2026-11-05 16:16 UTC (permalink / raw)
To: daniel.lezcano, tglx
Cc: pjw, palmer, aou, alex, geert, laurent, marscheng, eleanor15x,
jserv, linux-kernel, linux-riscv, linux-m68k, Kuan-Wei Chiu
The goldfish timer driver was previously only used and tested on
single core m68k virt, but the same device is also present on other
qemu virt machines such as riscv and or1k, where running on SMP exposes
several issues.
Fix the concurrency, oneshot, and registration bugs in the driver, add
device tree probing support so it can be used across these platforms,
and add a MAINTAINERS entry.
Tested on qemu m68k virt and on qemu riscv64 virt with 4 SMP cores. On
riscv64, testing was done by passing clocksource=goldfish_timer on the
kernel command line and locally bumping the clock_event_device rating
above the architected timer to verify both clocksource and oneshot
clockevent operation.
Kuan-Wei Chiu (8):
clocksource/drivers/timer-goldfish: Fix latch corruption with spinlock
clocksource/drivers/timer-goldfish: Fix oneshot mode spurious
interrupt
clocksource/drivers/timer-goldfish: Fix resource leaks in init
clocksource/drivers/timer-goldfish: Set CLOCK_SOURCE_IS_CONTINUOUS
flag
clocksource/drivers/timer-goldfish: Drop redundant max_idle_ns setting
clocksource/drivers/timer-goldfish: Set clock_event_device cpumask
clocksource/drivers/timer-goldfish: Add device tree probing support
MAINTAINERS: Add entry for goldfish timer driver
MAINTAINERS | 6 ++
drivers/clocksource/Kconfig | 5 +-
drivers/clocksource/timer-goldfish.c | 113 +++++++++++++++++++++------
3 files changed, 99 insertions(+), 25 deletions(-)
--
2.56.0.398.g882cbad275-goog
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/8] clocksource/drivers/timer-goldfish: Fix latch corruption with spinlock
2026-11-05 16:16 [PATCH 0/8] clocksource/drivers/timer-goldfish: Fix bugs and add DT support Kuan-Wei Chiu
@ 2026-11-05 16:16 ` Kuan-Wei Chiu
2026-11-05 16:16 ` [PATCH 2/8] clocksource/drivers/timer-goldfish: Fix oneshot mode spurious interrupt Kuan-Wei Chiu
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Kuan-Wei Chiu @ 2026-11-05 16:16 UTC (permalink / raw)
To: daniel.lezcano, tglx
Cc: pjw, palmer, aou, alex, geert, laurent, marscheng, eleanor15x,
jserv, linux-kernel, linux-riscv, linux-m68k, Kuan-Wei Chiu
Reading TIMER_TIME_LOW latches the upper 32 bits of the current time
into TIMER_TIME_HIGH. Because goldfish_timer_read() reads these two
registers without synchronization, a concurrent reader from an interrupt
or another CPU can read TIMER_TIME_LOW in between and overwrite the
latched high bits.
Protect the register read sequence with a raw spinlock.
Fixes: c92e7ef16400 ("clocksource/drivers: Add a goldfish-timer clocksource")
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
drivers/clocksource/timer-goldfish.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/clocksource/timer-goldfish.c b/drivers/clocksource/timer-goldfish.c
index 3fe12c7ee7b7..cc02b012ff76 100644
--- a/drivers/clocksource/timer-goldfish.c
+++ b/drivers/clocksource/timer-goldfish.c
@@ -6,6 +6,7 @@
#include <linux/clockchips.h>
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/spinlock.h>
#include <linux/goldfish.h>
#include <clocksource/timer-goldfish.h>
@@ -14,6 +15,7 @@ struct goldfish_timer {
struct clock_event_device ced;
struct resource res;
void __iomem *base;
+ raw_spinlock_t lock;
};
static struct goldfish_timer *ced_to_gf(struct clock_event_device *ced)
@@ -30,6 +32,7 @@ static u64 goldfish_timer_read(struct clocksource *cs)
{
struct goldfish_timer *timerdrv = cs_to_gf(cs);
void __iomem *base = timerdrv->base;
+ unsigned long flags;
u32 time_low, time_high;
u64 ticks;
@@ -37,8 +40,10 @@ static u64 goldfish_timer_read(struct clocksource *cs)
* time_low: get low bits of current time and update time_high
* time_high: get high bits of time at last time_low read
*/
+ raw_spin_lock_irqsave(&timerdrv->lock, flags);
time_low = gf_ioread32(base + TIMER_TIME_LOW);
time_high = gf_ioread32(base + TIMER_TIME_HIGH);
+ raw_spin_unlock_irqrestore(&timerdrv->lock, flags);
ticks = ((u64)time_high << 32) | time_low;
@@ -107,6 +112,7 @@ int __init goldfish_timer_init(int irq, void __iomem *base)
return -ENOMEM;
timerdrv->base = base;
+ raw_spin_lock_init(&timerdrv->lock);
timerdrv->ced = (struct clock_event_device){
.name = "goldfish_timer",
--
2.56.0.398.g882cbad275-goog
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/8] clocksource/drivers/timer-goldfish: Fix oneshot mode spurious interrupt
2026-11-05 16:16 [PATCH 0/8] clocksource/drivers/timer-goldfish: Fix bugs and add DT support Kuan-Wei Chiu
2026-11-05 16:16 ` [PATCH 1/8] clocksource/drivers/timer-goldfish: Fix latch corruption with spinlock Kuan-Wei Chiu
@ 2026-11-05 16:16 ` Kuan-Wei Chiu
2026-11-05 16:16 ` [PATCH 3/8] clocksource/drivers/timer-goldfish: Fix resource leaks in init Kuan-Wei Chiu
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Kuan-Wei Chiu @ 2026-11-05 16:16 UTC (permalink / raw)
To: daniel.lezcano, tglx
Cc: pjw, palmer, aou, alex, geert, laurent, marscheng, eleanor15x,
jserv, linux-kernel, linux-riscv, linux-m68k, Kuan-Wei Chiu
goldfish_timer_set_oneshot() writes 0 to TIMER_ALARM_HIGH and
TIMER_ALARM_LOW. Writing TIMER_ALARM_LOW arms the alarm for timestamp 0,
which immediately triggers a spurious interrupt when TIMER_IRQ_ENABLED
is set. Meanwhile, goldfish_timer_shutdown() disables interrupts without
disarming the alarm.
Use TIMER_CLEAR_ALARM to disarm the alarm in both functions.
Fixes: c92e7ef16400 ("clocksource/drivers: Add a goldfish-timer clocksource")
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
drivers/clocksource/timer-goldfish.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/clocksource/timer-goldfish.c b/drivers/clocksource/timer-goldfish.c
index cc02b012ff76..b1dc8b388470 100644
--- a/drivers/clocksource/timer-goldfish.c
+++ b/drivers/clocksource/timer-goldfish.c
@@ -55,8 +55,7 @@ static int goldfish_timer_set_oneshot(struct clock_event_device *evt)
struct goldfish_timer *timerdrv = ced_to_gf(evt);
void __iomem *base = timerdrv->base;
- gf_iowrite32(0, base + TIMER_ALARM_HIGH);
- gf_iowrite32(0, base + TIMER_ALARM_LOW);
+ gf_iowrite32(1, base + TIMER_CLEAR_ALARM);
gf_iowrite32(1, base + TIMER_IRQ_ENABLED);
return 0;
@@ -68,6 +67,7 @@ static int goldfish_timer_shutdown(struct clock_event_device *evt)
void __iomem *base = timerdrv->base;
gf_iowrite32(0, base + TIMER_IRQ_ENABLED);
+ gf_iowrite32(1, base + TIMER_CLEAR_ALARM);
return 0;
}
--
2.56.0.398.g882cbad275-goog
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/8] clocksource/drivers/timer-goldfish: Fix resource leaks in init
2026-11-05 16:16 [PATCH 0/8] clocksource/drivers/timer-goldfish: Fix bugs and add DT support Kuan-Wei Chiu
2026-11-05 16:16 ` [PATCH 1/8] clocksource/drivers/timer-goldfish: Fix latch corruption with spinlock Kuan-Wei Chiu
2026-11-05 16:16 ` [PATCH 2/8] clocksource/drivers/timer-goldfish: Fix oneshot mode spurious interrupt Kuan-Wei Chiu
@ 2026-11-05 16:16 ` Kuan-Wei Chiu
2026-11-05 16:16 ` [PATCH 4/8] clocksource/drivers/timer-goldfish: Set CLOCK_SOURCE_IS_CONTINUOUS flag Kuan-Wei Chiu
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Kuan-Wei Chiu @ 2026-11-05 16:16 UTC (permalink / raw)
To: daniel.lezcano, tglx
Cc: pjw, palmer, aou, alex, geert, laurent, marscheng, eleanor15x,
jserv, linux-kernel, linux-riscv, linux-m68k, Kuan-Wei Chiu
goldfish_timer_init() ignores the return value of
clocksource_register_hz() and fails to release allocated resources when
initialization fails.
Check the return value of clocksource_register_hz() and clean up
allocated resources on error.
Fixes: c92e7ef16400 ("clocksource/drivers: Add a goldfish-timer clocksource")
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
drivers/clocksource/timer-goldfish.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/clocksource/timer-goldfish.c b/drivers/clocksource/timer-goldfish.c
index b1dc8b388470..8c312c3a64a6 100644
--- a/drivers/clocksource/timer-goldfish.c
+++ b/drivers/clocksource/timer-goldfish.c
@@ -131,7 +131,7 @@ int __init goldfish_timer_init(int irq, void __iomem *base)
ret = request_resource(&iomem_resource, &timerdrv->res);
if (ret) {
pr_err("Cannot allocate '%s' resource\n", timerdrv->res.name);
- return ret;
+ goto err_free;
}
timerdrv->cs = (struct clocksource){
@@ -143,17 +143,29 @@ int __init goldfish_timer_init(int irq, void __iomem *base)
.max_idle_ns = LONG_MAX,
};
- clocksource_register_hz(&timerdrv->cs, NSEC_PER_SEC);
+ ret = clocksource_register_hz(&timerdrv->cs, NSEC_PER_SEC);
+ if (ret) {
+ pr_err("Couldn't register goldfish-timer clocksource\n");
+ goto err_release_res;
+ }
ret = request_irq(irq, goldfish_timer_irq, IRQF_TIMER,
"goldfish_timer", timerdrv);
if (ret) {
pr_err("Couldn't register goldfish-timer interrupt\n");
- return ret;
+ goto err_unregister_cs;
}
clockevents_config_and_register(&timerdrv->ced, NSEC_PER_SEC,
1, 0xffffffff);
return 0;
+
+err_unregister_cs:
+ clocksource_unregister(&timerdrv->cs);
+err_release_res:
+ release_resource(&timerdrv->res);
+err_free:
+ kfree(timerdrv);
+ return ret;
}
--
2.56.0.398.g882cbad275-goog
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/8] clocksource/drivers/timer-goldfish: Set CLOCK_SOURCE_IS_CONTINUOUS flag
2026-11-05 16:16 [PATCH 0/8] clocksource/drivers/timer-goldfish: Fix bugs and add DT support Kuan-Wei Chiu
` (2 preceding siblings ...)
2026-11-05 16:16 ` [PATCH 3/8] clocksource/drivers/timer-goldfish: Fix resource leaks in init Kuan-Wei Chiu
@ 2026-11-05 16:16 ` Kuan-Wei Chiu
2026-11-05 16:16 ` [PATCH 5/8] clocksource/drivers/timer-goldfish: Drop redundant max_idle_ns setting Kuan-Wei Chiu
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Kuan-Wei Chiu @ 2026-11-05 16:16 UTC (permalink / raw)
To: daniel.lezcano, tglx
Cc: pjw, palmer, aou, alex, geert, laurent, marscheng, eleanor15x,
jserv, linux-kernel, linux-riscv, linux-m68k, Kuan-Wei Chiu
The goldfish timer is a free-running counter, but timerdrv->cs.flags is
set to 0. Without CLOCK_SOURCE_IS_CONTINUOUS, the clocksource core does
not mark it as valid for high-resolution timers, preventing the kernel
from switching to it when oneshot mode is active:
[ 0.751173] clocksource: Override clocksource goldfish_timer is not currently HRT compatible - deferring
Set .flags to CLOCK_SOURCE_IS_CONTINUOUS.
Fixes: c92e7ef16400 ("clocksource/drivers: Add a goldfish-timer clocksource")
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
drivers/clocksource/timer-goldfish.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clocksource/timer-goldfish.c b/drivers/clocksource/timer-goldfish.c
index 8c312c3a64a6..88253bd1f569 100644
--- a/drivers/clocksource/timer-goldfish.c
+++ b/drivers/clocksource/timer-goldfish.c
@@ -139,7 +139,7 @@ int __init goldfish_timer_init(int irq, void __iomem *base)
.rating = 400,
.read = goldfish_timer_read,
.mask = CLOCKSOURCE_MASK(64),
- .flags = 0,
+ .flags = CLOCK_SOURCE_IS_CONTINUOUS,
.max_idle_ns = LONG_MAX,
};
--
2.56.0.398.g882cbad275-goog
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 5/8] clocksource/drivers/timer-goldfish: Drop redundant max_idle_ns setting
2026-11-05 16:16 [PATCH 0/8] clocksource/drivers/timer-goldfish: Fix bugs and add DT support Kuan-Wei Chiu
` (3 preceding siblings ...)
2026-11-05 16:16 ` [PATCH 4/8] clocksource/drivers/timer-goldfish: Set CLOCK_SOURCE_IS_CONTINUOUS flag Kuan-Wei Chiu
@ 2026-11-05 16:16 ` Kuan-Wei Chiu
2026-11-05 16:17 ` [PATCH 6/8] clocksource/drivers/timer-goldfish: Set clock_event_device cpumask Kuan-Wei Chiu
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Kuan-Wei Chiu @ 2026-11-05 16:16 UTC (permalink / raw)
To: daniel.lezcano, tglx
Cc: pjw, palmer, aou, alex, geert, laurent, marscheng, eleanor15x,
jserv, linux-kernel, linux-riscv, linux-m68k, Kuan-Wei Chiu
clocksource_register_hz() automatically calculates cs->max_idle_ns, so
the explicit max_idle_ns assignment in goldfish_timer_init() is
redundant and overwritten during registration.
Remove the redundant assignment.
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
drivers/clocksource/timer-goldfish.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/clocksource/timer-goldfish.c b/drivers/clocksource/timer-goldfish.c
index 88253bd1f569..bac84e0f9b7b 100644
--- a/drivers/clocksource/timer-goldfish.c
+++ b/drivers/clocksource/timer-goldfish.c
@@ -140,7 +140,6 @@ int __init goldfish_timer_init(int irq, void __iomem *base)
.read = goldfish_timer_read,
.mask = CLOCKSOURCE_MASK(64),
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
- .max_idle_ns = LONG_MAX,
};
ret = clocksource_register_hz(&timerdrv->cs, NSEC_PER_SEC);
--
2.56.0.398.g882cbad275-goog
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 6/8] clocksource/drivers/timer-goldfish: Set clock_event_device cpumask
2026-11-05 16:16 [PATCH 0/8] clocksource/drivers/timer-goldfish: Fix bugs and add DT support Kuan-Wei Chiu
` (4 preceding siblings ...)
2026-11-05 16:16 ` [PATCH 5/8] clocksource/drivers/timer-goldfish: Drop redundant max_idle_ns setting Kuan-Wei Chiu
@ 2026-11-05 16:17 ` Kuan-Wei Chiu
2026-11-05 16:17 ` [PATCH 7/8] clocksource/drivers/timer-goldfish: Add device tree probing support Kuan-Wei Chiu
2026-11-05 16:17 ` [PATCH 8/8] MAINTAINERS: Add entry for goldfish timer driver Kuan-Wei Chiu
7 siblings, 0 replies; 9+ messages in thread
From: Kuan-Wei Chiu @ 2026-11-05 16:17 UTC (permalink / raw)
To: daniel.lezcano, tglx
Cc: pjw, palmer, aou, alex, geert, laurent, marscheng, eleanor15x,
jserv, linux-kernel, linux-riscv, linux-m68k, Kuan-Wei Chiu
Leaving timerdrv->ced.cpumask uninitialized triggers a warning in
clockevents_register_device() when num_possible_cpus() > 1.
Initialize .cpumask to cpu_possible_mask.
Fixes: c92e7ef16400 ("clocksource/drivers: Add a goldfish-timer clocksource")
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
drivers/clocksource/timer-goldfish.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/clocksource/timer-goldfish.c b/drivers/clocksource/timer-goldfish.c
index bac84e0f9b7b..208b80c46193 100644
--- a/drivers/clocksource/timer-goldfish.c
+++ b/drivers/clocksource/timer-goldfish.c
@@ -117,6 +117,7 @@ int __init goldfish_timer_init(int irq, void __iomem *base)
timerdrv->ced = (struct clock_event_device){
.name = "goldfish_timer",
.features = CLOCK_EVT_FEAT_ONESHOT,
+ .cpumask = cpu_possible_mask,
.set_state_shutdown = goldfish_timer_shutdown,
.set_state_oneshot = goldfish_timer_set_oneshot,
.set_next_event = goldfish_timer_next_event,
--
2.56.0.398.g882cbad275-goog
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 7/8] clocksource/drivers/timer-goldfish: Add device tree probing support
2026-11-05 16:16 [PATCH 0/8] clocksource/drivers/timer-goldfish: Fix bugs and add DT support Kuan-Wei Chiu
` (5 preceding siblings ...)
2026-11-05 16:17 ` [PATCH 6/8] clocksource/drivers/timer-goldfish: Set clock_event_device cpumask Kuan-Wei Chiu
@ 2026-11-05 16:17 ` Kuan-Wei Chiu
2026-11-05 16:17 ` [PATCH 8/8] MAINTAINERS: Add entry for goldfish timer driver Kuan-Wei Chiu
7 siblings, 0 replies; 9+ messages in thread
From: Kuan-Wei Chiu @ 2026-11-05 16:17 UTC (permalink / raw)
To: daniel.lezcano, tglx
Cc: pjw, palmer, aou, alex, geert, laurent, marscheng, eleanor15x,
jserv, linux-kernel, linux-riscv, linux-m68k, Kuan-Wei Chiu
The driver currently only supports board-level initialization via
goldfish_timer_init() on m68k virt.
Register a platform driver matching "google,goldfish-rtc" so device
tree platforms can also probe the timer. Since DT platforms typically
expose a single goldfish-rtc device that cannot be bound by both
drivers at once, depend on M68K || !RTC_DRV_GOLDFISH in Kconfig to
avoid conflicting with rtc-goldfish.
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
drivers/clocksource/Kconfig | 5 +-
drivers/clocksource/timer-goldfish.c | 93 +++++++++++++++++++++-------
2 files changed, 74 insertions(+), 24 deletions(-)
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index da83483296d5..3a94feb377a5 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -760,8 +760,9 @@ config MICROCHIP_PIT64B
config GOLDFISH_TIMER
bool "Clocksource using goldfish-rtc"
- depends on M68K || COMPILE_TEST
- depends on RTC_DRV_GOLDFISH
+ depends on M68K || OF || COMPILE_TEST
+ depends on M68K || !RTC_DRV_GOLDFISH
+ depends on HAS_IOMEM
help
Support for the timer/counter of goldfish-rtc
diff --git a/drivers/clocksource/timer-goldfish.c b/drivers/clocksource/timer-goldfish.c
index 208b80c46193..563390012b89 100644
--- a/drivers/clocksource/timer-goldfish.c
+++ b/drivers/clocksource/timer-goldfish.c
@@ -5,6 +5,8 @@
#include <linux/clocksource.h>
#include <linux/clockchips.h>
#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/goldfish.h>
@@ -102,15 +104,11 @@ static irqreturn_t goldfish_timer_irq(int irq, void *dev_id)
return IRQ_HANDLED;
}
-int __init goldfish_timer_init(int irq, void __iomem *base)
+static int goldfish_timer_common_init(struct goldfish_timer *timerdrv,
+ int irq, void __iomem *base)
{
- struct goldfish_timer *timerdrv;
int ret;
- timerdrv = kzalloc_obj(*timerdrv);
- if (!timerdrv)
- return -ENOMEM;
-
timerdrv->base = base;
raw_spin_lock_init(&timerdrv->lock);
@@ -123,18 +121,6 @@ int __init goldfish_timer_init(int irq, void __iomem *base)
.set_next_event = goldfish_timer_next_event,
};
- timerdrv->res = (struct resource){
- .name = "goldfish_timer",
- .start = (unsigned long)base,
- .end = (unsigned long)base + 0xfff,
- };
-
- ret = request_resource(&iomem_resource, &timerdrv->res);
- if (ret) {
- pr_err("Cannot allocate '%s' resource\n", timerdrv->res.name);
- goto err_free;
- }
-
timerdrv->cs = (struct clocksource){
.name = "goldfish_timer",
.rating = 400,
@@ -146,26 +132,89 @@ int __init goldfish_timer_init(int irq, void __iomem *base)
ret = clocksource_register_hz(&timerdrv->cs, NSEC_PER_SEC);
if (ret) {
pr_err("Couldn't register goldfish-timer clocksource\n");
- goto err_release_res;
+ return ret;
}
ret = request_irq(irq, goldfish_timer_irq, IRQF_TIMER,
"goldfish_timer", timerdrv);
if (ret) {
pr_err("Couldn't register goldfish-timer interrupt\n");
- goto err_unregister_cs;
+ clocksource_unregister(&timerdrv->cs);
+ return ret;
}
clockevents_config_and_register(&timerdrv->ced, NSEC_PER_SEC,
1, 0xffffffff);
return 0;
+}
+
+int __init goldfish_timer_init(int irq, void __iomem *base)
+{
+ struct goldfish_timer *timerdrv;
+ int ret;
+
+ timerdrv = kzalloc_obj(*timerdrv);
+ if (!timerdrv)
+ return -ENOMEM;
+
+ timerdrv->res = (struct resource){
+ .name = "goldfish_timer",
+ .start = (unsigned long)base,
+ .end = (unsigned long)base + 0xfff,
+ };
+
+ ret = request_resource(&iomem_resource, &timerdrv->res);
+ if (ret) {
+ pr_err("Cannot allocate '%s' resource\n", timerdrv->res.name);
+ goto err_free;
+ }
+
+ ret = goldfish_timer_common_init(timerdrv, irq, base);
+ if (ret)
+ goto err_release_res;
+
+ return 0;
-err_unregister_cs:
- clocksource_unregister(&timerdrv->cs);
err_release_res:
release_resource(&timerdrv->res);
err_free:
kfree(timerdrv);
return ret;
}
+
+static int goldfish_timer_probe(struct platform_device *pdev)
+{
+ struct goldfish_timer *timerdrv;
+ void __iomem *base;
+ int irq;
+
+ base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(base))
+ return PTR_ERR(base);
+
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0)
+ return irq;
+
+ timerdrv = devm_kzalloc(&pdev->dev, sizeof(*timerdrv), GFP_KERNEL);
+ if (!timerdrv)
+ return -ENOMEM;
+
+ return goldfish_timer_common_init(timerdrv, irq, base);
+}
+
+static const struct of_device_id goldfish_timer_of_match[] = {
+ { .compatible = "google,goldfish-rtc", },
+ {},
+};
+
+static struct platform_driver goldfish_timer_driver = {
+ .probe = goldfish_timer_probe,
+ .driver = {
+ .name = "goldfish_timer",
+ .of_match_table = goldfish_timer_of_match,
+ .suppress_bind_attrs = true,
+ },
+};
+builtin_platform_driver(goldfish_timer_driver);
--
2.56.0.398.g882cbad275-goog
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 8/8] MAINTAINERS: Add entry for goldfish timer driver
2026-11-05 16:16 [PATCH 0/8] clocksource/drivers/timer-goldfish: Fix bugs and add DT support Kuan-Wei Chiu
` (6 preceding siblings ...)
2026-11-05 16:17 ` [PATCH 7/8] clocksource/drivers/timer-goldfish: Add device tree probing support Kuan-Wei Chiu
@ 2026-11-05 16:17 ` Kuan-Wei Chiu
7 siblings, 0 replies; 9+ messages in thread
From: Kuan-Wei Chiu @ 2026-11-05 16:17 UTC (permalink / raw)
To: daniel.lezcano, tglx
Cc: pjw, palmer, aou, alex, geert, laurent, marscheng, eleanor15x,
jserv, linux-kernel, linux-riscv, linux-m68k, Kuan-Wei Chiu
There is currently no MAINTAINERS entry for the goldfish timer driver.
Add one and list myself as maintainer, as I already maintain the same
driver in U-Boot [1].
Link: https://source.denx.de/u-boot/u-boot/-/commit/909f717eaf29 [1]
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
MAINTAINERS | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 93abbb315065..13688df0e060 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2078,6 +2078,12 @@ M: Jiaxun Yang <jiaxun.yang@flygoat.com>
S: Supported
F: drivers/rtc/rtc-goldfish.c
+ANDROID GOLDFISH TIMER DRIVER
+M: Kuan-Wei Chiu <visitorckw@gmail.com>
+S: Maintained
+F: drivers/clocksource/timer-goldfish.c
+F: include/clocksource/timer-goldfish.h
+
ANLOGIC DR1V90 CRU DRIVER
M: Junhui Liu <junhui.liu@pigmoral.tech>
S: Maintained
--
2.56.0.398.g882cbad275-goog
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-11-05 16:18 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-05 16:16 [PATCH 0/8] clocksource/drivers/timer-goldfish: Fix bugs and add DT support Kuan-Wei Chiu
2026-11-05 16:16 ` [PATCH 1/8] clocksource/drivers/timer-goldfish: Fix latch corruption with spinlock Kuan-Wei Chiu
2026-11-05 16:16 ` [PATCH 2/8] clocksource/drivers/timer-goldfish: Fix oneshot mode spurious interrupt Kuan-Wei Chiu
2026-11-05 16:16 ` [PATCH 3/8] clocksource/drivers/timer-goldfish: Fix resource leaks in init Kuan-Wei Chiu
2026-11-05 16:16 ` [PATCH 4/8] clocksource/drivers/timer-goldfish: Set CLOCK_SOURCE_IS_CONTINUOUS flag Kuan-Wei Chiu
2026-11-05 16:16 ` [PATCH 5/8] clocksource/drivers/timer-goldfish: Drop redundant max_idle_ns setting Kuan-Wei Chiu
2026-11-05 16:17 ` [PATCH 6/8] clocksource/drivers/timer-goldfish: Set clock_event_device cpumask Kuan-Wei Chiu
2026-11-05 16:17 ` [PATCH 7/8] clocksource/drivers/timer-goldfish: Add device tree probing support Kuan-Wei Chiu
2026-11-05 16:17 ` [PATCH 8/8] MAINTAINERS: Add entry for goldfish timer driver Kuan-Wei Chiu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®