^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * IRQ subsystem internal functions and variables:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Do not ever include this file from anything else than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * kernel/irq/. Do not even think about using any information outside
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * of this file for your non core code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/irqdesc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/kernel_stat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/pm_runtime.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/sched/clock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #ifdef CONFIG_SPARSE_IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) # define IRQ_BITMAP_BITS (NR_IRQS + 8196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) # define IRQ_BITMAP_BITS NR_IRQS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define istate core_internal_state__do_not_mess_with_it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) extern bool noirqdebug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) extern struct irqaction chained_action;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * Bits used by threaded handlers:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * IRQTF_RUNTHREAD - signals that the interrupt handler thread should run
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * IRQTF_WARNED - warning "IRQ_WAKE_THREAD w/o thread_fn" has been printed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * IRQTF_AFFINITY - irq thread is requested to adjust affinity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * IRQTF_FORCED_THREAD - irq action is force threaded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) IRQTF_RUNTHREAD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) IRQTF_WARNED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) IRQTF_AFFINITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) IRQTF_FORCED_THREAD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * Bit masks for desc->core_internal_state__do_not_mess_with_it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * IRQS_AUTODETECT - autodetection in progress
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * IRQS_SPURIOUS_DISABLED - was disabled due to spurious interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * detection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * IRQS_POLL_INPROGRESS - polling in progress
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * IRQS_ONESHOT - irq is not unmasked in primary handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * IRQS_REPLAY - irq is replayed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * IRQS_WAITING - irq is waiting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * IRQS_PENDING - irq is pending and replayed later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * IRQS_SUSPENDED - irq is suspended
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * IRQS_NMI - irq line is used to deliver NMIs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) IRQS_AUTODETECT = 0x00000001,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) IRQS_SPURIOUS_DISABLED = 0x00000002,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) IRQS_POLL_INPROGRESS = 0x00000008,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) IRQS_ONESHOT = 0x00000020,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) IRQS_REPLAY = 0x00000040,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) IRQS_WAITING = 0x00000080,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) IRQS_PENDING = 0x00000200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) IRQS_SUSPENDED = 0x00000800,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) IRQS_TIMINGS = 0x00001000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) IRQS_NMI = 0x00002000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #include "debug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #include "settings.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) extern int __irq_set_trigger(struct irq_desc *desc, unsigned long flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) extern void __disable_irq(struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) extern void __enable_irq(struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #define IRQ_RESEND true
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #define IRQ_NORESEND false
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #define IRQ_START_FORCE true
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #define IRQ_START_COND false
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) extern int irq_activate(struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) extern int irq_activate_and_startup(struct irq_desc *desc, bool resend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) extern int irq_startup(struct irq_desc *desc, bool resend, bool force);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) extern void irq_shutdown(struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) extern void irq_shutdown_and_deactivate(struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) extern void irq_enable(struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) extern void irq_disable(struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) extern void irq_percpu_enable(struct irq_desc *desc, unsigned int cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) extern void irq_percpu_disable(struct irq_desc *desc, unsigned int cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) extern void mask_irq(struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) extern void unmask_irq(struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) extern void unmask_threaded_irq(struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #ifdef CONFIG_SPARSE_IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) static inline void irq_mark_irq(unsigned int irq) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) extern void irq_mark_irq(unsigned int irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) extern int __irq_get_irqchip_state(struct irq_data *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) enum irqchip_irq_state which,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) bool *state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) irqreturn_t __handle_irq_event_percpu(struct irq_desc *desc, unsigned int *flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) irqreturn_t handle_irq_event_percpu(struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) irqreturn_t handle_irq_event(struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) /* Resending of interrupts :*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) int check_irq_resend(struct irq_desc *desc, bool inject);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) bool irq_wait_for_poll(struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) void __irq_wake_thread(struct irq_desc *desc, struct irqaction *action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #ifdef CONFIG_PROC_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) extern void register_irq_proc(unsigned int irq, struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) extern void unregister_irq_proc(unsigned int irq, struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) extern void register_handler_proc(unsigned int irq, struct irqaction *action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) extern void unregister_handler_proc(unsigned int irq, struct irqaction *action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static inline void register_irq_proc(unsigned int irq, struct irq_desc *desc) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static inline void unregister_irq_proc(unsigned int irq, struct irq_desc *desc) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) static inline void register_handler_proc(unsigned int irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) struct irqaction *action) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static inline void unregister_handler_proc(unsigned int irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) struct irqaction *action) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) extern bool irq_can_set_affinity_usr(unsigned int irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) extern void irq_set_thread_affinity(struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) extern int irq_do_set_affinity(struct irq_data *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) const struct cpumask *dest, bool force);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #ifdef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) extern int irq_setup_affinity(struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) static inline int irq_setup_affinity(struct irq_desc *desc) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) /* Inline functions for support of irq chips on slow busses */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static inline void chip_bus_lock(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) if (unlikely(desc->irq_data.chip->irq_bus_lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) desc->irq_data.chip->irq_bus_lock(&desc->irq_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) static inline void chip_bus_sync_unlock(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) if (unlikely(desc->irq_data.chip->irq_bus_sync_unlock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) desc->irq_data.chip->irq_bus_sync_unlock(&desc->irq_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #define _IRQ_DESC_CHECK (1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) #define _IRQ_DESC_PERCPU (1 << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) #define IRQ_GET_DESC_CHECK_GLOBAL (_IRQ_DESC_CHECK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) #define IRQ_GET_DESC_CHECK_PERCPU (_IRQ_DESC_CHECK | _IRQ_DESC_PERCPU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) #define for_each_action_of_desc(desc, act) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) for (act = desc->action; act; act = act->next)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) struct irq_desc *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) __irq_get_desc_lock(unsigned int irq, unsigned long *flags, bool bus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) unsigned int check);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) void __irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags, bool bus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) static inline struct irq_desc *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) irq_get_desc_buslock(unsigned int irq, unsigned long *flags, unsigned int check)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) return __irq_get_desc_lock(irq, flags, true, check);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) irq_put_desc_busunlock(struct irq_desc *desc, unsigned long flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) __irq_put_desc_unlock(desc, flags, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) static inline struct irq_desc *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) irq_get_desc_lock(unsigned int irq, unsigned long *flags, unsigned int check)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) return __irq_get_desc_lock(irq, flags, false, check);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) __irq_put_desc_unlock(desc, flags, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) #define __irqd_to_state(d) ACCESS_PRIVATE((d)->common, state_use_accessors)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) static inline unsigned int irqd_get(struct irq_data *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) return __irqd_to_state(d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) * Manipulation functions for irq_data.state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) static inline void irqd_set_move_pending(struct irq_data *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) __irqd_to_state(d) |= IRQD_SETAFFINITY_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) static inline void irqd_clr_move_pending(struct irq_data *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) __irqd_to_state(d) &= ~IRQD_SETAFFINITY_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) static inline void irqd_set_managed_shutdown(struct irq_data *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) __irqd_to_state(d) |= IRQD_MANAGED_SHUTDOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) static inline void irqd_clr_managed_shutdown(struct irq_data *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) __irqd_to_state(d) &= ~IRQD_MANAGED_SHUTDOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) static inline void irqd_clear(struct irq_data *d, unsigned int mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) __irqd_to_state(d) &= ~mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) static inline void irqd_set(struct irq_data *d, unsigned int mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) __irqd_to_state(d) |= mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) static inline bool irqd_has_set(struct irq_data *d, unsigned int mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) return __irqd_to_state(d) & mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) static inline void irq_state_set_disabled(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) irqd_set(&desc->irq_data, IRQD_IRQ_DISABLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) static inline void irq_state_set_masked(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) irqd_set(&desc->irq_data, IRQD_IRQ_MASKED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) #undef __irqd_to_state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) static inline void __kstat_incr_irqs_this_cpu(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) __this_cpu_inc(*desc->kstat_irqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) __this_cpu_inc(kstat.irqs_sum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) static inline void kstat_incr_irqs_this_cpu(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) __kstat_incr_irqs_this_cpu(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) desc->tot_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) static inline int irq_desc_get_node(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) return irq_common_data_get_node(&desc->irq_common_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) static inline int irq_desc_is_chained(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) return (desc->action && desc->action == &chained_action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) #ifdef CONFIG_PM_SLEEP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) bool irq_pm_check_wakeup(struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) void irq_pm_install_action(struct irq_desc *desc, struct irqaction *action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) void irq_pm_remove_action(struct irq_desc *desc, struct irqaction *action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) static inline bool irq_pm_check_wakeup(struct irq_desc *desc) { return false; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) irq_pm_install_action(struct irq_desc *desc, struct irqaction *action) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) irq_pm_remove_action(struct irq_desc *desc, struct irqaction *action) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) #ifdef CONFIG_IRQ_TIMINGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) #define IRQ_TIMINGS_SHIFT 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) #define IRQ_TIMINGS_SIZE (1 << IRQ_TIMINGS_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) #define IRQ_TIMINGS_MASK (IRQ_TIMINGS_SIZE - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) * struct irq_timings - irq timings storing structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) * @values: a circular buffer of u64 encoded <timestamp,irq> values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) * @count: the number of elements in the array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) struct irq_timings {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) u64 values[IRQ_TIMINGS_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) int count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) DECLARE_PER_CPU(struct irq_timings, irq_timings);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) extern void irq_timings_free(int irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) extern int irq_timings_alloc(int irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) static inline void irq_remove_timings(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) desc->istate &= ~IRQS_TIMINGS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) irq_timings_free(irq_desc_get_irq(desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) static inline void irq_setup_timings(struct irq_desc *desc, struct irqaction *act)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) int irq = irq_desc_get_irq(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) * We don't need the measurement because the idle code already
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) * knows the next expiry event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) if (act->flags & __IRQF_TIMER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) * In case the timing allocation fails, we just want to warn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) * not fail, so letting the system boot anyway.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) ret = irq_timings_alloc(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) pr_warn("Failed to allocate irq timing stats for irq%d (%d)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) irq, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) desc->istate |= IRQS_TIMINGS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) extern void irq_timings_enable(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) extern void irq_timings_disable(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) DECLARE_STATIC_KEY_FALSE(irq_timing_enabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) * The interrupt number and the timestamp are encoded into a single
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) * u64 variable to optimize the size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) * 48 bit time stamp and 16 bit IRQ number is way sufficient.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) * Who cares an IRQ after 78 hours of idle time?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) static inline u64 irq_timing_encode(u64 timestamp, int irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) return (timestamp << 16) | irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) static inline int irq_timing_decode(u64 value, u64 *timestamp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) *timestamp = value >> 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) return value & U16_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) static __always_inline void irq_timings_push(u64 ts, int irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) struct irq_timings *timings = this_cpu_ptr(&irq_timings);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) timings->values[timings->count & IRQ_TIMINGS_MASK] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) irq_timing_encode(ts, irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) timings->count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) * The function record_irq_time is only called in one place in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) * interrupts handler. We want this function always inline so the code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) * inside is embedded in the function and the static key branching
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) * code can act at the higher level. Without the explicit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) * __always_inline we can end up with a function call and a small
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) * overhead in the hotpath for nothing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) static __always_inline void record_irq_time(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) if (!static_branch_likely(&irq_timing_enabled))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) if (desc->istate & IRQS_TIMINGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) irq_timings_push(local_clock(), irq_desc_get_irq(desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) static inline void irq_remove_timings(struct irq_desc *desc) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) static inline void irq_setup_timings(struct irq_desc *desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) struct irqaction *act) {};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) static inline void record_irq_time(struct irq_desc *desc) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) #endif /* CONFIG_IRQ_TIMINGS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) #ifdef CONFIG_GENERIC_IRQ_CHIP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) void irq_init_generic_chip(struct irq_chip_generic *gc, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) int num_ct, unsigned int irq_base,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) void __iomem *reg_base, irq_flow_handler_t handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) irq_init_generic_chip(struct irq_chip_generic *gc, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) int num_ct, unsigned int irq_base,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) void __iomem *reg_base, irq_flow_handler_t handler) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) #endif /* CONFIG_GENERIC_IRQ_CHIP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) #ifdef CONFIG_GENERIC_PENDING_IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) static inline bool irq_can_move_pcntxt(struct irq_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) return irqd_can_move_in_process_context(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) static inline bool irq_move_pending(struct irq_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) return irqd_is_setaffinity_pending(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) irq_copy_pending(struct irq_desc *desc, const struct cpumask *mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) cpumask_copy(desc->pending_mask, mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) irq_get_pending(struct cpumask *mask, struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) cpumask_copy(mask, desc->pending_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) static inline struct cpumask *irq_desc_get_pending_mask(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) return desc->pending_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) static inline bool handle_enforce_irqctx(struct irq_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) return irqd_is_handle_enforce_irqctx(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) bool irq_fixup_move_pending(struct irq_desc *desc, bool force_clear);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) #else /* CONFIG_GENERIC_PENDING_IRQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) static inline bool irq_can_move_pcntxt(struct irq_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) static inline bool irq_move_pending(struct irq_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) irq_copy_pending(struct irq_desc *desc, const struct cpumask *mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) irq_get_pending(struct cpumask *mask, struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) static inline struct cpumask *irq_desc_get_pending_mask(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) static inline bool irq_fixup_move_pending(struct irq_desc *desc, bool fclear)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) static inline bool handle_enforce_irqctx(struct irq_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) #endif /* !CONFIG_GENERIC_PENDING_IRQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) #if !defined(CONFIG_IRQ_DOMAIN) || !defined(CONFIG_IRQ_DOMAIN_HIERARCHY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) static inline int irq_domain_activate_irq(struct irq_data *data, bool reserve)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) irqd_set_activated(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) static inline void irq_domain_deactivate_irq(struct irq_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) irqd_clr_activated(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) static inline struct irq_data *irqd_get_parent_data(struct irq_data *irqd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) return irqd->parent_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) #ifdef CONFIG_GENERIC_IRQ_DEBUGFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) static inline void irq_remove_debugfs_entry(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) debugfs_remove(desc->debugfs_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) kfree(desc->dev_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) void irq_debugfs_copy_devname(int irq, struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) # ifdef CONFIG_IRQ_DOMAIN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) void irq_domain_debugfs_init(struct dentry *root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) # else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) static inline void irq_domain_debugfs_init(struct dentry *root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) # endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) #else /* CONFIG_GENERIC_IRQ_DEBUGFS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) static inline void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) static inline void irq_remove_debugfs_entry(struct irq_desc *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) static inline void irq_debugfs_copy_devname(int irq, struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) #endif /* CONFIG_GENERIC_IRQ_DEBUGFS */