realtek: use irq_force_affinity on otto timer instead
authorINAGAKI Hiroshi <musashino.open@gmail.com>
Sat, 24 Dec 2022 12:34:29 +0000 (21:34 +0900)
committerSander Vanheule <sander@svanheule.net>
Sat, 21 Jan 2023 18:58:24 +0000 (19:58 +0100)
After commit e0d2c59ee995 ("genirq: Always limit the affinity to online
CPUs", 5.10) on Linux, the cpumask passed to irq_set_affinity of irqchip
driver is limited to online CPUs. When irq_do_set_affinity called from
otto timer driver with only one secondary CPU, that CPU is not marked as
online yet, filtered out by cpu_online_mask and fall to error path.
Then, fail to set affinity for that CPU and it leads to instability of
timer on secondary CPU(s).

At least, RTL839x system will be affected.

log:

[   37.560020] rcu: INFO: rcu_sched detected stalls on CPUs/tasks:
[   37.638025] rcu:     1-...!: (0 ticks this GP) idle=6ac/0/0x0 softirq=0/0 fqs=1  (false positive?)
[   37.752683]  (detected by 0, t=6002 jiffies, g=-1179, q=26293)
[   37.829510] Sending NMI from CPU 0 to CPUs 1:
[   37.886857] NMI backtrace for cpu 1 skipped: idling at r4k_wait_irqoff+0x1c/0x24
[   37.984801] rcu: rcu_sched kthread timer wakeup didn't happen for 5999 jiffies! g-1179 f0x0 RCU_GP_WAIT_FQS(5) ->state=0x402
[   38.132743] rcu:     Possible timer handling issue on cpu=1 timer-softirq=0
[   38.221033] rcu: rcu_sched kthread starved for 6000 jiffies! g-1179 f0x0 RCU_GP_WAIT_FQS(5) ->state=0x402 ->cpu=1
[   38.356336] rcu:     Unless rcu_sched kthread gets sufficient CPU time, OOM is now expected behavior.
[   38.474440] rcu: RCU grace-period kthread stack dump:
...

Replace to irq_force_affinity from irq_set_affinity and ignore
cpu_online_mask to fix the issue.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
Tested-by: Olliver Schinagl <oliver@schinagl.nl>
target/linux/realtek/files-5.10/drivers/clocksource/timer-rtl-otto.c
target/linux/realtek/files-5.15/drivers/clocksource/timer-rtl-otto.c

index 14e28e50f40eb4e2c81ed54ab894ddc633657dde..c096d8742b481403dacc87abc086ff134066743c 100644 (file)
@@ -244,7 +244,7 @@ static int rttm_cpu_starting(unsigned int cpu)
 
        RTTM_DEBUG(to->of_base.base);
        to->clkevt.cpumask = cpumask_of(cpu);
-       irq_set_affinity(to->of_irq.irq, to->clkevt.cpumask);
+       irq_force_affinity(to->of_irq.irq, to->clkevt.cpumask);
        clockevents_config_and_register(&to->clkevt, RTTM_TICKS_PER_SEC,
                                        RTTM_MIN_DELTA, RTTM_MAX_DELTA);
        rttm_enable_irq(to->of_base.base);
index 14e28e50f40eb4e2c81ed54ab894ddc633657dde..c096d8742b481403dacc87abc086ff134066743c 100644 (file)
@@ -244,7 +244,7 @@ static int rttm_cpu_starting(unsigned int cpu)
 
        RTTM_DEBUG(to->of_base.base);
        to->clkevt.cpumask = cpumask_of(cpu);
-       irq_set_affinity(to->of_irq.irq, to->clkevt.cpumask);
+       irq_force_affinity(to->of_irq.irq, to->clkevt.cpumask);
        clockevents_config_and_register(&to->clkevt, RTTM_TICKS_PER_SEC,
                                        RTTM_MIN_DELTA, RTTM_MAX_DELTA);
        rttm_enable_irq(to->of_base.base);