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)
commit614bba095845cb58f64f5cb82c1710d42a338b61
tree0ea36a553d59ccdd0f89964db0c3db3a48afd184
parent6e3acebe35cfc584e145e495b175ae5308d2f2bc
realtek: use irq_force_affinity on otto timer instead

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