Lines Matching full:irq

6  * This file contains driver APIs to the irq subsystem.
11 #include <linux/irq.h>
75 * synchronize_hardirq - wait for pending hard IRQ handlers (on other CPUs)
76 * @irq: interrupt number to wait for
78 * This function waits for any pending hard IRQ handlers for this interrupt
80 * resource the IRQ handler may need you will deadlock. It does not take
88 * This function may be called - with care - from IRQ context.
95 bool synchronize_hardirq(unsigned int irq) in synchronize_hardirq() argument
97 struct irq_desc *desc = irq_to_desc(irq); in synchronize_hardirq()
119 * synchronize_irq - wait for pending IRQ handlers (on other CPUs)
120 * @irq: interrupt number to wait for
122 * This function waits for any pending IRQ handlers for this interrupt to
124 * resource the IRQ handler may need you will deadlock.
127 * an interrupt thread is associated to @irq.
129 * It optionally makes sure (when the irq chip supports that method)
133 void synchronize_irq(unsigned int irq) in synchronize_irq() argument
135 struct irq_desc *desc = irq_to_desc(irq); in synchronize_irq()
154 * irq_can_set_affinity - Check if the affinity of a given irq can be set
155 * @irq: Interrupt to check
158 int irq_can_set_affinity(unsigned int irq) in irq_can_set_affinity() argument
160 return __irq_can_set_affinity(irq_to_desc(irq)); in irq_can_set_affinity()
164 * irq_can_set_affinity_usr - Check if affinity of a irq can be set from user space
165 * @irq: Interrupt to check
170 bool irq_can_set_affinity_usr(unsigned int irq) in irq_can_set_affinity_usr() argument
172 struct irq_desc *desc = irq_to_desc(irq); in irq_can_set_affinity_usr()
179 * irq_set_thread_affinity - Notify irq threads to adjust affinity
180 * @desc: irq descriptor which has affinity changed
211 pr_warn_once("irq_chip %s did not update eff. affinity mask of irq %u\n", in irq_validate_effective_affinity()
212 chip->name, data->irq); in irq_validate_effective_affinity()
332 * Handle irq chips which can handle affinity only in activated in irq_set_affinity_deactivated()
385 * @irq: The interrupt number to update
392 * for when the kernel is configured for generic IRQ reservation mode (in
398 int irq_update_affinity_desc(unsigned int irq, struct irq_affinity_desc *affinity) in irq_update_affinity_desc() argument
407 scoped_irqdesc_get_and_buslock(irq, 0) { in irq_update_affinity_desc()
441 static int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, in __irq_set_affinity() argument
444 struct irq_desc *desc = irq_to_desc(irq); in __irq_set_affinity()
454 * irq_set_affinity - Set the irq affinity of a given irq
455 * @irq: Interrupt to set affinity
460 int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask) in irq_set_affinity() argument
462 return __irq_set_affinity(irq, cpumask, false); in irq_set_affinity()
467 * irq_force_affinity - Force the irq affinity of a given irq
468 * @irq: Interrupt to set affinity
477 int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask) in irq_force_affinity() argument
479 return __irq_set_affinity(irq, cpumask, true); in irq_force_affinity()
483 int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m, bool setaffinity) in __irq_apply_affinity_hint() argument
487 scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_GLOBAL) { in __irq_apply_affinity_hint()
493 __irq_set_affinity(irq, m, false); in __irq_apply_affinity_hint()
501 struct irq_desc *desc = irq_to_desc(notify->irq); in irq_affinity_notify()
522 * irq_set_affinity_notifier - control notification of IRQ affinity changes
523 * @irq: Interrupt for which to enable/disable notification
529 * after the IRQ is allocated and must be disabled before the IRQ is freed
532 int irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify) in irq_set_affinity_notifier() argument
534 struct irq_desc *desc = irq_to_desc(irq); in irq_set_affinity_notifier()
545 notify->irq = irq; in irq_set_affinity_notifier()
622 * @irq: interrupt number to set affinity
627 * an irq. The vCPU specific data is passed from outside, such as KVM. One
630 int irq_set_vcpu_affinity(unsigned int irq, void *vcpu_info) in irq_set_vcpu_affinity() argument
632 scoped_irqdesc_get_and_lock(irq, 0) { in irq_set_vcpu_affinity()
660 static int __disable_irq_nosync(unsigned int irq) in __disable_irq_nosync() argument
662 scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_GLOBAL) { in __disable_irq_nosync()
670 * disable_irq_nosync - disable an irq without waiting
671 * @irq: Interrupt to disable
676 * instances of the IRQ handler have completed before returning.
678 * This function may be called from IRQ context.
680 void disable_irq_nosync(unsigned int irq) in disable_irq_nosync() argument
682 __disable_irq_nosync(irq); in disable_irq_nosync()
687 * disable_irq - disable an irq and wait for completion
688 * @irq: Interrupt to disable
692 * This function waits for any pending IRQ handlers for this interrupt to
694 * resource the IRQ handler may need you will deadlock.
697 * interrupt thread is associated to @irq.
700 void disable_irq(unsigned int irq) in disable_irq() argument
703 if (!__disable_irq_nosync(irq)) in disable_irq()
704 synchronize_irq(irq); in disable_irq()
709 * disable_hardirq - disables an irq and waits for hardirq completion
710 * @irq: Interrupt to disable
714 * This function waits for any pending hard IRQ handlers for this interrupt
716 * resource the hard IRQ handler may need you will deadlock.
723 * This function may be called - with care - from IRQ context.
725 bool disable_hardirq(unsigned int irq) in disable_hardirq() argument
727 if (!__disable_irq_nosync(irq)) in disable_hardirq()
728 return synchronize_hardirq(irq); in disable_hardirq()
735 * @irq: Interrupt to disable
741 * instances of the IRQ handler have completed before returning.
743 void disable_nmi_nosync(unsigned int irq) in disable_nmi_nosync() argument
745 disable_irq_nosync(irq); in disable_nmi_nosync()
753 WARN(1, KERN_WARNING "Unbalanced enable for IRQ %d\n", in __enable_irq()
759 /* Prevent probing on this irq: */ in __enable_irq()
781 * enable_irq - enable handling of an irq
782 * @irq: Interrupt to enable
785 * last disable, processing of interrupts on this IRQ line is re-enabled.
787 * This function may be called from IRQ context only when
790 void enable_irq(unsigned int irq) in enable_irq() argument
792 scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_GLOBAL) { in enable_irq()
795 if (WARN(!desc->irq_data.chip, "enable_irq before setup/request_irq: irq %u\n", irq)) in enable_irq()
804 * @irq: Interrupt to enable
808 * disable, processing of interrupts on this IRQ line is re-enabled.
810 void enable_nmi(unsigned int irq) in enable_nmi() argument
812 enable_irq(irq); in enable_nmi()
815 static int set_irq_wake_real(unsigned int irq, unsigned int on) in set_irq_wake_real() argument
817 struct irq_desc *desc = irq_to_desc(irq); in set_irq_wake_real()
830 * irq_set_irq_wake - control irq power management wakeup
831 * @irq: interrupt to control
838 * Wakeup mode lets this IRQ wake the system from sleep states like
841 * Note: irq enable/disable state is completely orthogonal to the
842 * enable/disable state of irq wake. An irq can be disabled with
843 * disable_irq() and still wake the system as long as the irq has wake
844 * enabled. If this does not hold, then the underlying irq chip and the
847 int irq_set_irq_wake(unsigned int irq, unsigned int on) in irq_set_irq_wake() argument
849 scoped_irqdesc_get_and_buslock(irq, IRQ_GET_DESC_CHECK_GLOBAL) { in irq_set_irq_wake()
863 ret = set_irq_wake_real(irq, on); in irq_set_irq_wake()
871 WARN(1, "Unbalanced IRQ %d wake disable\n", irq); in irq_set_irq_wake()
873 ret = set_irq_wake_real(irq, on); in irq_set_irq_wake()
888 * particular irq has been exclusively allocated or is available
891 bool can_request_irq(unsigned int irq, unsigned long irqflags) in can_request_irq() argument
893 scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_GLOBAL) { in can_request_irq()
914 pr_debug("No set_type function for IRQ %d (%s)\n", in __irq_set_trigger()
951 pr_err("Setting trigger mode %lu for irq %u failed (%pS)\n", in __irq_set_trigger()
960 int irq_set_parent(int irq, int parent_irq) in irq_set_parent() argument
962 scoped_irqdesc_get_and_lock(irq, 0) { in irq_set_parent()
976 static irqreturn_t irq_default_primary_handler(int irq, void *dev_id) in irq_default_primary_handler() argument
985 static irqreturn_t irq_nested_primary_handler(int irq, void *dev_id) in irq_nested_primary_handler() argument
987 WARN(1, "Primary handler called for nested irq %d\n", irq); in irq_nested_primary_handler()
991 static irqreturn_t irq_forced_secondary_handler(int irq, void *dev_id) in irq_forced_secondary_handler() argument
993 WARN(1, "Secondary action handler called for irq %d\n", irq); in irq_forced_secondary_handler()
1070 * Oneshot interrupts keep the irq line masked until the threaded
1089 * on the other CPU. If we unmask the irq line then the in irq_finalize_oneshot()
1091 * to IRQS_INPROGRESS and the irq line is masked forever. in irq_finalize_oneshot()
1131 irqreturn_t ret = action->thread_fn(action->irq, action->dev_id); in irq_thread_fn()
1142 * interrupts rely on the implicit bh/preempt disable of the hard irq
1177 pr_err("exiting task \"%s\" (%d) is an active IRQ thread (irq %d)\n", in irq_thread_dtor()
1178 tsk->comm, tsk->pid, action->irq); in irq_thread_dtor()
1181 desc = irq_to_desc(action->irq); in irq_thread_dtor()
1236 struct irq_desc *desc = irq_to_desc(action->irq); in irq_thread()
1274 * irq_wake_thread - wake the irq thread for the action identified by dev_id
1275 * @irq: Interrupt line
1278 void irq_wake_thread(unsigned int irq, void *dev_id) in irq_wake_thread() argument
1280 struct irq_desc *desc = irq_to_desc(irq); in irq_wake_thread()
1326 new->secondary->irq = new->irq; in irq_setup_forced_threading()
1387 setup_irq_thread(struct irqaction *new, unsigned int irq, bool secondary) in setup_irq_thread() argument
1392 t = kthread_create(irq_thread, new, "irq/%d-%s", irq, in setup_irq_thread()
1395 t = kthread_create(irq_thread, new, "irq/%d-s-%s", irq, in setup_irq_thread()
1436 __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) in __setup_irq() argument
1450 new->irq = irq; in __setup_irq()
1489 ret = setup_irq_thread(new, irq, false); in __setup_irq()
1493 ret = setup_irq_thread(new->secondary, irq, true); in __setup_irq()
1501 * underlying irq chip implementation, so a request for a in __setup_irq()
1502 * threaded irq without a primary hard irq context handler in __setup_irq()
1503 * requires the ONESHOT flag to be set. Some irq chips like in __setup_irq()
1531 pr_err("Failed to request resources for %s (irq %d) on irqchip %s\n", in __setup_irq()
1532 new->name, irq, desc->irq_data.chip->name); in __setup_irq()
1558 pr_err("Invalid attempt to share NMI for %s (irq %d) on irqchip %s.\n", in __setup_irq()
1559 new->name, irq, desc->irq_data.chip->name); in __setup_irq()
1590 /* add new interrupt at end of irq queue */ in __setup_irq()
1628 * If no thread is woken by primary (hard irq context) in __setup_irq()
1630 * also checked for zero to unmask the irq line in the in __setup_irq()
1631 * affected hard irq flow handlers in __setup_irq()
1648 * the irq lines is reenabled, but the device still in __setup_irq()
1649 * has the level irq asserted. Rinse and repeat.... in __setup_irq()
1657 pr_err("Threaded irq requested with handler=NULL and !ONESHOT for %s (irq %d)\n", in __setup_irq()
1658 new->name, irq); in __setup_irq()
1705 /* Exclude IRQ from balancing if requested */ in __setup_irq()
1732 pr_warn("irq %d uses trigger mode %u; requested %u\n", in __setup_irq()
1733 irq, omsk, nmsk); in __setup_irq()
1740 /* Reset broken irq detection when installing new handler */ in __setup_irq()
1745 * Check whether we disabled the irq via the spurious handler in __setup_irq()
1762 register_irq_proc(irq, desc); in __setup_irq()
1764 register_handler_proc(irq, new); in __setup_irq()
1769 pr_err("Flags mismatch irq %d. %08x (%s) vs. %08x (%s)\n", in __setup_irq()
1770 irq, new->flags, new->name, old->flags, old->name); in __setup_irq()
1810 unsigned irq = desc->irq_data.irq; in __free_irq() local
1814 WARN(in_interrupt(), "Trying to free IRQ %d from IRQ context!\n", irq); in __free_irq()
1821 * There can be multiple actions per IRQ descriptor, find the right in __free_irq()
1829 WARN(1, "Trying to free already-free IRQ %d\n", irq); in __free_irq()
1846 /* If this was the last handler, shut down the IRQ line: */ in __free_irq()
1862 * callbacks above are synced out to the irq chips which hang in __free_irq()
1871 * concurrent request_irq() of this irq so the release of resources in __free_irq()
1876 unregister_handler_proc(irq, action); in __free_irq()
1887 * It's a shared IRQ -- the driver ought to be prepared for an IRQ in __free_irq()
1892 * 'real' IRQ doesn't run in parallel with our fake. ) in __free_irq()
1896 action->handler(irq, dev_id); in __free_irq()
1942 * @irq: Interrupt line to free
1946 * line is no longer in use by any driver it is disabled. On a shared IRQ
1949 * executing interrupts for this IRQ have completed.
1955 const void *free_irq(unsigned int irq, void *dev_id) in free_irq() argument
1957 struct irq_desc *desc = irq_to_desc(irq); in free_irq()
1981 static const void *__cleanup_nmi(unsigned int irq, struct irq_desc *desc) in __cleanup_nmi() argument
1990 unregister_handler_proc(irq, desc->action); in __cleanup_nmi()
2007 const void *free_nmi(unsigned int irq, void *dev_id) in free_nmi() argument
2009 struct irq_desc *desc = irq_to_desc(irq); in free_nmi()
2019 disable_nmi_nosync(irq); in free_nmi()
2023 return __cleanup_nmi(irq, desc); in free_nmi()
2028 * @irq: Interrupt line to allocate
2029 * @handler: Function to be called when the IRQ occurs.
2033 * @thread_fn: Function called from the irq handler thread
2034 * If NULL, no irq thread is created
2040 * and IRQ handling. From the point this call is made your handler function
2045 * If you want to set up a threaded irq handler for your device then you
2066 int request_threaded_irq(unsigned int irq, irq_handler_t handler, in request_threaded_irq() argument
2074 if (irq == IRQ_NOTCONNECTED) in request_threaded_irq()
2096 desc = irq_to_desc(irq); in request_threaded_irq()
2126 retval = __setup_irq(irq, desc, action); in request_threaded_irq()
2137 * It's a shared IRQ -- the driver ought to be prepared for it in request_threaded_irq()
2139 * We disable the irq to make sure that a 'real' IRQ doesn't in request_threaded_irq()
2144 disable_irq(irq); in request_threaded_irq()
2147 handler(irq, dev_id); in request_threaded_irq()
2150 enable_irq(irq); in request_threaded_irq()
2159 * @irq: Interrupt line to allocate
2160 * @handler: Function to be called when the IRQ occurs.
2167 * and IRQ handling. It selects either a hardirq or threaded handling
2173 int request_any_context_irq(unsigned int irq, irq_handler_t handler, in request_any_context_irq() argument
2179 if (irq == IRQ_NOTCONNECTED) in request_any_context_irq()
2182 desc = irq_to_desc(irq); in request_any_context_irq()
2187 ret = request_threaded_irq(irq, NULL, handler, in request_any_context_irq()
2192 ret = request_irq(irq, handler, flags, name, dev_id); in request_any_context_irq()
2199 * @irq: Interrupt line to allocate
2200 * @handler: Function to be called when the IRQ occurs.
2207 * and IRQ handling. It sets up the IRQ line to be handled as an NMI.
2209 * An interrupt line delivering NMIs cannot be shared and IRQ handling
2222 int request_nmi(unsigned int irq, irq_handler_t handler, in request_nmi() argument
2229 if (irq == IRQ_NOTCONNECTED) in request_nmi()
2242 desc = irq_to_desc(irq); in request_nmi()
2264 retval = __setup_irq(irq, desc, action); in request_nmi()
2273 __cleanup_nmi(irq, desc); in request_nmi()
2287 void enable_percpu_irq(unsigned int irq, unsigned int type) in enable_percpu_irq() argument
2289 scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_PERCPU) { in enable_percpu_irq()
2302 WARN(1, "failed to set type for IRQ%d\n", irq); in enable_percpu_irq()
2311 void enable_percpu_nmi(unsigned int irq, unsigned int type) in enable_percpu_nmi() argument
2313 enable_percpu_irq(irq, type); in enable_percpu_nmi()
2317 * irq_percpu_is_enabled - Check whether the per cpu irq is enabled
2318 * @irq: Linux irq number to check for
2323 bool irq_percpu_is_enabled(unsigned int irq) in irq_percpu_is_enabled() argument
2325 scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_PERCPU) in irq_percpu_is_enabled()
2331 void disable_percpu_irq(unsigned int irq) in disable_percpu_irq() argument
2333 scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_PERCPU) in disable_percpu_irq()
2338 void disable_percpu_nmi(unsigned int irq) in disable_percpu_nmi() argument
2340 disable_percpu_irq(irq); in disable_percpu_nmi()
2346 static struct irqaction *__free_percpu_irq(unsigned int irq, void __percpu *dev_id) in __free_percpu_irq() argument
2348 struct irq_desc *desc = irq_to_desc(irq); in __free_percpu_irq()
2351 WARN(in_interrupt(), "Trying to free IRQ %d from IRQ context!\n", irq); in __free_percpu_irq()
2359 WARN(1, "Trying to free already-free IRQ %d\n", irq); in __free_percpu_irq()
2364 WARN(1, "percpu IRQ %d still enabled on CPU%d!\n", in __free_percpu_irq()
2365 irq, cpumask_first(desc->percpu_enabled)); in __free_percpu_irq()
2374 unregister_handler_proc(irq, action); in __free_percpu_irq()
2382 * @irq: Interrupt line to free
2388 * interrupts for this IRQ have completed.
2392 void free_percpu_irq(unsigned int irq, void __percpu *dev_id) in free_percpu_irq() argument
2394 struct irq_desc *desc = irq_to_desc(irq); in free_percpu_irq()
2400 kfree(__free_percpu_irq(irq, dev_id)); in free_percpu_irq()
2405 void free_percpu_nmi(unsigned int irq, void __percpu *dev_id) in free_percpu_nmi() argument
2407 struct irq_desc *desc = irq_to_desc(irq); in free_percpu_nmi()
2415 kfree(__free_percpu_irq(irq, dev_id)); in free_percpu_nmi()
2420 * @irq: Interrupt line to setup
2425 int setup_percpu_irq(unsigned int irq, struct irqaction *act) in setup_percpu_irq() argument
2427 struct irq_desc *desc = irq_to_desc(irq); in setup_percpu_irq()
2437 retval = __setup_irq(irq, desc, act); in setup_percpu_irq()
2447 * @irq: Interrupt line to allocate
2448 * @handler: Function to be called when the IRQ occurs.
2461 int __request_percpu_irq(unsigned int irq, irq_handler_t handler, in __request_percpu_irq() argument
2472 desc = irq_to_desc(irq); in __request_percpu_irq()
2495 retval = __setup_irq(irq, desc, action); in __request_percpu_irq()
2508 * @irq: Interrupt line to allocate
2509 * @handler: Function to be called when the IRQ occurs.
2527 int request_percpu_nmi(unsigned int irq, irq_handler_t handler, in request_percpu_nmi() argument
2537 desc = irq_to_desc(irq); in request_percpu_nmi()
2563 retval = __setup_irq(irq, desc, action); in request_percpu_nmi()
2581 * @irq: Interrupt line to prepare for NMI delivery
2592 int prepare_percpu_nmi(unsigned int irq) in prepare_percpu_nmi() argument
2598 scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_PERCPU) { in prepare_percpu_nmi()
2600 "prepare_percpu_nmi called for a non-NMI interrupt: irq %u\n", irq)) in prepare_percpu_nmi()
2605 pr_err("Failed to setup NMI delivery: irq %u\n", irq); in prepare_percpu_nmi()
2611 * teardown_percpu_nmi - undoes NMI setup of IRQ line
2612 * @irq: Interrupt line from which CPU local NMI configuration should be removed
2616 * IRQ line should not be enabled for the current CPU.
2620 void teardown_percpu_nmi(unsigned int irq) in teardown_percpu_nmi() argument
2624 scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_PERCPU) { in teardown_percpu_nmi()
2656 * @irq: Interrupt line that is forwarded to a VM
2666 int irq_get_irqchip_state(unsigned int irq, enum irqchip_irq_state which, bool *state) in irq_get_irqchip_state() argument
2668 scoped_irqdesc_get_and_buslock(irq, 0) { in irq_get_irqchip_state()
2679 * @irq: Interrupt line that is forwarded to a VM
2689 int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which, bool val) in irq_set_irqchip_state() argument
2691 scoped_irqdesc_get_and_buslock(irq, 0) { in irq_set_irqchip_state()
2716 * @irq: The linux irq number
2720 bool irq_has_action(unsigned int irq) in irq_has_action() argument
2725 res = irq_desc_has_action(irq_to_desc(irq)); in irq_has_action()
2732 * irq_check_status_bit - Check whether bits in the irq descriptor status are set
2733 * @irq: The linux irq number
2738 bool irq_check_status_bit(unsigned int irq, unsigned int bitmask) in irq_check_status_bit() argument
2744 desc = irq_to_desc(irq); in irq_check_status_bit()