drivers/irqchip/irq-gic-v5.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
set_handle_irq() cannot be undone: once a handler is installed, any
further call returns -EBUSY, so the set_handle_irq(NULL) in the error
path has never worked. Drop it, and install the root handler only
after gicv5_irs_enable() has succeeded.
set_handle_irq() only fails if another root handler is already
installed, which cannot happen on a GICv5 system. Should it ever
fail, the system is unusable: panic instead of unwinding.
Link: https://lore.kernel.org/r/87fqzrmywu.wl-maz@kernel.org
Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
---
drivers/irqchip/irq-gic-v5.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/irqchip/irq-gic-v5.c b/drivers/irqchip/irq-gic-v5.c
index ac2d423b1723..c365f8150300 100644
--- a/drivers/irqchip/irq-gic-v5.c
+++ b/drivers/irqchip/irq-gic-v5.c
@@ -1166,21 +1166,18 @@ static int __init gicv5_init_common(struct fwnode_handle *parent_domain)
if (ret)
goto out_int;
- ret = set_handle_irq(gicv5_handle_irq);
+ ret = gicv5_irs_enable();
if (ret)
goto out_int;
- ret = gicv5_irs_enable();
- if (ret)
- goto out_handle;
+ if (set_handle_irq(gicv5_handle_irq))
+ panic("GICv5: unable to install root IRQ handler\n");
gicv5_smp_init();
gicv5_irs_its_probe();
return 0;
-out_handle:
- set_handle_irq(NULL);
out_int:
gicv5_cpu_disable_interrupts();
gicv5_free_domains();
--
2.25.1
On Thu, 03 Sep 2026 11:40:14 +0100, Jiangshan Yi <yijiangshan@kylinos.cn> wrote: > > set_handle_irq() cannot be undone: once a handler is installed, any > further call returns -EBUSY, so the set_handle_irq(NULL) in the error > path has never worked. Drop it, and install the root handler only > after gicv5_irs_enable() has succeeded. > > set_handle_irq() only fails if another root handler is already > installed, which cannot happen on a GICv5 system. Should it ever > fail, the system is unusable: panic instead of unwinding. Note that the system is dead either way, as it isn't like someone is going to provide a replacement interrupt controller when GICv5 fails. So any error in this function is pretty fatal for the whole system. That said, this is still a reasonable cleanup. > > Link: https://lore.kernel.org/r/87fqzrmywu.wl-maz@kernel.org > Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn> Reviewed-by: Marc Zyngier <maz@kernel.org> M. -- Without deviation from the norm, progress is not possible.
On Thu, Sep 03, 2026 at 06:40:14PM +0800, Jiangshan Yi wrote:
> set_handle_irq() cannot be undone: once a handler is installed, any
> further call returns -EBUSY, so the set_handle_irq(NULL) in the error
> path has never worked. Drop it, and install the root handler only
> after gicv5_irs_enable() has succeeded.
Thank you.
Yes, that's what I should have done instead of trying to undo a fatal error.
> set_handle_irq() only fails if another root handler is already
> installed, which cannot happen on a GICv5 system. Should it ever
Nit: define "cannot happen". It should not happen.
> fail, the system is unusable: panic instead of unwinding.
Yes that's what needs to be done instead of trying to fix things up that are
clearly fatal.
Apologies for this churn.
> Link: https://lore.kernel.org/r/87fqzrmywu.wl-maz@kernel.org
> Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
> ---
> drivers/irqchip/irq-gic-v5.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
Reviewed-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
> diff --git a/drivers/irqchip/irq-gic-v5.c b/drivers/irqchip/irq-gic-v5.c
> index ac2d423b1723..c365f8150300 100644
> --- a/drivers/irqchip/irq-gic-v5.c
> +++ b/drivers/irqchip/irq-gic-v5.c
> @@ -1166,21 +1166,18 @@ static int __init gicv5_init_common(struct fwnode_handle *parent_domain)
> if (ret)
> goto out_int;
>
> - ret = set_handle_irq(gicv5_handle_irq);
> + ret = gicv5_irs_enable();
> if (ret)
> goto out_int;
>
> - ret = gicv5_irs_enable();
> - if (ret)
> - goto out_handle;
> + if (set_handle_irq(gicv5_handle_irq))
> + panic("GICv5: unable to install root IRQ handler\n");
>
> gicv5_smp_init();
>
> gicv5_irs_its_probe();
> return 0;
>
> -out_handle:
> - set_handle_irq(NULL);
> out_int:
> gicv5_cpu_disable_interrupts();
> gicv5_free_domains();
> --
> 2.25.1
>
The following commit has been merged into the irq/drivers branch of tip:
Commit-ID: 94713d60707bfe26c7cbc941abe26d1855448435
Gitweb: https://git.kernel.org/tip/94713d60707bfe26c7cbc941abe26d1855448435
Author: Jiangshan Yi <yijiangshan@kylinos.cn>
AuthorDate: Thu, 03 Sep 2026 18:40:14 +08:00
Committer: Thomas Gleixner <tglx@kernel.org>
CommitterDate: Fri, 04 Sep 2026 15:35:57 +02:00
irqchip/gic-v5: Install root IRQ handler last in gicv5_init_common()
set_handle_irq() cannot be undone: once a handler is installed, any
further call returns -EBUSY, so the set_handle_irq(NULL) in the error
path has never worked. Drop it, and install the root handler only
after gicv5_irs_enable() has succeeded.
set_handle_irq() only fails if another root handler is already
installed, which cannot happen on a GICv5 system. Should it ever
fail, the system is unusable: panic instead of unwinding.
Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Reviewed-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/87fqzrmywu.wl-maz@kernel.org
Link: https://patch.msgid.link/20260903104014.587068-1-yijiangshan@kylinos.cn
---
drivers/irqchip/irq-gic-v5.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/irqchip/irq-gic-v5.c b/drivers/irqchip/irq-gic-v5.c
index ac2d423..c365f81 100644
--- a/drivers/irqchip/irq-gic-v5.c
+++ b/drivers/irqchip/irq-gic-v5.c
@@ -1166,21 +1166,18 @@ static int __init gicv5_init_common(struct fwnode_handle *parent_domain)
if (ret)
goto out_int;
- ret = set_handle_irq(gicv5_handle_irq);
+ ret = gicv5_irs_enable();
if (ret)
goto out_int;
- ret = gicv5_irs_enable();
- if (ret)
- goto out_handle;
+ if (set_handle_irq(gicv5_handle_irq))
+ panic("GICv5: unable to install root IRQ handler\n");
gicv5_smp_init();
gicv5_irs_its_probe();
return 0;
-out_handle:
- set_handle_irq(NULL);
out_int:
gicv5_cpu_disable_interrupts();
gicv5_free_domains();
© 2016 - 2026 Red Hat, Inc.