Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^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) // Copyright 2017 Thomas Gleixner <tglx@linutronix.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) #include <linux/irqdomain.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include "internals.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) static struct dentry *irq_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) struct irq_bit_descr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 	unsigned int	mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 	char		*name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #define BIT_MASK_DESCR(m)	{ .mask = m, .name = #m }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) static void irq_debug_show_bits(struct seq_file *m, int ind, unsigned int state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 				const struct irq_bit_descr *sd, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	for (i = 0; i < size; i++, sd++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 		if (state & sd->mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 			seq_printf(m, "%*s%s\n", ind + 12, "", sd->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #ifdef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) static void irq_debug_show_masks(struct seq_file *m, struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	struct irq_data *data = irq_desc_get_irq_data(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	struct cpumask *msk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	msk = irq_data_get_affinity_mask(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	seq_printf(m, "affinity: %*pbl\n", cpumask_pr_args(msk));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #ifdef CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	msk = irq_data_get_effective_affinity_mask(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	seq_printf(m, "effectiv: %*pbl\n", cpumask_pr_args(msk));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #ifdef CONFIG_GENERIC_PENDING_IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	msk = desc->pending_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	seq_printf(m, "pending:  %*pbl\n", cpumask_pr_args(msk));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) static void irq_debug_show_masks(struct seq_file *m, struct irq_desc *desc) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) static const struct irq_bit_descr irqchip_flags[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	BIT_MASK_DESCR(IRQCHIP_SET_TYPE_MASKED),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	BIT_MASK_DESCR(IRQCHIP_EOI_IF_HANDLED),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	BIT_MASK_DESCR(IRQCHIP_MASK_ON_SUSPEND),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	BIT_MASK_DESCR(IRQCHIP_ONOFFLINE_ENABLED),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	BIT_MASK_DESCR(IRQCHIP_SKIP_SET_WAKE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	BIT_MASK_DESCR(IRQCHIP_ONESHOT_SAFE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	BIT_MASK_DESCR(IRQCHIP_EOI_THREADED),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	BIT_MASK_DESCR(IRQCHIP_SUPPORTS_LEVEL_MSI),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	BIT_MASK_DESCR(IRQCHIP_SUPPORTS_NMI),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	BIT_MASK_DESCR(IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) irq_debug_show_chip(struct seq_file *m, struct irq_data *data, int ind)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	struct irq_chip *chip = data->chip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	if (!chip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		seq_printf(m, "chip: None\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	seq_printf(m, "%*schip:    %s\n", ind, "", chip->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	seq_printf(m, "%*sflags:   0x%lx\n", ind + 1, "", chip->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	irq_debug_show_bits(m, ind, chip->flags, irqchip_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 			    ARRAY_SIZE(irqchip_flags));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) irq_debug_show_data(struct seq_file *m, struct irq_data *data, int ind)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	seq_printf(m, "%*sdomain:  %s\n", ind, "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		   data->domain ? data->domain->name : "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	seq_printf(m, "%*shwirq:   0x%lx\n", ind + 1, "", data->hwirq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	irq_debug_show_chip(m, data, ind + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	if (data->domain && data->domain->ops && data->domain->ops->debug_show)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		data->domain->ops->debug_show(m, NULL, data, ind + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) #ifdef	CONFIG_IRQ_DOMAIN_HIERARCHY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	if (!data->parent_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	seq_printf(m, "%*sparent:\n", ind + 1, "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	irq_debug_show_data(m, data->parent_data, ind + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) static const struct irq_bit_descr irqdata_states[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	BIT_MASK_DESCR(IRQ_TYPE_EDGE_RISING),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	BIT_MASK_DESCR(IRQ_TYPE_EDGE_FALLING),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	BIT_MASK_DESCR(IRQ_TYPE_LEVEL_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	BIT_MASK_DESCR(IRQ_TYPE_LEVEL_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	BIT_MASK_DESCR(IRQD_LEVEL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	BIT_MASK_DESCR(IRQD_ACTIVATED),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	BIT_MASK_DESCR(IRQD_IRQ_STARTED),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	BIT_MASK_DESCR(IRQD_IRQ_DISABLED),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	BIT_MASK_DESCR(IRQD_IRQ_MASKED),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	BIT_MASK_DESCR(IRQD_IRQ_INPROGRESS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	BIT_MASK_DESCR(IRQD_PER_CPU),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	BIT_MASK_DESCR(IRQD_NO_BALANCING),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	BIT_MASK_DESCR(IRQD_SINGLE_TARGET),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	BIT_MASK_DESCR(IRQD_MOVE_PCNTXT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	BIT_MASK_DESCR(IRQD_AFFINITY_SET),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	BIT_MASK_DESCR(IRQD_SETAFFINITY_PENDING),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	BIT_MASK_DESCR(IRQD_AFFINITY_MANAGED),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	BIT_MASK_DESCR(IRQD_AFFINITY_ON_ACTIVATE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	BIT_MASK_DESCR(IRQD_MANAGED_SHUTDOWN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	BIT_MASK_DESCR(IRQD_CAN_RESERVE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	BIT_MASK_DESCR(IRQD_MSI_NOMASK_QUIRK),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	BIT_MASK_DESCR(IRQD_FORWARDED_TO_VCPU),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	BIT_MASK_DESCR(IRQD_WAKEUP_STATE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	BIT_MASK_DESCR(IRQD_WAKEUP_ARMED),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	BIT_MASK_DESCR(IRQD_DEFAULT_TRIGGER_SET),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	BIT_MASK_DESCR(IRQD_HANDLE_ENFORCE_IRQCTX),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	BIT_MASK_DESCR(IRQD_IRQ_ENABLED_ON_SUSPEND),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static const struct irq_bit_descr irqdesc_states[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	BIT_MASK_DESCR(_IRQ_NOPROBE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	BIT_MASK_DESCR(_IRQ_NOREQUEST),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	BIT_MASK_DESCR(_IRQ_NOTHREAD),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	BIT_MASK_DESCR(_IRQ_NOAUTOEN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	BIT_MASK_DESCR(_IRQ_NESTED_THREAD),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	BIT_MASK_DESCR(_IRQ_PER_CPU_DEVID),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	BIT_MASK_DESCR(_IRQ_IS_POLLED),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	BIT_MASK_DESCR(_IRQ_DISABLE_UNLAZY),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	BIT_MASK_DESCR(_IRQ_HIDDEN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	BIT_MASK_DESCR(_IRQ_RAW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) static const struct irq_bit_descr irqdesc_istates[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	BIT_MASK_DESCR(IRQS_AUTODETECT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	BIT_MASK_DESCR(IRQS_SPURIOUS_DISABLED),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	BIT_MASK_DESCR(IRQS_POLL_INPROGRESS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	BIT_MASK_DESCR(IRQS_ONESHOT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	BIT_MASK_DESCR(IRQS_REPLAY),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	BIT_MASK_DESCR(IRQS_WAITING),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	BIT_MASK_DESCR(IRQS_PENDING),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	BIT_MASK_DESCR(IRQS_SUSPENDED),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	BIT_MASK_DESCR(IRQS_NMI),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) static int irq_debug_show(struct seq_file *m, void *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	struct irq_desc *desc = m->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	struct irq_data *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	raw_spin_lock_irq(&desc->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	data = irq_desc_get_irq_data(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	seq_printf(m, "handler:  %ps\n", desc->handle_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	seq_printf(m, "device:   %s\n", desc->dev_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	seq_printf(m, "status:   0x%08x\n", desc->status_use_accessors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	irq_debug_show_bits(m, 0, desc->status_use_accessors, irqdesc_states,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 			    ARRAY_SIZE(irqdesc_states));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	seq_printf(m, "istate:   0x%08x\n", desc->istate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	irq_debug_show_bits(m, 0, desc->istate, irqdesc_istates,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 			    ARRAY_SIZE(irqdesc_istates));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	seq_printf(m, "ddepth:   %u\n", desc->depth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	seq_printf(m, "wdepth:   %u\n", desc->wake_depth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	seq_printf(m, "dstate:   0x%08x\n", irqd_get(data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	irq_debug_show_bits(m, 0, irqd_get(data), irqdata_states,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			    ARRAY_SIZE(irqdata_states));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	seq_printf(m, "node:     %d\n", irq_data_get_node(data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	irq_debug_show_masks(m, desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	irq_debug_show_data(m, data, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	raw_spin_unlock_irq(&desc->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) static int irq_debug_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	return single_open(file, irq_debug_show, inode->i_private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) static ssize_t irq_debug_write(struct file *file, const char __user *user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 			       size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	struct irq_desc *desc = file_inode(file)->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	char buf[8] = { 0, };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	size_t size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	size = min(sizeof(buf) - 1, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	if (copy_from_user(buf, user_buf, size))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	if (!strncmp(buf, "trigger", size)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		int err = irq_inject_interrupt(irq_desc_get_irq(desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		return err ? err : count;
^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) 	return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) static const struct file_operations dfs_irq_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	.open		= irq_debug_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	.write		= irq_debug_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	.read		= seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	.llseek		= seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	.release	= single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) void irq_debugfs_copy_devname(int irq, struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	struct irq_desc *desc = irq_to_desc(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	const char *name = dev_name(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	if (name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		desc->dev_name = kstrdup(name, GFP_KERNEL);
^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) void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	char name [10];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	if (!irq_dir || !desc || desc->debugfs_file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	sprintf(name, "%d", irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	desc->debugfs_file = debugfs_create_file(name, 0644, irq_dir, desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 						 &dfs_irq_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) static int __init irq_debugfs_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	struct dentry *root_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	root_dir = debugfs_create_dir("irq", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	irq_domain_debugfs_init(root_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	irq_dir = debugfs_create_dir("irqs", root_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	irq_lock_sparse();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	for_each_active_irq(irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		irq_add_debugfs_entry(irq, irq_to_desc(irq));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	irq_unlock_sparse();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) __initcall(irq_debugfs_init);