public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@kernel.org>
To: liu.xuemei1@zte.com.cn, anup@brainfault.org, pjw@kernel.org,
	palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr,
	liujingqi@lanxincomputing.com, cyan.yang@sifive.com,
	nick.hu@sifive.com, yongxuan.wang@sifive.com
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] irqchip/riscv-aplic: Register syscore operations only once
Date: Mon, 09 Mar 2026 10:17:04 +0100	[thread overview]
Message-ID: <87ms0hs6pb.ffs@tglx> (raw)
In-Reply-To: <20260309161140133ZhM76Wt3uPliHU5_R8O0j@zte.com.cn>

On Mon, Mar 09 2026 at 16:11, liu wrote:
> From: Jessica Liu <liu.xuemei1@zte.com.cn>
>
> We can have multiple APLIC instances so setup global state

s/We/A system/

Also which global state are you referring to? 

> and resgister syscore operations only once.

register

You also fail to describe what the problem is caused by registering the
syscore ops more than once. 

> Fixes: 95a8ddde3660 ("irqchip/riscv-aplic: Preserve APLIC states across suspend/resume")
> Signed-off-by: Jessica Liu <liu.xuemei1@zte.com.cn>
> ---
>  drivers/irqchip/irq-riscv-aplic-main.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/irqchip/irq-riscv-aplic-main.c b/drivers/irqchip/irq-riscv-aplic-main.c
> index 4495ca26abf5..8299e0da6577 100644
> --- a/drivers/irqchip/irq-riscv-aplic-main.c
> +++ b/drivers/irqchip/irq-riscv-aplic-main.c
> @@ -20,6 +20,7 @@
>  #include "irq-riscv-aplic-main.h"
>
>  static LIST_HEAD(aplics);
> +static bool aplic_global_setup_done __ro_after_init;

Again. That global state reference is confusing at best.

>  static void aplic_restore_states(struct aplic_priv *priv)
>  {
> @@ -375,8 +376,10 @@ 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
> +	else if (!aplic_global_setup_done) {
>  		register_syscore(&aplic_syscore);
> +		aplic_global_setup_done = true;
> +	}

Aside of violating the bracket rules, this code is broken already in a
very subtle way:

If the probe fails then it should not invoke
acpi_dev_clear_dependencies() either.

Something like the below makes it entirely clear what this is about.

The fix for the probe fail vs. acpi dependencies obviously wants to be
split out into a separate patch.

Thanks,

        tglx
---
--- a/drivers/irqchip/irq-riscv-aplic-main.c
+++ b/drivers/irqchip/irq-riscv-aplic-main.c
@@ -116,6 +116,16 @@ static struct syscore aplic_syscore = {
 	.ops = &aplic_syscore_ops,
 };
 
+static bool aplic_syscore_registered __ro_after_init;
+
+static void aplic_syscore_init(void);
+{
+	if (!aplic_syscore_registered) {
+		register_syscore(&aplic_syscore);
+		aplic_syscore_registered = true;
+	}
+}
+
 static int aplic_pm_notifier(struct notifier_block *nb, unsigned long action, void *data)
 {
 	struct aplic_priv *priv = container_of(nb, struct aplic_priv, genpd_nb);
@@ -372,18 +382,20 @@ static int aplic_probe(struct platform_d
 		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;
+	}
+
+	aplic_syscore_register();
 
 #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[] = {


      reply	other threads:[~2026-03-09  9:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-09  8:11 [PATCH] irqchip/riscv-aplic: Register syscore operations only once liu.xuemei1
2026-03-09  9:17 ` Thomas Gleixner [this message]

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=87ms0hs6pb.ffs@tglx \
    --to=tglx@kernel.org \
    --cc=alex@ghiti.fr \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=cyan.yang@sifive.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=liu.xuemei1@zte.com.cn \
    --cc=liujingqi@lanxincomputing.com \
    --cc=nick.hu@sifive.com \
    --cc=palmer@dabbelt.com \
    --cc=pjw@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