Skip to contentSkip to conversation

irqdomain: Fix disposal of mappings for interrupt hierarchies

RFC PATCH New Jon Hunter 2 participants 2 messages Jun 21, 2016 – Jun 23, 2016

Subsystems (2)
lore
Share & tools
lore

Jon Hunter

author
#0 lore raw

RFC PATCH 1/1 irqdomain: Fix disposal of mappings for interrupt hierarchies

The function irq_create_of_mapping() is used to create an interrupt mapping. However, depending on whether the irqdomain, to which the interrupt belongs, is part of a hierarchy, determines whether the mapping is created via calling irq_domain_alloc_irqs() or irq_create_mapping().

To dispose of the interrupt mapping, drivers call irq_dispose_mapping(). However, this function does not check to see if the irqdomain is part of a hierarchy or not and simply assumes that it was mapped via calling irq_create_mapping() so calls irq_domain_disassociate() to unmap the interrupt.

Fix this by checking to see if the irqdomain is part of a hierarchy and if so call irq_domain_free_irqs() to free/unmap the interrupt.

---

Please note that I have not observed issues with this, but something that did not make sense to me from looking at the code.

 kernel/irq/irqdomain.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/irq/irqdomain.c +6 -2
index caa6a63d26f0..5d89d724a02a 100644
@@ -680,8 +680,12 @@ void irq_dispose_mapping(unsigned int virq)
 	if (WARN_ON(domain == NULL))
 		return;
 
-	irq_domain_disassociate(domain, virq);
-	irq_free_desc(virq);
+	if (irq_domain_is_hierarchy(domain)) {
+		irq_domain_free_irqs(virq, 1);
+	} else {
+		irq_domain_disassociate(domain, virq);
+		irq_free_desc(virq);
+	}
 }
 EXPORT_SYMBOL_GPL(irq_dispose_mapping);
 
Signature · 1 line
2.1.4
#1 lore raw
irqdomain: Fix disposal of mappings for interrupt hierarchies
Commit-ID:  d16dcd3d18759eb955e0325572d07457f93494f5
Gitweb:     http://git.kernel.org/tip/d16dcd3d18759eb955e0325572d07457f93494f5
Author:     Jon Hunter <[email protected]>
AuthorDate: Tue, 21 Jun 2016 10:23:22 +0100
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Thu, 23 Jun 2016 10:21:06 +0200

irqdomain: Fix disposal of mappings for interrupt hierarchies

The function irq_create_of_mapping() is used to create an interrupt mapping. However, depending on whether the irqdomain, to which the interrupt belongs, is part of a hierarchy, determines whether the mapping is created via calling irq_domain_alloc_irqs() or irq_create_mapping().

To dispose of the interrupt mapping, drivers call irq_dispose_mapping(). However, this function does not check to see if the irqdomain is part of a hierarchy or not and simply assumes that it was mapped via calling irq_create_mapping() so calls irq_domain_disassociate() to unmap the interrupt.

Fix this by checking to see if the irqdomain is part of a hierarchy and if so call irq_domain_free_irqs() to free/unmap the interrupt.

---
 kernel/irq/irqdomain.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/irq/irqdomain.c +6 -2
index caa6a63..5d89d72 100644
@@ -680,8 +680,12 @@ void irq_dispose_mapping(unsigned int virq)
 	if (WARN_ON(domain == NULL))
 		return;
 
-	irq_domain_disassociate(domain, virq);
-	irq_free_desc(virq);
+	if (irq_domain_is_hierarchy(domain)) {
+		irq_domain_free_irqs(virq, 1);
+	} else {
+		irq_domain_disassociate(domain, virq);
+		irq_free_desc(virq);
+	}
 }
 EXPORT_SYMBOL_GPL(irq_dispose_mapping);