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()
329 * Handle irq chips which can handle affinity only in activated in irq_set_affinity_deactivated()
382 * @irq: The interrupt number to update
389 * for when the kernel is configured for generic IRQ reservation mode (in
395 int irq_update_affinity_desc(unsigned int irq, in irq_update_affinity_desc() argument
410 desc = irq_get_desc_buslock(irq, &flags, 0); in irq_update_affinity_desc()
450 static int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, in __irq_set_affinity() argument
453 struct irq_desc *desc = irq_to_desc(irq); in __irq_set_affinity()
467 * irq_set_affinity - Set the irq affinity of a given irq
468 * @irq: Interrupt to set affinity
473 int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask) in irq_set_affinity() argument
475 return __irq_set_affinity(irq, cpumask, false); in irq_set_affinity()
480 * irq_force_affinity - Force the irq affinity of a given irq
481 * @irq: Interrupt to set affinity
490 int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask) in irq_force_affinity() argument
492 return __irq_set_affinity(irq, cpumask, true); in irq_force_affinity()
496 int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m, in __irq_apply_affinity_hint() argument
500 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); in __irq_apply_affinity_hint()
507 __irq_set_affinity(irq, m, false); in __irq_apply_affinity_hint()
516 struct irq_desc *desc = irq_to_desc(notify->irq); in irq_affinity_notify()
538 * irq_set_affinity_notifier - control notification of IRQ affinity changes
539 * @irq: Interrupt for which to enable/disable notification
545 * after the IRQ is allocated and must be disabled before the IRQ is
549 irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify) in irq_set_affinity_notifier() argument
551 struct irq_desc *desc = irq_to_desc(irq); in irq_set_affinity_notifier()
563 notify->irq = irq; in irq_set_affinity_notifier()
641 * @irq: interrupt number to set affinity
646 * affinity for an irq. The vCPU specific data is passed from
650 int irq_set_vcpu_affinity(unsigned int irq, void *vcpu_info) in irq_set_vcpu_affinity() argument
653 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); in irq_set_vcpu_affinity()
687 static int __disable_irq_nosync(unsigned int irq) in __disable_irq_nosync() argument
690 struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); in __disable_irq_nosync()
700 * disable_irq_nosync - disable an irq without waiting
701 * @irq: Interrupt to disable
706 * instances of the IRQ handler have completed before returning.
708 * This function may be called from IRQ context.
710 void disable_irq_nosync(unsigned int irq) in disable_irq_nosync() argument
712 __disable_irq_nosync(irq); in disable_irq_nosync()
717 * disable_irq - disable an irq and wait for completion
718 * @irq: Interrupt to disable
722 * This function waits for any pending IRQ handlers for this interrupt
724 * holding a resource the IRQ handler may need you will deadlock.
726 * This function may be called - with care - from IRQ context.
728 void disable_irq(unsigned int irq) in disable_irq() argument
730 if (!__disable_irq_nosync(irq)) in disable_irq()
731 synchronize_irq(irq); in disable_irq()
736 * disable_hardirq - disables an irq and waits for hardirq completion
737 * @irq: Interrupt to disable
741 * This function waits for any pending hard IRQ handlers for this
743 * holding a resource the hard IRQ handler may need you will deadlock.
750 * This function may be called - with care - from IRQ context.
752 bool disable_hardirq(unsigned int irq) in disable_hardirq() argument
754 if (!__disable_irq_nosync(irq)) in disable_hardirq()
755 return synchronize_hardirq(irq); in disable_hardirq()
763 * @irq: Interrupt to disable
769 * instances of the IRQ handler have completed before returning.
771 void disable_nmi_nosync(unsigned int irq) in disable_nmi_nosync() argument
773 disable_irq_nosync(irq); in disable_nmi_nosync()
781 WARN(1, KERN_WARNING "Unbalanced enable for IRQ %d\n", in __enable_irq()
787 /* Prevent probing on this irq: */ in __enable_irq()
805 * enable_irq - enable handling of an irq
806 * @irq: Interrupt to enable
810 * IRQ line is re-enabled.
812 * This function may be called from IRQ context only when
815 void enable_irq(unsigned int irq) in enable_irq() argument
818 struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); in enable_irq()
823 KERN_ERR "enable_irq before setup/request_irq: irq %u\n", irq)) in enable_irq()
834 * @irq: Interrupt to enable
839 * IRQ line is re-enabled.
841 void enable_nmi(unsigned int irq) in enable_nmi() argument
843 enable_irq(irq); in enable_nmi()
846 static int set_irq_wake_real(unsigned int irq, unsigned int on) in set_irq_wake_real() argument
848 struct irq_desc *desc = irq_to_desc(irq); in set_irq_wake_real()
861 * irq_set_irq_wake - control irq power management wakeup
862 * @irq: interrupt to control
869 * Wakeup mode lets this IRQ wake the system from sleep
872 * Note: irq enable/disable state is completely orthogonal
873 * to the enable/disable state of irq wake. An irq can be
875 * long as the irq has wake enabled. If this does not hold,
876 * then the underlying irq chip and the related driver need
879 int irq_set_irq_wake(unsigned int irq, unsigned int on) in irq_set_irq_wake() argument
882 struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); in irq_set_irq_wake()
899 ret = set_irq_wake_real(irq, on); in irq_set_irq_wake()
907 WARN(1, "Unbalanced IRQ %d wake disable\n", irq); in irq_set_irq_wake()
909 ret = set_irq_wake_real(irq, on); in irq_set_irq_wake()
925 * particular irq has been exclusively allocated or is available
928 int can_request_irq(unsigned int irq, unsigned long irqflags) in can_request_irq() argument
931 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); in can_request_irq()
956 pr_debug("No set_type function for IRQ %d (%s)\n", in __irq_set_trigger()
993 pr_err("Setting trigger mode %lu for irq %u failed (%pS)\n", in __irq_set_trigger()
1002 int irq_set_parent(int irq, int parent_irq) in irq_set_parent() argument
1005 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); in irq_set_parent()
1023 static irqreturn_t irq_default_primary_handler(int irq, void *dev_id) in irq_default_primary_handler() argument
1032 static irqreturn_t irq_nested_primary_handler(int irq, void *dev_id) in irq_nested_primary_handler() argument
1034 WARN(1, "Primary handler called for nested irq %d\n", irq); in irq_nested_primary_handler()
1038 static irqreturn_t irq_forced_secondary_handler(int irq, void *dev_id) in irq_forced_secondary_handler() argument
1040 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()
1172 * interrupts rely on the implicit bh/preempt disable of the hard irq
1184 ret = action->thread_fn(action->irq, action->dev_id); in irq_forced_thread_fn()
1205 ret = action->thread_fn(action->irq, action->dev_id); in irq_thread_fn()
1230 pr_err("exiting task \"%s\" (%d) is an active IRQ thread (irq %d)\n", in irq_thread_dtor()
1231 tsk->comm, tsk->pid, action->irq); in irq_thread_dtor()
1234 desc = irq_to_desc(action->irq); in irq_thread_dtor()
1290 struct irq_desc *desc = irq_to_desc(action->irq); in irq_thread()
1332 * irq_wake_thread - wake the irq thread for the action identified by dev_id
1333 * @irq: Interrupt line
1337 void irq_wake_thread(unsigned int irq, void *dev_id) in irq_wake_thread() argument
1339 struct irq_desc *desc = irq_to_desc(irq); in irq_wake_thread()
1387 new->secondary->irq = new->irq; in irq_setup_forced_threading()
1448 setup_irq_thread(struct irqaction *new, unsigned int irq, bool secondary) in setup_irq_thread() argument
1453 t = kthread_create(irq_thread, new, "irq/%d-%s", irq, in setup_irq_thread()
1456 t = kthread_create(irq_thread, new, "irq/%d-s-%s", irq, in setup_irq_thread()
1497 __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) in __setup_irq() argument
1511 new->irq = irq; in __setup_irq()
1550 ret = setup_irq_thread(new, irq, false); in __setup_irq()
1554 ret = setup_irq_thread(new->secondary, irq, true); in __setup_irq()
1562 * underlying irq chip implementation, so a request for a in __setup_irq()
1563 * threaded irq without a primary hard irq context handler in __setup_irq()
1564 * requires the ONESHOT flag to be set. Some irq chips like in __setup_irq()
1592 pr_err("Failed to request resources for %s (irq %d) on irqchip %s\n", in __setup_irq()
1593 new->name, irq, desc->irq_data.chip->name); in __setup_irq()
1619 pr_err("Invalid attempt to share NMI for %s (irq %d) on irqchip %s.\n", in __setup_irq()
1620 new->name, irq, desc->irq_data.chip->name); in __setup_irq()
1646 /* add new interrupt at end of irq queue */ in __setup_irq()
1684 * If no thread is woken by primary (hard irq context) in __setup_irq()
1686 * also checked for zero to unmask the irq line in the in __setup_irq()
1687 * affected hard irq flow handlers in __setup_irq()
1704 * the irq lines is reenabled, but the device still in __setup_irq()
1705 * has the level irq asserted. Rinse and repeat.... in __setup_irq()
1713 pr_err("Threaded irq requested with handler=NULL and !ONESHOT for %s (irq %d)\n", in __setup_irq()
1714 new->name, irq); in __setup_irq()
1761 /* Exclude IRQ from balancing if requested */ in __setup_irq()
1788 pr_warn("irq %d uses trigger mode %u; requested %u\n", in __setup_irq()
1789 irq, omsk, nmsk); in __setup_irq()
1796 /* Reset broken irq detection when installing new handler */ in __setup_irq()
1801 * Check whether we disabled the irq via the spurious handler in __setup_irq()
1818 register_irq_proc(irq, desc); in __setup_irq()
1820 register_handler_proc(irq, new); in __setup_irq()
1825 pr_err("Flags mismatch irq %d. %08x (%s) vs. %08x (%s)\n", in __setup_irq()
1826 irq, new->flags, new->name, old->flags, old->name); in __setup_irq()
1868 unsigned irq = desc->irq_data.irq; in __free_irq() local
1872 WARN(in_interrupt(), "Trying to free IRQ %d from IRQ context!\n", irq); in __free_irq()
1879 * There can be multiple actions per IRQ descriptor, find the right in __free_irq()
1887 WARN(1, "Trying to free already-free IRQ %d\n", irq); in __free_irq()
1904 /* If this was the last handler, shut down the IRQ line: */ in __free_irq()
1920 * callbacks above are synced out to the irq chips which hang in __free_irq()
1929 * concurrent request_irq() of this irq so the release of resources in __free_irq()
1934 unregister_handler_proc(irq, action); in __free_irq()
1945 * It's a shared IRQ -- the driver ought to be prepared for an IRQ in __free_irq()
1950 * 'real' IRQ doesn't run in parallel with our fake. ) in __free_irq()
1954 action->handler(irq, dev_id); in __free_irq()
2004 * @irq: Interrupt line to free
2009 * On a shared IRQ the caller must ensure the interrupt is disabled
2011 * does not return until any executing interrupts for this IRQ
2018 const void *free_irq(unsigned int irq, void *dev_id) in free_irq() argument
2020 struct irq_desc *desc = irq_to_desc(irq); in free_irq()
2044 static const void *__cleanup_nmi(unsigned int irq, struct irq_desc *desc) in __cleanup_nmi() argument
2053 unregister_handler_proc(irq, desc->action); in __cleanup_nmi()
2070 const void *free_nmi(unsigned int irq, void *dev_id) in free_nmi() argument
2072 struct irq_desc *desc = irq_to_desc(irq); in free_nmi()
2084 disable_nmi_nosync(irq); in free_nmi()
2089 devname = __cleanup_nmi(irq, desc); in free_nmi()
2098 * @irq: Interrupt line to allocate
2099 * @handler: Function to be called when the IRQ occurs.
2103 * @thread_fn: Function called from the irq handler thread
2104 * If NULL, no irq thread is created
2110 * interrupt line and IRQ handling. From the point this
2116 * If you want to set up a threaded irq handler for your device
2138 int request_threaded_irq(unsigned int irq, irq_handler_t handler, in request_threaded_irq() argument
2146 if (irq == IRQ_NOTCONNECTED) in request_threaded_irq()
2168 desc = irq_to_desc(irq); in request_threaded_irq()
2198 retval = __setup_irq(irq, desc, action); in request_threaded_irq()
2209 * It's a shared IRQ -- the driver ought to be prepared for it in request_threaded_irq()
2211 * We disable the irq to make sure that a 'real' IRQ doesn't in request_threaded_irq()
2216 disable_irq(irq); in request_threaded_irq()
2219 handler(irq, dev_id); in request_threaded_irq()
2222 enable_irq(irq); in request_threaded_irq()
2231 * @irq: Interrupt line to allocate
2232 * @handler: Function to be called when the IRQ occurs.
2239 * interrupt line and IRQ handling. It selects either a
2246 int request_any_context_irq(unsigned int irq, irq_handler_t handler, in request_any_context_irq() argument
2252 if (irq == IRQ_NOTCONNECTED) in request_any_context_irq()
2255 desc = irq_to_desc(irq); in request_any_context_irq()
2260 ret = request_threaded_irq(irq, NULL, handler, in request_any_context_irq()
2265 ret = request_irq(irq, handler, flags, name, dev_id); in request_any_context_irq()
2272 * @irq: Interrupt line to allocate
2273 * @handler: Function to be called when the IRQ occurs.
2280 * interrupt line and IRQ handling. It sets up the IRQ line
2283 * An interrupt line delivering NMIs cannot be shared and IRQ handling
2296 int request_nmi(unsigned int irq, irq_handler_t handler, in request_nmi() argument
2304 if (irq == IRQ_NOTCONNECTED) in request_nmi()
2317 desc = irq_to_desc(irq); in request_nmi()
2339 retval = __setup_irq(irq, desc, action); in request_nmi()
2349 __cleanup_nmi(irq, desc); in request_nmi()
2366 void enable_percpu_irq(unsigned int irq, unsigned int type) in enable_percpu_irq() argument
2370 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_PERCPU); in enable_percpu_irq()
2389 WARN(1, "failed to set type for IRQ%d\n", irq); in enable_percpu_irq()
2400 void enable_percpu_nmi(unsigned int irq, unsigned int type) in enable_percpu_nmi() argument
2402 enable_percpu_irq(irq, type); in enable_percpu_nmi()
2406 * irq_percpu_is_enabled - Check whether the per cpu irq is enabled
2407 * @irq: Linux irq number to check for
2412 bool irq_percpu_is_enabled(unsigned int irq) in irq_percpu_is_enabled() argument
2419 desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_PERCPU); in irq_percpu_is_enabled()
2430 void disable_percpu_irq(unsigned int irq) in disable_percpu_irq() argument
2434 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_PERCPU); in disable_percpu_irq()
2444 void disable_percpu_nmi(unsigned int irq) in disable_percpu_nmi() argument
2446 disable_percpu_irq(irq); in disable_percpu_nmi()
2452 static struct irqaction *__free_percpu_irq(unsigned int irq, void __percpu *dev_id) in __free_percpu_irq() argument
2454 struct irq_desc *desc = irq_to_desc(irq); in __free_percpu_irq()
2458 WARN(in_interrupt(), "Trying to free IRQ %d from IRQ context!\n", irq); in __free_percpu_irq()
2467 WARN(1, "Trying to free already-free IRQ %d\n", irq); in __free_percpu_irq()
2472 WARN(1, "percpu IRQ %d still enabled on CPU%d!\n", in __free_percpu_irq()
2473 irq, cpumask_first(desc->percpu_enabled)); in __free_percpu_irq()
2484 unregister_handler_proc(irq, action); in __free_percpu_irq()
2497 * @irq: Interrupt line to free
2502 void remove_percpu_irq(unsigned int irq, struct irqaction *act) in remove_percpu_irq() argument
2504 struct irq_desc *desc = irq_to_desc(irq); in remove_percpu_irq()
2507 __free_percpu_irq(irq, act->percpu_dev_id); in remove_percpu_irq()
2512 * @irq: Interrupt line to free
2518 * until any executing interrupts for this IRQ have completed.
2522 void free_percpu_irq(unsigned int irq, void __percpu *dev_id) in free_percpu_irq() argument
2524 struct irq_desc *desc = irq_to_desc(irq); in free_percpu_irq()
2530 kfree(__free_percpu_irq(irq, dev_id)); in free_percpu_irq()
2535 void free_percpu_nmi(unsigned int irq, void __percpu *dev_id) in free_percpu_nmi() argument
2537 struct irq_desc *desc = irq_to_desc(irq); in free_percpu_nmi()
2545 kfree(__free_percpu_irq(irq, dev_id)); in free_percpu_nmi()
2550 * @irq: Interrupt line to setup
2555 int setup_percpu_irq(unsigned int irq, struct irqaction *act) in setup_percpu_irq() argument
2557 struct irq_desc *desc = irq_to_desc(irq); in setup_percpu_irq()
2567 retval = __setup_irq(irq, desc, act); in setup_percpu_irq()
2577 * @irq: Interrupt line to allocate
2578 * @handler: Function to be called when the IRQ occurs.
2592 int __request_percpu_irq(unsigned int irq, irq_handler_t handler, in __request_percpu_irq() argument
2603 desc = irq_to_desc(irq); in __request_percpu_irq()
2626 retval = __setup_irq(irq, desc, action); in __request_percpu_irq()
2639 * @irq: Interrupt line to allocate
2640 * @handler: Function to be called when the IRQ occurs.
2658 int request_percpu_nmi(unsigned int irq, irq_handler_t handler, in request_percpu_nmi() argument
2669 desc = irq_to_desc(irq); in request_percpu_nmi()
2695 retval = __setup_irq(irq, desc, action); in request_percpu_nmi()
2715 * @irq: Interrupt line to prepare for NMI delivery
2726 int prepare_percpu_nmi(unsigned int irq) in prepare_percpu_nmi() argument
2734 desc = irq_get_desc_lock(irq, &flags, in prepare_percpu_nmi()
2740 KERN_ERR "prepare_percpu_nmi called for a non-NMI interrupt: irq %u\n", in prepare_percpu_nmi()
2741 irq)) { in prepare_percpu_nmi()
2748 pr_err("Failed to setup NMI delivery: irq %u\n", irq); in prepare_percpu_nmi()
2758 * teardown_percpu_nmi - undoes NMI setup of IRQ line
2759 * @irq: Interrupt line from which CPU local NMI configuration should be
2764 * IRQ line should not be enabled for the current CPU.
2769 void teardown_percpu_nmi(unsigned int irq) in teardown_percpu_nmi() argument
2776 desc = irq_get_desc_lock(irq, &flags, in teardown_percpu_nmi()
2815 * @irq: Interrupt line that is forwarded to a VM
2826 int irq_get_irqchip_state(unsigned int irq, enum irqchip_irq_state which, in irq_get_irqchip_state() argument
2834 desc = irq_get_desc_buslock(irq, &flags, 0); in irq_get_irqchip_state()
2849 * @irq: Interrupt line that is forwarded to a VM
2859 int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which, in irq_set_irqchip_state() argument
2868 desc = irq_get_desc_buslock(irq, &flags, 0); in irq_set_irqchip_state()
2900 * @irq: The linux irq number
2904 bool irq_has_action(unsigned int irq) in irq_has_action() argument
2909 res = irq_desc_has_action(irq_to_desc(irq)); in irq_has_action()
2916 * irq_check_status_bit - Check whether bits in the irq descriptor status are set
2917 * @irq: The linux irq number
2922 bool irq_check_status_bit(unsigned int irq, unsigned int bitmask) in irq_check_status_bit() argument
2928 desc = irq_to_desc(irq); in irq_check_status_bit()