Lines Matching full:irq

6  * This file contains driver APIs to the irq subsystem.
11 #include <linux/irq.h>
77 * synchronize_hardirq - wait for pending hard IRQ handlers (on other CPUs)
78 * @irq: interrupt number to wait for
80 * This function waits for any pending hard IRQ handlers for this
82 * function while holding a resource the IRQ handler may need you
91 * This function may be called - with care - from IRQ context.
98 bool synchronize_hardirq(unsigned int irq) in synchronize_hardirq() argument
100 struct irq_desc *desc = irq_to_desc(irq); in synchronize_hardirq()
112 * synchronize_irq - wait for pending IRQ handlers (on other CPUs)
113 * @irq: interrupt number to wait for
115 * This function waits for any pending IRQ handlers for this interrupt
117 * holding a resource the IRQ handler may need you will deadlock.
120 * an interrupt thread is associated to @irq.
122 * It optionally makes sure (when the irq chip supports that method)
126 void synchronize_irq(unsigned int irq) in synchronize_irq() argument
128 struct irq_desc *desc = irq_to_desc(irq); in synchronize_irq()
155 * irq_can_set_affinity - Check if the affinity of a given irq can be set
156 * @irq: Interrupt to check
159 int irq_can_set_affinity(unsigned int irq) in irq_can_set_affinity() argument
161 return __irq_can_set_affinity(irq_to_desc(irq)); in irq_can_set_affinity()
165 * irq_can_set_affinity_usr - Check if affinity of a irq can be set from user space
166 * @irq: Interrupt to check
171 bool irq_can_set_affinity_usr(unsigned int irq) in irq_can_set_affinity_usr() argument
173 struct irq_desc *desc = irq_to_desc(irq); in irq_can_set_affinity_usr()
180 * irq_set_thread_affinity - Notify irq threads to adjust affinity
181 * @desc: irq descriptor which has affinity changed
205 pr_warn_once("irq_chip %s did not update eff. affinity mask of irq %u\n", in irq_validate_effective_affinity()
206 chip->name, data->irq); in irq_validate_effective_affinity()
322 * Handle irq chips which can handle affinity only in activated in irq_set_affinity_deactivated()
375 * @irq: The interrupt number to update
382 * for when the kernel is configured for generic IRQ reservation mode (in
388 int irq_update_affinity_desc(unsigned int irq, in irq_update_affinity_desc() argument
403 desc = irq_get_desc_buslock(irq, &flags, 0); in irq_update_affinity_desc()
443 static int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, in __irq_set_affinity() argument
446 struct irq_desc *desc = irq_to_desc(irq); in __irq_set_affinity()
460 * irq_set_affinity - Set the irq affinity of a given irq
461 * @irq: Interrupt to set affinity
466 int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask) in irq_set_affinity() argument
468 return __irq_set_affinity(irq, cpumask, false); in irq_set_affinity()
473 * irq_force_affinity - Force the irq affinity of a given irq
474 * @irq: Interrupt to set affinity
483 int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask) in irq_force_affinity() argument
485 return __irq_set_affinity(irq, cpumask, true); in irq_force_affinity()
489 int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m) in irq_set_affinity_hint() argument
492 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); in irq_set_affinity_hint()
500 __irq_set_affinity(irq, m, false); in irq_set_affinity_hint()
509 struct irq_desc *desc = irq_to_desc(notify->irq); in irq_affinity_notify()
531 * irq_set_affinity_notifier - control notification of IRQ affinity changes
532 * @irq: Interrupt for which to enable/disable notification
538 * after the IRQ is allocated and must be disabled before the IRQ is
542 irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify) in irq_set_affinity_notifier() argument
544 struct irq_desc *desc = irq_to_desc(irq); in irq_set_affinity_notifier()
556 notify->irq = irq; in irq_set_affinity_notifier()
634 * @irq: interrupt number to set affinity
639 * affinity for an irq. The vCPU specific data is passed from
643 int irq_set_vcpu_affinity(unsigned int irq, void *vcpu_info) in irq_set_vcpu_affinity() argument
646 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); in irq_set_vcpu_affinity()
680 static int __disable_irq_nosync(unsigned int irq) in __disable_irq_nosync() argument
683 struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); in __disable_irq_nosync()
693 * disable_irq_nosync - disable an irq without waiting
694 * @irq: Interrupt to disable
699 * instances of the IRQ handler have completed before returning.
701 * This function may be called from IRQ context.
703 void disable_irq_nosync(unsigned int irq) in disable_irq_nosync() argument
705 __disable_irq_nosync(irq); in disable_irq_nosync()
710 * disable_irq - disable an irq and wait for completion
711 * @irq: Interrupt to disable
715 * This function waits for any pending IRQ handlers for this interrupt
717 * holding a resource the IRQ handler may need you will deadlock.
719 * This function may be called - with care - from IRQ context.
721 void disable_irq(unsigned int irq) in disable_irq() argument
723 if (!__disable_irq_nosync(irq)) in disable_irq()
724 synchronize_irq(irq); in disable_irq()
729 * disable_hardirq - disables an irq and waits for hardirq completion
730 * @irq: Interrupt to disable
734 * This function waits for any pending hard IRQ handlers for this
736 * holding a resource the hard IRQ handler may need you will deadlock.
743 * This function may be called - with care - from IRQ context.
745 bool disable_hardirq(unsigned int irq) in disable_hardirq() argument
747 if (!__disable_irq_nosync(irq)) in disable_hardirq()
748 return synchronize_hardirq(irq); in disable_hardirq()
756 * @irq: Interrupt to disable
762 * instances of the IRQ handler have completed before returning.
764 void disable_nmi_nosync(unsigned int irq) in disable_nmi_nosync() argument
766 disable_irq_nosync(irq); in disable_nmi_nosync()
774 WARN(1, KERN_WARNING "Unbalanced enable for IRQ %d\n", in __enable_irq()
780 /* Prevent probing on this irq: */ in __enable_irq()
798 * enable_irq - enable handling of an irq
799 * @irq: Interrupt to enable
803 * IRQ line is re-enabled.
805 * This function may be called from IRQ context only when
808 void enable_irq(unsigned int irq) in enable_irq() argument
811 struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); in enable_irq()
816 KERN_ERR "enable_irq before setup/request_irq: irq %u\n", irq)) in enable_irq()
827 * @irq: Interrupt to enable
832 * IRQ line is re-enabled.
834 void enable_nmi(unsigned int irq) in enable_nmi() argument
836 enable_irq(irq); in enable_nmi()
839 static int set_irq_wake_real(unsigned int irq, unsigned int on) in set_irq_wake_real() argument
841 struct irq_desc *desc = irq_to_desc(irq); in set_irq_wake_real()
854 * irq_set_irq_wake - control irq power management wakeup
855 * @irq: interrupt to control
862 * Wakeup mode lets this IRQ wake the system from sleep
865 * Note: irq enable/disable state is completely orthogonal
866 * to the enable/disable state of irq wake. An irq can be
868 * long as the irq has wake enabled. If this does not hold,
869 * then the underlying irq chip and the related driver need
872 int irq_set_irq_wake(unsigned int irq, unsigned int on) in irq_set_irq_wake() argument
875 struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); in irq_set_irq_wake()
892 ret = set_irq_wake_real(irq, on); in irq_set_irq_wake()
900 WARN(1, "Unbalanced IRQ %d wake disable\n", irq); in irq_set_irq_wake()
902 ret = set_irq_wake_real(irq, on); in irq_set_irq_wake()
918 * particular irq has been exclusively allocated or is available
921 int can_request_irq(unsigned int irq, unsigned long irqflags) in can_request_irq() argument
924 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); in can_request_irq()
949 pr_debug("No set_type function for IRQ %d (%s)\n", in __irq_set_trigger()
986 pr_err("Setting trigger mode %lu for irq %u failed (%pS)\n", in __irq_set_trigger()
995 int irq_set_parent(int irq, int parent_irq) in irq_set_parent() argument
998 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); in irq_set_parent()
1016 static irqreturn_t irq_default_primary_handler(int irq, void *dev_id) in irq_default_primary_handler() argument
1025 static irqreturn_t irq_nested_primary_handler(int irq, void *dev_id) in irq_nested_primary_handler() argument
1027 WARN(1, "Primary handler called for nested irq %d\n", irq); in irq_nested_primary_handler()
1031 static irqreturn_t irq_forced_secondary_handler(int irq, void *dev_id) in irq_forced_secondary_handler() argument
1033 WARN(1, "Secondary action handler called for irq %d\n", irq); in irq_forced_secondary_handler()
1063 * Oneshot interrupts keep the irq line masked until the threaded
1082 * on the other CPU. If we unmask the irq line then the in irq_finalize_oneshot()
1084 * to IRQS_INPROGRESS and the irq line is masked forever. in irq_finalize_oneshot()
1165 * interrupts rely on the implicit bh/preempt disable of the hard irq
1177 ret = action->thread_fn(action->irq, action->dev_id); in irq_forced_thread_fn()
1198 ret = action->thread_fn(action->irq, action->dev_id); in irq_thread_fn()
1223 pr_err("exiting task \"%s\" (%d) is an active IRQ thread (irq %d)\n", in irq_thread_dtor()
1224 tsk->comm, tsk->pid, action->irq); in irq_thread_dtor()
1227 desc = irq_to_desc(action->irq); in irq_thread_dtor()
1258 struct irq_desc *desc = irq_to_desc(action->irq); in irq_thread()
1296 * irq_wake_thread - wake the irq thread for the action identified by dev_id
1297 * @irq: Interrupt line
1301 void irq_wake_thread(unsigned int irq, void *dev_id) in irq_wake_thread() argument
1303 struct irq_desc *desc = irq_to_desc(irq); in irq_wake_thread()
1351 new->secondary->irq = new->irq; in irq_setup_forced_threading()
1412 setup_irq_thread(struct irqaction *new, unsigned int irq, bool secondary) in setup_irq_thread() argument
1417 t = kthread_create(irq_thread, new, "irq/%d-%s", irq, in setup_irq_thread()
1420 t = kthread_create(irq_thread, new, "irq/%d-s-%s", irq, in setup_irq_thread()
1463 __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) in __setup_irq() argument
1477 new->irq = irq; in __setup_irq()
1516 ret = setup_irq_thread(new, irq, false); in __setup_irq()
1520 ret = setup_irq_thread(new->secondary, irq, true); in __setup_irq()
1528 * underlying irq chip implementation, so a request for a in __setup_irq()
1529 * threaded irq without a primary hard irq context handler in __setup_irq()
1530 * requires the ONESHOT flag to be set. Some irq chips like in __setup_irq()
1558 pr_err("Failed to request resources for %s (irq %d) on irqchip %s\n", in __setup_irq()
1559 new->name, irq, desc->irq_data.chip->name); in __setup_irq()
1585 pr_err("Invalid attempt to share NMI for %s (irq %d) on irqchip %s.\n", in __setup_irq()
1586 new->name, irq, desc->irq_data.chip->name); in __setup_irq()
1612 /* add new interrupt at end of irq queue */ in __setup_irq()
1650 * If no thread is woken by primary (hard irq context) in __setup_irq()
1652 * also checked for zero to unmask the irq line in the in __setup_irq()
1653 * affected hard irq flow handlers in __setup_irq()
1670 * the irq lines is reenabled, but the device still in __setup_irq()
1671 * has the level irq asserted. Rinse and repeat.... in __setup_irq()
1679 pr_err("Threaded irq requested with handler=NULL and !ONESHOT for %s (irq %d)\n", in __setup_irq()
1680 new->name, irq); in __setup_irq()
1729 /* Exclude IRQ from balancing if requested */ in __setup_irq()
1756 pr_warn("irq %d uses trigger mode %u; requested %u\n", in __setup_irq()
1757 irq, omsk, nmsk); in __setup_irq()
1764 /* Reset broken irq detection when installing new handler */ in __setup_irq()
1769 * Check whether we disabled the irq via the spurious handler in __setup_irq()
1792 register_irq_proc(irq, desc); in __setup_irq()
1794 register_handler_proc(irq, new); in __setup_irq()
1799 pr_err("Flags mismatch irq %d. %08x (%s) vs. %08x (%s)\n", in __setup_irq()
1800 irq, new->flags, new->name, old->flags, old->name); in __setup_irq()
1842 unsigned irq = desc->irq_data.irq; in __free_irq() local
1846 WARN(in_interrupt(), "Trying to free IRQ %d from IRQ context!\n", irq); in __free_irq()
1853 * There can be multiple actions per IRQ descriptor, find the right in __free_irq()
1861 WARN(1, "Trying to free already-free IRQ %d\n", irq); in __free_irq()
1878 /* If this was the last handler, shut down the IRQ line: */ in __free_irq()
1894 * callbacks above are synced out to the irq chips which hang in __free_irq()
1903 * concurrent request_irq() of this irq so the release of resources in __free_irq()
1908 unregister_handler_proc(irq, action); in __free_irq()
1919 * It's a shared IRQ -- the driver ought to be prepared for an IRQ in __free_irq()
1924 * 'real' IRQ doesn't run in parallel with our fake. ) in __free_irq()
1928 action->handler(irq, dev_id); in __free_irq()
1978 * @irq: Interrupt line to free
1983 * On a shared IRQ the caller must ensure the interrupt is disabled
1985 * does not return until any executing interrupts for this IRQ
1992 const void *free_irq(unsigned int irq, void *dev_id) in free_irq() argument
1994 struct irq_desc *desc = irq_to_desc(irq); in free_irq()
2018 static const void *__cleanup_nmi(unsigned int irq, struct irq_desc *desc) in __cleanup_nmi() argument
2027 unregister_handler_proc(irq, desc->action); in __cleanup_nmi()
2044 const void *free_nmi(unsigned int irq, void *dev_id) in free_nmi() argument
2046 struct irq_desc *desc = irq_to_desc(irq); in free_nmi()
2058 disable_nmi_nosync(irq); in free_nmi()
2063 devname = __cleanup_nmi(irq, desc); in free_nmi()
2072 * @irq: Interrupt line to allocate
2073 * @handler: Function to be called when the IRQ occurs.
2077 * @thread_fn: Function called from the irq handler thread
2078 * If NULL, no irq thread is created
2084 * interrupt line and IRQ handling. From the point this
2090 * If you want to set up a threaded irq handler for your device
2112 int request_threaded_irq(unsigned int irq, irq_handler_t handler, in request_threaded_irq() argument
2120 if (irq == IRQ_NOTCONNECTED) in request_threaded_irq()
2142 desc = irq_to_desc(irq); in request_threaded_irq()
2172 retval = __setup_irq(irq, desc, action); in request_threaded_irq()
2183 * It's a shared IRQ -- the driver ought to be prepared for it in request_threaded_irq()
2185 * We disable the irq to make sure that a 'real' IRQ doesn't in request_threaded_irq()
2190 disable_irq(irq); in request_threaded_irq()
2193 handler(irq, dev_id); in request_threaded_irq()
2196 enable_irq(irq); in request_threaded_irq()
2205 * @irq: Interrupt line to allocate
2206 * @handler: Function to be called when the IRQ occurs.
2213 * interrupt line and IRQ handling. It selects either a
2220 int request_any_context_irq(unsigned int irq, irq_handler_t handler, in request_any_context_irq() argument
2226 if (irq == IRQ_NOTCONNECTED) in request_any_context_irq()
2229 desc = irq_to_desc(irq); in request_any_context_irq()
2234 ret = request_threaded_irq(irq, NULL, handler, in request_any_context_irq()
2239 ret = request_irq(irq, handler, flags, name, dev_id); in request_any_context_irq()
2246 * @irq: Interrupt line to allocate
2247 * @handler: Function to be called when the IRQ occurs.
2254 * interrupt line and IRQ handling. It sets up the IRQ line
2257 * An interrupt line delivering NMIs cannot be shared and IRQ handling
2270 int request_nmi(unsigned int irq, irq_handler_t handler, in request_nmi() argument
2278 if (irq == IRQ_NOTCONNECTED) in request_nmi()
2291 desc = irq_to_desc(irq); in request_nmi()
2313 retval = __setup_irq(irq, desc, action); in request_nmi()
2323 __cleanup_nmi(irq, desc); in request_nmi()
2340 void enable_percpu_irq(unsigned int irq, unsigned int type) in enable_percpu_irq() argument
2344 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_PERCPU); in enable_percpu_irq()
2363 WARN(1, "failed to set type for IRQ%d\n", irq); in enable_percpu_irq()
2374 void enable_percpu_nmi(unsigned int irq, unsigned int type) in enable_percpu_nmi() argument
2376 enable_percpu_irq(irq, type); in enable_percpu_nmi()
2380 * irq_percpu_is_enabled - Check whether the per cpu irq is enabled
2381 * @irq: Linux irq number to check for
2386 bool irq_percpu_is_enabled(unsigned int irq) in irq_percpu_is_enabled() argument
2393 desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_PERCPU); in irq_percpu_is_enabled()
2404 void disable_percpu_irq(unsigned int irq) in disable_percpu_irq() argument
2408 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_PERCPU); in disable_percpu_irq()
2418 void disable_percpu_nmi(unsigned int irq) in disable_percpu_nmi() argument
2420 disable_percpu_irq(irq); in disable_percpu_nmi()
2426 static struct irqaction *__free_percpu_irq(unsigned int irq, void __percpu *dev_id) in __free_percpu_irq() argument
2428 struct irq_desc *desc = irq_to_desc(irq); in __free_percpu_irq()
2432 WARN(in_interrupt(), "Trying to free IRQ %d from IRQ context!\n", irq); in __free_percpu_irq()
2441 WARN(1, "Trying to free already-free IRQ %d\n", irq); in __free_percpu_irq()
2446 WARN(1, "percpu IRQ %d still enabled on CPU%d!\n", in __free_percpu_irq()
2447 irq, cpumask_first(desc->percpu_enabled)); in __free_percpu_irq()
2458 unregister_handler_proc(irq, action); in __free_percpu_irq()
2471 * @irq: Interrupt line to free
2476 void remove_percpu_irq(unsigned int irq, struct irqaction *act) in remove_percpu_irq() argument
2478 struct irq_desc *desc = irq_to_desc(irq); in remove_percpu_irq()
2481 __free_percpu_irq(irq, act->percpu_dev_id); in remove_percpu_irq()
2486 * @irq: Interrupt line to free
2492 * until any executing interrupts for this IRQ have completed.
2496 void free_percpu_irq(unsigned int irq, void __percpu *dev_id) in free_percpu_irq() argument
2498 struct irq_desc *desc = irq_to_desc(irq); in free_percpu_irq()
2504 kfree(__free_percpu_irq(irq, dev_id)); in free_percpu_irq()
2509 void free_percpu_nmi(unsigned int irq, void __percpu *dev_id) in free_percpu_nmi() argument
2511 struct irq_desc *desc = irq_to_desc(irq); in free_percpu_nmi()
2519 kfree(__free_percpu_irq(irq, dev_id)); in free_percpu_nmi()
2524 * @irq: Interrupt line to setup
2529 int setup_percpu_irq(unsigned int irq, struct irqaction *act) in setup_percpu_irq() argument
2531 struct irq_desc *desc = irq_to_desc(irq); in setup_percpu_irq()
2541 retval = __setup_irq(irq, desc, act); in setup_percpu_irq()
2551 * @irq: Interrupt line to allocate
2552 * @handler: Function to be called when the IRQ occurs.
2566 int __request_percpu_irq(unsigned int irq, irq_handler_t handler, in __request_percpu_irq() argument
2577 desc = irq_to_desc(irq); in __request_percpu_irq()
2600 retval = __setup_irq(irq, desc, action); in __request_percpu_irq()
2613 * @irq: Interrupt line to allocate
2614 * @handler: Function to be called when the IRQ occurs.
2632 int request_percpu_nmi(unsigned int irq, irq_handler_t handler, in request_percpu_nmi() argument
2643 desc = irq_to_desc(irq); in request_percpu_nmi()
2669 retval = __setup_irq(irq, desc, action); in request_percpu_nmi()
2689 * @irq: Interrupt line to prepare for NMI delivery
2700 int prepare_percpu_nmi(unsigned int irq) in prepare_percpu_nmi() argument
2708 desc = irq_get_desc_lock(irq, &flags, in prepare_percpu_nmi()
2714 KERN_ERR "prepare_percpu_nmi called for a non-NMI interrupt: irq %u\n", in prepare_percpu_nmi()
2715 irq)) { in prepare_percpu_nmi()
2722 pr_err("Failed to setup NMI delivery: irq %u\n", irq); in prepare_percpu_nmi()
2732 * teardown_percpu_nmi - undoes NMI setup of IRQ line
2733 * @irq: Interrupt line from which CPU local NMI configuration should be
2738 * IRQ line should not be enabled for the current CPU.
2743 void teardown_percpu_nmi(unsigned int irq) in teardown_percpu_nmi() argument
2750 desc = irq_get_desc_lock(irq, &flags, in teardown_percpu_nmi()
2789 * @irq: Interrupt line that is forwarded to a VM
2800 int irq_get_irqchip_state(unsigned int irq, enum irqchip_irq_state which, in irq_get_irqchip_state() argument
2808 desc = irq_get_desc_buslock(irq, &flags, 0); in irq_get_irqchip_state()
2823 * @irq: Interrupt line that is forwarded to a VM
2833 int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which, in irq_set_irqchip_state() argument
2842 desc = irq_get_desc_buslock(irq, &flags, 0); in irq_set_irqchip_state()
2874 * @irq: The linux irq number
2878 bool irq_has_action(unsigned int irq) in irq_has_action() argument
2883 res = irq_desc_has_action(irq_to_desc(irq)); in irq_has_action()
2890 * irq_check_status_bit - Check whether bits in the irq descriptor status are set
2891 * @irq: The linux irq number
2896 bool irq_check_status_bit(unsigned int irq, unsigned int bitmask) in irq_check_status_bit() argument
2902 desc = irq_to_desc(irq); in irq_check_status_bit()