Commit 2cb7b5a3 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'irqdomain-for-linus' of git://git.secretlab.ca/git/linux

Pull irqdomain refactoring from Grant Likely:
 "This is the long awaited simplification of irqdomain.  It gets rid of
  the different types of irq domains and instead both linear and tree
  mappings can be supported in a single domain.  Doing this removes a
  lot of special case code and makes irq domains simpler to understand
  overall"

* tag 'irqdomain-for-linus' of git://git.secretlab.ca/git/linux:
  irq: fix checkpatch error
  irqdomain: Include hwirq number in /proc/interrupts
  irqdomain: make irq_linear_revmap() a fast path again
  irqdomain: remove irq_domain_generate_simple()
  irqdomain: Refactor irq_domain_associate_many()
  irqdomain: Beef up debugfs output
  irqdomain: Clean up aftermath of irq_domain refactoring
  irqdomain: Eliminate revmap type
  irqdomain: merge linear and tree reverse mappings.
  irqdomain: Add a name field
  irqdomain: Replace LEGACY mapping with LINEAR
  irqdomain: Relax failure path on setting up mappings
parents b2c31107 798f0fd1
...@@ -239,7 +239,7 @@ void __init beatic_init_IRQ(void) ...@@ -239,7 +239,7 @@ void __init beatic_init_IRQ(void)
ppc_md.get_irq = beatic_get_irq; ppc_md.get_irq = beatic_get_irq;
/* Allocate an irq host */ /* Allocate an irq host */
beatic_host = irq_domain_add_nomap(NULL, 0, &beatic_pic_host_ops, NULL); beatic_host = irq_domain_add_nomap(NULL, ~0, &beatic_pic_host_ops, NULL);
BUG_ON(beatic_host == NULL); BUG_ON(beatic_host == NULL);
irq_set_default_host(beatic_host); irq_set_default_host(beatic_host);
} }
......
...@@ -192,7 +192,7 @@ static int psurge_secondary_ipi_init(void) ...@@ -192,7 +192,7 @@ static int psurge_secondary_ipi_init(void)
{ {
int rc = -ENOMEM; int rc = -ENOMEM;
psurge_host = irq_domain_add_nomap(NULL, 0, &psurge_host_ops, NULL); psurge_host = irq_domain_add_nomap(NULL, ~0, &psurge_host_ops, NULL);
if (psurge_host) if (psurge_host)
psurge_secondary_virq = irq_create_direct_mapping(psurge_host); psurge_secondary_virq = irq_create_direct_mapping(psurge_host);
......
...@@ -364,9 +364,7 @@ static void dt_add_ioapic_domain(unsigned int ioapic_num, ...@@ -364,9 +364,7 @@ static void dt_add_ioapic_domain(unsigned int ioapic_num,
* and assigned so we can keep the 1:1 mapping which the ioapic * and assigned so we can keep the 1:1 mapping which the ioapic
* is having. * is having.
*/ */
ret = irq_domain_associate_many(id, 0, 0, NR_IRQS_LEGACY); irq_domain_associate_many(id, 0, 0, NR_IRQS_LEGACY);
if (ret)
pr_err("Error mapping legacy IRQs: %d\n", ret);
if (num > NR_IRQS_LEGACY) { if (num > NR_IRQS_LEGACY) {
ret = irq_create_strict_mappings(id, NR_IRQS_LEGACY, ret = irq_create_strict_mappings(id, NR_IRQS_LEGACY,
......
...@@ -73,57 +73,48 @@ struct irq_domain_chip_generic; ...@@ -73,57 +73,48 @@ struct irq_domain_chip_generic;
/** /**
* struct irq_domain - Hardware interrupt number translation object * struct irq_domain - Hardware interrupt number translation object
* @link: Element in global irq_domain list. * @link: Element in global irq_domain list.
* @revmap_type: Method used for reverse mapping hwirq numbers to linux irq. This * @name: Name of interrupt domain
* will be one of the IRQ_DOMAIN_MAP_* values.
* @revmap_data: Revmap method specific data.
* @ops: pointer to irq_domain methods * @ops: pointer to irq_domain methods
* @host_data: private data pointer for use by owner. Not touched by irq_domain * @host_data: private data pointer for use by owner. Not touched by irq_domain
* core code. * core code.
* @irq_base: Start of irq_desc range assigned to the irq_domain. The creator *
* of the irq_domain is responsible for allocating the array of * Optional elements
* irq_desc structures. * @of_node: Pointer to device tree nodes associated with the irq_domain. Used
* @nr_irq: Number of irqs managed by the irq domain * when decoding device tree interrupt specifiers.
* @hwirq_base: Starting number for hwirqs managed by the irq domain * @gc: Pointer to a list of generic chips. There is a helper function for
* @of_node: (optional) Pointer to device tree nodes associated with the * setting up one or more generic chips for interrupt controllers
* irq_domain. Used when decoding device tree interrupt specifiers. * drivers using the generic chip library which uses this pointer.
*
* Revmap data, used internally by irq_domain
* @revmap_direct_max_irq: The largest hwirq that can be set for controllers that
* support direct mapping
* @revmap_size: Size of the linear map table @linear_revmap[]
* @revmap_tree: Radix map tree for hwirqs that don't fit in the linear map
* @linear_revmap: Linear table of hwirq->virq reverse mappings
*/ */
struct irq_domain { struct irq_domain {
struct list_head link; struct list_head link;
const char *name;
/* type of reverse mapping_technique */
unsigned int revmap_type;
union {
struct {
unsigned int size;
unsigned int first_irq;
irq_hw_number_t first_hwirq;
} legacy;
struct {
unsigned int size;
unsigned int *revmap;
} linear;
struct {
unsigned int max_irq;
} nomap;
struct radix_tree_root tree;
} revmap_data;
const struct irq_domain_ops *ops; const struct irq_domain_ops *ops;
void *host_data; void *host_data;
irq_hw_number_t inval_irq;
/* Optional device node pointer */ /* Optional data */
struct device_node *of_node; struct device_node *of_node;
/* Optional pointer to generic interrupt chips */
struct irq_domain_chip_generic *gc; struct irq_domain_chip_generic *gc;
};
#define IRQ_DOMAIN_MAP_LEGACY 0 /* driver allocated fixed range of irqs. /* reverse map data. The linear map gets appended to the irq_domain */
* ie. legacy 8259, gets irqs 1..15 */ irq_hw_number_t hwirq_max;
#define IRQ_DOMAIN_MAP_NOMAP 1 /* no fast reverse mapping */ unsigned int revmap_direct_max_irq;
#define IRQ_DOMAIN_MAP_LINEAR 2 /* linear map of interrupts */ unsigned int revmap_size;
#define IRQ_DOMAIN_MAP_TREE 3 /* radix tree */ struct radix_tree_root revmap_tree;
unsigned int linear_revmap[];
};
#ifdef CONFIG_IRQ_DOMAIN #ifdef CONFIG_IRQ_DOMAIN
struct irq_domain *__irq_domain_add(struct device_node *of_node, int size,
irq_hw_number_t hwirq_max, int direct_max,
const struct irq_domain_ops *ops,
void *host_data);
struct irq_domain *irq_domain_add_simple(struct device_node *of_node, struct irq_domain *irq_domain_add_simple(struct device_node *of_node,
unsigned int size, unsigned int size,
unsigned int first_irq, unsigned int first_irq,
...@@ -135,21 +126,30 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node, ...@@ -135,21 +126,30 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
irq_hw_number_t first_hwirq, irq_hw_number_t first_hwirq,
const struct irq_domain_ops *ops, const struct irq_domain_ops *ops,
void *host_data); void *host_data);
struct irq_domain *irq_domain_add_linear(struct device_node *of_node, extern struct irq_domain *irq_find_host(struct device_node *node);
extern void irq_set_default_host(struct irq_domain *host);
/**
* irq_domain_add_linear() - Allocate and register a linear revmap irq_domain.
* @of_node: pointer to interrupt controller's device tree node.
* @size: Number of interrupts in the domain.
* @ops: map/unmap domain callbacks
* @host_data: Controller private data pointer
*/
static inline struct irq_domain *irq_domain_add_linear(struct device_node *of_node,
unsigned int size, unsigned int size,
const struct irq_domain_ops *ops, const struct irq_domain_ops *ops,
void *host_data); void *host_data)
struct irq_domain *irq_domain_add_nomap(struct device_node *of_node, {
return __irq_domain_add(of_node, size, size, 0, ops, host_data);
}
static inline struct irq_domain *irq_domain_add_nomap(struct device_node *of_node,
unsigned int max_irq, unsigned int max_irq,
const struct irq_domain_ops *ops, const struct irq_domain_ops *ops,
void *host_data); void *host_data)
struct irq_domain *irq_domain_add_tree(struct device_node *of_node, {
const struct irq_domain_ops *ops, return __irq_domain_add(of_node, 0, max_irq, max_irq, ops, host_data);
void *host_data); }
extern struct irq_domain *irq_find_host(struct device_node *node);
extern void irq_set_default_host(struct irq_domain *host);
static inline struct irq_domain *irq_domain_add_legacy_isa( static inline struct irq_domain *irq_domain_add_legacy_isa(
struct device_node *of_node, struct device_node *of_node,
const struct irq_domain_ops *ops, const struct irq_domain_ops *ops,
...@@ -158,21 +158,40 @@ static inline struct irq_domain *irq_domain_add_legacy_isa( ...@@ -158,21 +158,40 @@ static inline struct irq_domain *irq_domain_add_legacy_isa(
return irq_domain_add_legacy(of_node, NUM_ISA_INTERRUPTS, 0, 0, ops, return irq_domain_add_legacy(of_node, NUM_ISA_INTERRUPTS, 0, 0, ops,
host_data); host_data);
} }
static inline struct irq_domain *irq_domain_add_tree(struct device_node *of_node,
const struct irq_domain_ops *ops,
void *host_data)
{
return __irq_domain_add(of_node, 0, ~0, 0, ops, host_data);
}
extern void irq_domain_remove(struct irq_domain *host); extern void irq_domain_remove(struct irq_domain *host);
extern int irq_domain_associate_many(struct irq_domain *domain, extern int irq_domain_associate(struct irq_domain *domain, unsigned int irq,
irq_hw_number_t hwirq);
extern void irq_domain_associate_many(struct irq_domain *domain,
unsigned int irq_base, unsigned int irq_base,
irq_hw_number_t hwirq_base, int count); irq_hw_number_t hwirq_base, int count);
static inline int irq_domain_associate(struct irq_domain *domain, unsigned int irq,
irq_hw_number_t hwirq)
{
return irq_domain_associate_many(domain, irq, hwirq, 1);
}
extern unsigned int irq_create_mapping(struct irq_domain *host, extern unsigned int irq_create_mapping(struct irq_domain *host,
irq_hw_number_t hwirq); irq_hw_number_t hwirq);
extern void irq_dispose_mapping(unsigned int virq); extern void irq_dispose_mapping(unsigned int virq);
/**
* irq_linear_revmap() - Find a linux irq from a hw irq number.
* @domain: domain owning this hardware interrupt
* @hwirq: hardware irq number in that domain space
*
* This is a fast path alternative to irq_find_mapping() that can be
* called directly by irq controller code to save a handful of
* instructions. It is always safe to call, but won't find irqs mapped
* using the radix tree.
*/
static inline unsigned int irq_linear_revmap(struct irq_domain *domain,
irq_hw_number_t hwirq)
{
return hwirq < domain->revmap_size ? domain->linear_revmap[hwirq] : 0;
}
extern unsigned int irq_find_mapping(struct irq_domain *host, extern unsigned int irq_find_mapping(struct irq_domain *host,
irq_hw_number_t hwirq); irq_hw_number_t hwirq);
extern unsigned int irq_create_direct_mapping(struct irq_domain *host); extern unsigned int irq_create_direct_mapping(struct irq_domain *host);
...@@ -186,9 +205,6 @@ static inline int irq_create_identity_mapping(struct irq_domain *host, ...@@ -186,9 +205,6 @@ static inline int irq_create_identity_mapping(struct irq_domain *host,
return irq_create_strict_mappings(host, hwirq, hwirq, 1); return irq_create_strict_mappings(host, hwirq, hwirq, 1);
} }
extern unsigned int irq_linear_revmap(struct irq_domain *host,
irq_hw_number_t hwirq);
extern const struct irq_domain_ops irq_domain_simple_ops; extern const struct irq_domain_ops irq_domain_simple_ops;
/* stock xlate functions */ /* stock xlate functions */
...@@ -202,14 +218,6 @@ int irq_domain_xlate_onetwocell(struct irq_domain *d, struct device_node *ctrlr, ...@@ -202,14 +218,6 @@ int irq_domain_xlate_onetwocell(struct irq_domain *d, struct device_node *ctrlr,
const u32 *intspec, unsigned int intsize, const u32 *intspec, unsigned int intsize,
irq_hw_number_t *out_hwirq, unsigned int *out_type); irq_hw_number_t *out_hwirq, unsigned int *out_type);
#if defined(CONFIG_OF_IRQ)
extern void irq_domain_generate_simple(const struct of_device_id *match,
u64 phys_base, unsigned int irq_start);
#else /* CONFIG_OF_IRQ */
static inline void irq_domain_generate_simple(const struct of_device_id *match,
u64 phys_base, unsigned int irq_start) { }
#endif /* !CONFIG_OF_IRQ */
#else /* CONFIG_IRQ_DOMAIN */ #else /* CONFIG_IRQ_DOMAIN */
static inline void irq_dispose_mapping(unsigned int virq) { } static inline void irq_dispose_mapping(unsigned int virq) { }
#endif /* !CONFIG_IRQ_DOMAIN */ #endif /* !CONFIG_IRQ_DOMAIN */
......
...@@ -275,10 +275,7 @@ int irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip, ...@@ -275,10 +275,7 @@ int irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
if (d->gc) if (d->gc)
return -EBUSY; return -EBUSY;
if (d->revmap_type != IRQ_DOMAIN_MAP_LINEAR) numchips = d->revmap_size / irqs_per_chip;
return -EINVAL;
numchips = d->revmap_data.linear.size / irqs_per_chip;
if (!numchips) if (!numchips)
return -EINVAL; return -EINVAL;
...@@ -310,6 +307,7 @@ int irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip, ...@@ -310,6 +307,7 @@ int irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
/* Calc pointer to the next generic chip */ /* Calc pointer to the next generic chip */
tmp += sizeof(*gc) + num_ct * sizeof(struct irq_chip_type); tmp += sizeof(*gc) + num_ct * sizeof(struct irq_chip_type);
} }
d->name = name;
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(irq_alloc_domain_generic_chips); EXPORT_SYMBOL_GPL(irq_alloc_domain_generic_chips);
......
This diff is collapsed.
...@@ -462,6 +462,8 @@ int show_interrupts(struct seq_file *p, void *v) ...@@ -462,6 +462,8 @@ int show_interrupts(struct seq_file *p, void *v)
} else { } else {
seq_printf(p, " %8s", "None"); seq_printf(p, " %8s", "None");
} }
if (desc->irq_data.domain)
seq_printf(p, " %*d", prec, (int) desc->irq_data.hwirq);
#ifdef CONFIG_GENERIC_IRQ_SHOW_LEVEL #ifdef CONFIG_GENERIC_IRQ_SHOW_LEVEL
seq_printf(p, " %-8s", irqd_is_level_type(&desc->irq_data) ? "Level" : "Edge"); seq_printf(p, " %-8s", irqd_is_level_type(&desc->irq_data) ? "Level" : "Edge");
#endif #endif
......
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