[PATCH] realtek: mark clock source as continuous

Sander Vanheule sander at svanheule.net
Mon Oct 31 02:11:04 PDT 2022


After replacing the R4K event timer and clock source with the new
Realtek Otto timer, performance for RTL839x devices was severely
impacted, as reported by Hiroshi.

Research by Markus showed that after commit 4657a5301eb5 (realtek: avoid
busy waiting for RTL839x PHY read/write, 2022-10-14), the ethernet
driver could only update a phy once per timer interval, which also
heavily impacted boot time. On e.g. a Zyxel GS1900-48, this added around
a minute to the time to fully initialise the switch.

By marking the otto clocksource as continuous, the kernel enables it to
be used for high resolution timers. This allows readx_poll_timeout() to
sleep for less than one system timer interval, reducing system dead
time.

Link: https://github.com/openwrt/openwrt/issues/11117
Reported-by: INAGAKI Hiroshi <musashino.open at gmail.com>
Cc: Markus Stockhausen <markus.stockhausen at gmx.de>
Signed-off-by: Sander Vanheule <sander at svanheule.net>
---
With this patch, initialisation time for my GS1900-48 drops from 110
seconds to 50 seconds. Please check if you can reproduce this. The 'why
this works' from the commit message is from a quick look at the places
where this CLOCK_SOURCE flag is checked, so I hope it actually makes sense.

Best,
Sander

 .../realtek/files-5.10/drivers/clocksource/timer-rtl-otto.c      | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/linux/realtek/files-5.10/drivers/clocksource/timer-rtl-otto.c b/target/linux/realtek/files-5.10/drivers/clocksource/timer-rtl-otto.c
index 12eed78653d0..14e28e50f40e 100644
--- a/target/linux/realtek/files-5.10/drivers/clocksource/timer-rtl-otto.c
+++ b/target/linux/realtek/files-5.10/drivers/clocksource/timer-rtl-otto.c
@@ -227,6 +227,7 @@ struct rttm_cs rttm_cs = {
 		.name	= "realtek_otto_timer",
 		.rating	= 400,
 		.mask	= CLOCKSOURCE_MASK(RTTM_BIT_COUNT),
+		.flags	= CLOCK_SOURCE_IS_CONTINUOUS,
 		.read	= rttm_read_clocksource,
 		.enable	= rttm_enable_clocksource
 	}
-- 
2.38.1




More information about the openwrt-devel mailing list