linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan+linaro@kernel.org>
To: Marc Zyngier <maz@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	x86@kernel.org, platform-driver-x86@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Johan Hovold <johan+linaro@kernel.org>
Subject: [PATCH v3 06/19] irqdomain: Drop revmap mutex
Date: Fri,  9 Dec 2022 15:01:37 +0100	[thread overview]
Message-ID: <20221209140150.1453-7-johan+linaro@kernel.org> (raw)
In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org>

The global irq_domain_mutex is now held in all paths that update the
revmap structures so there is no longer any need for the revmap mutex.

Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 include/linux/irqdomain.h |  2 --
 kernel/irq/irqdomain.c    | 13 ++++++-------
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index a372086750ca..16399de00b48 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -143,7 +143,6 @@ struct irq_domain_chip_generic;
  * Revmap data, used internally by the irq domain code:
  * @revmap_size:	Size of the linear map table @revmap[]
  * @revmap_tree:	Radix map tree for hwirqs that don't fit in the linear map
- * @revmap_mutex:	Lock for the revmap
  * @revmap:		Linear table of irq_data pointers
  */
 struct irq_domain {
@@ -171,7 +170,6 @@ struct irq_domain {
 	irq_hw_number_t			hwirq_max;
 	unsigned int			revmap_size;
 	struct radix_tree_root		revmap_tree;
-	struct mutex			revmap_mutex;
 	struct irq_data __rcu		*revmap[];
 };
 
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 23f5919e58b7..248e6acfafbe 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -214,7 +214,6 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int s
 
 	/* Fill structure */
 	INIT_RADIX_TREE(&domain->revmap_tree, GFP_KERNEL);
-	mutex_init(&domain->revmap_mutex);
 	domain->ops = ops;
 	domain->host_data = host_data;
 	domain->hwirq_max = hwirq_max;
@@ -501,30 +500,30 @@ static bool irq_domain_is_nomap(struct irq_domain *domain)
 static void irq_domain_clear_mapping(struct irq_domain *domain,
 				     irq_hw_number_t hwirq)
 {
+	lockdep_assert_held(&irq_domain_mutex);
+
 	if (irq_domain_is_nomap(domain))
 		return;
 
-	mutex_lock(&domain->revmap_mutex);
 	if (hwirq < domain->revmap_size)
 		rcu_assign_pointer(domain->revmap[hwirq], NULL);
 	else
 		radix_tree_delete(&domain->revmap_tree, hwirq);
-	mutex_unlock(&domain->revmap_mutex);
 }
 
 static void irq_domain_set_mapping(struct irq_domain *domain,
 				   irq_hw_number_t hwirq,
 				   struct irq_data *irq_data)
 {
+	lockdep_assert_held(&irq_domain_mutex);
+
 	if (irq_domain_is_nomap(domain))
 		return;
 
-	mutex_lock(&domain->revmap_mutex);
 	if (hwirq < domain->revmap_size)
 		rcu_assign_pointer(domain->revmap[hwirq], irq_data);
 	else
 		radix_tree_insert(&domain->revmap_tree, hwirq, irq_data);
-	mutex_unlock(&domain->revmap_mutex);
 }
 
 static void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq)
