irqdomain.c (9dc6be3d419398eae9a19cd09b7969ceff8eaf10) irqdomain.c (087cdfb662ae50e3826e7cd2e54b6519d07b60f0)
1#define pr_fmt(fmt) "irq: " fmt
2
3#include <linux/debugfs.h>
4#include <linux/hardirq.h>
5#include <linux/interrupt.h>
6#include <linux/irq.h>
7#include <linux/irqdesc.h>
8#include <linux/irqdomain.h>

--- 15 unchanged lines hidden (view full) ---

24static struct irq_domain *irq_default_domain;
25
26static void irq_domain_check_hierarchy(struct irq_domain *domain);
27
28struct irqchip_fwid {
29 struct fwnode_handle fwnode;
30 unsigned int type;
31 char *name;
1#define pr_fmt(fmt) "irq: " fmt
2
3#include <linux/debugfs.h>
4#include <linux/hardirq.h>
5#include <linux/interrupt.h>
6#include <linux/irq.h>
7#include <linux/irqdesc.h>
8#include <linux/irqdomain.h>

--- 15 unchanged lines hidden (view full) ---

24static struct irq_domain *irq_default_domain;
25
26static void irq_domain_check_hierarchy(struct irq_domain *domain);
27
28struct irqchip_fwid {
29 struct fwnode_handle fwnode;
30 unsigned int type;
31 char *name;
32 void *data;
32 void *data;
33};
34
33};
34
35#ifdef CONFIG_GENERIC_IRQ_DEBUGFS
36static void debugfs_add_domain_dir(struct irq_domain *d);
37static void debugfs_remove_domain_dir(struct irq_domain *d);
38#else
39static inline void debugfs_add_domain_dir(struct irq_domain *d) { }
40static inline void debugfs_remove_domain_dir(struct irq_domain *d) { }
41#endif
42
35/**
36 * irq_domain_alloc_fwnode - Allocate a fwnode_handle suitable for
37 * identifying an irq domain
38 * @type: Type of irqchip_fwnode. See linux/irqdomain.h
39 * @name: Optional user provided domain name
40 * @id: Optional user provided id if name != NULL
41 * @data: Optional user-provided data
42 *

--- 146 unchanged lines hidden (view full) ---

189 domain->ops = ops;
190 domain->host_data = host_data;
191 domain->hwirq_max = hwirq_max;
192 domain->revmap_size = size;
193 domain->revmap_direct_max_irq = direct_max;
194 irq_domain_check_hierarchy(domain);
195
196 mutex_lock(&irq_domain_mutex);
43/**
44 * irq_domain_alloc_fwnode - Allocate a fwnode_handle suitable for
45 * identifying an irq domain
46 * @type: Type of irqchip_fwnode. See linux/irqdomain.h
47 * @name: Optional user provided domain name
48 * @id: Optional user provided id if name != NULL
49 * @data: Optional user-provided data
50 *

--- 146 unchanged lines hidden (view full) ---

197 domain->ops = ops;
198 domain->host_data = host_data;
199 domain->hwirq_max = hwirq_max;
200 domain->revmap_size = size;
201 domain->revmap_direct_max_irq = direct_max;
202 irq_domain_check_hierarchy(domain);
203
204 mutex_lock(&irq_domain_mutex);
205 debugfs_add_domain_dir(domain);
197 list_add(&domain->link, &irq_domain_list);
198 mutex_unlock(&irq_domain_mutex);
199
200 pr_debug("Added domain %s\n", domain->name);
201 return domain;
202}
203EXPORT_SYMBOL_GPL(__irq_domain_add);
204
205/**
206 * irq_domain_remove() - Remove an irq domain.
207 * @domain: domain to remove
208 *
209 * This routine is used to remove an irq domain. The caller must ensure
210 * that all mappings within the domain have been disposed of prior to
211 * use, depending on the revmap type.
212 */
213void irq_domain_remove(struct irq_domain *domain)
214{
215 mutex_lock(&irq_domain_mutex);
206 list_add(&domain->link, &irq_domain_list);
207 mutex_unlock(&irq_domain_mutex);
208
209 pr_debug("Added domain %s\n", domain->name);
210 return domain;
211}
212EXPORT_SYMBOL_GPL(__irq_domain_add);
213
214/**
215 * irq_domain_remove() - Remove an irq domain.
216 * @domain: domain to remove
217 *
218 * This routine is used to remove an irq domain. The caller must ensure
219 * that all mappings within the domain have been disposed of prior to
220 * use, depending on the revmap type.
221 */
222void irq_domain_remove(struct irq_domain *domain)
223{
224 mutex_lock(&irq_domain_mutex);
225 debugfs_remove_domain_dir(domain);
216
217 WARN_ON(!radix_tree_empty(&domain->revmap_tree));
218
219 list_del(&domain->link);
220
221 /*
222 * If the going away domain is the default one, reset it.
223 */

--- 1370 unchanged lines hidden (view full) ---

1594 irq_set_chip_data(virq, chip_data);
1595 irq_set_handler_data(virq, handler_data);
1596}
1597
1598static void irq_domain_check_hierarchy(struct irq_domain *domain)
1599{
1600}
1601#endif /* CONFIG_IRQ_DOMAIN_HIERARCHY */
226
227 WARN_ON(!radix_tree_empty(&domain->revmap_tree));
228
229 list_del(&domain->link);
230
231 /*
232 * If the going away domain is the default one, reset it.
233 */

