[PATCH v2 1/2] irqchip/riscv-aplic: Do not clear ACPI dependencies on probe failure

liu.xuemei1@zte.com.cn posted 2 patches 1 month ago
[PATCH v2 1/2] irqchip/riscv-aplic: Do not clear ACPI dependencies on probe failure
Posted by liu.xuemei1@zte.com.cn 1 month ago
From: Jessica Liu <liu.xuemei1@zte.com.cn>

The aplic_probe() function calls acpi_dev_clear_dependencies()
unconditionally at the end, even when the preceding setup (MSI or
direct mode) has failed. This is incorrect because if the device
failed to probe, it should not be considered as active and should
not clear dependencies for other devices waiting on it.

Fix this by returning immediately when the setup fails, skipping
the ACPI dependency cleanup. Also, explicitly return 0 on success
instead of relying on the value of 'rc' to make the success path
clear.

Fixes: 5122e380c23b ("irqchip/riscv-aplic: Add ACPI support")
Signed-off-by: Jessica Liu <liu.xuemei1@zte.com.cn>
---
 drivers/irqchip/irq-riscv-aplic-main.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/irqchip/irq-riscv-aplic-main.c b/drivers/irqchip/irq-riscv-aplic-main.c
index 4495ca26abf5..8775f188ea4f 100644
--- a/drivers/irqchip/irq-riscv-aplic-main.c
+++ b/drivers/irqchip/irq-riscv-aplic-main.c
@@ -372,18 +372,21 @@ static int aplic_probe(struct platform_device *pdev)
 		rc = aplic_msi_setup(dev, regs);
 	else
 		rc = aplic_direct_setup(dev, regs);
-	if (rc)
+
+	if (rc) {
 		dev_err_probe(dev, rc, "failed to setup APLIC in %s mode\n",
 			      msi_mode ? "MSI" : "direct");
-	else
-		register_syscore(&aplic_syscore);
+		return rc;
+	}
+
+	register_syscore(&aplic_syscore);

 #ifdef CONFIG_ACPI
 	if (!acpi_disabled)
 		acpi_dev_clear_dependencies(ACPI_COMPANION(dev));
 #endif

-	return rc;
+	return 0;
 }

 static const struct of_device_id aplic_match[] = {
-- 
2.27.0
[tip: irq/urgent] irqchip/riscv-aplic: Do not clear ACPI dependencies on probe failure
Posted by tip-bot2 for Jessica Liu 4 weeks, 1 day ago
The following commit has been merged into the irq/urgent branch of tip:

Commit-ID:     620b6ded72a7f0f77be6ec44d0462bb85729ab7a
Gitweb:        https://git.kernel.org/tip/620b6ded72a7f0f77be6ec44d0462bb85729ab7a
Author:        Jessica Liu <liu.xuemei1@zte.com.cn>
AuthorDate:    Tue, 10 Mar 2026 14:16:00 +08:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Tue, 10 Mar 2026 18:42:33 +01:00

irqchip/riscv-aplic: Do not clear ACPI dependencies on probe failure

aplic_probe() calls acpi_dev_clear_dependencies() unconditionally at the
end, even when the preceding setup (MSI or direct mode) has failed. This is
incorrect because if the device failed to probe, it should not be
considered as active and should not clear dependencies for other devices
waiting on it.

Fix this by returning immediately when the setup fails, skipping the ACPI
dependency cleanup. Also, explicitly return 0 on success instead of relying
on the value of 'rc' to make the success path clear.

Fixes: 5122e380c23b ("irqchip/riscv-aplic: Add ACPI support")
Signed-off-by: Jessica Liu <liu.xuemei1@zte.com.cn>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260310141600411Fu8H8-GXOOgKISU48Tjgx@zte.com.cn
---
 drivers/irqchip/irq-riscv-aplic-main.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/irqchip/irq-riscv-aplic-main.c b/drivers/irqchip/irq-riscv-aplic-main.c
index 4495ca2..8775f18 100644
--- a/drivers/irqchip/irq-riscv-aplic-main.c
+++ b/drivers/irqchip/irq-riscv-aplic-main.c
@@ -372,18 +372,21 @@ static int aplic_probe(struct platform_device *pdev)
 		rc = aplic_msi_setup(dev, regs);
 	else
 		rc = aplic_direct_setup(dev, regs);
-	if (rc)
+
+	if (rc) {
 		dev_err_probe(dev, rc, "failed to setup APLIC in %s mode\n",
 			      msi_mode ? "MSI" : "direct");
-	else
-		register_syscore(&aplic_syscore);
+		return rc;
+	}
+
+	register_syscore(&aplic_syscore);
 
 #ifdef CONFIG_ACPI
 	if (!acpi_disabled)
 		acpi_dev_clear_dependencies(ACPI_COMPANION(dev));
 #endif
 
-	return rc;
+	return 0;
 }
 
 static const struct of_device_id aplic_match[] = {