Commit 48b15a79 authored by Marc Zyngier's avatar Marc Zyngier

irqdomain: Cache irq_data instead of a virq number in the revmap

Caching a virq number in the revmap is pretty inefficient, as
it means we will need to convert it back to either an irq_data
or irq_desc to do anything with it.

It is also a bit odd, as the radix tree does cache irq_data
pointers.

Change the revmap type to be an irq_data pointer instead of
an unsigned int, and preserve the current API for now.
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
parent 426fa316
...@@ -151,7 +151,7 @@ struct irq_domain_chip_generic; ...@@ -151,7 +151,7 @@ struct irq_domain_chip_generic;
* Revmap data, used internally by irq_domain * Revmap data, used internally by irq_domain
* @revmap_size: Size of the linear map table @revmap[] * @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_tree: Radix map tree for hwirqs that don't fit in the linear map
* @revmap: Linear table of hwirq->virq reverse mappings * @revmap: Linear table of irq_data pointers
*/ */
struct irq_domain { struct irq_domain {
struct list_head link; struct list_head link;
...@@ -174,7 +174,7 @@ struct irq_domain { ...@@ -174,7 +174,7 @@ struct irq_domain {
unsigned int revmap_size; unsigned int revmap_size;
struct radix_tree_root revmap_tree; struct radix_tree_root revmap_tree;
struct mutex revmap_tree_mutex; struct mutex revmap_tree_mutex;
unsigned int revmap[]; struct irq_data *revmap[];
}; };
/* Irq domain flags */ /* Irq domain flags */
......
...@@ -505,7 +505,7 @@ static void irq_domain_clear_mapping(struct irq_domain *domain, ...@@ -505,7 +505,7 @@ static void irq_domain_clear_mapping(struct irq_domain *domain,
return; return;
if (hwirq < domain->revmap_size) { if (hwirq < domain->revmap_size) {
domain->revmap[hwirq] = 0; domain->revmap[hwirq] = NULL;
} else { } else {
mutex_lock(&domain->revmap_tree_mutex); mutex_lock(&domain->revmap_tree_mutex);
radix_tree_delete(&domain->revmap_tree, hwirq); radix_tree_delete(&domain->revmap_tree, hwirq);
...@@ -521,7 +521,7 @@ static void irq_domain_set_mapping(struct irq_domain *domain, ...@@ -521,7 +521,7 @@ static void irq_domain_set_mapping(struct irq_domain *domain,
return; return;
if (hwirq < domain->revmap_size) { if (hwirq < domain->revmap_size) {
domain->revmap[hwirq] = irq_data->irq; domain->revmap[hwirq] = irq_data;
} else { } else {
mutex_lock(&domain->revmap_tree_mutex); mutex_lock(&domain->revmap_tree_mutex);
radix_tree_insert(&domain->revmap_tree, hwirq, irq_data); radix_tree_insert(&domain->revmap_tree, hwirq, irq_data);
...@@ -913,7 +913,7 @@ unsigned int irq_find_mapping(struct irq_domain *domain, ...@@ -913,7 +913,7 @@ unsigned int irq_find_mapping(struct irq_domain *domain,
/* Check if the hwirq is in the linear revmap. */ /* Check if the hwirq is in the linear revmap. */
if (hwirq < domain->revmap_size) if (hwirq < domain->revmap_size)
return domain->revmap[hwirq]; return domain->revmap[hwirq]->irq;
rcu_read_lock(); rcu_read_lock();
data = radix_tree_lookup(&domain->revmap_tree, hwirq); data = radix_tree_lookup(&domain->revmap_tree, hwirq);
...@@ -1496,8 +1496,14 @@ static void irq_domain_fix_revmap(struct irq_data *d) ...@@ -1496,8 +1496,14 @@ static void irq_domain_fix_revmap(struct irq_data *d)
{ {
void __rcu **slot; void __rcu **slot;
if (irq_domain_is_nomap(d->domain) || d->hwirq < d->domain->revmap_size) if (irq_domain_is_nomap(d->domain))
return; /* Not using radix tree. */ return;
if (d->hwirq < d->domain->revmap_size) {
/* Not using radix tree */
d->domain->revmap[d->hwirq] = d;
return;
}
/* Fix up the revmap. */ /* Fix up the revmap. */
mutex_lock(&d->domain->revmap_tree_mutex); mutex_lock(&d->domain->revmap_tree_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment