Skip to contentSkip to conversation

irqchip/gic-v5: Holdover fixes

PATCH RESEND Applied Lorenzo Pieralisi 2 participants 7 messages Sep 8, 2025 – Sep 9, 2025

Subsystems (3)
lore
Share & tools
lore

Lorenzo Pieralisi

author maintainer
#0 lore raw

v2 cover irqchip/gic-v5: Holdover fixes

Hi Thomas,

I am just resending fixes posted by Dan in [1] before the v6.17 merge window started and GICv5 code was queued for -next to make sure they did not get lost in the process.

I tested them by forcing the relevant error paths to happen (patches (2)-(3), for patch (1) there is nothing to test).

Please apply them whenever you deem that suitable, thank you.

[1] https://lore.kernel.org/lkml/[email protected]/

Cc Dan Carpenter <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Zenghui Yu <[email protected]>
Cc Marc Zyngier <[email protected]>

Dan Carpenter (3):
irqchip/gic-v5: Delete a stray tab
irqchip/gic-v5: Fix loop in gicv5_its_create_itt_two_level() cleanup
path
irqchip/gic-v5: Fix error handling in gicv5_its_irq_domain_alloc()

 drivers/irqchip/irq-gic-v5-irs.c |  2 +-
 drivers/irqchip/irq-gic-v5-its.c | 24 ++++++++++++++++--------
 2 files changed, 17 insertions(+), 9 deletions(-)
Signature · 1 line
2.48.0
author maintainer
#1 lore raw

PATCH RESEND v2 1/3 irqchip/gic-v5: Delete a stray tab

From: Dan Carpenter <[email protected]>

Delete a stray tab that is indenting the code erroneously.

[lpieralisi: reworded log message]

---
 drivers/irqchip/irq-gic-v5-irs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-v5-irs.c +1 -1
