aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/irq/irqdomain.c219
1 files changed, 108 insertions, 111 deletions
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 8f7b91ce53c4..432d292b33f8 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -19,11 +19,11 @@ static DEFINE_MUTEX(irq_domain_mutex);
19#ifdef CONFIG_PPC 19#ifdef CONFIG_PPC
20static DEFINE_MUTEX(revmap_trees_mutex); 20static DEFINE_MUTEX(revmap_trees_mutex);
21static unsigned int irq_virq_count = NR_IRQS; 21static unsigned int irq_virq_count = NR_IRQS;
22static struct irq_domain *irq_default_host; 22static struct irq_domain *irq_default_domain;
23 23
24static int default_irq_host_match(struct irq_domain *h, struct device_node *np) 24static int default_irq_domain_match(struct irq_domain *d, struct device_node *np)
25{ 25{
26 return h->of_node != NULL && h->of_node == np; 26 return d->of_node != NULL && d->of_node == np;
27} 27}
28 28
29/** 29/**
@@ -31,8 +31,8 @@ static int default_irq_host_match(struct irq_domain *h, struct device_node *np)
31 * @of_node: optional device-tree node of the interrupt controller 31 * @of_node: optional device-tree node of the interrupt controller
32 * @revmap_type: type of reverse mapping to use 32 * @revmap_type: type of reverse mapping to use
33 * @revmap_arg: for IRQ_DOMAIN_MAP_LINEAR linear only: size of the map 33 * @revmap_arg: for IRQ_DOMAIN_MAP_LINEAR linear only: size of the map
34 * @ops: map/unmap host callbacks 34 * @ops: map/unmap domain callbacks
35 * @inval_irq: provide a hw number in that host space that is always invalid 35 * @inval_irq: provide a hw number in that domain space that is always invalid
36 * 36 *
37 * Allocates and initialize and irq_domain structure. Note that in the case of 37 * Allocates and initialize and irq_domain structure. Note that in the case of
38 * IRQ_DOMAIN_MAP_LEGACY, the map() callback will be called before this returns 38 * IRQ_DOMAIN_MAP_LEGACY, the map() callback will be called before this returns
@@ -48,7 +48,7 @@ struct irq_domain *irq_alloc_host(struct device_node *of_node,
48 struct irq_domain_ops *ops, 48 struct irq_domain_ops *ops,
49 irq_hw_number_t inval_irq) 49 irq_hw_number_t inval_irq)
50{ 50{
51 struct irq_domain *host, *h; 51 struct irq_domain *domain, *h;
52 unsigned int size = sizeof(struct irq_domain); 52 unsigned int size = sizeof(struct irq_domain);
53 unsigned int i; 53 unsigned int i;
54 unsigned int *rmap; 54 unsigned int *rmap;
@@ -56,18 +56,18 @@ struct irq_domain *irq_alloc_host(struct device_node *of_node,
56 /* Allocate structure and revmap table if using linear mapping */ 56 /* Allocate structure and revmap table if using linear mapping */
57 if (revmap_type == IRQ_DOMAIN_MAP_LINEAR) 57 if (revmap_type == IRQ_DOMAIN_MAP_LINEAR)
58 size += revmap_arg * sizeof(unsigned int); 58 size += revmap_arg * sizeof(unsigned int);
59 host = kzalloc(size, GFP_KERNEL); 59 domain = kzalloc(size, GFP_KERNEL);
60 if (host == NULL) 60 if (domain == NULL)
61 return NULL; 61 return NULL;
62 62
63 /* Fill structure */ 63 /* Fill structure */
64 host->revmap_type = revmap_type; 64 domain->revmap_type = revmap_type;
65 host->inval_irq = inval_irq; 65 domain->inval_irq = inval_irq;
66 host->ops = ops; 66 domain->ops = ops;
67 host->of_node = of_node_get(of_node); 67 domain->of_node = of_node_get(of_node);
68 68
69 if (host->ops->match == NULL) 69 if (domain->ops->match == NULL)
70 host->ops->match = default_irq_host_match; 70 domain->ops->match = default_irq_domain_match;
71 71
72 mutex_lock(&irq_domain_mutex); 72 mutex_lock(&irq_domain_mutex);
73 /* Make sure only one legacy controller can be created */ 73 /* Make sure only one legacy controller can be created */
@@ -75,53 +75,53 @@ struct irq_domain *irq_alloc_host(struct device_node *of_node,
75 list_for_each_entry(h, &irq_domain_list, link) { 75 list_for_each_entry(h, &irq_domain_list, link) {
76 if (WARN_ON(h->revmap_type == IRQ_DOMAIN_MAP_LEGACY)) { 76 if (WARN_ON(h->revmap_type == IRQ_DOMAIN_MAP_LEGACY)) {
77 mutex_unlock(&irq_domain_mutex); 77 mutex_unlock(&irq_domain_mutex);
78 of_node_put(host->of_node); 78 of_node_put(domain->of_node);
79 kfree(host); 79 kfree(domain);
80 return NULL; 80 return NULL;
81 } 81 }
82 } 82 }
83 } 83 }
84 list_add(&host->link, &irq_domain_list); 84 list_add(&domain->link, &irq_domain_list);
85 mutex_unlock(&irq_domain_mutex); 85 mutex_unlock(&irq_domain_mutex);
86 86
87 /* Additional setups per revmap type */ 87 /* Additional setups per revmap type */
88 switch(revmap_type) { 88 switch(revmap_type) {
89 case IRQ_DOMAIN_MAP_LEGACY: 89 case IRQ_DOMAIN_MAP_LEGACY:
90 /* 0 is always the invalid number for legacy */ 90 /* 0 is always the invalid number for legacy */
91 host->inval_irq = 0; 91 domain->inval_irq = 0;
92 /* setup us as the host for all legacy interrupts */ 92 /* setup us as the domain for all legacy interrupts */
93 for (i = 1; i < NUM_ISA_INTERRUPTS; i++) { 93 for (i = 1; i < NUM_ISA_INTERRUPTS; i++) {
94 struct irq_data *irq_data = irq_get_irq_data(i); 94 struct irq_data *irq_data = irq_get_irq_data(i);
95 irq_data->hwirq = i; 95 irq_data->hwirq = i;
96 irq_data->domain = host; 96 irq_data->domain = domain;
97 97
98 /* Legacy flags are left to default at this point, 98 /* Legacy flags are left to default at this point,
99 * one can then use irq_create_mapping() to 99 * one can then use irq_create_mapping() to
100 * explicitly change them 100 * explicitly change them
101 */ 101 */
102 ops->map(host, i, i); 102 ops->map(domain, i, i);
103 103
104 /* Clear norequest flags */ 104 /* Clear norequest flags */
105 irq_clear_status_flags(i, IRQ_NOREQUEST); 105 irq_clear_status_flags(i, IRQ_NOREQUEST);
106 } 106 }
107 break; 107 break;
108 case IRQ_DOMAIN_MAP_LINEAR: 108 case IRQ_DOMAIN_MAP_LINEAR:
109 rmap = (unsigned int *)(host + 1); 109 rmap = (unsigned int *)(domain + 1);
110 for (i = 0; i < revmap_arg; i++) 110 for (i = 0; i < revmap_arg; i++)
111 rmap[i] = 0; 111 rmap[i] = 0;
112 host->revmap_data.linear.size = revmap_arg; 112 domain->revmap_data.linear.size = revmap_arg;
113 host->revmap_data.linear.revmap = rmap; 113 domain->revmap_data.linear.revmap = rmap;
114 break; 114 break;
115 case IRQ_DOMAIN_MAP_TREE: 115 case IRQ_DOMAIN_MAP_TREE:
116 INIT_RADIX_TREE(&host->revmap_data.tree, GFP_KERNEL); 116 INIT_RADIX_TREE(&domain->revmap_data.tree, GFP_KERNEL);
117 break; 117 break;
118 default: 118 default:
119 break; 119 break;
120 } 120 }
121 121
122 pr_debug("irq: Allocated host of type %d @0x%p\n", revmap_type, host); 122 pr_debug("irq: Allocated domain of type %d @0x%p\n", revmap_type, domain);
123 123
124 return host; 124 return domain;
125} 125}
126 126
127/** 127/**
@@ -150,18 +150,18 @@ EXPORT_SYMBOL_GPL(irq_find_host);
150 150
151/** 151/**
152 * irq_set_default_host() - Set a "default" irq domain 152 * irq_set_default_host() - Set a "default" irq domain
153 * @host: default host pointer 153 * @domain: default domain pointer
154 * 154 *
155 * For convenience, it's possible to set a "default" domain that will be used 155 * For convenience, it's possible to set a "default" domain that will be used
156 * whenever NULL is passed to irq_create_mapping(). It makes life easier for 156 * whenever NULL is passed to irq_create_mapping(). It makes life easier for
157 * platforms that want to manipulate a few hard coded interrupt numbers that 157 * platforms that want to manipulate a few hard coded interrupt numbers that
158 * aren't properly represented in the device-tree. 158 * aren't properly represented in the device-tree.
159 */ 159 */
160void irq_set_default_host(struct irq_domain *host) 160void irq_set_default_host(struct irq_domain *domain)
161{ 161{
162 pr_debug("irq: Default host set to @0x%p\n", host); 162 pr_debug("irq: Default domain set to @0x%p\n", domain);
163 163
164 irq_default_host = host; 164 irq_default_domain = domain;
165} 165}
166 166
167/** 167/**
@@ -180,14 +180,14 @@ void irq_set_virq_count(unsigned int count)
180 irq_virq_count = count; 180 irq_virq_count = count;
181} 181}
182 182
183static int irq_setup_virq(struct irq_domain *host, unsigned int virq, 183static int irq_setup_virq(struct irq_domain *domain, unsigned int virq,
184 irq_hw_number_t hwirq) 184 irq_hw_number_t hwirq)
185{ 185{
186 struct irq_data *irq_data = irq_get_irq_data(virq); 186 struct irq_data *irq_data = irq_get_irq_data(virq);
187 187
188 irq_data->hwirq = hwirq; 188 irq_data->hwirq = hwirq;
189 irq_data->domain = host; 189 irq_data->domain = domain;
190 if (host->ops->map(host, virq, hwirq)) { 190 if (domain->ops->map(domain, virq, hwirq)) {
191 pr_debug("irq: -> mapping failed, freeing\n"); 191 pr_debug("irq: -> mapping failed, freeing\n");
192 irq_data->domain = NULL; 192 irq_data->domain = NULL;
193 irq_data->hwirq = 0; 193 irq_data->hwirq = 0;
@@ -201,21 +201,21 @@ static int irq_setup_virq(struct irq_domain *host, unsigned int virq,
201 201
202/** 202/**
203 * irq_create_direct_mapping() - Allocate an irq for direct mapping 203 * irq_create_direct_mapping() - Allocate an irq for direct mapping
204 * @host: domain to allocate the irq for or NULL for default host 204 * @domain: domain to allocate the irq for or NULL for default domain
205 * 205 *
206 * This routine is used for irq controllers which can choose the hardware 206 * This routine is used for irq controllers which can choose the hardware
207 * interrupt numbers they generate. In such a case it's simplest to use 207 * interrupt numbers they generate. In such a case it's simplest to use
208 * the linux irq as the hardware interrupt number. 208 * the linux irq as the hardware interrupt number.
209 */ 209 */
210unsigned int irq_create_direct_mapping(struct irq_domain *host) 210unsigned int irq_create_direct_mapping(struct irq_domain *domain)
211{ 211{
212 unsigned int virq; 212 unsigned int virq;
213 213
214 if (host == NULL) 214 if (domain == NULL)
215 host = irq_default_host; 215 domain = irq_default_domain;
216 216
217 BUG_ON(host == NULL); 217 BUG_ON(domain == NULL);
218 WARN_ON(host->revmap_type != IRQ_DOMAIN_MAP_NOMAP); 218 WARN_ON(domain->revmap_type != IRQ_DOMAIN_MAP_NOMAP);
219 219
220 virq = irq_alloc_desc_from(1, 0); 220 virq = irq_alloc_desc_from(1, 0);
221 if (!virq) { 221 if (!virq) {
@@ -231,7 +231,7 @@ unsigned int irq_create_direct_mapping(struct irq_domain *host)
231 231
232 pr_debug("irq: create_direct obtained virq %d\n", virq); 232 pr_debug("irq: create_direct obtained virq %d\n", virq);
233 233
234 if (irq_setup_virq(host, virq, virq)) { 234 if (irq_setup_virq(domain, virq, virq)) {
235 irq_free_desc(virq); 235 irq_free_desc(virq);
236 return 0; 236 return 0;
237 } 237 }
@@ -241,41 +241,41 @@ unsigned int irq_create_direct_mapping(struct irq_domain *host)
241 241
242/** 242/**
243 * irq_create_mapping() - Map a hardware interrupt into linux irq space 243 * irq_create_mapping() - Map a hardware interrupt into linux irq space
244 * @host: host owning this hardware interrupt or NULL for default host 244 * @domain: domain owning this hardware interrupt or NULL for default domain
245 * @hwirq: hardware irq number in that host space 245 * @hwirq: hardware irq number in that domain space
246 * 246 *
247 * Only one mapping per hardware interrupt is permitted. Returns a linux 247 * Only one mapping per hardware interrupt is permitted. Returns a linux
248 * irq number. 248 * irq number.
249 * If the sense/trigger is to be specified, set_irq_type() should be called 249 * If the sense/trigger is to be specified, set_irq_type() should be called
250 * on the number returned from that call. 250 * on the number returned from that call.
251 */ 251 */
252unsigned int irq_create_mapping(struct irq_domain *host, 252unsigned int irq_create_mapping(struct irq_domain *domain,
253 irq_hw_number_t hwirq) 253 irq_hw_number_t hwirq)
254{ 254{
255 unsigned int virq, hint; 255 unsigned int virq, hint;
256 256
257 pr_debug("irq: irq_create_mapping(0x%p, 0x%lx)\n", host, hwirq); 257 pr_debug("irq: irq_create_mapping(0x%p, 0x%lx)\n", domain, hwirq);
258 258
259 /* Look for default host if nececssary */ 259 /* Look for default domain if nececssary */
260 if (host == NULL) 260 if (domain == NULL)
261 host = irq_default_host; 261 domain = irq_default_domain;
262 if (host == NULL) { 262 if (domain == NULL) {
263 printk(KERN_WARNING "irq_create_mapping called for" 263 printk(KERN_WARNING "irq_create_mapping called for"
264 " NULL host, hwirq=%lx\n", hwirq); 264 " NULL domain, hwirq=%lx\n", hwirq);
265 WARN_ON(1); 265 WARN_ON(1);
266 return 0; 266 return 0;
267 } 267 }
268 pr_debug("irq: -> using host @%p\n", host); 268 pr_debug("irq: -> using domain @%p\n", domain);
269 269
270 /* Check if mapping already exists */ 270 /* Check if mapping already exists */
271 virq = irq_find_mapping(host, hwirq); 271 virq = irq_find_mapping(domain, hwirq);
272 if (virq) { 272 if (virq) {
273 pr_debug("irq: -> existing mapping on virq %d\n", virq); 273 pr_debug("irq: -> existing mapping on virq %d\n", virq);
274 return virq; 274 return virq;
275 } 275 }
276 276
277 /* Get a virtual interrupt number */ 277 /* Get a virtual interrupt number */
278 if (host->revmap_type == IRQ_DOMAIN_MAP_LEGACY) { 278 if (domain->revmap_type == IRQ_DOMAIN_MAP_LEGACY) {
279 /* Handle legacy */ 279 /* Handle legacy */
280 virq = (unsigned int)hwirq; 280 virq = (unsigned int)hwirq;
281 if (virq == 0 || virq >= NUM_ISA_INTERRUPTS) 281 if (virq == 0 || virq >= NUM_ISA_INTERRUPTS)
@@ -295,14 +295,14 @@ unsigned int irq_create_mapping(struct irq_domain *host,
295 } 295 }
296 } 296 }
297 297
298 if (irq_setup_virq(host, virq, hwirq)) { 298 if (irq_setup_virq(domain, virq, hwirq)) {
299 if (host->revmap_type != IRQ_DOMAIN_MAP_LEGACY) 299 if (domain->revmap_type != IRQ_DOMAIN_MAP_LEGACY)
300 irq_free_desc(virq); 300 irq_free_desc(virq);
301 return 0; 301 return 0;
302 } 302 }
303 303
304 pr_debug("irq: irq %lu on host %s mapped to virtual irq %u\n", 304 pr_debug("irq: irq %lu on domain %s mapped to virtual irq %u\n",
305 hwirq, host->of_node ? host->of_node->full_name : "null", virq); 305 hwirq, domain->of_node ? domain->of_node->full_name : "null", virq);
306 306
307 return virq; 307 return virq;
308} 308}
@@ -311,32 +311,29 @@ EXPORT_SYMBOL_GPL(irq_create_mapping);
311unsigned int irq_create_of_mapping(struct device_node *controller, 311unsigned int irq_create_of_mapping(struct device_node *controller,
312 const u32 *intspec, unsigned int intsize) 312 const u32 *intspec, unsigned int intsize)
313{ 313{
314 struct irq_domain *host; 314 struct irq_domain *domain;
315 irq_hw_number_t hwirq; 315 irq_hw_number_t hwirq;
316 unsigned int type = IRQ_TYPE_NONE; 316 unsigned int type = IRQ_TYPE_NONE;
317 unsigned int virq; 317 unsigned int virq;
318 318
319 if (controller == NULL) 319 domain = controller ? irq_find_host(controller) : irq_default_domain;
320 host = irq_default_host; 320 if (!domain) {
321 else 321 printk(KERN_WARNING "irq: no irq domain found for %s !\n",
322 host = irq_find_host(controller);
323 if (host == NULL) {
324 printk(KERN_WARNING "irq: no irq host found for %s !\n",
325 controller->full_name); 322 controller->full_name);
326 return 0; 323 return 0;
327 } 324 }
328 325
329 /* If host has no translation, then we assume interrupt line */ 326 /* If domain has no translation, then we assume interrupt line */
330 if (host->ops->xlate == NULL) 327 if (domain->ops->xlate == NULL)
331 hwirq = intspec[0]; 328 hwirq = intspec[0];
332 else { 329 else {
333 if (host->ops->xlate(host, controller, intspec, intsize, 330 if (domain->ops->xlate(domain, controller, intspec, intsize,
334 &hwirq, &type)) 331 &hwirq, &type))
335 return 0; 332 return 0;
336 } 333 }
337 334
338 /* Create mapping */ 335 /* Create mapping */
339 virq = irq_create_mapping(host, hwirq); 336 virq = irq_create_mapping(domain, hwirq);
340 if (!virq) 337 if (!virq)
341 return virq; 338 return virq;
342 339
@@ -355,18 +352,18 @@ EXPORT_SYMBOL_GPL(irq_create_of_mapping);
355void irq_dispose_mapping(unsigned int virq) 352void irq_dispose_mapping(unsigned int virq)
356{ 353{
357 struct irq_data *irq_data = irq_get_irq_data(virq); 354 struct irq_data *irq_data = irq_get_irq_data(virq);
358 struct irq_domain *host; 355 struct irq_domain *domain;
359 irq_hw_number_t hwirq; 356 irq_hw_number_t hwirq;
360 357
361 if (!virq || !irq_data) 358 if (!virq || !irq_data)
362 return; 359 return;
363 360
364 host = irq_data->domain; 361 domain = irq_data->domain;
365 if (WARN_ON(host == NULL)) 362 if (WARN_ON(domain == NULL))
366 return; 363 return;
367 364
368 /* Never unmap legacy interrupts */ 365 /* Never unmap legacy interrupts */
369 if (host->revmap_type == IRQ_DOMAIN_MAP_LEGACY) 366 if (domain->revmap_type == IRQ_DOMAIN_MAP_LEGACY)
370 return; 367 return;
371 368
372 irq_set_status_flags(virq, IRQ_NOREQUEST); 369 irq_set_status_flags(virq, IRQ_NOREQUEST);
@@ -378,26 +375,26 @@ void irq_dispose_mapping(unsigned int virq)
378 synchronize_irq(virq); 375 synchronize_irq(virq);
379 376
380 /* Tell the PIC about it */ 377 /* Tell the PIC about it */
381 if (host->ops->unmap) 378 if (domain->ops->unmap)
382 host->ops->unmap(host, virq); 379 domain->ops->unmap(domain, virq);
383 smp_mb(); 380 smp_mb();
384 381
385 /* Clear reverse map */ 382 /* Clear reverse map */
386 hwirq = irq_data->hwirq; 383 hwirq = irq_data->hwirq;
387 switch(host->revmap_type) { 384 switch(domain->revmap_type) {
388 case IRQ_DOMAIN_MAP_LINEAR: 385 case IRQ_DOMAIN_MAP_LINEAR:
389 if (hwirq < host->revmap_data.linear.size) 386 if (hwirq < domain->revmap_data.linear.size)
390 host->revmap_data.linear.revmap[hwirq] = 0; 387 domain->revmap_data.linear.revmap[hwirq] = 0;
391 break; 388 break;
392 case IRQ_DOMAIN_MAP_TREE: 389 case IRQ_DOMAIN_MAP_TREE:
393 mutex_lock(&revmap_trees_mutex); 390 mutex_lock(&revmap_trees_mutex);
394 radix_tree_delete(&host->revmap_data.tree, hwirq); 391 radix_tree_delete(&domain->revmap_data.tree, hwirq);
395 mutex_unlock(&revmap_trees_mutex); 392 mutex_unlock(&revmap_trees_mutex);
396 break; 393 break;
397 } 394 }
398 395
399 /* Destroy map */ 396 /* Destroy map */
400 irq_data->hwirq = host->inval_irq; 397 irq_data->hwirq = domain->inval_irq;
401 398
402 irq_free_desc(virq); 399 irq_free_desc(virq);
403} 400}
@@ -405,27 +402,27 @@ EXPORT_SYMBOL_GPL(irq_dispose_mapping);
405 402
406/** 403/**
407 * irq_find_mapping() - Find a linux irq from an hw irq number. 404 * irq_find_mapping() - Find a linux irq from an hw irq number.
408 * @host: domain owning this hardware interrupt 405 * @domain: domain owning this hardware interrupt
409 * @hwirq: hardware irq number in that host space 406 * @hwirq: hardware irq number in that domain space
410 * 407 *
411 * This is a slow path, for use by generic code. It's expected that an 408 * This is a slow path, for use by generic code. It's expected that an
412 * irq controller implementation directly calls the appropriate low level 409 * irq controller implementation directly calls the appropriate low level
413 * mapping function. 410 * mapping function.
414 */ 411 */
415unsigned int irq_find_mapping(struct irq_domain *host, 412unsigned int irq_find_mapping(struct irq_domain *domain,
416 irq_hw_number_t hwirq) 413 irq_hw_number_t hwirq)
417{ 414{
418 unsigned int i; 415 unsigned int i;
419 unsigned int hint = hwirq % irq_virq_count; 416 unsigned int hint = hwirq % irq_virq_count;
420 417
421 /* Look for default host if nececssary */ 418 /* Look for default domain if nececssary */
422 if (host == NULL) 419 if (domain == NULL)
423 host = irq_default_host; 420 domain = irq_default_domain;
424 if (host == NULL) 421 if (domain == NULL)
425 return 0; 422 return 0;
426 423
427 /* legacy -> bail early */ 424 /* legacy -> bail early */
428 if (host->revmap_type == IRQ_DOMAIN_MAP_LEGACY) 425 if (domain->revmap_type == IRQ_DOMAIN_MAP_LEGACY)
429 return hwirq; 426 return hwirq;
430 427
431 /* Slow path does a linear search of the map */ 428 /* Slow path does a linear search of the map */
@@ -434,7 +431,7 @@ unsigned int irq_find_mapping(struct irq_domain *host,
434 i = hint; 431 i = hint;
435 do { 432 do {
436 struct irq_data *data = irq_get_irq_data(i); 433 struct irq_data *data = irq_get_irq_data(i);
437 if (data && (data->domain == host) && (data->hwirq == hwirq)) 434 if (data && (data->domain == domain) && (data->hwirq == hwirq))
438 return i; 435 return i;
439 i++; 436 i++;
440 if (i >= irq_virq_count) 437 if (i >= irq_virq_count)
@@ -446,26 +443,26 @@ EXPORT_SYMBOL_GPL(irq_find_mapping);
446 443
447/** 444/**
448 * irq_radix_revmap_lookup() - Find a linux irq from a hw irq number. 445 * irq_radix_revmap_lookup() - Find a linux irq from a hw irq number.
449 * @host: host owning this hardware interrupt 446 * @domain: domain owning this hardware interrupt
450 * @hwirq: hardware irq number in that host space 447 * @hwirq: hardware irq number in that domain space
451 * 448 *
452 * This is a fast path, for use by irq controller code that uses radix tree 449 * This is a fast path, for use by irq controller code that uses radix tree
453 * revmaps 450 * revmaps
454 */ 451 */
455unsigned int irq_radix_revmap_lookup(struct irq_domain *host, 452unsigned int irq_radix_revmap_lookup(struct irq_domain *domain,
456 irq_hw_number_t hwirq) 453 irq_hw_number_t hwirq)
457{ 454{
458 struct irq_data *irq_data; 455 struct irq_data *irq_data;
459 456
460 if (WARN_ON_ONCE(host->revmap_type != IRQ_DOMAIN_MAP_TREE)) 457 if (WARN_ON_ONCE(domain->revmap_type != IRQ_DOMAIN_MAP_TREE))
461 return irq_find_mapping(host, hwirq); 458 return irq_find_mapping(domain, hwirq);
462 459
463 /* 460 /*
464 * Freeing an irq can delete nodes along the path to 461 * Freeing an irq can delete nodes along the path to
465 * do the lookup via call_rcu. 462 * do the lookup via call_rcu.
466 */ 463 */
467 rcu_read_lock(); 464 rcu_read_lock();
468 irq_data = radix_tree_lookup(&host->revmap_data.tree, hwirq); 465 irq_data = radix_tree_lookup(&domain->revmap_data.tree, hwirq);
469 rcu_read_unlock(); 466 rcu_read_unlock();
470 467
471 /* 468 /*
@@ -473,62 +470,62 @@ unsigned int irq_radix_revmap_lookup(struct irq_domain *host,
473 * Else fallback to linear lookup - this should not happen in practice 470 * Else fallback to linear lookup - this should not happen in practice
474 * as it means that we failed to insert the node in the radix tree. 471 * as it means that we failed to insert the node in the radix tree.
475 */ 472 */
476 return irq_data ? irq_data->irq : irq_find_mapping(host, hwirq); 473 return irq_data ? irq_data->irq : irq_find_mapping(domain, hwirq);
477} 474}
478 475
479/** 476/**
480 * irq_radix_revmap_insert() - Insert a hw irq to linux irq number mapping. 477 * irq_radix_revmap_insert() - Insert a hw irq to linux irq number mapping.
481 * @host: host owning this hardware interrupt 478 * @domain: domain owning this hardware interrupt
482 * @virq: linux irq number 479 * @virq: linux irq number
483 * @hwirq: hardware irq number in that host space 480 * @hwirq: hardware irq number in that domain space
484 * 481 *
485 * This is for use by irq controllers that use a radix tree reverse 482 * This is for use by irq controllers that use a radix tree reverse
486 * mapping for fast lookup. 483 * mapping for fast lookup.
487 */ 484 */
488void irq_radix_revmap_insert(struct irq_domain *host, unsigned int virq, 485void irq_radix_revmap_insert(struct irq_domain *domain, unsigned int virq,
489 irq_hw_number_t hwirq) 486 irq_hw_number_t hwirq)
490{ 487{
491 struct irq_data *irq_data = irq_get_irq_data(virq); 488 struct irq_data *irq_data = irq_get_irq_data(virq);
492 489
493 if (WARN_ON(host->revmap_type != IRQ_DOMAIN_MAP_TREE)) 490 if (WARN_ON(domain->revmap_type != IRQ_DOMAIN_MAP_TREE))
494 return; 491 return;
495 492
496 if (virq) { 493 if (virq) {
497 mutex_lock(&revmap_trees_mutex); 494 mutex_lock(&revmap_trees_mutex);
498 radix_tree_insert(&host->revmap_data.tree, hwirq, irq_data); 495 radix_tree_insert(&domain->revmap_data.tree, hwirq, irq_data);
499 mutex_unlock(&revmap_trees_mutex); 496 mutex_unlock(&revmap_trees_mutex);
500 } 497 }
501} 498}
502 499
503/** 500/**
504 * irq_linear_revmap() - Find a linux irq from a hw irq number. 501 * irq_linear_revmap() - Find a linux irq from a hw irq number.
505 * @host: host owning this hardware interrupt 502 * @domain: domain owning this hardware interrupt
506 * @hwirq: hardware irq number in that host space 503 * @hwirq: hardware irq number in that domain space
507 * 504 *
508 * This is a fast path, for use by irq controller code that uses linear 505 * This is a fast path, for use by irq controller code that uses linear
509 * revmaps. It does fallback to the slow path if the revmap doesn't exist 506 * revmaps. It does fallback to the slow path if the revmap doesn't exist
510 * yet and will create the revmap entry with appropriate locking 507 * yet and will create the revmap entry with appropriate locking
511 */ 508 */
512unsigned int irq_linear_revmap(struct irq_domain *host, 509unsigned int irq_linear_revmap(struct irq_domain *domain,
513 irq_hw_number_t hwirq) 510 irq_hw_number_t hwirq)
514{ 511{
515 unsigned int *revmap; 512 unsigned int *revmap;
516 513
517 if (WARN_ON_ONCE(host->revmap_type != IRQ_DOMAIN_MAP_LINEAR)) 514 if (WARN_ON_ONCE(domain->revmap_type != IRQ_DOMAIN_MAP_LINEAR))
518 return irq_find_mapping(host, hwirq); 515 return irq_find_mapping(domain, hwirq);
519 516
520 /* Check revmap bounds */ 517 /* Check revmap bounds */
521 if (unlikely(hwirq >= host->revmap_data.linear.size)) 518 if (unlikely(hwirq >= domain->revmap_data.linear.size))
522 return irq_find_mapping(host, hwirq); 519 return irq_find_mapping(domain, hwirq);
523 520
524 /* Check if revmap was allocated */ 521 /* Check if revmap was allocated */
525 revmap = host->revmap_data.linear.revmap; 522 revmap = domain->revmap_data.linear.revmap;
526 if (unlikely(revmap == NULL)) 523 if (unlikely(revmap == NULL))
527 return irq_find_mapping(host, hwirq); 524 return irq_find_mapping(domain, hwirq);
528 525
529 /* Fill up revmap with slow path if no mapping found */ 526 /* Fill up revmap with slow path if no mapping found */
530 if (unlikely(!revmap[hwirq])) 527 if (unlikely(!revmap[hwirq]))
531 revmap[hwirq] = irq_find_mapping(host, hwirq); 528 revmap[hwirq] = irq_find_mapping(domain, hwirq);
532 529
533 return revmap[hwirq]; 530 return revmap[hwirq];
534} 531}
@@ -544,7 +541,7 @@ static int virq_debug_show(struct seq_file *m, void *private)
544 int i; 541 int i;
545 542
546 seq_printf(m, "%-5s %-7s %-15s %-18s %s\n", "virq", "hwirq", 543 seq_printf(m, "%-5s %-7s %-15s %-18s %s\n", "virq", "hwirq",
547 "chip name", "chip data", "host name"); 544 "chip name", "chip data", "domain name");
548 545
549 for (i = 1; i < nr_irqs; i++) { 546 for (i = 1; i < nr_irqs; i++) {
550 desc = irq_to_desc(i); 547 desc = irq_to_desc(i);