From: "Nutty Liu" <liujingqi@lanxincomputing.com>
To: "Nick Hu" <nick.hu@sifive.com>, <anup@brainfault.org>,
"Alexandre Ghiti" <alex@ghiti.fr>,
<linux-riscv@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Cc: "Thomas Gleixner" <tglx@linutronix.de>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>
Subject: Re: [PATCH v2 1/2] irqchip/riscv-imsic: Restore the IMSIC registers
Date: Wed, 6 Aug 2025 17:28:55 +0800 [thread overview]
Message-ID: <c1d4cc3e-c688-4610-8b15-488cde2836d1@lanxincomputing.com> (raw)
In-Reply-To: <20250806082726.8835-2-nick.hu@sifive.com>
On 8/6/2025 4:27 PM, Nick Hu wrote:
> When the system woken up from the low power state, the IMSIC might be in
> the reset state. Therefore adding the CPU PM callbacks to restore the
> IMSIC register when the cpu resume from the low power state.
>
> Signed-off-by: Nick Hu <nick.hu@sifive.com>
> Reviewed-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
> Reviewed-by: Cyan Yang <cyan.yang@sifive.com>
> Reviewed-by: Anup Patel <anup@brainfault.org>
> ---
> drivers/irqchip/irq-riscv-imsic-early.c | 40 ++++++++++++++++++++-----
> 1 file changed, 32 insertions(+), 8 deletions(-)
Reviewed-by: Nutty Liu <liujingqi@lanxincomputing.com>
Thanks,
Nutty
> diff --git a/drivers/irqchip/irq-riscv-imsic-early.c b/drivers/irqchip/irq-riscv-imsic-early.c
> index d9ae87808651..62bcbcae8bd4 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/interrupt.h>
> #include <linux/io.h>
> #include <linux/irq.h>
> @@ -109,14 +110,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_restore(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();
>
> @@ -128,6 +123,19 @@ 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));
> +
> + /* Restore the imsic reg */
> + imsic_restore();
>
> return 0;
> }
> @@ -143,6 +151,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:
> + /* Restore the imsic reg */
> + imsic_restore();
> + 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;
> @@ -180,7 +204,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)
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-08-06 9:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-06 8:27 [PATCH v2 0/2] riscv-imsic/aplic: Save and restore the registers Nick Hu
2025-08-06 8:27 ` [PATCH v2 1/2] irqchip/riscv-imsic: Restore the IMSIC registers Nick Hu
2025-08-06 9:28 ` Nutty Liu [this message]
2025-08-06 12:08 ` Thomas Gleixner
2025-08-15 2:18 ` Nick Hu
2025-08-06 8:27 ` [PATCH v2 2/2] irqchip/riscv-aplic: Save and restore APLIC registers Nick Hu
2025-08-06 9:47 ` Nutty Liu
2025-08-06 12:52 ` Thomas Gleixner
2025-08-15 7:33 ` Nick Hu
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=c1d4cc3e-c688-4610-8b15-488cde2836d1@lanxincomputing.com \
--to=liujingqi@lanxincomputing.com \
--cc=alex@ghiti.fr \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=nick.hu@sifive.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=tglx@linutronix.de \
/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