Skip to contentSkip to conversation

pipeline: irq: ack the irq when it is postponed inband irq from outside of the pipeline entry path.

PATCH In review Hongzhan Chen 1 participant 2 messages Sep 6, 2023 – Sep 7, 2023 IRQ

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pipeline: irq: ack the irq when it is postponed inband irq from outside of the pipeline entry path.

1. To avoid double ack for the interrupt that already acked in pipeline entry path, we add new flag to note such status and differentiate.
2. For postponed stacked edge irq that is handling outside of the pipeline entry path, as discussed in [1], ack the irq directly because it would never be acked in the pipeline entry path.

[1]: https://lore.kernel.org/xenomai/BY5PR11MB4276FEFA2C6D88C4B6CFFEFCF2E9A@BY5PR11MB4276.namprd11.prod.outlook.com/T/#t

kernel/irq/chip.c +10 -1
index 6aca6c036ada..7280a338bd3e 100644
@@ -863,14 +863,23 @@ void handle_edge_irq(struct irq_desc *desc)
 		chip->irq_ack(&desc->irq_data);
 		desc->istate |= IRQS_EDGE;
 		handle_oob_irq(desc);
+
+		/* For inband irq, we tag acked status
+		 * to avoid double ack
+		 */
+		if (!irq_settings_is_oob(desc))
+			desc->istate |= IRQS_ACK;
+
 		goto out_unlock;
 	}
 
 	kstat_incr_irqs_this_cpu(desc);
 
 	/* Start handling the irq */
-	if (!irqs_pipelined())
+	if (!(desc->istate & IRQS_ACK))
 		chip->irq_ack(&desc->irq_data);
+	else
+		desc->istate &= ~IRQS_ACK;
 
 	do {
 		if (unlikely(!desc->action)) {
kernel/irq/internals.h +2 -0
index a9121f6e6f1c..1b43467b5407 100644
@@ -54,6 +54,7 @@ enum {
  * IRQS_NMI			- irq line is used to deliver NMIs
  * IRQS_SYSFS			- descriptor has been added to sysfs
  * IRQS_EDGE			- irq line received an edge event
+ * IRQS_ACK			- acked irq line
  */
 enum {
 	IRQS_AUTODETECT		= 0x00000001,
@@ -68,6 +69,7 @@ enum {
 	IRQS_NMI		= 0x00002000,
 	IRQS_SYSFS		= 0x00004000,
 	IRQS_EDGE		= 0x00008000,
+	IRQS_ACK		= 0x00010000,
 };
 
 #include "debug.h"
Signature · 1 line
2.17.1
#1 lore raw
Quoted 27 lines

-----Original Message-----
From: Hongzhan Chen <[email protected]>
Sent: Wednesday, September 6, 2023 9:41 AM
To: [email protected]
Subject: [PATCH] pipeline: irq: ack the irq when it is postponed inband irq from outside of the pipeline entry path.

1. To avoid double ack for the interrupt that already acked in pipeline entry path, we add new flag to note such status and differentiate.
2. For postponed stacked edge irq that is handling outside of the pipeline entry path, as discussed in [1], ack the irq directly because it would never be acked in the pipeline entry path.

[1]:
https://lore.kernel.org/xenomai/BY5PR11MB4276FEFA2C6D88C4B6CFFEFCF2E
[email protected]/T/#t

kernel/irq/chip.c +0 -0
index 6aca6c036ada..7280a338bd3e 100644

kernel/irq/chip.c void handle_edge_irq(struct irq_desc *desc) · line 871

Quoted 9 lines
kernel/irq/chip.c +6 -0
@@ -863,14 +863,23 @@ void handle_edge_irq(struct irq_desc *desc)
 		chip->irq_ack(&desc->irq_data);
 		desc->istate |= IRQS_EDGE;
 		handle_oob_irq(desc);
+
+		/* For inband irq, we tag acked status
+		 * to avoid double ack
+		 */
+		if (!irq_settings_is_oob(desc))
+			desc->istate |= IRQS_ACK;

Please ignore this patch. need to be optimized here.

Regards

Hongzhan Chen

Quoted 38 lines
kernel/irq/chip.c +4 -1
+
 		goto out_unlock;
 	}
 
 	kstat_incr_irqs_this_cpu(desc);
 
 	/* Start handling the irq */
-	if (!irqs_pipelined())
+	if (!(desc->istate & IRQS_ACK))
 		chip->irq_ack(&desc->irq_data);
+	else
+		desc->istate &= ~IRQS_ACK;
 
 	do {
 		if (unlikely(!desc->action)) {
kernel/irq/internals.h +2 -1
index a9121f6e6f1c..1b43467b5407 100644
@@ -54,6 +54,7 @@ enum {
 * IRQS_NMI			- irq line is used to deliver NMIs
 * IRQS_SYSFS			- descriptor has been added to sysfs
 * IRQS_EDGE			- irq line received an edge event
+ * IRQS_ACK			- acked irq line
 */
 enum {
 	IRQS_AUTODETECT		= 0x00000001,
@@ -68,6 +69,7 @@ enum {
 	IRQS_NMI		= 0x00002000,
 	IRQS_SYSFS		= 0x00004000,
 	IRQS_EDGE		= 0x00008000,
+	IRQS_ACK		= 0x00010000,
 };
 
 #include "debug.h"
--

2.17.1