[PATCH] realtek: mark clock source as continuous

INAGAKI Hiroshi musashino.open at gmail.com
Mon Oct 31 06:09:19 PDT 2022


Hi Sander,

thanks for the patch!

I tested on my Panasonic Switch-M48eG PN28480K (RTL8393M) and all 
issues are solved :)

- top page loading of LuCI (WebUI) at login: 2.64 s
- ethtool lanX (10x times): avg 0.00 s, max 0.01 s
- /proc/interrupts (per (about) 1s):
   root at OpenWrt:/# while :; do grep "timer" /proc/interrupts; echo 
"---"; sleep 1; done
    28:          0     388182  realtek-rtl-intc  28  timer at 3100
    29:    1179094          0  realtek-rtl-intc  29  timer at 3100
   ---
    28:          0     388632  realtek-rtl-intc  28  timer at 3100
    29:    1181698          0  realtek-rtl-intc  29  timer at 3100
   ---
    28:          0     389094  realtek-rtl-intc  28  timer at 3100
    29:    1184276          0  realtek-rtl-intc  29  timer at 3100
   ---
    28:          0     389350  realtek-rtl-intc  28  timer at 3100
    29:    1185182          0  realtek-rtl-intc  29  timer at 3100
   ---
    28:          0     389651  realtek-rtl-intc  28  timer at 3100
    29:    1186753          0  realtek-rtl-intc  29  timer at 3100
   ---
- bootlog:
https://gist.github.com/musashino205/2aa32ff858d863de9790c75c3a0b5bf8

   (without the patch):
https://gist.github.com/musashino205/0db98d9f99fbacc8a311f65739b72eb7

Thanks,
Hiroshi

On 2022/10/31 18:11, Sander Vanheule wrote:
> 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
>   	}



More information about the openwrt-devel mailing list