[PATCH] irqchip/riscv-aplic: fix PM for multi-aplic system

Vladimir Kondratiev posted 1 patch 4 weeks ago
drivers/irqchip/irq-riscv-aplic-main.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
[PATCH] irqchip/riscv-aplic: fix PM for multi-aplic system
Posted by Vladimir Kondratiev 4 weeks ago
The aplic_syscore is a singleton and should be registered once.
If it is registered from the driver probe, register_syscore()
called multiple times for the system having multiple aplic instances.
This results in double registration of the same syscore. Warning
triggered:

[    0.553569] ------------[ cut here ]------------
[    0.553572] list_add double add: new=ffffffff81314a68, prev=ffffffff81314a68, next=ffffffff8131f588.
[    0.553643] WARNING: lib/list_debug.c:35 at __list_add_valid_or_report+0x4e/0xe8, CPU#23: swapper/0/1
[    0.553660] Modules linked in:
[    0.553668] CPU: 23 UID: 0 PID: 1 Comm: swapper/0 Not tainted 7.0.0-rc1 #2 PREEMPT_RT
[    0.553675] Hardware name: EyeQ7 evaluation board (DT)
[    0.553679] epc : __list_add_valid_or_report+0x4e/0xe8
[    0.553685]  ra : __list_add_valid_or_report+0x4e/0xe8
[    0.553691] epc : ffffffff80443e72 ra : ffffffff80443e72 sp : ffffffc6000dbaf0
[    0.553696]  gp : ffffffff81391b48 tp : ffffffd6007d9b00 t0 : ffffffd9efbc4318
[    0.553700]  t1 : 0000000000000004 t2 : 2d2d2d2d2d2d2d2d s0 : ffffffc6000dbb20
[    0.553704]  s1 : ffffffff8131f588 a0 : 0000000000000058 a1 : ffffffff80089b9a
[    0.553708]  a2 : ffffffd9effab4d0 a3 : 0000000000000000 a4 : 0000000000000000
[    0.553711]  a5 : 0000000000000000 a6 : ffffffff80da4889 a7 : ffffffffffffffff
[    0.553715]  s2 : ffffffff8131f558 s3 : ffffffff81314a68 s4 : ffffffff8131f588
[    0.553719]  s5 : ffffffff81367d40 s6 : ffffffff80a00db8 s7 : ffffffff80a00d78
[    0.553722]  s8 : ffffffff80e4ac38 s9 : ffffffff80a1c430 s10: 0000000000000008
[    0.553726]  s11: ffffffff808000c4 t3 : 0000000000000002 t4 : ffffffd9efca3bfc
[    0.553730]  t5 : ffffffd9efca3bd8 t6 : ffffffc6000db828 ssp : 0000000000000000
[    0.553734] status: 0000000200000120 badaddr: ffffffff80443e72 cause: 0000000000000003
[    0.553738] [<ffffffff80443e72>] __list_add_valid_or_report+0x4e/0xe8
[    0.553745] [<ffffffff804f1c3a>] register_syscore+0x3a/0x6c
[    0.553754] [<ffffffff80009cd8>] aplic_probe+0xd8/0xe8
[    0.553765] [<ffffffff804f350e>] platform_probe+0x3e/0x7c
[    0.553772] [<ffffffff804f0d5e>] really_probe+0x98/0x34a
[    0.553779] [<ffffffff804f10ba>] __driver_probe_device+0xaa/0xf6
[    0.553785] [<ffffffff804f11d0>] driver_probe_device+0x36/0xc4
[    0.553791] [<ffffffff804f1470>] __driver_attach+0x108/0x1ec
[    0.553797] [<ffffffff804eebde>] bus_for_each_dev+0x58/0xa4
[    0.553803] [<ffffffff804f0608>] driver_attach+0x1a/0x22
[    0.553809] [<ffffffff804eff32>] bus_add_driver+0xe2/0x204
[    0.553814] [<ffffffff804f1f82>] driver_register+0x3e/0xd8
[    0.553820] [<ffffffff804f3204>] __platform_driver_register+0x1e/0x26
[    0.553827] [<ffffffff8082be50>] aplic_driver_init+0x1a/0x22
[    0.553837] [<ffffffff8000e910>] do_one_initcall+0x44/0x286
[    0.553843] [<ffffffff8080171c>] kernel_init_freeable+0x262/0x2e8
[    0.553853] [<ffffffff8073cd98>] kernel_init+0x28/0x14c
[    0.553863] [<ffffffff800101fa>] ret_from_fork_kernel+0x1a/0x15c
[    0.553870] [<ffffffff807493ae>] ret_from_fork_kernel_asm+0x16/0x18
[    0.553877] ---[ end trace 0000000000000000 ]---

Move syscore registration to the driver init

Fixes: 95a8ddde3660 ("irqchip/riscv-aplic: Preserve APLIC states across suspend/resume")
Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
---
 drivers/irqchip/irq-riscv-aplic-main.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-riscv-aplic-main.c b/drivers/irqchip/irq-riscv-aplic-main.c
index 8fe4dc5cfdae..12d22b9d65cb 100644
--- a/drivers/irqchip/irq-riscv-aplic-main.c
+++ b/drivers/irqchip/irq-riscv-aplic-main.c
@@ -376,8 +376,6 @@ static int aplic_probe(struct platform_device *pdev)
 	if (rc)
 		dev_err_probe(dev, rc, "failed to setup APLIC in %s mode\n",
 			      msi_mode ? "MSI" : "direct");
-	else
-		register_syscore(&aplic_syscore);
 
 #ifdef CONFIG_ACPI
 	if (!acpi_disabled)
@@ -400,4 +398,10 @@ static struct platform_driver aplic_driver = {
 	},
 	.probe = aplic_probe,
 };
-builtin_platform_driver(aplic_driver);
+
+static int __init aplic_driver_init(void)
+{
+	register_syscore(&aplic_syscore);
+	return platform_driver_register(&aplic_driver);
+}
+device_initcall(aplic_driver_init);

base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
-- 
2.43.0
Re: [PATCH] irqchip/riscv-aplic: fix PM for multi-aplic system
Posted by Thomas Gleixner 4 weeks ago
On Wed, Mar 11 2026 at 16:37, Vladimir Kondratiev wrote:

> This results in double registration of the same syscore. Warning
> triggered:
>
> [    0.553569] ------------[ cut here ]------------
> [    0.553572] list_add double add: new=ffffffff81314a68, prev=ffffffff81314a68, next=ffffffff8131f588.
>
> Move syscore registration to the driver init

This is completely wrong because it installs the syscore ops
unconditionally even when there is no APLIC available in the
system. Works for me is not the right approach.

> Fixes: 95a8ddde3660 ("irqchip/riscv-aplic: Preserve APLIC states across suspend/resume")

No. It makes it worse.

> Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>

But nothing to do here anymore. This got already fixed correctly:

  https://lore.kernel.org/all/20260310141349432DBRJJclgnBHYWu8it0geX@zte.com.cn/

Thanks

        tglx
Re: [PATCH] irqchip/riscv-aplic: fix PM for multi-aplic system
Posted by Vladimir Kondratiev 3 weeks, 6 days ago
On 3/11/26 20:21, Thomas Gleixner wrote:
> But nothing to do here anymore. This got already fixed correctly:
> 
>   https://lore.kernel.org/all/20260310141349432DBRJJclgnBHYWu8it0geX@zte.com.cn/
>

My bad, didn't saw this thread.

Thanks, Vladimir