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()
122 * synchronize_irq - wait for pending IRQ handlers (on other CPUs)
123 * @irq: interrupt number to wait for
125 * This function waits for any pending IRQ handlers for this interrupt
127 * holding a resource the IRQ handler may need you will deadlock.
130 * an interrupt thread is associated to @irq.
132 * It optionally makes sure (when the irq chip supports that method)
136 void synchronize_irq(unsigned int irq) in synchronize_irq() argument
138 struct irq_desc *desc = irq_to_desc(irq); in synchronize_irq()
157 * irq_can_set_affinity - Check if the affinity of a given irq can be set
158 * @irq: Interrupt to check
161 int irq_can_set_affinity(unsigned int irq) in irq_can_set_affinity() argument
163 return __irq_can_set_affinity(irq_to_desc(irq)); in irq_can_set_affinity()
167 * irq_can_set_affinity_usr - Check if affinity of a irq can be set from user space
168 * @irq: Interrupt to check
173 bool irq_can_set_affinity_usr(unsigned int irq) in irq_can_set_affinity_usr() argument
175 struct irq_desc *desc = irq_to_desc(irq); in irq_can_set_affinity_usr()
182 * irq_set_thread_affinity - Notify irq threads to adjust affinity
183 * @desc: irq descriptor which has affinity changed
214 pr_warn_once("irq_chip %s did not update eff. affinity mask of irq %u\n", in irq_validate_effective_affinity()
215 chip->name, data->irq); in irq_validate_effective_affinity()
335 * Handle irq chips which can handle affinity only in activated in irq_set_affinity_deactivated()
388 * @irq: The interrupt number to update
395 * for when the kernel is configured for generic IRQ reservation mode (in
401 int irq_update_affinity_desc(unsigned int irq, in irq_update_affinity_desc() argument
416 desc = irq_get_desc_buslock(irq, &flags, 0); in irq_update_affinity_desc()
456 static int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, in __irq_set_affinity() argument
459 struct irq_desc *desc = irq_to_desc(irq); in __irq_set_affinity()
473 * irq_set_affinity - Set the irq affinity of a given irq
474 * @irq: Interrupt to set affinity
479 int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask) in irq_set_affinity() argument
481 return __irq_set_affinity(irq, cpumask, false); in irq_set_affinity()
486 * irq_force_affinity - Force the irq affinity of a given irq
487 * @irq: Interrupt to set affinity
496 int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask) in irq_force_affinity() argument
498 return __irq_set_affinity(irq, cpumask, true); in irq_force_affinity()
502 int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m, in __irq_apply_affinity_hint() argument
506 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); in __irq_apply_affinity_hint()
513 __irq_set_affinity(irq, m, false); in __irq_apply_affinity_hint()
522 struct irq_desc *desc = irq_to_desc(notify->irq); in irq_affinity_notify()
544 * irq_set_affinity_notifier - control notification of IRQ affinity changes
545 * @irq: Interrupt for which to enable/disable notification
551 * after the IRQ is allocated and must be disabled before the IRQ is
555 irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify) in irq_set_affinity_notifier() argument
557 struct irq_desc *desc = irq_to_desc(irq); in irq_set_affinity_notifier()
569 notify->irq = irq; in irq_set_affinity_notifier()
647 * @irq: interrupt number to set affinity
652 * affinity for an irq. The vCPU specific data is passed from
656 int irq_set_vcpu_affinity(unsigned int irq, void *vcpu_info) in irq_set_vcpu_affinity() argument
659 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); in irq_set_vcpu_affinity()
693 static int __disable_irq_nosync(unsigned int irq) in __disable_irq_nosync() argument
696 struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); in __disable_irq_nosync()
706 * disable_irq_nosync - disable an irq without waiting
707 * @irq: Interrupt to disable
712 * instances of the IRQ handler have completed before returning.
714 * This function may be called from IRQ context.
716 void disable_irq_nosync(unsigned int irq) in disable_irq_nosync() argument
718 __disable_irq_nosync(irq); in disable_irq_nosync()
723 * disable_irq - disable an irq and wait for completion
724 * @irq: Interrupt to disable
728 * This function waits for any pending IRQ handlers for this interrupt
730 * holding a resource the IRQ handler may need you will deadlock.
733 * an interrupt thread is associated to @irq.
736 void disable_irq(unsigned int irq) in disable_irq() argument
739 if (!__disable_irq_nosync(irq)) in disable_irq()
740 synchronize_irq(irq); in disable_irq()
745 * disable_hardirq - disables an irq and waits for hardirq completion
746 * @irq: Interrupt to disable
750 * This function waits for any pending hard IRQ handlers for this
752 * holding a resource the hard IRQ handler may need you will deadlock.
759 * This function may be called - with care - from IRQ context.
761 bool disable_hardirq(unsigned int irq) in disable_hardirq() argument
763 if (!__disable_irq_nosync(irq)) in disable_hardirq()
764 return synchronize_hardirq(irq); in disable_hardirq()
772 * @irq: Interrupt to disable
778 * instances of the IRQ handler have completed before returning.
780 void disable_nmi_nosync(unsigned int irq) in disable_nmi_nosync() argument
782 disable_irq_nosync(irq); in disable_nmi_nosync()
790 WARN(1, KERN_WARNING "Unbalanced enable for IRQ %d\n", in __enable_irq()
796 /* Prevent probing on this irq: */ in __enable_irq()
818 * enable_irq - enable handling of an irq
819 * @irq: Interrupt to enable
823 * IRQ line is re-enabled.
825 * This function may be called from IRQ context only when
828 void enable_irq(unsigned int irq) in enable_irq() argument
831 struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); in enable_irq()
836 KERN_ERR "enable_irq before setup/request_irq: irq %u\n", irq)) in enable_irq()
847 * @irq: Interrupt to enable
852 * IRQ line is re-enabled.
854 void enable_nmi(unsigned int irq) in enable_nmi() argument
856 enable_irq(irq); in enable_nmi()
859 static int set_irq_wake_real(unsigned int irq, unsigned int on) in set_irq_wake_real() argument
861 struct irq_desc *desc = irq_to_desc(irq); in set_irq_wake_real()
874 * irq_set_irq_wake - control irq power management wakeup
875 * @irq: interrupt to control
882 * Wakeup mode lets this IRQ wake the system from sleep
885 * Note: irq enable/disable state is completely orthogonal
886 * to the enable/disable state of irq wake. An irq can be
888 * long as the irq has wake enabled. If this does not hold,
889 * then the underlying irq chip and the related driver need
892 int irq_set_irq_wake(unsigned int irq, unsigned int on) in irq_set_irq_wake() argument
895 struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); in irq_set_irq_wake()
912 ret = set_irq_wake_real(irq, on); in irq_set_irq_wake()
920 WARN(1, "Unbalanced IRQ %d wake disable\n", irq); in irq_set_irq_wake()
922 ret = set_irq_wake_real(irq, on); in irq_set_irq_wake()
938 * particular irq has been exclusively allocated or is available
941 int can_request_irq(unsigned int irq, unsigned long irqflags) in can_request_irq() argument
944 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); in can_request_irq()
969 pr_debug("No set_type function for IRQ %d (%s)\n", in __irq_set_trigger()
1006 pr_err("Setting trigger mode %lu for irq %u failed (%pS)\n", in __irq_set_trigger()
1015 int irq_set_parent(int irq, int parent_irq) in irq_set_parent() argument
1018 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); in irq_set_parent()
1036 static irqreturn_t irq_default_primary_handler(int irq, void *dev_id) in irq_default_primary_handler() argument
1045 static irqreturn_t irq_nested_primary_handler(int irq, void *dev_id) in irq_nested_primary_handler() argument
1047 WARN(1, "Primary handler called for nested irq %d\n", irq); in irq_nested_primary_handler()
1051 static irqreturn_t irq_forced_secondary_handler(int irq, void *dev_id) in irq_forced_secondary_handler() argument
1053 WARN(1, "Secondary action handler called for irq %d\n", irq); in irq_forced_secondary_handler()
1130 * Oneshot interrupts keep the irq line masked until the threaded
1149 * on the other CPU. If we unmask the irq line then the in irq_finalize_oneshot()
1151 * to IRQS_INPROGRESS and the irq line is masked forever. in irq_finalize_oneshot()
1186 * interrupts rely on the implicit bh/preempt disable of the hard irq
1198 ret = action->thread_fn(action->irq, action->dev_id); in irq_forced_thread_fn()
1219 ret = action->thread_fn(action->irq, action->dev_id); in irq_thread_fn()
1244 pr_err("exiting task \"%s\" (%d) is an active IRQ thread (irq %d)\n", in irq_thread_dtor()
1245 tsk->comm, tsk->pid, action->irq); in irq_thread_dtor()
1248 desc = irq_to_desc(action->irq); in irq_thread_dtor()
1304 struct irq_desc *desc = irq_to_desc(action->irq); in irq_thread()
1342 * irq_wake_thread - wake the irq thread for the action identified by dev_id
1343 * @irq: Interrupt line
1347 void irq_wake_thread(unsigned int irq, void *dev_id) in irq_wake_thread() argument
1349 struct irq_desc *desc = irq_to_desc(irq); in irq_wake_thread()
1397 new->secondary->irq = new->irq; in irq_setup_forced_threading()
1458 setup_irq_thread(struct irqaction *new, unsigned int irq, bool secondary) in setup_irq_thread() argument
1463 t = kthread_create(irq_thread, new, "irq/%d-%s", irq, in setup_irq_thread()
1466 t = kthread_create(irq_thread, new, "irq/%d-s-%s", irq, in setup_irq_thread()
1507 __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) in __setup_irq() argument
1521 new->irq = irq; in __setup_irq()
1560 ret = setup_irq_thread(new, irq, false); in __setup_irq()
1564 ret = setup_irq_thread(new->secondary, irq, true); in __setup_irq()
1572 * underlying irq chip implementation, so a request for a in __setup_irq()
1573 * threaded irq without a primary hard irq context handler in __setup_irq()
1574 * requires the ONESHOT flag to be set. Some irq chips like in __setup_irq()
1602 pr_err("Failed to request resources for %s (irq %d) on irqchip %s\n", in __setup_irq()
1603 new->name, irq, desc->irq_data.chip->name); in __setup_irq()
1629 pr_err("Invalid attempt to share NMI for %s (irq %d) on irqchip %s.\n", in __setup_irq()
1630 new->name, irq, desc->irq_data.chip->name); in __setup_irq()
1661 /* add new interrupt at end of irq queue */ in __setup_irq()
1699 * If no thread is woken by primary (hard irq context) in __setup_irq()
1701 * also checked for zero to unmask the irq line in the in __setup_irq()
1702 * affected hard irq flow handlers in __setup_irq()
1719 * the irq lines is reenabled, but the device still in __setup_irq()
1720 * has the level irq asserted. Rinse and repeat.... in __setup_irq()
1728 pr_err("Threaded irq requested with handler=NULL and !ONESHOT for %s (irq %d)\n", in __setup_irq()
1729 new->name, irq); in __setup_irq()
1776 /* Exclude IRQ from balancing if requested */ in __setup_irq()
1803 pr_warn("irq %d uses trigger mode %u; requested %u\n", in __setup_irq()
1804 irq, omsk, nmsk); in __setup_irq()
1811 /* Reset broken irq detection when installing new handler */ in __setup_irq()
1816 * Check whether we disabled the irq via the spurious handler in __setup_irq()
1833 register_irq_proc(irq, desc); in __setup_irq()
1835 register_handler_proc(irq, new); in __setup_irq()
1840 pr_err("Flags mismatch irq %d. %08x (%s) vs. %08x (%s)\n", in __setup_irq()
1841 irq, new->flags, new->name, old->flags, old->name); in __setup_irq()
1881 unsigned irq = desc->irq_data.irq; in __free_irq() local
1885 WARN(in_interrupt(), "Trying to free IRQ %d from IRQ context!\n", irq); in __free_irq()
1892 * There can be multiple actions per IRQ descriptor, find the right in __free_irq()
1900 WARN(1, "Trying to free already-free IRQ %d\n", irq); in __free_irq()
1917 /* If this was the last handler, shut down the IRQ line: */ in __free_irq()
1933 * callbacks above are synced out to the irq chips which hang in __free_irq()
1942 * concurrent request_irq() of this irq so the release of resources in __free_irq()
1947 unregister_handler_proc(irq, action); in __free_irq()
1958 * It's a shared IRQ -- the driver ought to be prepared for an IRQ in __free_irq()
1963 * 'real' IRQ doesn't run in parallel with our fake. ) in __free_irq()
1967 action->handler(irq, dev_id); in __free_irq()
2014 * @irq: Interrupt line to free
2019 * On a shared IRQ the caller must ensure the interrupt is disabled
2021 * does not return until any executing interrupts for this IRQ
2028 const void *free_irq(unsigned int irq, void *dev_id) in free_irq() argument
2030 struct irq_desc *desc = irq_to_desc(irq); in free_irq()
2054 static const void *__cleanup_nmi(unsigned int irq, struct irq_desc *desc) in __cleanup_nmi() argument
2063 unregister_handler_proc(irq, desc->action); in __cleanup_nmi()
2080 const void *free_nmi(unsigned int irq, void *dev_id) in free_nmi() argument
2082 struct irq_desc *desc = irq_to_desc(irq); in free_nmi()
2094 disable_nmi_nosync(irq); in free_nmi()
2099 devname = __cleanup_nmi(irq, desc); in free_nmi()
2108 * @irq: Interrupt line to allocate
2109 * @handler: Function to be called when the IRQ occurs.
2113 * @thread_fn: Function called from the irq handler thread
2114 * If NULL, no irq thread is created
2120 * interrupt line and IRQ handling. From the point this
2126 * If you want to set up a threaded irq handler for your device
2148 int request_threaded_irq(unsigned int irq, irq_handler_t handler, in request_threaded_irq() argument
2156 if (irq == IRQ_NOTCONNECTED) in request_threaded_irq()
2178 desc = irq_to_desc(irq); in request_threaded_irq()
2208 retval = __setup_irq(irq, desc, action); in request_threaded_irq()
2219 * It's a shared IRQ -- the driver ought to be prepared for it in request_threaded_irq()
2221 * We disable the irq to make sure that a 'real' IRQ doesn't in request_threaded_irq()
2226 disable_irq(irq); in request_threaded_irq()
2229 handler(irq, dev_id); in request_threaded_irq()
2232 enable_irq(irq); in request_threaded_irq()
2241 * @irq: Interrupt line to allocate
2242 * @handler: Function to be called when the IRQ occurs.
2249 * interrupt line and IRQ handling. It selects either a
2256 int request_any_context_irq(unsigned int irq, irq_handler_t handler, in request_any_context_irq() argument
2262 if (irq == IRQ_NOTCONNECTED) in request_any_context_irq()
2265 desc = irq_to_desc(irq); in request_any_context_irq()
2270 ret = request_threaded_irq(irq, NULL, handler, in request_any_context_irq()
2275 ret = request_irq(irq, handler, flags, name, dev_id); in request_any_context_irq()
2282 * @irq: Interrupt line to allocate
2283 * @handler: Function to be called when the IRQ occurs.
2290 * interrupt line and IRQ handling. It sets up the IRQ line
2293 * An interrupt line delivering NMIs cannot be shared and IRQ handling
2306 int request_nmi(unsigned int irq, irq_handler_t handler, in request_nmi() argument
2314 if (irq == IRQ_NOTCONNECTED) in request_nmi()
2327 desc = irq_to_desc(irq); in request_nmi()
2349 retval = __setup_irq(irq, desc, action); in request_nmi()
2359 __cleanup_nmi(irq, desc); in request_nmi()
2376 void enable_percpu_irq(unsigned int irq, unsigned int type) in enable_percpu_irq() argument
2380 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_PERCPU); in enable_percpu_irq()
2399 WARN(1, "failed to set type for IRQ%d\n", irq); in enable_percpu_irq()
2410 void enable_percpu_nmi(unsigned int irq, unsigned int type) in enable_percpu_nmi() argument
2412 enable_percpu_irq(irq, type); in enable_percpu_nmi()
2416 * irq_percpu_is_enabled - Check whether the per cpu irq is enabled
2417 * @irq: Linux irq number to check for
2422 bool irq_percpu_is_enabled(unsigned int irq) in irq_percpu_is_enabled() argument
2429 desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_PERCPU); in irq_percpu_is_enabled()
2440 void disable_percpu_irq(unsigned int irq) in disable_percpu_irq() argument
2444 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_PERCPU); in disable_percpu_irq()
2454 void disable_percpu_nmi(unsigned int irq) in disable_percpu_nmi() argument
2456 disable_percpu_irq(irq); in disable_percpu_nmi()
2462 static struct irqaction *__free_percpu_irq(unsigned int irq, void __percpu *dev_id) in __free_percpu_irq() argument
2464 struct irq_desc *desc = irq_to_desc(irq); in __free_percpu_irq()
2468 WARN(in_interrupt(), "Trying to free IRQ %d from IRQ context!\n", irq); in __free_percpu_irq()
2477 WARN(1, "Trying to free already-free IRQ %d\n", irq); in __free_percpu_irq()
2482 WARN(1, "percpu IRQ %d still enabled on CPU%d!\n", in __free_percpu_irq()
2483 irq, cpumask_first(desc->percpu_enabled)); in __free_percpu_irq()
2494 unregister_handler_proc(irq, action); in __free_percpu_irq()
2507 * @irq: Interrupt line to free
2512 void remove_percpu_irq(unsigned int irq, struct irqaction *act) in remove_percpu_irq() argument
2514 struct irq_desc *desc = irq_to_desc(irq); in remove_percpu_irq()
2517 __free_percpu_irq(irq, act->percpu_dev_id); in remove_percpu_irq()
2522 * @irq: Interrupt line to free
2528 * until any executing interrupts for this IRQ have completed.
2532 void free_percpu_irq(unsigned int irq, void __percpu *dev_id) in free_percpu_irq() argument
2534 struct irq_desc *desc = irq_to_desc(irq); in free_percpu_irq()
2540 kfree(__free_percpu_irq(irq, dev_id)); in free_percpu_irq()
2545 void free_percpu_nmi(unsigned int irq, void __percpu *dev_id) in free_percpu_nmi() argument
2547 struct irq_desc *desc = irq_to_desc(irq); in free_percpu_nmi()
2555 kfree(__free_percpu_irq(irq, dev_id)); in free_percpu_nmi()
2560 * @irq: Interrupt line to setup
2565 int setup_percpu_irq(unsigned int irq, struct irqaction *act) in setup_percpu_irq() argument
2567 struct irq_desc *desc = irq_to_desc(irq); in setup_percpu_irq()
2577 retval = __setup_irq(irq, desc, act); in setup_percpu_irq()
2587 * @irq: Interrupt line to allocate
2588 * @handler: Function to be called when the IRQ occurs.
2602 int __request_percpu_irq(unsigned int irq, irq_handler_t handler, in __request_percpu_irq() argument
2613 desc = irq_to_desc(irq); in __request_percpu_irq()
2636 retval = __setup_irq(irq, desc, action); in __request_percpu_irq()
2649 * @irq: Interrupt line to allocate
2650 * @handler: Function to be called when the IRQ occurs.
2668 int request_percpu_nmi(unsigned int irq, irq_handler_t handler, in request_percpu_nmi() argument
2679 desc = irq_to_desc(irq); in request_percpu_nmi()
2705 retval = __setup_irq(irq, desc, action); in request_percpu_nmi()
2725 * @irq: Interrupt line to prepare for NMI delivery
2736 int prepare_percpu_nmi(unsigned int irq) in prepare_percpu_nmi() argument
2744 desc = irq_get_desc_lock(irq, &flags, in prepare_percpu_nmi()
2750 KERN_ERR "prepare_percpu_nmi called for a non-NMI interrupt: irq %u\n", in prepare_percpu_nmi()
2751 irq)) { in prepare_percpu_nmi()
2758 pr_err("Failed to setup NMI delivery: irq %u\n", irq); in prepare_percpu_nmi()
2768 * teardown_percpu_nmi - undoes NMI setup of IRQ line
2769 * @irq: Interrupt line from which CPU local NMI configuration should be
2774 * IRQ line should not be enabled for the current CPU.
2779 void teardown_percpu_nmi(unsigned int irq) in teardown_percpu_nmi() argument
2786 desc = irq_get_desc_lock(irq, &flags, in teardown_percpu_nmi()
2825 * @irq: Interrupt line that is forwarded to a VM
2836 int irq_get_irqchip_state(unsigned int irq, enum irqchip_irq_state which, in irq_get_irqchip_state() argument
2844 desc = irq_get_desc_buslock(irq, &flags, 0); in irq_get_irqchip_state()
2859 * @irq: Interrupt line that is forwarded to a VM
2869 int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which, in irq_set_irqchip_state() argument
2878 desc = irq_get_desc_buslock(irq, &flags, 0); in irq_set_irqchip_state()
2910 * @irq: The linux irq number
2914 bool irq_has_action(unsigned int irq) in irq_has_action() argument
2919 res = irq_desc_has_action(irq_to_desc(irq)); in irq_has_action()
2926 * irq_check_status_bit - Check whether bits in the irq descriptor status are set
2927 * @irq: The linux irq number
2932 bool irq_check_status_bit(unsigned int irq, unsigned int bitmask) in irq_check_status_bit() argument
2938 desc = irq_to_desc(irq); in irq_check_status_bit()