Skip to contentSkip to conversation

irqchip/ti-sci-inta: fix processing of masked irqs

PATCH Applied Grygorii Strashko 4 participants 6 messages Apr 8, 2020 – Apr 17, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 irqchip/ti-sci-inta: fix processing of masked irqs

The ti_sci_inta_irq_handler() does not take into account INTA IRQs state (masked/unmasked) as it uses INTA_STATUS_CLEAR_j register to get INTA IRQs status, which provides raw status value.
This causes hard IRQ handlers to be called or threaded handlers to be scheduled many times even if corresponding INTA IRQ is masked. Above, first of all, affects the LEVEL interrupts processing and causes unexpected behavior up the system stack or crash.

Fix it by using the Interrupt Masked Status INTA_STATUSM_j register which provides masked INTA IRQs status.

Fixes 9f1463b86c13 ("irqchip/ti-sci-inta: Add support for Interrupt Aggregator driver")
---
 drivers/irqchip/irq-ti-sci-inta.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/irqchip/irq-ti-sci-inta.c +2 -1
index 8f6e6b08eadf..7e3ebf6ed2cd 100644
@@ -37,6 +37,7 @@
 #define VINT_ENABLE_SET_OFFSET	0x0
 #define VINT_ENABLE_CLR_OFFSET	0x8
 #define VINT_STATUS_OFFSET	0x18
