From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: linux-kernel@vger.kernel.org
Cc: "Cédric Le Goater" <clg@kaod.org>,
"Frederic Barrat" <fbarrat@linux.ibm.com>,
"Michal Suchánek" <msuchanek@suse.de>,
"Oliver O'Halloran" <oohall@gmail.com>,
"Marc Zyngier" <maz@kernel.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
x86@kernel.org, linuxppc-dev@lists.ozlabs.org,
"Alexey Kardashevskiy" <aik@ozlabs.ru>
Subject: [PATCH kernel v4 6/8] genirq/irqdomain: Move hierarchical IRQ cleanup to kobject_release
Date: Tue, 24 Nov 2020 17:17:18 +1100 [thread overview]
Message-ID: <20201124061720.86766-7-aik@ozlabs.ru> (raw)
In-Reply-To: <20201124061720.86766-1-aik@ozlabs.ru>
This moves hierarchical domain's irqs cleanup into the kobject release
hook to make irq_domain_free_irqs() as simple as kobject_put.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
kernel/irq/irqdomain.c | 43 +++++++++++++++++++++---------------------
1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 4779d912bb86..a0a81cc6c524 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -863,21 +863,9 @@ EXPORT_SYMBOL_GPL(irq_create_of_mapping);
*/
void irq_dispose_mapping(unsigned int virq)
{
- struct irq_data *irq_data = irq_get_irq_data(virq);
- struct irq_domain *domain;
+ struct irq_desc *desc = irq_to_desc(virq);
- if (!virq || !irq_data)
- return;
-
- domain = irq_data->domain;
- if (WARN_ON(domain == NULL))
- return;
-
- if (irq_domain_is_hierarchy(domain)) {
- irq_domain_free_irqs(virq, 1);
- } else {
- irq_free_desc(virq);
- }
+ kobject_put(&desc->kobj);
}
EXPORT_SYMBOL_GPL(irq_dispose_mapping);
@@ -1396,6 +1384,19 @@ int irq_domain_alloc_irqs_hierarchy(struct irq_domain *domain,
return domain->ops->alloc(domain, irq_base, nr_irqs, arg);
}
+static void irq_domain_hierarchy_free_desc(struct irq_desc *desc)
+{
+ unsigned int virq = desc->irq_data.irq;
+ struct irq_data *data = irq_get_irq_data(virq);
+
+ mutex_lock(&irq_domain_mutex);
+ irq_domain_remove_irq(virq);
+ irq_domain_free_irqs_hierarchy(data->domain, virq, 1);
+ mutex_unlock(&irq_domain_mutex);
+
+ irq_domain_free_irq_data(virq, 1);
+}
+
int __irq_domain_alloc_irqs_data(struct irq_domain *domain, int virq,
unsigned int nr_irqs, int node, void *arg,
const struct irq_affinity_desc *affinity)
@@ -1430,7 +1431,10 @@ int __irq_domain_alloc_irqs_data(struct irq_domain *domain, int virq,
}
for (i = 0; i < nr_irqs; i++) {
+ struct irq_desc *desc = irq_to_desc(virq + i);
+
irq_domain_insert_irq(virq + i);
+ desc->free_irq = irq_domain_hierarchy_free_desc;
}
mutex_unlock(&irq_domain_mutex);
@@ -1675,14 +1679,11 @@ void irq_domain_free_irqs(unsigned int virq, unsigned int nr_irqs)
"NULL pointer, cannot free irq\n"))
return;
- mutex_lock(&irq_domain_mutex);
- for (i = 0; i < nr_irqs; i++)
- irq_domain_remove_irq(virq + i);
- irq_domain_free_irqs_hierarchy(data->domain, virq, nr_irqs);
- mutex_unlock(&irq_domain_mutex);
+ for (i = 0; i < nr_irqs; i++) {
+ struct irq_desc *desc = irq_to_desc(virq + i);
- irq_domain_free_irq_data(virq, nr_irqs);
- irq_free_descs(virq, nr_irqs);
+ kobject_put(&desc->kobj);
+ }
}
/**
--
2.17.1
next prev parent reply other threads:[~2020-11-24 6:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-24 6:17 [PATCH kernel v4 0/8] genirq/irqdomain: Add reference counting to IRQs Alexey Kardashevskiy
2020-11-24 6:17 ` [PATCH kernel v4 1/8] genirq/ipi: Simplify irq_reserve_ipi Alexey Kardashevskiy
2020-11-24 16:54 ` Cédric Le Goater
2020-11-24 6:17 ` [PATCH kernel v4 2/8] genirq/irqdomain: Clean legacy IRQ allocation Alexey Kardashevskiy
2020-11-24 9:19 ` Andy Shevchenko
2020-11-24 10:56 ` Alexey Kardashevskiy
2020-11-30 21:41 ` Thomas Gleixner
2020-11-24 6:17 ` [PATCH kernel v4 3/8] genirq/irqdomain: Drop unused realloc parameter from __irq_domain_alloc_irqs Alexey Kardashevskiy
2020-11-24 6:17 ` [PATCH kernel v4 4/8] genirq: Free IRQ descriptor via embedded kobject Alexey Kardashevskiy
2020-11-24 6:17 ` [PATCH kernel v4 5/8] genirq: Add free_irq hook for IRQ descriptor and use for mapping disposal Alexey Kardashevskiy
2020-11-30 22:18 ` Thomas Gleixner
2020-11-30 22:33 ` Thomas Gleixner
2020-11-24 6:17 ` Alexey Kardashevskiy [this message]
2020-11-24 8:12 ` [PATCH kernel v4 6/8] genirq/irqdomain: Move hierarchical IRQ cleanup to kobject_release kernel test robot
2020-11-30 23:13 ` Thomas Gleixner
2020-11-24 6:17 ` [PATCH kernel v4 7/8] genirq/irqdomain: Reference irq_desc for already mapped irqs Alexey Kardashevskiy
2020-11-24 6:17 ` [PATCH kernel v4 8/8] powerpc/pci: Remove LSI mappings on device teardown Alexey Kardashevskiy
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=20201124061720.86766-7-aik@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=clg@kaod.org \
--cc=fbarrat@linux.ibm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maz@kernel.org \
--cc=msuchanek@suse.de \
--cc=oohall@gmail.com \
--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).