Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Radu Rendec <radu@rendec.net>
To: Haofeng Li <920484857@qq.com>, tglx@kernel.org
Cc: linux-kernel@vger.kernel.org, Haofeng Li <13266079573@163.com>,
	Haofeng Li	 <lihaofeng@kylinos.cn>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	 Marc Zyngier <maz@kernel.org>,
	Paul Burton <paulburton@kernel.org>,
	linux-mips@vger.kernel.org
Subject: Re: [PATCH 07/16] irqchip/mips-gic: clean up IRQ domain creation failure
Date: Sun, 02 Aug 2026 15:19:21 -0400	[thread overview]
Message-ID: <b9f6cd2aa90ec2bbcf46d98695e52762d698d8b4.camel@rendec.net> (raw)
In-Reply-To: <tencent_BE6F86AC74FBD69E73A00D9B3552D1C06A06@qq.com>

On Tue, 2026-07-14 at 21:24 +0800, Haofeng Li wrote:
> From: Haofeng Li <lihaofeng@kylinos.cn>
> 
> After mapping the register base, irq_domain_create_simple() failure
> returns without unmapping it.

It does, but this driver is meant to initialize once during the (early)
kernel start-up and stay there for the rest of the kernel lifetime.
Also, this is the Global Interrupt Controller (GIC) driver. If this
fails to initialize, I very much doubt the system is usable anyway.

> The CPU chained or VEIC handler is also installed before either IRQ
> domain is ready. Unmapping the registers while that handler remains
> published would leave a path to unmapped MMIO,

... which is probably one of the reasons why the IO range was not
unmapped originally.

>  and a later IPI domain
> failure would expose a half-initialized controller.
> 
> Unmap and clear the register base when primary domain creation fails,
> and publish the CPU interrupt handler only after both domains have
> been created successfully.

Why? Please see my point above about the role of this driver. This
driver not only has a fundamental role, but also has a different
lifecycle and does not follow the cleanup paradigm of a typical driver
that can be unloaded/reloaded/re-probed.

> 
> Fixes: fbea754123ae ("irqchip: mips-gic: Inline __gic_init()")
> 
> Signed-off-by: Haofeng Li <lihaofeng@kylinos.cn>
> ---
>  drivers/irqchip/irq-mips-gic.c | 24 +++++++++++++-----------
>  1 file changed, 13 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c
> index 19a57c5e2b2e..85fe0d8a34c5 100644
> --- a/drivers/irqchip/irq-mips-gic.c
> +++ b/drivers/irqchip/irq-mips-gic.c
> @@ -956,23 +956,14 @@ static int __init gic_of_init(struct device_node *node,
>  	gic_shared_intrs = FIELD_GET(GIC_CONFIG_NUMINTERRUPTS, gicconfig);
>  	gic_shared_intrs = (gic_shared_intrs + 1) * 8;
>  
> -	if (cpu_has_veic) {
> -		/* Always use vector 1 in EIC mode */
> -		gic_cpu_pin = 0;
> -		set_vi_handler(gic_cpu_pin + GIC_PIN_TO_VEC_OFFSET,
> -			       __gic_irq_dispatch);
> -	} else {
> -		gic_cpu_pin = cpu_vec - GIC_CPU_PIN_OFFSET;
> -		irq_set_chained_handler(MIPS_CPU_IRQ_BASE + cpu_vec,
> -					gic_irq_dispatch);
> -	}
> -
>  	gic_irq_domain = irq_domain_create_simple(of_fwnode_handle(node),
>  						  GIC_NUM_LOCAL_INTRS +
>  						  gic_shared_intrs, 0,
>  						  &gic_irq_domain_ops, NULL);
>  	if (!gic_irq_domain) {
>  		pr_err("Failed to add IRQ domain");
> +		iounmap(mips_gic_base);
> +		mips_gic_base = NULL;
>  		return -ENXIO;
>  	}
>  
> @@ -980,6 +971,17 @@ static int __init gic_of_init(struct device_node *node,
>  	if (ret)
>  		return ret;
>  
> +	if (cpu_has_veic) {
> +		/* Always use vector 1 in EIC mode */
> +		gic_cpu_pin = 0;
> +		set_vi_handler(gic_cpu_pin + GIC_PIN_TO_VEC_OFFSET,
> +			       __gic_irq_dispatch);
> +	} else {
> +		gic_cpu_pin = cpu_vec - GIC_CPU_PIN_OFFSET;
> +		irq_set_chained_handler(MIPS_CPU_IRQ_BASE + cpu_vec,
> +					gic_irq_dispatch);
> +	}
> +
>  	board_bind_eic_interrupt = &gic_bind_eic_interrupt;
>  
>  	/*

  reply	other threads:[~2026-08-02 19:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260714122351.3274006-1-lihaofeng@kylinos.cn>
     [not found] ` <20260714132453.3302672-1-920484857@qq.com>
2026-07-14 13:24   ` [PATCH 05/16] irqchip/bcm7038-l1: clean up init failure paths Haofeng Li
2026-07-28 17:36     ` Florian Fainelli
2026-07-14 13:24   ` [PATCH 06/16] irqchip/loongson-liointc: unmap per-core iomaps on error Haofeng Li
2026-08-02 16:31     ` Radu Rendec
2026-07-14 13:24   ` [PATCH 07/16] irqchip/mips-gic: clean up IRQ domain creation failure Haofeng Li
2026-08-02 19:19     ` Radu Rendec [this message]
2026-07-14 13:24   ` [PATCH 08/16] irqchip/mips-gic: clean up if IPI domain registration fails Haofeng Li
2026-08-02 19:26     ` Radu Rendec
2026-07-14 13:24   ` [PATCH 09/16] irqchip/econet: clean up VEIC initialization Haofeng Li
2026-07-23  1:09     ` Caleb James DeLisle
2026-07-14 13:24   ` [PATCH 11/16] irqchip/loongson-eiointc: preserve live state on cascade failure Haofeng Li
2026-07-14 13:24   ` [PATCH 16/16] irqchip/bcm7120-l2: fix parent IRQ count error handling Haofeng Li
2026-07-28 15:57     ` Florian Fainelli

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=b9f6cd2aa90ec2bbcf46d98695e52762d698d8b4.camel@rendec.net \
    --to=radu@rendec.net \
    --cc=13266079573@163.com \
    --cc=920484857@qq.com \
    --cc=lihaofeng@kylinos.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=paulburton@kernel.org \
    --cc=tglx@kernel.org \
    --cc=tsbogend@alpha.franken.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