diff options
| author | Marc Zyngier <marc.zyngier@arm.com> | 2014-08-26 06:03:16 -0400 |
|---|---|---|
| committer | Jason Cooper <jason@lakedaemon.net> | 2014-09-03 08:57:27 -0400 |
| commit | 76ba59f8366f2d9282cb5bda9de75b4b68cbe55f (patch) | |
| tree | 567c5a7b10fb8f7a1e597a8cc83c0afe92dbce50 /kernel/irq | |
| parent | 7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9 (diff) | |
genirq: Add irq_domain-aware core IRQ handler
Calling irq_find_mapping from outside a irq_{enter,exit} section is
unsafe and produces ugly messages if CONFIG_PROVE_RCU is enabled:
If coming from the idle state, the rcu_read_lock call in irq_find_mapping
will generate an unpleasant warning:
<quote>
===============================
[ INFO: suspicious RCU usage. ]
3.16.0-rc1+ #135 Not tainted
-------------------------------
include/linux/rcupdate.h:871 rcu_read_lock() used illegally while idle!
other info that might help us debug this:
RCU used illegally from idle CPU!
rcu_scheduler_active = 1, debug_locks = 0
RCU used illegally from extended quiescent state!
1 lock held by swapper/0/0:
#0: (rcu_read_lock){......}, at: [<ffffffc00010206c>]
irq_find_mapping+0x4c/0x198
</quote>
As this issue is fairly widespread and involves at least three
different architectures, a possible solution is to add a new
handle_domain_irq entry point into the generic IRQ code that
the interrupt controller code can call.
This new function takes an irq_domain, and calls into irq_find_domain
inside the irq_{enter,exit} block. An additional "lookup" parameter is
used to allow non-domain architecture code to be replaced by this as well.
Interrupt controllers can then be updated to use the new mechanism.
This code is sitting behind a new CONFIG_HANDLE_DOMAIN_IRQ, as not all
architectures implement set_irq_regs (yes, mn10300, I'm looking at you...).
Reported-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Link: https://lkml.kernel.org/r/1409047421-27649-2-git-send-email-marc.zyngier@arm.com
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
Diffstat (limited to 'kernel/irq')
| -rw-r--r-- | kernel/irq/Kconfig | 3 | ||||
| -rw-r--r-- | kernel/irq/irqdesc.c | 42 |
2 files changed, 45 insertions, 0 deletions
diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig index d269cecdfbf0..225086b2652e 100644 --- a/kernel/irq/Kconfig +++ b/kernel/irq/Kconfig | |||
| @@ -55,6 +55,9 @@ config GENERIC_IRQ_CHIP | |||
| 55 | config IRQ_DOMAIN | 55 | config IRQ_DOMAIN |
| 56 | bool | 56 | bool |
| 57 | 57 | ||
| 58 | config HANDLE_DOMAIN_IRQ | ||
| 59 | bool | ||
| 60 | |||
| 58 | config IRQ_DOMAIN_DEBUG | 61 | config IRQ_DOMAIN_DEBUG |
| 59 | bool "Expose hardware/virtual IRQ mapping via debugfs" | 62 | bool "Expose hardware/virtual IRQ mapping via debugfs" |
| 60 | depends on IRQ_DOMAIN && DEBUG_FS | 63 | depends on IRQ_DOMAIN && DEBUG_FS |
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index 1487a123db5c..a1782f88f0af 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include <linux/kernel_stat.h> | 14 | #include <linux/kernel_stat.h> |
| 15 | #include <linux/radix-tree.h> | 15 | #include <linux/radix-tree.h> |
| 16 | #include <linux/bitmap.h> | 16 | #include <linux/bitmap.h> |
| 17 | #include <linux/irqdomain.h> | ||
| 17 | 18 | ||
| 18 | #include "internals.h" | 19 | #include "internals.h" |
| 19 | 20 | ||
| @@ -336,6 +337,47 @@ int generic_handle_irq(unsigned int irq) | |||
| 336 | } | 337 | } |
| 337 | EXPORT_SYMBOL_GPL(generic_handle_irq); | 338 | EXPORT_SYMBOL_GPL(generic_handle_irq); |
| 338 | 339 | ||
| 340 | #ifdef CONFIG_HANDLE_DOMAIN_IRQ | ||
| 341 | /** | ||
| 342 | * __handle_domain_irq - Invoke the handler for a HW irq belonging to a domain | ||
| 343 | * @domain: The domain where to perform the lookup | ||
| 344 | * @hwirq: The HW irq number to convert to a logical one | ||
| 345 | * @lookup: Whether to perform the domain lookup or not | ||
| 346 | * @regs: Register file coming from the low-level handling code | ||
| 347 | * | ||
| 348 | * Returns: 0 on success, or -EINVAL if conversion has failed | ||
| 349 | */ | ||
| 350 | int __handle_domain_irq(struct irq_domain *domain, unsigned int hwirq, | ||
| 351 | bool lookup, struct pt_regs *regs) | ||
| 352 | { | ||
| 353 | struct pt_regs *old_regs = set_irq_regs(regs); | ||
| 354 | unsigned int irq = hwirq; | ||
| 355 | int ret = 0; | ||
| 356 | |||
| 357 | irq_enter(); | ||
| 358 | |||
| 359 | #ifdef CONFIG_IRQ_DOMAIN | ||
| 360 | if (lookup) | ||
| 361 | irq = irq_find_mapping(domain, hwirq); | ||
| 362 | #endif | ||
| 363 | |||
| 364 | /* | ||
| 365 | * Some hardware gives randomly wrong interrupts. Rather | ||
| 366 | * than crashing, do something sensible. | ||
| 367 | */ | ||
| 368 | if (unlikely(!irq || irq >= nr_irqs)) { | ||
| 369 | ack_bad_irq(irq); | ||
| 370 | ret = -EINVAL; | ||
| 371 | } else { | ||
| 372 | generic_handle_irq(irq); | ||
| 373 | } | ||
| 374 | |||
| 375 | irq_exit(); | ||
| 376 | set_irq_regs(old_regs); | ||
| 377 | return ret; | ||
| 378 | } | ||
| 379 | #endif | ||
| 380 | |||
| 339 | /* Dynamic interrupt handling */ | 381 | /* Dynamic interrupt handling */ |
| 340 | 382 | ||
| 341 | /** | 383 | /** |