+#define VINT_STATUS_MASKED_OFFSET	0x20
 
 /**
  * struct ti_sci_inta_event_desc - Description of an event coming to
@@ -116,7 +117,7 @@ static void ti_sci_inta_irq_handler(struct irq_desc *desc)
 	chained_irq_enter(irq_desc_get_chip(desc), desc);
 
 	val = readq_relaxed(inta->base + vint_desc->vint_id * 0x1000 +
-			    VINT_STATUS_OFFSET);
+			    VINT_STATUS_MASKED_OFFSET);
 
 	for_each_set_bit(bit, &val, MAX_EVENTS_PER_VINT) {
 		virq = irq_find_mapping(domain, vint_desc->events[bit].hwirq);
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Grygorii Strashko

The ti_sci_inta_irq_handler() does not take into account INTA IRQs state (masked/unmasked) as it uses INTA_STATUS_CLEAR_j register to get INTA IRQs status, which provides raw status value.
This causes hard IRQ handlers to be called or threaded handlers to be scheduled many times even if corresponding INTA IRQ is masked. Above, first of all, affects the LEVEL interrupts processing and causes unexpected behavior up the system stack or crash.

Quoted 5 lines

Fix it by using the Interrupt Masked Status INTA_STATUSM_j register which provides masked INTA IRQs status.

Fixes 9f1463b86c13 ("irqchip/ti-sci-inta: Add support for Interrupt Aggregator driver")

Thanks and regards,
Lokesh

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#2 lore raw
In reply to Grygorii Strashko
Quoted 8 lines · On Wed, 8 Apr 2020 22:15:32 +0300 Grygorii Strashko <[email protected]>…

The ti_sci_inta_irq_handler() does not take into account INTA IRQs state (masked/unmasked) as it uses INTA_STATUS_CLEAR_j register to get INTA IRQs status, which provides raw status value.
This causes hard IRQ handlers to be called or threaded handlers to be scheduled many times even if corresponding INTA IRQ is masked. Above, first of all, affects the LEVEL interrupts processing and causes unexpected behavior up the system stack or crash.

Quoted 5 lines

Fix it by using the Interrupt Masked Status INTA_STATUSM_j register which provides masked INTA IRQs status.

Fixes 9f1463b86c13 ("irqchip/ti-sci-inta: Add support for Interrupt Aggregator driver")

Given the failure mode, doesn't this deserve a Cc stable?

Quoted 17 lines
---
 drivers/irqchip/irq-ti-sci-inta.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/irqchip/irq-ti-sci-inta.c +1 -0
index 8f6e6b08eadf..7e3ebf6ed2cd 100644
@@ -37,6 +37,7 @@
 #define VINT_ENABLE_SET_OFFSET	0x0
 #define VINT_ENABLE_CLR_OFFSET	0x8
 #define VINT_STATUS_OFFSET	0x18
+#define VINT_STATUS_MASKED_OFFSET	0x20
 
 /**
  * struct ti_sci_inta_event_desc - Description of an event coming to

drivers/irqchip/irq-ti-sci-inta.c static void ti_sci_inta_irq_handler(struct irq_desc *desc) · line 123

Quoted 8 lines
drivers/irqchip/irq-ti-sci-inta.c +1 -1
@@ -116,7 +117,7 @@ static void ti_sci_inta_irq_handler(struct irq_desc *desc)
 	chained_irq_enter(irq_desc_get_chip(desc), desc);
 
 	val = readq_relaxed(inta->base + vint_desc->vint_id * 0x1000 +
-			    VINT_STATUS_OFFSET);
+			    VINT_STATUS_MASKED_OFFSET);
 
 	for_each_set_bit(bit, &val, MAX_EVENTS_PER_VINT) {
 		virq = irq_find_mapping(domain, vint_desc->events[bit].hwirq);

Otherwise queued for post -rc1.

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#3 lore raw
Quoted 11 lines · Marc Zyngier
Quoted 8 lines · On Wed, 8 Apr 2020 22:15:32 +0300 Grygorii Strashko <[email protected]>…

The ti_sci_inta_irq_handler() does not take into account INTA IRQs state (masked/unmasked) as it uses INTA_STATUS_CLEAR_j register to get INTA IRQs status, which provides raw status value.
This causes hard IRQ handlers to be called or threaded handlers to be scheduled many times even if corresponding INTA IRQ is masked. Above, first of all, affects the LEVEL interrupts processing and causes unexpected behavior up the system stack or crash.

Quoted 7 lines
Quoted 5 lines

Fix it by using the Interrupt Masked Status INTA_STATUSM_j register which provides masked INTA IRQs status.

Fixes 9f1463b86c13 ("irqchip/ti-sci-inta: Add support for Interrupt Aggregator driver")

Given the failure mode, doesn't this deserve a Cc stable?

Sorry, was not sure how it works here.
"Fixes" tag now is usually enough to get included in stable. Any way, I'll track it and if not included will re-send for stable.

Quoted 24 lines
Quoted 24 lines
---
  drivers/irqchip/irq-ti-sci-inta.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/irqchip/irq-ti-sci-inta.c +2 -1
index 8f6e6b08eadf..7e3ebf6ed2cd 100644
@@ -37,6 +37,7 @@
  #define VINT_ENABLE_SET_OFFSET	0x0
  #define VINT_ENABLE_CLR_OFFSET	0x8
  #define VINT_STATUS_OFFSET	0x18
+#define VINT_STATUS_MASKED_OFFSET	0x20
 
  /**
   * struct ti_sci_inta_event_desc - Description of an event coming to
@@ -116,7 +117,7 @@ static void ti_sci_inta_irq_handler(struct irq_desc *desc)
  	chained_irq_enter(irq_desc_get_chip(desc), desc);
 
  	val = readq_relaxed(inta->base + vint_desc->vint_id * 0x1000 +
-			    VINT_STATUS_OFFSET);
+			    VINT_STATUS_MASKED_OFFSET);
 
Quoted 5 lines

drivers/irqchip/irq-ti-sci-inta.c static void ti_sci_inta_irq_handler(struct irq_desc *desc) · line 123

Quoted 2 lines
drivers/irqchip/irq-ti-sci-inta.c +0 -0
  	for_each_set_bit(bit, &val, MAX_EVENTS_PER_VINT) {
  		virq = irq_find_mapping(domain, vint_desc->events[bit].hwirq);

Otherwise queued for post -rc1.

Thanks.

Signature · 7 lines
Best regards,
grygorii

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#4 lore raw
Quoted 15 lines · On Thu, 9 Apr 2020 14:11:12 +0300 Grygorii Strashko <[email protected]>…
Quoted 14 lines · Marc Zyngier
Quoted 11 lines · On Wed, 8 Apr 2020 22:15:32 +0300 Grygorii Strashko <[email protected]>…

The ti_sci_inta_irq_handler() does not take into account INTA IRQs state (masked/unmasked) as it uses INTA_STATUS_CLEAR_j register to get INTA IRQs status, which provides raw status value.
This causes hard IRQ handlers to be called or threaded handlers to be scheduled many times even if corresponding INTA IRQ is masked. Above, first of all, affects the LEVEL interrupts processing and causes unexpected behavior up the system stack or crash.

Fix it by using the Interrupt Masked Status INTA_STATUSM_j register which provides masked INTA IRQs status.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes 9f1463b86c13 ("irqchip/ti-sci-inta: Add support for Interrupt Aggregator driver")

Given the failure mode, doesn't this deserve a Cc stable?

Sorry, was not sure how it works here.
"Fixes" tag now is usually enough to get included in stable. Any way, I'll track it and if not included will re-send for stable.

Last time I asked, Greg was adamant that a Cc: stable was needed to guarantee a backport. In some cases, the patch is picked up anyway, but it doesn't hurt to have the stable tag if you think it should be backported.

Anyway, I've now added such tag.

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#5 lore raw

[tip: irq/urgent] irqchip/ti-sci-inta: Fix processing of masked irqs

In reply to Grygorii Strashko
The following commit has been merged into the irq/urgent branch of tip:

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

Commit-ID:     3688b0db5c331f4ec3fa5eb9f670a4b04f530700
Gitweb:        https://git.kernel.org/tip/3688b0db5c331f4ec3fa5eb9f670a4b04f530700
Author:        Grygorii Strashko <[email protected]>
AuthorDate:    Wed, 08 Apr 2020 22:15:32 +03:00
Committer:     Marc Zyngier <[email protected]>
CommitterDate: Fri, 17 Apr 2020 08:59:28 +01:00

irqchip/ti-sci-inta: Fix processing of masked irqs

The ti_sci_inta_irq_handler() does not take into account INTA IRQs state (masked/unmasked) as it uses INTA_STATUS_CLEAR_j register to get INTA IRQs status, which provides raw status value.
This causes hard IRQ handlers to be called or threaded handlers to be scheduled many times even if corresponding INTA IRQ is masked. Above, first of all, affects the LEVEL interrupts processing and causes unexpected behavior up the system stack or crash.

Fix it by using the Interrupt Masked Status INTA_STATUSM_j register which provides masked INTA IRQs status.

Fixes 9f1463b86c13 ("irqchip/ti-sci-inta: Add support for Interrupt Aggregator driver")
---
 drivers/irqchip/irq-ti-sci-inta.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/irqchip/irq-ti-sci-inta.c +2 -1
index 8f6e6b0..7e3ebf6 100644
@@ -37,6 +37,7 @@
 #define VINT_ENABLE_SET_OFFSET	0x0
 #define VINT_ENABLE_CLR_OFFSET	0x8
 #define VINT_STATUS_OFFSET	0x18
+#define VINT_STATUS_MASKED_OFFSET	0x20
 
 /**
  * struct ti_sci_inta_event_desc - Description of an event coming to
@@ -116,7 +117,7 @@ static void ti_sci_inta_irq_handler(struct irq_desc *desc)
 	chained_irq_enter(irq_desc_get_chip(desc), desc);
 
 	val = readq_relaxed(inta->base + vint_desc->vint_id * 0x1000 +
-			    VINT_STATUS_OFFSET);
+			    VINT_STATUS_MASKED_OFFSET);
 
 	for_each_set_bit(bit, &val, MAX_EVENTS_PER_VINT) {
 		virq = irq_find_mapping(domain, vint_desc->events[bit].hwirq);