--- 1370 unchanged lines hidden (view full) ---

1604 irq_set_chip_data(virq, chip_data);
1605 irq_set_handler_data(virq, handler_data);
1606}
1607
1608static void irq_domain_check_hierarchy(struct irq_domain *domain)
1609{
1610}
1611#endif /* CONFIG_IRQ_DOMAIN_HIERARCHY */
1612
1613#ifdef CONFIG_GENERIC_IRQ_DEBUGFS
1614static struct dentry *domain_dir;
1615
1616static void
1617irq_domain_debug_show_one(struct seq_file *m, struct irq_domain *d, int ind)
1618{
1619 seq_printf(m, "%*sname: %s\n", ind, "", d->name);
1620 seq_printf(m, "%*ssize: %u\n", ind + 1, "",
1621 d->revmap_size + d->revmap_direct_max_irq);
1622 seq_printf(m, "%*smapped: %u\n", ind + 1, "", d->mapcount);
1623 seq_printf(m, "%*sflags: 0x%08x\n", ind +1 , "", d->flags);
1624#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
1625 if (!d->parent)
1626 return;
1627 seq_printf(m, "%*sparent: %s\n", ind + 1, "", d->parent->name);
1628 irq_domain_debug_show_one(m, d->parent, ind + 4);
1629#endif
1630}
1631
1632static int irq_domain_debug_show(struct seq_file *m, void *p)
1633{
1634 struct irq_domain *d = m->private;
1635
1636 /* Default domain? Might be NULL */
1637 if (!d) {
1638 if (!irq_default_domain)
1639 return 0;
1640 d = irq_default_domain;
1641 }
1642 irq_domain_debug_show_one(m, d, 0);
1643 return 0;
1644}
1645
1646static int irq_domain_debug_open(struct inode *inode, struct file *file)
1647{
1648 return single_open(file, irq_domain_debug_show, inode->i_private);
1649}
1650
1651static const struct file_operations dfs_domain_ops = {
1652 .open = irq_domain_debug_open,
1653 .read = seq_read,
1654 .llseek = seq_lseek,
1655 .release = single_release,
1656};
1657
1658static void debugfs_add_domain_dir(struct irq_domain *d)
1659{
1660 if (!d->name || !domain_dir || d->debugfs_file)
1661 return;
1662 d->debugfs_file = debugfs_create_file(d->name, 0444, domain_dir, d,
1663 &dfs_domain_ops);
1664}
1665
1666static void debugfs_remove_domain_dir(struct irq_domain *d)
1667{
1668 if (d->debugfs_file)
1669 debugfs_remove(d->debugfs_file);
1670}
1671
1672void __init irq_domain_debugfs_init(struct dentry *root)
1673{
1674 struct irq_domain *d;
1675
1676 domain_dir = debugfs_create_dir("domains", root);
1677 if (!domain_dir)
1678 return;
1679
1680 debugfs_create_file("default", 0444, domain_dir, NULL, &dfs_domain_ops);
1681 mutex_lock(&irq_domain_mutex);
1682 list_for_each_entry(d, &irq_domain_list, link)
1683 debugfs_add_domain_dir(d);
1684 mutex_unlock(&irq_domain_mutex);
1685}
1686#endif