Lines Matching full:irq
6 * This file contains driver APIs to the irq subsystem.
11 #include <linux/irq.h>
79 * synchronize_hardirq - wait for pending hard IRQ handlers (on other CPUs)
80 * @irq: interrupt number to wait for
82 * This function waits for any pending hard IRQ handlers for this
84 * function while holding a resource the IRQ handler may need you
93 * This function may be called - with care - from IRQ context.
100 bool synchronize_hardirq(unsigned int irq) in synchronize_hardirq() argument
102 struct irq_desc *desc = irq_to_desc(irq); in synchronize_hardirq()
124 * synchronize_irq - wait for pending IRQ handlers (on other CPUs)
125 * @irq: interrupt number to wait for
127 * This function waits for any pending IRQ handlers for this interrupt
129 * holding a resource the IRQ handler may need you will deadlock.
132 * an interrupt thread is associated to @irq.
134 * It optionally makes sure (when the irq chip supports that method)
138 void synchronize_irq(unsigned int irq) in synchronize_irq() argument
140 struct irq_desc *desc = irq_to_desc(irq); in synchronize_irq()
159 * irq_can_set_affinity - Check if the affinity of a given irq can be set
160 * @irq: Interrupt to check
163 int irq_can_set_affinity(unsigned int irq) in irq_can_set_affinity() argument
165 return __irq_can_set_affinity(irq_to_desc(irq)); in irq_can_set_affinity()
169 * irq_can_set_affinity_usr - Check if affinity of a irq can be set from user space
170 * @irq: Interrupt to check
175 bool irq_can_set_affinity_usr(unsigned int irq) in irq_can_set_affinity_usr() argument
177 struct irq_desc *desc = irq_to_desc(irq); in irq_can_set_affinity_usr()
184 * irq_set_thread_affinity - Notify irq threads to adjust affinity
185 * @desc: irq descriptor which has affinity changed
216 pr_warn_once("irq_chip %s did not update eff. affinity mask of irq %u\n", in irq_validate_effective_affinity()
217 chip->name, data->irq); in irq_validate_effective_affinity()
337 * Handle irq chips which can handle affinity only in activated in irq_set_affinity_deactivated()
390 * @irq: The interrupt number to update
397 * for when the kernel is configured for generic IRQ reservation mode (in
403 int irq_update_affinity_desc(unsigned int irq, in irq_update_affinity_desc() argument
418 desc = irq_get_desc_buslock(irq, &flags, 0); in irq_update_affinity_desc()
458 static int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, in __irq_set_affinity() argument
461 struct irq_desc *desc = irq_to_desc(irq); in __irq_set_affinity()
475 * irq_set_affinity - Set the irq affinity of a given irq
476 * @irq: Interrupt to set affinity
481 int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask) in irq_set_affinity() argument
483 return __irq_set_affinity(irq, cpumask, false); in irq_set_affinity()
488 * irq_force_affinity - Force the irq affinity of a given irq
489 * @irq: Interrupt to set affinity
498 int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask) in irq_force_affinity() argument
500 return __irq_set_affinity(irq, cpumask, true); in irq_force_affinity()
504 int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m, in __irq_apply_affinity_hint() argument
508 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); in __irq_apply_affinity_hint()
515 __irq_set_affinity(irq, m, false); in __irq_apply_affinity_hint()
524 struct irq_desc *desc = irq_to_desc(notify->irq); in irq_affinity_notify()
546 * irq_set_affinity_notifier - control notification of IRQ affinity changes
547 * @irq: Interrupt for which to enable/disable notification
553 * after the IRQ is allocated and must be disabled before the IRQ is
557 irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify) in irq_set_affinity_notifier() argument
559 struct irq_desc *desc = irq_to_desc(irq); in irq_set_affinity_notifier()
571 notify->irq = irq; in irq_set_affinity_notifier()
649 * @irq: interrupt number to set affinity
654 * affinity for an irq. The vCPU specific data is passed from
658 int irq_set_vcpu_affinity(unsigned int irq, void *vcpu_info) in irq_set_vcpu_affinity() argument
661 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); in irq_set_vcpu_affinity()
695 static int __disable_irq_nosync(unsigned int irq) in __disable_irq_nosync() argument
698 struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); in __disable_irq_nosync()
708 * disable_irq_nosync - disable an irq without waiting
709 * @irq: Interrupt to disable
714 * instances of the IRQ handler have completed before returning.
716 * This function may be called from IRQ context.
718 void disable_irq_nosync(unsigned int irq) in disable_irq_nosync() argument
720 __disable_irq_nosync(irq); in disable_irq_nosync()
725 * disable_irq - disable an irq and wait for completion
726 * @irq: Interrupt to disable
730 * This function waits for any pending IRQ handlers for this interrupt
732 * holding a resource the IRQ handler may need you will deadlock.
735 * an interrupt thread is associated to @irq.
738 void disable_irq(unsigned int irq) in disable_irq() argument
741 if (!__disable_irq_nosync(irq)) in disable_irq()
742 synchronize_irq(irq); in disable_irq()
747 * disable_hardirq - disables an irq and waits for hardirq completion
748 * @irq: Interrupt to disable
752 * This function waits for any pending hard IRQ handlers for this
754 * holding a resource the hard IRQ handler may need you will deadlock.
761 * This function may be called - with care - from IRQ context.
763 bool disable_hardirq(unsigned int irq) in disable_hardirq() argument
765 if (!__disable_irq_nosync(irq)) in disable_hardirq()
766 return synchronize_hardirq(irq); in disable_hardirq()
774 * @irq: Interrupt to disable
780 * instances of the IRQ handler have completed before returning.
782 void disable_nmi_nosync(unsigned int irq) in disable_nmi_nosync() argument
784 disable_irq_nosync(irq); in disable_nmi_nosync()
792 WARN(1, KERN_WARNING "Unbalanced enable for IRQ %d\n", in __enable_irq()
798 /* Prevent probing on this irq: */ in __enable_irq()
820 * enable_irq - enable handling of an irq
821 * @irq: Interrupt to enable
825 * IRQ line is re-enabled.
827 * This function may be called from IRQ context only when
830 void enable_irq(unsigned int irq) in enable_irq() argument
833 struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); in enable_irq()
838 KERN_ERR "enable_irq before setup/request_irq: irq %u\n", irq)) in enable_irq()
849 * @irq: Interrupt to enable
854 * IRQ line is re-enabled.
856 void enable_nmi(unsigned int irq) in enable_nmi() argument
858 enable_irq(irq); in enable_nmi()
861 static int set_irq_wake_real(unsigned int irq, unsigned int on) in set_irq_wake_real() argument
863 struct irq_desc *desc = irq_to_desc(irq); in set_irq_wake_real()
876 * irq_set_irq_wake - control irq power management wakeup
877 * @irq: interrupt to control
884 * Wakeup mode lets this IRQ wake the system from sleep
887 * Note: irq enable/disable state is completely orthogonal
888 * to the enable/disable state of irq wake. An irq can be
890 * long as the irq has wake enabled. If this does not hold,
891 * then the underlying irq chip and the related driver need
894 int irq_set_irq_wake(unsigned int irq, unsigned int on) in irq_set_irq_wake() argument
897 struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); in irq_set_irq_wake()
914 ret = set_irq_wake_real(irq, on); in irq_set_irq_wake()
922 WARN(1, "Unbalanced IRQ %d wake disable\n", irq); in irq_set_irq_wake()
924 ret = set_irq_wake_real(irq, on); in irq_set_irq_wake()
940 * particular irq has been exclusively allocated or is available
943 int can_request_irq(unsigned int irq, unsigned long irqflags) in can_request_irq() argument
946 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); in can_request_irq()
971 pr_debug("No set_type function for IRQ %d (%s)\n", in __irq_set_trigger()
1008 pr_err("Setting trigger mode %lu for irq %u failed (%pS)\n", in __irq_set_trigger()
1017 int irq_set_parent(int irq, int parent_irq) in irq_set_parent() argument
1020 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); in irq_set_parent()
1038 static irqreturn_t irq_default_primary_handler(int irq, void *dev_id) in irq_default_primary_handler() argument
1047 static irqreturn_t irq_nested_primary_handler(int irq, void *dev_id) in irq_nested_primary_handler() argument
1049 WARN(1, "Primary handler called for nested irq %d\n", irq); in irq_nested_primary_handler()
1053 static irqreturn_t irq_forced_secondary_handler(int irq, void *dev_id) in irq_forced_secondary_handler() argument
1055 WARN(1, "Secondary action handler called for irq %d\n", irq); in irq_forced_secondary_handler()
1132 * Oneshot interrupts keep the irq line masked until the threaded
1151 * on the other CPU. If we unmask the irq line then the in irq_finalize_oneshot()
1153 * to IRQS_INPROGRESS and the irq line is masked forever. in irq_finalize_oneshot()
1193 irqreturn_t ret = action->thread_fn(action->irq, action->dev_id); in irq_thread_fn()
1204 * interrupts rely on the implicit bh/preempt disable of the hard irq
1239 pr_err("exiting task \"%s\" (%d) is an active IRQ thread (irq %d)\n", in irq_thread_dtor()
1240 tsk->comm, tsk->pid, action->irq); in irq_thread_dtor()
1243 desc = irq_to_desc(action->irq); in irq_thread_dtor()
1299 struct irq_desc *desc = irq_to_desc(action->irq); in irq_thread()
1337 * irq_wake_thread - wake the irq thread for the action identified by dev_id
1338 * @irq: Interrupt line
1342 void irq_wake_thread(unsigned int irq, void *dev_id) in irq_wake_thread() argument
1344 struct irq_desc *desc = irq_to_desc(irq); in irq_wake_thread()
1392 new->secondary->irq = new->irq; in irq_setup_forced_threading()
1453 setup_irq_thread(struct irqaction *new, unsigned int irq, bool secondary) in setup_irq_thread() argument
1458 t = kthread_create(irq_thread, new, "irq/%d-%s", irq, in setup_irq_thread()
1461 t = kthread_create(irq_thread, new, "irq/%d-s-%s", irq, in setup_irq_thread()
1502 __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) in __setup_irq() argument
1516 new->irq = irq; in __setup_irq()
1555 ret = setup_irq_thread(new, irq, false); in __setup_irq()
1559 ret = setup_irq_thread(new->secondary, irq, true); in __setup_irq()
1567 * underlying irq chip implementation, so a request for a in __setup_irq()
1568 * threaded irq without a primary hard irq context handler in __setup_irq()
1569 * requires the ONESHOT flag to be set. Some irq chips like in __setup_irq()
1597 pr_err("Failed to request resources for %s (irq %d) on irqchip %s\n", in __setup_irq()
1598 new->name, irq, desc->irq_data.chip->name); in __setup_irq()
1624 pr_err("Invalid attempt to share NMI for %s (irq %d) on irqchip %s.\n", in __setup_irq()
1625 new->name, irq, desc->irq_data.chip->name); in __setup_irq()
1656 /* add new interrupt at end of irq queue */ in __setup_irq()
1694 * If no thread is woken by primary (hard irq context) in __setup_irq()
1696 * also checked for zero to unmask the irq line in the in __setup_irq()
1697 * affected hard irq flow handlers in __setup_irq()
1714 * the irq lines is reenabled, but the device still in __setup_irq()
1715 * has the level irq asserted. Rinse and repeat.... in __setup_irq()
1723 pr_err("Threaded irq requested with handler=NULL and !ONESHOT for %s (irq %d)\n", in __setup_irq()
1724 new->name, irq); in __setup_irq()
1771 /* Exclude IRQ from balancing if requested */ in __setup_irq()
1798 pr_warn("irq %d uses trigger mode %u; requested %u\n", in __setup_irq()
1799 irq, omsk, nmsk); in __setup_irq()
1806 /* Reset broken irq detection when installing new handler */ in __setup_irq()
1811 * Check whether we disabled the irq via the spurious handler in __setup_irq()
1828 register_irq_proc(irq, desc); in __setup_irq()
1830 register_handler_proc(irq, new); in __setup_irq()
1835 pr_err("Flags mismatch irq %d. %08x (%s) vs. %08x (%s)\n", in __setup_irq()
1836 irq, new->flags, new->name, old->flags, old->name); in __setup_irq()
1876 unsigned irq = desc->irq_data.irq; in __free_irq() local
1880 WARN(in_interrupt(), "Trying to free IRQ %d from IRQ context!\n", irq); in __free_irq()
1887 * There can be multiple actions per IRQ descriptor, find the right in __free_irq()
1895 WARN(1, "Trying to free already-free IRQ %d\n", irq); in __free_irq()
1912 /* If this was the last handler, shut down the IRQ line: */ in __free_irq()
1928 * callbacks above are synced out to the irq chips which hang in __free_irq()
1937 * concurrent request_irq() of this irq so the release of resources in __free_irq()
1942 unregister_handler_proc(irq, action); in __free_irq()
1953 * It's a shared IRQ -- the driver ought to be prepared for an IRQ in __free_irq()
1958 * 'real' IRQ doesn't run in parallel with our fake. ) in __free_irq()
1962 action->handler(irq, dev_id); in __free_irq()
2009 * @irq: Interrupt line to free
2014 * On a shared IRQ the caller must ensure the interrupt is disabled
2016 * does not return until any executing interrupts for this IRQ
2023 const void *free_irq(unsigned int irq, void *dev_id) in free_irq() argument
2025 struct irq_desc *desc = irq_to_desc(irq); in free_irq()
2049 static const void *__cleanup_nmi(unsigned int irq, struct irq_desc *desc) in __cleanup_nmi() argument
2058 unregister_handler_proc(irq, desc->action); in __cleanup_nmi()
2075 const void *free_nmi(unsigned int irq, void *dev_id) in free_nmi() argument
2077 struct irq_desc *desc = irq_to_desc(irq); in free_nmi()
2089 disable_nmi_nosync(irq); in free_nmi()
2094 devname = __cleanup_nmi(irq, desc); in free_nmi()
2103 * @irq: Interrupt line to allocate
2104 * @handler: Function to be called when the IRQ occurs.
2108 * @thread_fn: Function called from the irq handler thread
2109 * If NULL, no irq thread is created
2115 * interrupt line and IRQ handling. From the point this
2121 * If you want to set up a threaded irq handler for your device
2143 int request_threaded_irq(unsigned int irq, irq_handler_t handler, in request_threaded_irq() argument
2151 if (irq == IRQ_NOTCONNECTED) in request_threaded_irq()
2173 desc = irq_to_desc(irq); in request_threaded_irq()
2203 retval = __setup_irq(irq, desc, action); in request_threaded_irq()
2214 * It's a shared IRQ -- the driver ought to be prepared for it in request_threaded_irq()
2216 * We disable the irq to make sure that a 'real' IRQ doesn't in request_threaded_irq()
2221 disable_irq(irq); in request_threaded_irq()
2224 handler(irq, dev_id); in request_threaded_irq()
2227 enable_irq(irq); in request_threaded_irq()
2236 * @irq: Interrupt line to allocate
2237 * @handler: Function to be called when the IRQ occurs.
2244 * interrupt line and IRQ handling. It selects either a
2251 int request_any_context_irq(unsigned int irq, irq_handler_t handler, in request_any_context_irq() argument
2257 if (irq == IRQ_NOTCONNECTED) in request_any_context_irq()
2260 desc = irq_to_desc(irq); in request_any_context_irq()
2265 ret = request_threaded_irq(irq, NULL, handler, in request_any_context_irq()
2270 ret = request_irq(irq, handler, flags, name, dev_id); in request_any_context_irq()
2277 * @irq: Interrupt line to allocate
2278 * @handler: Function to be called when the IRQ occurs.
2285 * interrupt line and IRQ handling. It sets up the IRQ line
2288 * An interrupt line delivering NMIs cannot be shared and IRQ handling
2301 int request_nmi(unsigned int irq, irq_handler_t handler, in request_nmi() argument
2309 if (irq == IRQ_NOTCONNECTED) in request_nmi()
2322 desc = irq_to_desc(irq); in request_nmi()
2344 retval = __setup_irq(irq, desc, action); in request_nmi()
2354 __cleanup_nmi(irq, desc); in request_nmi()
2371 void enable_percpu_irq(unsigned int irq, unsigned int type) in enable_percpu_irq() argument
2375 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_PERCPU); in enable_percpu_irq()
2394 WARN(1, "failed to set type for IRQ%d\n", irq); in enable_percpu_irq()
2405 void enable_percpu_nmi(unsigned int irq, unsigned int type) in enable_percpu_nmi() argument
2407 enable_percpu_irq(irq, type); in enable_percpu_nmi()
2411 * irq_percpu_is_enabled - Check whether the per cpu irq is enabled
2412 * @irq: Linux irq number to check for
2417 bool irq_percpu_is_enabled(unsigned int irq) in irq_percpu_is_enabled() argument
2424 desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_PERCPU); in irq_percpu_is_enabled()
2435 void disable_percpu_irq(unsigned int irq) in disable_percpu_irq() argument
2439 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_PERCPU); in disable_percpu_irq()
2449 void disable_percpu_nmi(unsigned int irq) in disable_percpu_nmi() argument
2451 disable_percpu_irq(irq); in disable_percpu_nmi()
2457 static struct irqaction *__free_percpu_irq(unsigned int irq, void __percpu *dev_id) in __free_percpu_irq() argument
2459 struct irq_desc *desc = irq_to_desc(irq); in __free_percpu_irq()
2463 WARN(in_interrupt(), "Trying to free IRQ %d from IRQ context!\n", irq); in __free_percpu_irq()
2472 WARN(1, "Trying to free already-free IRQ %d\n", irq); in __free_percpu_irq()
2477 WARN(1, "percpu IRQ %d still enabled on CPU%d!\n", in __free_percpu_irq()
2478 irq, cpumask_first(desc->percpu_enabled)); in __free_percpu_irq()
2489 unregister_handler_proc(irq, action); in __free_percpu_irq()
2502 * @irq: Interrupt line to free
2507 void remove_percpu_irq(unsigned int irq, struct irqaction *act) in remove_percpu_irq() argument
2509 struct irq_desc *desc = irq_to_desc(irq); in remove_percpu_irq()
2512 __free_percpu_irq(irq, act->percpu_dev_id); in remove_percpu_irq()
2517 * @irq: Interrupt line to free
2523 * until any executing interrupts for this IRQ have completed.
2527 void free_percpu_irq(unsigned int irq, void __percpu *dev_id) in free_percpu_irq() argument
2529 struct irq_desc *desc = irq_to_desc(irq); in free_percpu_irq()
2535 kfree(__free_percpu_irq(irq, dev_id)); in free_percpu_irq()
2540 void free_percpu_nmi(unsigned int irq, void __percpu *dev_id) in free_percpu_nmi() argument
2542 struct irq_desc *desc = irq_to_desc(irq); in free_percpu_nmi()
2550 kfree(__free_percpu_irq(irq, dev_id)); in free_percpu_nmi()
2555 * @irq: Interrupt line to setup
2560 int setup_percpu_irq(unsigned int irq, struct irqaction *act) in setup_percpu_irq() argument
2562 struct irq_desc *desc = irq_to_desc(irq); in setup_percpu_irq()
2572 retval = __setup_irq(irq, desc, act); in setup_percpu_irq()
2582 * @irq: Interrupt line to allocate
2583 * @handler: Function to be called when the IRQ occurs.
2597 int __request_percpu_irq(unsigned int irq, irq_handler_t handler, in __request_percpu_irq() argument
2608 desc = irq_to_desc(irq); in __request_percpu_irq()
2631 retval = __setup_irq(irq, desc, action); in __request_percpu_irq()
2644 * @irq: Interrupt line to allocate
2645 * @handler: Function to be called when the IRQ occurs.
2663 int request_percpu_nmi(unsigned int irq, irq_handler_t handler, in request_percpu_nmi() argument
2674 desc = irq_to_desc(irq); in request_percpu_nmi()
2700 retval = __setup_irq(irq, desc, action); in request_percpu_nmi()
2720 * @irq: Interrupt line to prepare for NMI delivery
2731 int prepare_percpu_nmi(unsigned int irq) in prepare_percpu_nmi() argument
2739 desc = irq_get_desc_lock(irq, &flags, in prepare_percpu_nmi()
2745 KERN_ERR "prepare_percpu_nmi called for a non-NMI interrupt: irq %u\n", in prepare_percpu_nmi()
2746 irq)) { in prepare_percpu_nmi()
2753 pr_err("Failed to setup NMI delivery: irq %u\n", irq); in prepare_percpu_nmi()
2763 * teardown_percpu_nmi - undoes NMI setup of IRQ line
2764 * @irq: Interrupt line from which CPU local NMI configuration should be
2769 * IRQ line should not be enabled for the current CPU.
2774 void teardown_percpu_nmi(unsigned int irq) in teardown_percpu_nmi() argument
2781 desc = irq_get_desc_lock(irq, &flags, in teardown_percpu_nmi()
2819 * @irq: Interrupt line that is forwarded to a VM
2830 int irq_get_irqchip_state(unsigned int irq, enum irqchip_irq_state which, in irq_get_irqchip_state() argument
2838 desc = irq_get_desc_buslock(irq, &flags, 0); in irq_get_irqchip_state()
2853 * @irq: Interrupt line that is forwarded to a VM
2863 int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which, in irq_set_irqchip_state() argument
2872 desc = irq_get_desc_buslock(irq, &flags, 0); in irq_set_irqchip_state()
2904 * @irq: The linux irq number
2908 bool irq_has_action(unsigned int irq) in irq_has_action() argument
2913 res = irq_desc_has_action(irq_to_desc(irq)); in irq_has_action()
2920 * irq_check_status_bit - Check whether bits in the irq descriptor status are set
2921 * @irq: The linux irq number
2926 bool irq_check_status_bit(unsigned int irq, unsigned int bitmask) in irq_check_status_bit() argument
2932 desc = irq_to_desc(irq); in irq_check_status_bit()