Skip to content

Commit 61d0a00

Browse files
Marc ZyngierKAGA-KOKO
authored andcommitted
genirq/irqdomain: Add irq_domain_update_bus_token helper
We can have irq domains that are identified by the same fwnode (because they are serviced by the same HW), and yet have different functionnality (because they serve different busses, for example). This is what we use the bus_token field. Since we don't use this field when generating the domain name, all the aliasing domains will get the same name, and the debugfs file creation fails. Also, bus_token is updated by individual drivers, and the core code is unaware of that update. In order to sort this mess, let's introduce a helper that takes care of updating bus_token, and regenerate the debugfs file. A separate patch will update all the individual users. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 9a0ef98 commit 61d0a00

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

include/linux/irqdomain.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ static inline bool is_fwnode_irqchip(struct fwnode_handle *fwnode)
273273
return fwnode && fwnode->type == FWNODE_IRQCHIP;
274274
}
275275

276+
extern void irq_domain_update_bus_token(struct irq_domain *domain,
277+
enum irq_domain_bus_token bus_token);
278+
276279
static inline
277280
struct irq_domain *irq_find_matching_fwnode(struct fwnode_handle *fwnode,
278281
enum irq_domain_bus_token bus_token)

kernel/irq/irqdomain.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,37 @@ void irq_domain_remove(struct irq_domain *domain)
245245
}
246246
EXPORT_SYMBOL_GPL(irq_domain_remove);
247247

248+
void irq_domain_update_bus_token(struct irq_domain *domain,
249+
enum irq_domain_bus_token bus_token)
250+
{
251+
char *name;
252+
253+
if (domain->bus_token == bus_token)
254+
return;
255+
256+
mutex_lock(&irq_domain_mutex);
257+
258+
domain->bus_token = bus_token;
259+
260+
name = kasprintf(GFP_KERNEL, "%s-%d", domain->name, bus_token);
261+
if (!name) {
262+
mutex_unlock(&irq_domain_mutex);
263+
return;
264+
}
265+
266+
debugfs_remove_domain_dir(domain);
267+
268+
if (domain->flags & IRQ_DOMAIN_NAME_ALLOCATED)
269+
kfree(domain->name);
270+
else
271+
domain->flags |= IRQ_DOMAIN_NAME_ALLOCATED;
272+
273+
domain->name = name;
274+
debugfs_add_domain_dir(domain);
275+
276+
mutex_unlock(&irq_domain_mutex);
277+
}
278+
248279
/**
249280
* irq_domain_add_simple() - Register an irq_domain and optionally map a range of irqs
250281
* @of_node: pointer to interrupt controller's device tree node.

0 commit comments

Comments
 (0)