@@ -1511,11 +1510,12 @@ static void irq_domain_fix_revmap(struct irq_data *d)
 {
 	void __rcu **slot;
 
+	lockdep_assert_held(&irq_domain_mutex);
+
 	if (irq_domain_is_nomap(d->domain))
 		return;
 
 	/* Fix up the revmap. */
-	mutex_lock(&d->domain->revmap_mutex);
 	if (d->hwirq < d->domain->revmap_size) {
 		/* Not using radix tree */
 		rcu_assign_pointer(d->domain->revmap[d->hwirq], d);
@@ -1524,7 +1524,6 @@ static void irq_domain_fix_revmap(struct irq_data *d)
 		if (slot)
 			radix_tree_replace_slot(&d->domain->revmap_tree, slot, d);
 	}
-	mutex_unlock(&d->domain->revmap_mutex);
 }
 
 /**
-- 
2.37.4


  parent reply	other threads:[~2022-12-09 14:05 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-09 14:01 [PATCH v3 00/19] irqdomain: fix mapping race and clean up locking Johan Hovold
2022-12-09 14:01 ` [PATCH v3 01/19] irqdomain: Drop bogus fwspec-mapping error handling Johan Hovold
2022-12-09 14:01 ` [PATCH v3 02/19] irqdomain: Drop dead domain-name assignment Johan Hovold
2022-12-09 14:01 ` [PATCH v3 03/19] irqdomain: Drop leftover brackets Johan Hovold
2022-12-12 22:44   ` Philippe Mathieu-Daudé
2022-12-09 14:01 ` [PATCH v3 04/19] irqdomain: Fix association race Johan Hovold
2022-12-09 14:01 ` [PATCH v3 05/19] irqdomain: Fix disassociation race Johan Hovold
2022-12-09 14:01 ` Johan Hovold [this message]
2022-12-09 14:01 ` [PATCH v3 07/19] irqdomain: Look for existing mapping only once Johan Hovold
2022-12-09 14:01 ` [PATCH v3 08/19] irqdomain: Refactor __irq_domain_alloc_irqs() Johan Hovold
2022-12-09 14:01 ` [PATCH v3 09/19] irqdomain: Fix mapping-creation race Johan Hovold
2022-12-09 14:01 ` [PATCH v3 10/19] irqdomain: Clean up irq_domain_push/pop_irq() Johan Hovold
2022-12-12 22:32   ` Philippe Mathieu-Daudé
2022-12-09 14:01 ` [PATCH v3 11/19] x86/ioapic: Use irq_domain_create_hierarchy() Johan Hovold
2022-12-12 22:37   ` Philippe Mathieu-Daudé
2022-12-09 14:01 ` [PATCH v3 12/19] x86/apic: " Johan Hovold
2022-12-12 22:41   ` Philippe Mathieu-Daudé
2022-12-09 14:01 ` [PATCH v3 13/19] irqchip/alpine-msi: Use irq_domain_add_hierarchy() Johan Hovold
2022-12-12 22:41   ` Philippe Mathieu-Daudé
2022-12-09 14:01 ` [PATCH v3 14/19] irqchip/gic-v2m: Use irq_domain_create_hierarchy() Johan Hovold
2022-12-12 22:42   ` Philippe Mathieu-Daudé
2022-12-09 14:01 ` [PATCH v3 15/19] irqchip/gic-v3-its: " Johan Hovold
2022-12-09 14:01 ` [PATCH v3 16/19] irqchip/gic-v3-mbi: " Johan Hovold
2022-12-12 22:42   ` Philippe Mathieu-Daudé
2022-12-09 14:01 ` [PATCH v3 17/19] irqchip/loongson-pch-msi: " Johan Hovold
2022-12-12 22:36   ` Philippe Mathieu-Daudé
2022-12-09 14:01 ` [PATCH v3 18/19] irqchip/mvebu-odmi: " Johan Hovold
2022-12-12 22:37   ` Philippe Mathieu-Daudé
2022-12-09 14:01 ` [PATCH v3 19/19] irqdomain: Switch to per-domain locking Johan Hovold
2022-12-12 14:14   ` Thomas Gleixner
2022-12-12 14:29     ` Johan Hovold
2022-12-12 16:18       ` Thomas Gleixner
2023-01-11 18:28         ` Thomas Gleixner
2023-01-12 17:21           ` Johan Hovold
2022-12-09 15:51 ` [PATCH v3 00/19] irqdomain: fix mapping race and clean up locking Thomas Gleixner
2022-12-09 16:16   ` Johan Hovold
2022-12-09 19:53     ` Thomas Gleixner
2022-12-15  9:31 ` Hsin-Yi Wang
2023-01-16 13:53   ` Johan Hovold
2022-12-20  3:30 ` [PATCH v3 0/19] " Mark-PK Tsai
2023-01-16 13:55   ` Johan Hovold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221209140150.1453-7-johan+linaro@kernel.org \
    --to=johan+linaro@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).