index 13c035727e32..ce2732d649a3 100644
@@ -571,7 +571,7 @@ static void __init gicv5_irs_init_bases(struct gicv5_irs_chip_data *irs_data,
 			FIELD_PREP(GICV5_IRS_CR1_IST_RA, GICV5_NO_READ_ALLOC)	|
 			FIELD_PREP(GICV5_IRS_CR1_IC, GICV5_NON_CACHE)		|
 			FIELD_PREP(GICV5_IRS_CR1_OC, GICV5_NON_CACHE);
-			irs_data->flags |= IRS_FLAGS_NON_COHERENT;
+		irs_data->flags |= IRS_FLAGS_NON_COHERENT;
 	} else {
 		cr1 = FIELD_PREP(GICV5_IRS_CR1_VPED_WA, GICV5_WRITE_ALLOC)	|
 			FIELD_PREP(GICV5_IRS_CR1_VPED_RA, GICV5_READ_ALLOC)	|
Signature · 1 line
2.48.0
merge bot Applied
#2 lore raw

[tip: irq/drivers] irqchip/gic-v5: Delete a stray tab

The following commit has been merged into the irq/drivers branch of tip:

The following commit has been merged into the irq/drivers branch of tip:

Commit-ID:     5a5c48e870ed8d8aa9349be625c72f57bde45a4f
Gitweb:        https://git.kernel.org/tip/5a5c48e870ed8d8aa9349be625c72f57bde45a4f
Author:        Dan Carpenter <[email protected]>
AuthorDate:    Mon, 08 Sep 2025 10:27:43 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Tue, 09 Sep 2025 11:51:08 +02:00

irqchip/gic-v5: Delete a stray tab

Delete a stray tab that is indenting the code erroneously.

[ lpieralisi: Reworded commit message]

---
 drivers/irqchip/irq-gic-v5-irs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-v5-irs.c +1 -1
index f845415..ad1435a 100644
@@ -568,7 +568,7 @@ static void __init gicv5_irs_init_bases(struct gicv5_irs_chip_data *irs_data,
 			FIELD_PREP(GICV5_IRS_CR1_IST_RA, GICV5_NO_READ_ALLOC)	|
 			FIELD_PREP(GICV5_IRS_CR1_IC, GICV5_NON_CACHE)		|
 			FIELD_PREP(GICV5_IRS_CR1_OC, GICV5_NON_CACHE);
-			irs_data->flags |= IRS_FLAGS_NON_COHERENT;
+		irs_data->flags |= IRS_FLAGS_NON_COHERENT;
 	} else {
 		cr1 = FIELD_PREP(GICV5_IRS_CR1_VPED_WA, GICV5_WRITE_ALLOC)	|
 			FIELD_PREP(GICV5_IRS_CR1_VPED_RA, GICV5_READ_ALLOC)	|
author maintainer
#3 lore raw

PATCH RESEND v2 2/3 irqchip/gic-v5: Fix loop in gicv5_its_create_itt_two_level() cleanup path

In reply to Lorenzo Pieralisi

From: Dan Carpenter <[email protected]>

The "i" variable in gicv5_its_create_itt_two_level() needs to be signed otherwise it would cause a forever loop in the function cleanup path.

[lpieralisi: reworded commit log]

Fixes 57d72196dfc8 ("irqchip/gic-v5: Add GICv5 ITS support")
Cc Thomas Gleixner <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 drivers/irqchip/irq-gic-v5-its.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/irqchip/irq-gic-v5-its.c +2 -2
index 9290ac741949..4701ef62b8b2 100644
@@ -191,9 +191,9 @@ static int gicv5_its_create_itt_two_level(struct gicv5_its_chip_data *its,
 					  unsigned int num_events)
 {
 	unsigned int l1_bits, l2_bits, span, events_per_l2_table;
-	unsigned int i, complete_tables, final_span, num_ents;
+	unsigned int complete_tables, final_span, num_ents;
 	__le64 *itt_l1, *itt_l2, **l2ptrs;
-	int ret;
+	int i, ret;
 	u64 val;
 
 	ret = gicv5_its_l2sz_to_l2_bits(itt_l2sz);
Signature · 1 line
2.48.0
merge bot Applied
#4 lore raw

[tip: irq/drivers] irqchip/gic-v5: Fix loop in gicv5_its_create_itt_two_level() cleanup path

The following commit has been merged into the irq/drivers branch of tip:

The following commit has been merged into the irq/drivers branch of tip:

Commit-ID:     bfcd1fdaae92faa8cae880eb4c3aaaa60c54bf0d
Gitweb:        https://git.kernel.org/tip/bfcd1fdaae92faa8cae880eb4c3aaaa60c54bf0d
Author:        Dan Carpenter <[email protected]>
AuthorDate:    Mon, 08 Sep 2025 10:27:44 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Tue, 09 Sep 2025 11:51:09 +02:00

irqchip/gic-v5: Fix loop in gicv5_its_create_itt_two_level() cleanup path

The "i" variable in gicv5_its_create_itt_two_level() needs to be signed otherwise it can cause a forever loop in the function's cleanup path.

[ lpieralisi: Reworded commit message ]

---
 drivers/irqchip/irq-gic-v5-its.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/irqchip/irq-gic-v5-its.c +2 -2
index 81d813c..dcdf8bc 100644
@@ -191,9 +191,9 @@ static int gicv5_its_create_itt_two_level(struct gicv5_its_chip_data *its,
 					  unsigned int num_events)
 {
 	unsigned int l1_bits, l2_bits, span, events_per_l2_table;
-	unsigned int i, complete_tables, final_span, num_ents;
+	unsigned int complete_tables, final_span, num_ents;
 	__le64 *itt_l1, *itt_l2, **l2ptrs;
-	int ret;
+	int i, ret;
 	u64 val;
 
 	ret = gicv5_its_l2sz_to_l2_bits(itt_l2sz);
author maintainer
#5 lore raw

PATCH RESEND v2 3/3 irqchip/gic-v5: Fix error handling in gicv5_its_irq_domain_alloc()

In reply to Lorenzo Pieralisi

From: Dan Carpenter <[email protected]>

Code in gicv5_its_irq_domain_alloc() has two issues:

- it checks the wrong return value/variable when calling gicv5_alloc_lpi()
- The cleanup code does not take previous loop iterations into account

Fix both issues at once by adding the right gicv5_alloc_lpi() variable check and by reworking the function cleanup code to take into account current and previous iterations.

[lpieralisi: reworded commit log]

Fixes 57d72196dfc8 ("irqchip/gic-v5: Add GICv5 ITS support")
Cc Thomas Gleixner <[email protected]>
Cc Marc Zyngier <[email protected]>
---
 drivers/irqchip/irq-gic-v5-its.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/irqchip/irq-gic-v5-its.c +14 -6
index 4701ef62b8b2..2fb58d76f521 100644
@@ -949,15 +949,18 @@ static int gicv5_its_irq_domain_alloc(struct irq_domain *domain, unsigned int vi
 	device_id = its_dev->device_id;
 
 	for (i = 0; i < nr_irqs; i++) {
-		lpi = gicv5_alloc_lpi();
+		ret = gicv5_alloc_lpi();
 		if (ret < 0) {
 			pr_debug("Failed to find free LPI!\n");
-			goto out_eventid;
+			goto out_free_irqs;
 		}
+		lpi = ret;
 
 		ret = irq_domain_alloc_irqs_parent(domain, virq + i, 1, &lpi);
-		if (ret)
-			goto out_free_lpi;
+		if (ret) {
+			gicv5_free_lpi(lpi);
+			goto out_free_irqs;
+		}
 
 		/*
 		 * Store eventid and deviceid into the hwirq for later use.
@@ -977,8 +980,13 @@ static int gicv5_its_irq_domain_alloc(struct irq_domain *domain, unsigned int vi
 
 	return 0;
 
-out_free_lpi:
-	gicv5_free_lpi(lpi);
+out_free_irqs:
+	while (--i >= 0) {
+		irqd = irq_domain_get_irq_data(domain, virq + i);
+		gicv5_free_lpi(irqd->parent_data->hwirq);
+		irq_domain_reset_irq_data(irqd);
+		irq_domain_free_irqs_parent(domain, virq + i, 1);
+	}
 out_eventid:
 	gicv5_its_free_eventid(its_dev, event_id_base, nr_irqs);
 	return ret;
Signature · 1 line
2.48.0
merge bot Applied
#6 lore raw

[tip: irq/drivers] irqchip/gic-v5: Fix error handling in gicv5_its_irq_domain_alloc()

The following commit has been merged into the irq/drivers branch of tip:

The following commit has been merged into the irq/drivers branch of tip:

Commit-ID:     a186120c780e21e4cfd186a925e34f718e30de88
Gitweb:        https://git.kernel.org/tip/a186120c780e21e4cfd186a925e34f718e30de88
Author:        Dan Carpenter <[email protected]>
AuthorDate:    Mon, 08 Sep 2025 10:27:45 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Tue, 09 Sep 2025 11:51:09 +02:00

irqchip/gic-v5: Fix error handling in gicv5_its_irq_domain_alloc()

Code in gicv5_its_irq_domain_alloc() has two issues:

- it checks the wrong return value/variable when calling gicv5_alloc_lpi()

- The cleanup code does not take previous loop iterations into account

Fix both issues at once by adding the right gicv5_alloc_lpi() variable check and by reworking the function cleanup code to take into account current and previous iterations.

[ lpieralisi: Reworded commit message ]

---
 drivers/irqchip/irq-gic-v5-its.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/irqchip/irq-gic-v5-its.c +14 -6
index dcdf8bc..554485f 100644
@@ -947,15 +947,18 @@ static int gicv5_its_irq_domain_alloc(struct irq_domain *domain, unsigned int vi
 	device_id = its_dev->device_id;
 
 	for (i = 0; i < nr_irqs; i++) {
-		lpi = gicv5_alloc_lpi();
+		ret = gicv5_alloc_lpi();
 		if (ret < 0) {
 			pr_debug("Failed to find free LPI!\n");
-			goto out_eventid;
+			goto out_free_irqs;
 		}
+		lpi = ret;
 
 		ret = irq_domain_alloc_irqs_parent(domain, virq + i, 1, &lpi);
-		if (ret)
-			goto out_free_lpi;
+		if (ret) {
+			gicv5_free_lpi(lpi);
+			goto out_free_irqs;
+		}
 
 		/*
 		 * Store eventid and deviceid into the hwirq for later use.
@@ -975,8 +978,13 @@ static int gicv5_its_irq_domain_alloc(struct irq_domain *domain, unsigned int vi
 
 	return 0;
 
-out_free_lpi:
-	gicv5_free_lpi(lpi);
+out_free_irqs:
+	while (--i >= 0) {
+		irqd = irq_domain_get_irq_data(domain, virq + i);
+		gicv5_free_lpi(irqd->parent_data->hwirq);
+		irq_domain_reset_irq_data(irqd);
+		irq_domain_free_irqs_parent(domain, virq + i, 1);
+	}
 out_eventid:
 	gicv5_its_free_eventid(its_dev, event_id_base, nr_irqs);
 	return ret;