From: "tip-bot2 for Nick Hu" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Nick Hu <nick.hu@sifive.com>,
Thomas Gleixner <tglx@linutronix.de>,
"Yong-Xuan Wang" <yongxuan.wang@sifive.com>,
Cyan Yang <cyan.yang@sifive.com>,
Anup Patel <anup@brainfault.org>,
Nutty Liu <liujingqi@lanxincomputing.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: irq/drivers] irqchip/riscv-imsic: Add a CPU pm notifier to restore the IMSIC on exit
Date: Mon, 15 Dec 2025 21:46:57 -0000 [thread overview]
Message-ID: <176583521790.510.1665731901615507646.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20251202-preserve-aplic-imsic-v3-1-1844fbf1fe92@sifive.com>
The following commit has been merged into the irq/drivers branch of tip:
Commit-ID: f48b4bd0915bf61ac12b8c65c7939ebd03bc8abf
Gitweb: https://git.kernel.org/tip/f48b4bd0915bf61ac12b8c65c7939ebd03bc8abf
Author: Nick Hu <nick.hu@sifive.com>
AuthorDate: Tue, 02 Dec 2025 14:07:40 +08:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Mon, 15 Dec 2025 22:44:33 +01:00
irqchip/riscv-imsic: Add a CPU pm notifier to restore the IMSIC on exit
The IMSIC might be reset when the system enters a low power state, but on
exit nothing restores the registers, which prevents interrupt delivery.
Solve this by registering a CPU power management notifier, which restores
the IMSIC on exit.
Signed-off-by: Nick Hu <nick.hu@sifive.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
Reviewed-by: Cyan Yang <cyan.yang@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Reviewed-by: Nutty Liu <liujingqi@lanxincomputing.com>
Link: https://patch.msgid.link/20251202-preserve-aplic-imsic-v3-1-1844fbf1fe92@sifive.com
---
drivers/irqchip/irq-riscv-imsic-early.c | 39 +++++++++++++++++++-----
1 file changed, 31 insertions(+), 8 deletions(-)
diff --git a/drivers/irqchip/irq-riscv-imsic-early.c b/drivers/irqchip/irq-riscv-imsic-early.c
index 6bac67c..ba903fa 100644
--- a/drivers/irqchip/irq-riscv-imsic-early.c
+++ b/drivers/irqchip/irq-riscv-imsic-early.c
@@ -7,6 +7,7 @@
#define pr_fmt(fmt) "riscv-imsic: " fmt
#include <linux/acpi.h>
#include <linux/cpu.h>
+#include <linux/cpu_pm.h>
#include <linux/export.h>
#include <linux/interrupt.h>
#include <linux/init.h>
@@ -123,14 +124,8 @@ static void imsic_handle_irq(struct irq_desc *desc)
chained_irq_exit(chip, desc);
}
-static int imsic_starting_cpu(unsigned int cpu)
+static void imsic_hw_states_init(void)
{
- /* Mark per-CPU IMSIC state as online */
- imsic_state_online();
-
- /* Enable per-CPU parent interrupt */
- enable_percpu_irq(imsic_parent_irq, irq_get_trigger_type(imsic_parent_irq));
-
/* Setup IPIs */
imsic_ipi_starting_cpu();
@@ -142,6 +137,18 @@ static int imsic_starting_cpu(unsigned int cpu)
/* Enable local interrupt delivery */
imsic_local_delivery(true);
+}
+
+static int imsic_starting_cpu(unsigned int cpu)
+{
+ /* Mark per-CPU IMSIC state as online */
+ imsic_state_online();
+
+ /* Enable per-CPU parent interrupt */
+ enable_percpu_irq(imsic_parent_irq, irq_get_trigger_type(imsic_parent_irq));
+
+ /* Initialize the IMSIC registers to enable the interrupt delivery */
+ imsic_hw_states_init();
return 0;
}
@@ -157,6 +164,22 @@ static int imsic_dying_cpu(unsigned int cpu)
return 0;
}
+static int imsic_pm_notifier(struct notifier_block *self, unsigned long cmd, void *v)
+{
+ switch (cmd) {
+ case CPU_PM_EXIT:
+ /* Initialize the IMSIC registers to enable the interrupt delivery */
+ imsic_hw_states_init();
+ break;
+ }
+
+ return NOTIFY_OK;
+}
+
+static struct notifier_block imsic_pm_notifier_block = {
+ .notifier_call = imsic_pm_notifier,
+};
+
static int __init imsic_early_probe(struct fwnode_handle *fwnode)
{
struct irq_domain *domain;
@@ -194,7 +217,7 @@ static int __init imsic_early_probe(struct fwnode_handle *fwnode)
cpuhp_setup_state(CPUHP_AP_IRQ_RISCV_IMSIC_STARTING, "irqchip/riscv/imsic:starting",
imsic_starting_cpu, imsic_dying_cpu);
- return 0;
+ return cpu_pm_register_notifier(&imsic_pm_notifier_block);
}
static int __init imsic_early_dt_init(struct device_node *node, struct device_node *parent)
next prev parent reply other threads:[~2025-12-15 21:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-02 6:07 [PATCH v3 0/2] riscv-imsic/aplic: Preserve IMSIC and APLIC states during suspend Nick Hu
2025-12-02 6:07 ` [PATCH v3 1/2] irqchip/riscv-imsic: Add a CPU pm notifier to restore the IMSIC on exit Nick Hu
2025-12-15 21:46 ` tip-bot2 for Nick Hu [this message]
2025-12-02 6:07 ` [PATCH v3 2/2] irqchip/riscv-aplic: Preserve APLIC states across suspend/resume Nick Hu
2025-12-03 14:16 ` Anup Patel
2025-12-15 21:46 ` [tip: irq/drivers] " tip-bot2 for Nick Hu
2025-12-17 17:36 ` tip-bot2 for Nick Hu
2026-02-20 4:10 ` [PATCH v3 0/2] riscv-imsic/aplic: Preserve IMSIC and APLIC states during suspend patchwork-bot+linux-riscv
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=176583521790.510.1665731901615507646.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=anup@brainfault.org \
--cc=cyan.yang@sifive.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=liujingqi@lanxincomputing.com \
--cc=nick.hu@sifive.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yongxuan.wang@sifive.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®