lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200211131240.15853-6-brgl@bgdev.pl>
Date:   Tue, 11 Feb 2020 14:12:39 +0100
From:   Bartosz Golaszewski <brgl@...ev.pl>
To:     Linus Walleij <linus.walleij@...aro.org>,
        Jonathan Cameron <jic23@...nel.org>,
        Hartmut Knaack <knaack.h@....de>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Peter Meerwald-Stadler <pmeerw@...erw.net>,
        Thomas Gleixner <tglx@...utronix.de>,
        Jason Cooper <jason@...edaemon.net>,
        Marc Zyngier <maz@...nel.org>
Cc:     linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-iio@...r.kernel.org,
        Bartosz Golaszewski <bgolaszewski@...libre.com>
Subject: [PATCH v2 5/6] irq/domain: provide irq_domain_dispose_mappings() helper

From: Bartosz Golaszewski <bgolaszewski@...libre.com>

Unmapping all interrupts before removing an irq_domain is a common
use-case. Provide an appropriate helper that can also be used with
the remove() callback in irq_domain ops.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@...libre.com>
---
 include/linux/irqdomain.h |  2 ++
 kernel/irq/irqdomain.c    | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index fbc25f464f62..8fd27614dafd 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -390,6 +390,7 @@ extern unsigned int irq_create_mapping(struct irq_domain *host,
 				       irq_hw_number_t hwirq);
 extern unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec);
 extern void irq_dispose_mapping(unsigned int virq);
+extern void irq_domain_dispose_mappings(struct irq_domain *domain);
 
 /**
  * irq_linear_revmap() - Find a linux irq from a hw irq number.
@@ -594,6 +595,7 @@ irq_domain_hierarchical_is_msi_remap(struct irq_domain *domain)
 
 #else /* CONFIG_IRQ_DOMAIN */
 static inline void irq_dispose_mapping(unsigned int virq) { }
+static inline void irq_domain_dispose_mappings(struct irq_domain *domain) { }
 static inline struct irq_domain *irq_find_matching_fwnode(
 	struct fwnode_handle *fwnode, enum irq_domain_bus_token bus_token)
 {
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index b391d2e65bdd..d09de9f2411a 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -888,6 +888,23 @@ void irq_dispose_mapping(unsigned int virq)
 }
 EXPORT_SYMBOL_GPL(irq_dispose_mapping);
 
+/**
+ * irq_domain_dispose_mappings() - Unmap all interrupts
+ * @domain: domain for which to unmap all interrupts
+ */
+void irq_domain_dispose_mappings(struct irq_domain *domain)
+{
+	unsigned int virq;
+	int i;
+
+	for (i = 0; i < domain->hwirq_max; i++) {
+		virq = irq_find_mapping(domain, i);
+		if (virq)
+			irq_dispose_mapping(virq);
+	}
+}
+EXPORT_SYMBOL_GPL(irq_domain_dispose_mappings);
+
 /**
  * irq_find_mapping() - Find a linux irq from a hw irq number.
  * @domain: domain owning this hardware interrupt
-- 
2.25.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