Skip to contentSkip to conversation

irq: Add untracked irq handler

PATCH In review Keith Busch 3 participants 5 messages Jun 17, 2016 – Jun 18, 2016

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

PATCH 1/2 irq: Add untracked irq handler

This adds a software irq handler for controllers that multiplex interrupts from multiple devices, but don't know which device generated the interrupt. For these devices, the irq handler that demuxes must check every action for every software irq using the same h/w irq in order to find out which device generated the interrupt. This will inevitably trigger spurious interrupt detection if we are noting the irq.

The new irq handler does not track the handling for spurious interrupt detection. An irq that uses this also won't get stats tracked since it didn't generate the interrupt, nor added to randomness since they are not random.

---
 include/linux/irq.h    |  1 +
 kernel/irq/chip.c      | 43 +++++++++++++++++++++++++++++++++++++++++++
 kernel/irq/handle.c    | 18 ++++++++++++++----
 kernel/irq/internals.h |  1 +
 4 files changed, 59 insertions(+), 4 deletions(-)
include/linux/irq.h +1 -0
index 4d758a7..cd7b94e 100644
@@ -482,6 +482,7 @@ extern void handle_fasteoi_irq(struct irq_desc *desc);
 extern void handle_edge_irq(struct irq_desc *desc);
 extern void handle_edge_eoi_irq(struct irq_desc *desc);
 extern void handle_simple_irq(struct irq_desc *desc);
+extern void handle_untracked_irq(struct irq_desc *desc);
 extern void handle_percpu_irq(struct irq_desc *desc);
 extern void handle_percpu_devid_irq(struct irq_desc *desc);
 extern void handle_bad_irq(struct irq_desc *desc);
kernel/irq/chip.c +43 -0

49 lines not on this page · raw message

kernel/irq/handle.c +14 -4
index a15b548..d3f2490 100644
@@ -132,10 +132,10 @@ void __irq_wake_thread(struct irq_desc *desc, struct irqaction *action)
 	wake_up_process(action->thread);
 }
 
-irqreturn_t handle_irq_event_percpu(struct irq_desc *desc)
+irqreturn_t __handle_irq_event_percpu(struct irq_desc *desc, unsigned int *flags)
 {
 	irqreturn_t retval = IRQ_NONE;
-	unsigned int flags = 0, irq = desc->irq_data.irq;
+	unsigned int irq = desc->irq_data.irq;
 	struct irqaction *action;
 
 	for_each_action_of_desc(desc, action) {
@@ -164,7 +164,7 @@ irqreturn_t handle_irq_event_percpu(struct irq_desc *desc)
 
 			/* Fall through to add to randomness */
 		case IRQ_HANDLED:
-			flags |= action->flags;
+			*flags |= action->flags;
 			break;
 
 		default:
@@ -174,7 +174,17 @@ irqreturn_t handle_irq_event_percpu(struct irq_desc *desc)
 		retval |= res;
 	}
 
-	add_interrupt_randomness(irq, flags);
+	return retval;
+}
+
+irqreturn_t handle_irq_event_percpu(struct irq_desc *desc)
+{
+	irqreturn_t retval;
+	unsigned int flags = 0;
+
+	retval = __handle_irq_event_percpu(desc, &flags);
+
+	add_interrupt_randomness(desc->irq_data.irq, flags);
 
 	if (!noirqdebug)
 		note_interrupt(desc, retval);
kernel/irq/internals.h +1 -0
index 09be2c9..d788150 100644
@@ -83,6 +83,7 @@ extern void irq_mark_irq(unsigned int irq);
 
 extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr);
 
+irqreturn_t __handle_irq_event_percpu(struct irq_desc *desc, unsigned int *flags);
 irqreturn_t handle_irq_event_percpu(struct irq_desc *desc);
 irqreturn_t handle_irq_event(struct irq_desc *desc);
 
Signature · 1 line
2.7.2
#1 lore raw

PATCH 2/2 vmd: use untracked irq handler

There is no way to know which device in a VMD tiggered an interrupt without invoking every registered driver's actions. This uses the untracked irq handler so that a less used device does not trigger spurious interrupt.

We have been previously recommending users enable "noirqdebug", but do not want to force a system setting just to keep this domain functional.

---
 arch/x86/pci/vmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/pci/vmd.c +1 -1
index 7792aba..613cac7 100644
@@ -195,7 +195,7 @@ static int vmd_msi_init(struct irq_domain *domain, struct msi_domain_info *info,
 	vmdirq->virq = virq;
 
 	irq_domain_set_info(domain, virq, vmdirq->irq->vmd_vector, info->chip,
-			    vmdirq, handle_simple_irq, vmd, NULL);
+			    vmdirq, handle_untracked_irq, vmd, NULL);
 	return 0;
 }
 
Signature · 1 line
2.7.2
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] vmd: use untracked irq handler

Quoted 1 line · Keith Busch

There is no way to know which device in a VMD tiggered an interrupt

s/tiggered/triggered/

Quoted 6 lines

without invoking every registered driver's actions. This uses the untracked irq handler so that a less used device does not trigger spurious interrupt.

We have been previously recommending users enable "noirqdebug", but do not want to force a system setting just to keep this domain functional.

I applaud that goal.

Quoted 1 line

Since this depends on the previous patch and I'm not qualified to review that one, I'll ack this and somebody else can merge both or none:

Quoted 20 lines
---
 arch/x86/pci/vmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/pci/vmd.c +1 -1
index 7792aba..613cac7 100644
@@ -195,7 +195,7 @@ static int vmd_msi_init(struct irq_domain *domain, struct msi_domain_info *info,
 	vmdirq->virq = virq;
 
 	irq_domain_set_info(domain, virq, vmdirq->irq->vmd_vector, info->chip,
-			    vmdirq, handle_simple_irq, vmd, NULL);
+			    vmdirq, handle_untracked_irq, vmd, NULL);
 	return 0;
 }
 
