Skip to content

Commit 2cb7b5a

Browse files
committed
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
2 parents b2c3110 + 798f0fd commit 2cb7b5a

7 files changed

Lines changed: 264 additions & 473 deletions

File tree

‎arch/powerpc/platforms/cell/beat_interrupt.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void __init beatic_init_IRQ(void)
239239
ppc_md.get_irq = beatic_get_irq;
240240

241241
/* Allocate an irq host */
242-
beatic_host = irq_domain_add_nomap(NULL, 0, &beatic_pic_host_ops, NULL);
242+
beatic_host = irq_domain_add_nomap(NULL, ~0, &beatic_pic_host_ops, NULL);
243243
BUG_ON(beatic_host == NULL);
244244
irq_set_default_host(beatic_host);
245245
}

‎arch/powerpc/platforms/powermac/smp.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ static int psurge_secondary_ipi_init(void)
192192
{
193193
int rc = -ENOMEM;
194194

195-
psurge_host = irq_domain_add_nomap(NULL, 0, &psurge_host_ops, NULL);
195+
psurge_host = irq_domain_add_nomap(NULL, ~0, &psurge_host_ops, NULL);
196196

197197
if (psurge_host)
198198
psurge_secondary_virq = irq_create_direct_mapping(psurge_host);

‎arch/x86/kernel/devicetree.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,7 @@ static void dt_add_ioapic_domain(unsigned int ioapic_num,
364364
* and assigned so we can keep the 1:1 mapping which the ioapic
365365
* is having.
366366
*/
367-
ret = irq_domain_associate_many(id, 0, 0, NR_IRQS_LEGACY);
368-
if (ret)
369-
pr_err("Error mapping legacy IRQs: %d\n", ret);
367+
irq_domain_associate_many(id, 0, 0, NR_IRQS_LEGACY);
370368

371369
if (num > NR_IRQS_LEGACY) {
372370
ret = irq_create_strict_mappings(id, NR_IRQS_LEGACY,

‎include/linux/irqdomain.h‎

Lines changed: 75 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -73,57 +73,48 @@ struct irq_domain_chip_generic;
7373
/**
7474
* struct irq_domain - Hardware interrupt number translation object
7575
* @link: Element in global irq_domain list.
76-
* @revmap_type: Method used for reverse mapping hwirq numbers to linux irq. This
77-
* will be one of the IRQ_DOMAIN_MAP_* values.
78-
* @revmap_data: Revmap method specific data.
76+
* @name: Name of interrupt domain
7977
* @ops: pointer to irq_domain methods
8078
* @host_data: private data pointer for use by owner. Not touched by irq_domain
8179
* core code.
82-
* @irq_base: Start of irq_desc range assigned to the irq_domain. The creator
83-
* of the irq_domain is responsible for allocating the array of
84-
* irq_desc structures.
85-
* @nr_irq: Number of irqs managed by the irq domain
86-
* @hwirq_base: Starting number for hwirqs managed by the irq domain
87-
* @of_node: (optional) Pointer to device tree nodes associated with the
88-
* irq_domain. Used when decoding device tree interrupt specifiers.
80+
*
81+
* Optional elements
82+
* @of_node: Pointer to device tree nodes associated with the irq_domain. Used
83+
* when decoding device tree interrupt specifiers.
84+
* @gc: Pointer to a list of generic chips. There is a helper function for
85+
* setting up one or more generic chips for interrupt controllers
86+
* drivers using the generic chip library which uses this pointer.
87+
*
88+
* Revmap data, used internally by irq_domain
89+
* @revmap_direct_max_irq: The largest hwirq that can be set for controllers that
90+
* support direct mapping
91+
* @revmap_size: Size of the linear map table @linear_revmap[]
92+
* @revmap_tree: Radix map tree for hwirqs that don't fit in the linear map
93+
* @linear_revmap: Linear table of hwirq->virq reverse mappings
8994
*/
9095
struct irq_domain {
9196
struct list_head link;
92-
93-
/* type of reverse mapping_technique */
94-
unsigned int revmap_type;
95-
union {
96-
struct {
97-
unsigned int size;
98-
unsigned int first_irq;
99-
irq_hw_number_t first_hwirq;
100-
} legacy;
101-
struct {
102-
unsigned int size;
103-
unsigned int *revmap;
104-
} linear;
105-
struct {
106-
unsigned int max_irq;
107-
} nomap;
108-
struct radix_tree_root tree;
109-
} revmap_data;
97+
const char *name;
11098
const struct irq_domain_ops *ops;
11199
void *host_data;
112-
irq_hw_number_t inval_irq;
113100

114-
/* Optional device node pointer */
101+
/* Optional data */
115102
struct device_node *of_node;
116-
/* Optional pointer to generic interrupt chips */
117103
struct irq_domain_chip_generic *gc;
118-
};
119104

120-
#define IRQ_DOMAIN_MAP_LEGACY 0 /* driver allocated fixed range of irqs.
121-
* ie. legacy 8259, gets irqs 1..15 */
122-
#define IRQ_DOMAIN_MAP_NOMAP 1 /* no fast reverse mapping */
123-
#define IRQ_DOMAIN_MAP_LINEAR 2 /* linear map of interrupts */
124-
#define IRQ_DOMAIN_MAP_TREE 3 /* radix tree */
105+
/* reverse map data. The linear map gets appended to the irq_domain */
106+
irq_hw_number_t hwirq_max;
107+
unsigned int revmap_direct_max_irq;
108+
unsigned int revmap_size;
109+
struct radix_tree_root revmap_tree;
110+
unsigned int linear_revmap[];
111+
};
125112

126113
#ifdef CONFIG_IRQ_DOMAIN
114+
struct irq_domain *__irq_domain_add(struct device_node *of_node, int size,
115+
irq_hw_number_t hwirq_max, int direct_max,
116+
const struct irq_domain_ops *ops,
117+
void *host_data);
127118
struct irq_domain *irq_domain_add_simple(struct device_node *of_node,
128119
unsigned int size,
129120
unsigned int first_irq,
@@ -135,21 +126,30 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
135126
irq_hw_number_t first_hwirq,
136127
const struct irq_domain_ops *ops,
137128
void *host_data);
138-
struct irq_domain *irq_domain_add_linear(struct device_node *of_node,
129+
extern struct irq_domain *irq_find_host(struct device_node *node);
130+
extern void irq_set_default_host(struct irq_domain *host);
131+
132+
/**
133+
* irq_domain_add_linear() - Allocate and register a linear revmap irq_domain.
134+
* @of_node: pointer to interrupt controller's device tree node.
135+
* @size: Number of interrupts in the domain.
136+
* @ops: map/unmap domain callbacks
137+
* @host_data: Controller private data pointer
138+
*/
139+
static inline struct irq_domain *irq_domain_add_linear(struct device_node *of_node,
139140
unsigned int size,
140141
const struct irq_domain_ops *ops,
141-
void *host_data);
142-
struct irq_domain *irq_domain_add_nomap(struct device_node *of_node,
142+
void *host_data)
143+
{
144+
return __irq_domain_add(of_node, size, size, 0, ops, host_data);
145+
}
146+
static inline struct irq_domain *irq_domain_add_nomap(struct device_node *of_node,
143147
unsigned int max_irq,
144148
const struct irq_domain_ops *ops,
145-
void *host_data);
146-
struct irq_domain *irq_domain_add_tree(struct device_node *of_node,
147-
const struct irq_domain_ops *ops,
148-
void *host_data);
149-
150-
extern struct irq_domain *irq_find_host(struct device_node *node);
151-
extern void irq_set_default_host(struct irq_domain *host);
152-
149+
void *host_data)
150+
{
151+
return __irq_domain_add(of_node, 0, max_irq, max_irq, ops, host_data);
152+
}
153153
static inline struct irq_domain *irq_domain_add_legacy_isa(
154154
struct device_node *of_node,
155155
const struct irq_domain_ops *ops,
@@ -158,21 +158,40 @@ static inline struct irq_domain *irq_domain_add_legacy_isa(
158158
return irq_domain_add_legacy(of_node, NUM_ISA_INTERRUPTS, 0, 0, ops,
159159
host_data);
160160
}
161+
static inline struct irq_domain *irq_domain_add_tree(struct device_node *of_node,
162+
const struct irq_domain_ops *ops,
163+
void *host_data)
164+
{
165+
return __irq_domain_add(of_node, 0, ~0, 0, ops, host_data);
166+
}
161167

162168
extern void irq_domain_remove(struct irq_domain *host);
163169

164-
extern int irq_domain_associate_many(struct irq_domain *domain,
165-
unsigned int irq_base,
166-
irq_hw_number_t hwirq_base, int count);
167-
static inline int irq_domain_associate(struct irq_domain *domain, unsigned int irq,
168-
irq_hw_number_t hwirq)
169-
{
170-
return irq_domain_associate_many(domain, irq, hwirq, 1);
171-
}
170+
extern int irq_domain_associate(struct irq_domain *domain, unsigned int irq,
171+
irq_hw_number_t hwirq);
172+
extern void irq_domain_associate_many(struct irq_domain *domain,
173+
unsigned int irq_base,
174+
irq_hw_number_t hwirq_base, int count);
172175

173176
extern unsigned int irq_create_mapping(struct irq_domain *host,
174177
irq_hw_number_t hwirq);
175178
extern void irq_dispose_mapping(unsigned int virq);
179+
180+
/**
181+
* irq_linear_revmap() - Find a linux irq from a hw irq number.
182+
* @domain: domain owning this hardware interrupt
183+
* @hwirq: hardware irq number in that domain space
184+
*
185+
* This is a fast path alternative to irq_find_mapping() that can be
186+
* called directly by irq controller code to save a handful of
187+
* instructions. It is always safe to call, but won't find irqs mapped
188+
* using the radix tree.
189+
*/
190+
static inline unsigned int irq_linear_revmap(struct irq_domain *domain,
191+
irq_hw_number_t hwirq)
192+
{
193+
return hwirq < domain->revmap_size ? domain->linear_revmap[hwirq] : 0;
194+
}
176195
extern unsigned int irq_find_mapping(struct irq_domain *host,
177196
irq_hw_number_t hwirq);
178197
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,
186205
return irq_create_strict_mappings(host, hwirq, hwirq, 1);
187206
}
188207

189-
extern unsigned int irq_linear_revmap(struct irq_domain *host,
190-
irq_hw_number_t hwirq);
191-
192208
extern const struct irq_domain_ops irq_domain_simple_ops;
193209

194210
/* stock xlate functions */
@@ -202,14 +218,6 @@ int irq_domain_xlate_onetwocell(struct irq_domain *d, struct device_node *ctrlr,
202218
const u32 *intspec, unsigned int intsize,
203219
irq_hw_number_t *out_hwirq, unsigned int *out_type);
204220

205-
#if defined(CONFIG_OF_IRQ)
206-
extern void irq_domain_generate_simple(const struct of_device_id *match,
207-
u64 phys_base, unsigned int irq_start);
208-
#else /* CONFIG_OF_IRQ */
209-
static inline void irq_domain_generate_simple(const struct of_device_id *match,
210-
u64 phys_base, unsigned int irq_start) { }
211-
#endif /* !CONFIG_OF_IRQ */
212-
213221
#else /* CONFIG_IRQ_DOMAIN */
214222
static inline void irq_dispose_mapping(unsigned int virq) { }
215223
#endif /* !CONFIG_IRQ_DOMAIN */

‎kernel/irq/generic-chip.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,7 @@ int irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
275275
if (d->gc)
276276
return -EBUSY;
277277

278-
if (d->revmap_type != IRQ_DOMAIN_MAP_LINEAR)
279-
return -EINVAL;
280-
281-
numchips = d->revmap_data.linear.size / irqs_per_chip;
278+
numchips = d->revmap_size / irqs_per_chip;
282279
if (!numchips)
283280
return -EINVAL;
284281

@@ -310,6 +307,7 @@ int irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
310307
/* Calc pointer to the next generic chip */
311308
tmp += sizeof(*gc) + num_ct * sizeof(struct irq_chip_type);
312309
}
310+
d->name = name;
313311
return 0;
314312
}
315313
EXPORT_SYMBOL_GPL(irq_alloc_domain_generic_chips);

0 commit comments

Comments
 (0)