Signature · 1 line
2.7.2
#3 lore raw

[tip:irq/core] x86/PCI/VMD: Use untracked irq handler

In reply to Keith Busch
x86/PCI/VMD: Use untracked irq handler
Commit-ID:  30ce0350381351646ef86b64e6d3840b3869833b
Gitweb:     http://git.kernel.org/tip/30ce0350381351646ef86b64e6d3840b3869833b
Author:     Keith Busch <[email protected]>
AuthorDate: Fri, 17 Jun 2016 16:00:21 -0600
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Sat, 18 Jun 2016 10:00:55 +0200

x86/PCI/VMD: Use untracked irq handler

There is no way to know which device in a VMD triggered an interrupt without invoking every registered driver's actions. This uses the untracked irq handler so that a less used device does not trigger spurious interrupt.

We have been previously recommending users to enable "noirqdebug", but do not want to force a system setting just to keep this domain functional.

---
 arch/x86/pci/vmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/pci/vmd.c +1 -1
index 7792aba..613cac7 100644
@@ -195,7 +195,7 @@ static int vmd_msi_init(struct irq_domain *domain, struct msi_domain_info *info,
 	vmdirq->virq = virq;
 
 	irq_domain_set_info(domain, virq, vmdirq->irq->vmd_vector, info->chip,
-			    vmdirq, handle_simple_irq, vmd, NULL);
+			    vmdirq, handle_untracked_irq, vmd, NULL);
 	return 0;
 }
 
#4 lore raw

[tip:irq/core] genirq: Add untracked irq handler

In reply to Keith Busch
genirq: Add untracked irq handler
Commit-ID:  edd14cfebc4404698544d407ecf8eda6e19aa19e
Gitweb:     http://git.kernel.org/tip/edd14cfebc4404698544d407ecf8eda6e19aa19e
Author:     Keith Busch <[email protected]>
AuthorDate: Fri, 17 Jun 2016 16:00:20 -0600
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Sat, 18 Jun 2016 10:00:55 +0200

genirq: Add untracked irq handler

This adds a software irq handler for controllers that multiplex interrupts from multiple devices, but don't know which device generated the interrupt. For these devices, the irq handler that demuxes must check every action for every software irq using the same h/w irq in order to find out which device generated the interrupt. This will inevitably trigger spurious interrupt detection if we are noting the irq.

The new irq handler does not track the handling for spurious interrupt detection. An irq that uses this also won't get stats tracked since it didn't generate the interrupt, nor added to randomness since they are not random.

---
 include/linux/irq.h    |  1 +
 kernel/irq/chip.c      | 43 +++++++++++++++++++++++++++++++++++++++++++
 kernel/irq/handle.c    | 18 ++++++++++++++----
 kernel/irq/internals.h |  1 +
 4 files changed, 59 insertions(+), 4 deletions(-)
include/linux/irq.h +1 -0
index 6c92a84..562cef0 100644
@@ -484,6 +484,7 @@ extern void handle_fasteoi_irq(struct irq_desc *desc);
 extern void handle_edge_irq(struct irq_desc *desc);
 extern void handle_edge_eoi_irq(struct irq_desc *desc);
 extern void handle_simple_irq(struct irq_desc *desc);
+extern void handle_untracked_irq(struct irq_desc *desc);
 extern void handle_percpu_irq(struct irq_desc *desc);
 extern void handle_percpu_devid_irq(struct irq_desc *desc);
 extern void handle_bad_irq(struct irq_desc *desc);
kernel/irq/chip.c +43 -0

49 lines not on this page · raw message

kernel/irq/handle.c +14 -4
index a15b548..d3f2490 100644
@@ -132,10 +132,10 @@ void __irq_wake_thread(struct irq_desc *desc, struct irqaction *action)
 	wake_up_process(action->thread);
 }
 
-irqreturn_t handle_irq_event_percpu(struct irq_desc *desc)
+irqreturn_t __handle_irq_event_percpu(struct irq_desc *desc, unsigned int *flags)
 {
 	irqreturn_t retval = IRQ_NONE;
-	unsigned int flags = 0, irq = desc->irq_data.irq;
+	unsigned int irq = desc->irq_data.irq;
 	struct irqaction *action;
 
 	for_each_action_of_desc(desc, action) {
@@ -164,7 +164,7 @@ irqreturn_t handle_irq_event_percpu(struct irq_desc *desc)
 
 			/* Fall through to add to randomness */
 		case IRQ_HANDLED:
-			flags |= action->flags;
+			*flags |= action->flags;
 			break;
 
 		default:
@@ -174,7 +174,17 @@ irqreturn_t handle_irq_event_percpu(struct irq_desc *desc)
 		retval |= res;
 	}
 
-	add_interrupt_randomness(irq, flags);
+	return retval;
+}
+
+irqreturn_t handle_irq_event_percpu(struct irq_desc *desc)
+{
+	irqreturn_t retval;
+	unsigned int flags = 0;
+
+	retval = __handle_irq_event_percpu(desc, &flags);
+
+	add_interrupt_randomness(desc->irq_data.irq, flags);
 
 	if (!noirqdebug)
 		note_interrupt(desc, retval);
kernel/irq/internals.h +1 -0
index d5edcdc..0c6f35b 100644
@@ -84,6 +84,7 @@ extern void irq_mark_irq(unsigned int irq);
 
 extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr);
 
+irqreturn_t __handle_irq_event_percpu(struct irq_desc *desc, unsigned int *flags);
 irqreturn_t handle_irq_event_percpu(struct irq_desc *desc);
 irqreturn_t handle_irq_event(struct irq_desc *desc);