Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/kernel/irq/proc.c |
| 3 | * |
| 4 | * Copyright (C) 1992, 1998-2004 Linus Torvalds, Ingo Molnar |
| 5 | * |
| 6 | * This file contains the /proc/irq/ handling code. |
| 7 | */ |
| 8 | |
| 9 | #include <linux/irq.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 10 | #include <linux/gfp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/proc_fs.h> |
Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 12 | #include <linux/seq_file.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/interrupt.h> |
Thomas Gleixner | c78b9b6 | 2010-12-16 17:21:47 +0100 | [diff] [blame^] | 14 | #include <linux/kernel_stat.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
Adrian Bunk | 97a41e2 | 2006-01-08 01:02:17 -0800 | [diff] [blame] | 16 | #include "internals.h" |
| 17 | |
Ingo Molnar | 4a733ee | 2006-06-29 02:24:42 -0700 | [diff] [blame] | 18 | static struct proc_dir_entry *root_irq_dir; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
| 20 | #ifdef CONFIG_SMP |
| 21 | |
Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 22 | static int irq_affinity_proc_show(struct seq_file *m, void *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | { |
Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 24 | struct irq_desc *desc = irq_to_desc((long)m->private); |
Thomas Gleixner | 6b8ff31 | 2010-10-01 12:58:38 +0200 | [diff] [blame] | 25 | const struct cpumask *mask = desc->irq_data.affinity; |
Andi Kleen | 42ee2b7 | 2007-07-21 17:09:54 +0200 | [diff] [blame] | 26 | |
| 27 | #ifdef CONFIG_GENERIC_PENDING_IRQ |
| 28 | if (desc->status & IRQ_MOVE_PENDING) |
Mike Travis | 7f7ace0 | 2009-01-10 21:58:08 -0800 | [diff] [blame] | 29 | mask = desc->pending_mask; |
Andi Kleen | 42ee2b7 | 2007-07-21 17:09:54 +0200 | [diff] [blame] | 30 | #endif |
Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 31 | seq_cpumask(m, mask); |
| 32 | seq_putc(m, '\n'); |
| 33 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | } |
| 35 | |
Peter P Waskiewicz Jr | e7a297b | 2010-04-30 14:44:50 -0700 | [diff] [blame] | 36 | static int irq_affinity_hint_proc_show(struct seq_file *m, void *v) |
| 37 | { |
| 38 | struct irq_desc *desc = irq_to_desc((long)m->private); |
| 39 | unsigned long flags; |
| 40 | cpumask_var_t mask; |
| 41 | |
Peter P Waskiewicz Jr | 4308ad8 | 2010-05-05 13:56:42 -0700 | [diff] [blame] | 42 | if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) |
Peter P Waskiewicz Jr | e7a297b | 2010-04-30 14:44:50 -0700 | [diff] [blame] | 43 | return -ENOMEM; |
| 44 | |
| 45 | raw_spin_lock_irqsave(&desc->lock, flags); |
| 46 | if (desc->affinity_hint) |
| 47 | cpumask_copy(mask, desc->affinity_hint); |
Peter P Waskiewicz Jr | e7a297b | 2010-04-30 14:44:50 -0700 | [diff] [blame] | 48 | raw_spin_unlock_irqrestore(&desc->lock, flags); |
| 49 | |
| 50 | seq_cpumask(m, mask); |
| 51 | seq_putc(m, '\n'); |
| 52 | free_cpumask_var(mask); |
| 53 | |
| 54 | return 0; |
| 55 | } |
| 56 | |
John Keller | 25d6157 | 2007-05-10 22:42:44 -0700 | [diff] [blame] | 57 | #ifndef is_affinity_mask_valid |
| 58 | #define is_affinity_mask_valid(val) 1 |
| 59 | #endif |
| 60 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | int no_irq_affinity; |
Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 62 | static ssize_t irq_affinity_proc_write(struct file *file, |
| 63 | const char __user *buffer, size_t count, loff_t *pos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | { |
Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 65 | unsigned int irq = (int)(long)PDE(file->f_path.dentry->d_inode)->data; |
Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 66 | cpumask_var_t new_value; |
Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 67 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
Thomas Gleixner | c96b3b3 | 2010-09-27 12:45:41 +0000 | [diff] [blame] | 69 | if (!irq_to_desc(irq)->irq_data.chip->irq_set_affinity || no_irq_affinity || |
Thomas Gleixner | 950f442 | 2007-02-16 01:27:24 -0800 | [diff] [blame] | 70 | irq_balancing_disabled(irq)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | return -EIO; |
| 72 | |
Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 73 | if (!alloc_cpumask_var(&new_value, GFP_KERNEL)) |
| 74 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 76 | err = cpumask_parse_user(buffer, count, new_value); |
| 77 | if (err) |
| 78 | goto free_cpumask; |
| 79 | |
Ingo Molnar | 6bdf197 | 2009-01-03 12:50:46 +0100 | [diff] [blame] | 80 | if (!is_affinity_mask_valid(new_value)) { |
Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 81 | err = -EINVAL; |
| 82 | goto free_cpumask; |
| 83 | } |
John Keller | 25d6157 | 2007-05-10 22:42:44 -0700 | [diff] [blame] | 84 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | /* |
| 86 | * Do not allow disabling IRQs completely - it's a too easy |
| 87 | * way to make the system unusable accidentally :-) At least |
| 88 | * one online CPU still has to be targeted. |
| 89 | */ |
Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 90 | if (!cpumask_intersects(new_value, cpu_online_mask)) { |
Ivan Kokshaysky | eee4526 | 2006-01-06 00:12:21 -0800 | [diff] [blame] | 91 | /* Special case for empty set - allow the architecture |
| 92 | code to set default SMP affinity. */ |
Thomas Gleixner | 3b8249e | 2011-02-07 16:02:20 +0100 | [diff] [blame] | 93 | err = irq_select_affinity_usr(irq, new_value) ? -EINVAL : count; |
Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 94 | } else { |
| 95 | irq_set_affinity(irq, new_value); |
| 96 | err = count; |
| 97 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | |
Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 99 | free_cpumask: |
| 100 | free_cpumask_var(new_value); |
| 101 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | } |
| 103 | |
Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 104 | static int irq_affinity_proc_open(struct inode *inode, struct file *file) |
Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 105 | { |
Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 106 | return single_open(file, irq_affinity_proc_show, PDE(inode)->data); |
Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 107 | } |
| 108 | |
Peter P Waskiewicz Jr | e7a297b | 2010-04-30 14:44:50 -0700 | [diff] [blame] | 109 | static int irq_affinity_hint_proc_open(struct inode *inode, struct file *file) |
| 110 | { |
| 111 | return single_open(file, irq_affinity_hint_proc_show, PDE(inode)->data); |
| 112 | } |
| 113 | |
Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 114 | static const struct file_operations irq_affinity_proc_fops = { |
| 115 | .open = irq_affinity_proc_open, |
| 116 | .read = seq_read, |
| 117 | .llseek = seq_lseek, |
| 118 | .release = single_release, |
| 119 | .write = irq_affinity_proc_write, |
| 120 | }; |
| 121 | |
Peter P Waskiewicz Jr | e7a297b | 2010-04-30 14:44:50 -0700 | [diff] [blame] | 122 | static const struct file_operations irq_affinity_hint_proc_fops = { |
| 123 | .open = irq_affinity_hint_proc_open, |
| 124 | .read = seq_read, |
| 125 | .llseek = seq_lseek, |
| 126 | .release = single_release, |
| 127 | }; |
| 128 | |
Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 129 | static int default_affinity_show(struct seq_file *m, void *v) |
Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 130 | { |
Rusty Russell | d036e67 | 2009-01-01 10:12:26 +1030 | [diff] [blame] | 131 | seq_cpumask(m, irq_default_affinity); |
Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 132 | seq_putc(m, '\n'); |
| 133 | return 0; |
| 134 | } |
| 135 | |
| 136 | static ssize_t default_affinity_write(struct file *file, |
| 137 | const char __user *buffer, size_t count, loff_t *ppos) |
| 138 | { |
Rusty Russell | d036e67 | 2009-01-01 10:12:26 +1030 | [diff] [blame] | 139 | cpumask_var_t new_value; |
Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 140 | int err; |
Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 141 | |
Rusty Russell | d036e67 | 2009-01-01 10:12:26 +1030 | [diff] [blame] | 142 | if (!alloc_cpumask_var(&new_value, GFP_KERNEL)) |
| 143 | return -ENOMEM; |
Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 144 | |
Rusty Russell | d036e67 | 2009-01-01 10:12:26 +1030 | [diff] [blame] | 145 | err = cpumask_parse_user(buffer, count, new_value); |
| 146 | if (err) |
| 147 | goto out; |
| 148 | |
| 149 | if (!is_affinity_mask_valid(new_value)) { |
| 150 | err = -EINVAL; |
| 151 | goto out; |
| 152 | } |
Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 153 | |
| 154 | /* |
| 155 | * Do not allow disabling IRQs completely - it's a too easy |
| 156 | * way to make the system unusable accidentally :-) At least |
| 157 | * one online CPU still has to be targeted. |
| 158 | */ |
Rusty Russell | d036e67 | 2009-01-01 10:12:26 +1030 | [diff] [blame] | 159 | if (!cpumask_intersects(new_value, cpu_online_mask)) { |
| 160 | err = -EINVAL; |
| 161 | goto out; |
| 162 | } |
Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 163 | |
Rusty Russell | d036e67 | 2009-01-01 10:12:26 +1030 | [diff] [blame] | 164 | cpumask_copy(irq_default_affinity, new_value); |
| 165 | err = count; |
Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 166 | |
Rusty Russell | d036e67 | 2009-01-01 10:12:26 +1030 | [diff] [blame] | 167 | out: |
| 168 | free_cpumask_var(new_value); |
| 169 | return err; |
Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 170 | } |
Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 171 | |
| 172 | static int default_affinity_open(struct inode *inode, struct file *file) |
| 173 | { |
Thomas Gleixner | 3476994 | 2009-11-20 11:46:21 +0100 | [diff] [blame] | 174 | return single_open(file, default_affinity_show, PDE(inode)->data); |
Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | static const struct file_operations default_affinity_proc_fops = { |
| 178 | .open = default_affinity_open, |
| 179 | .read = seq_read, |
| 180 | .llseek = seq_lseek, |
| 181 | .release = single_release, |
| 182 | .write = default_affinity_write, |
| 183 | }; |
Dimitri Sivanich | 92d6b71 | 2010-03-11 14:08:56 -0800 | [diff] [blame] | 184 | |
| 185 | static int irq_node_proc_show(struct seq_file *m, void *v) |
| 186 | { |
| 187 | struct irq_desc *desc = irq_to_desc((long) m->private); |
| 188 | |
Thomas Gleixner | 6b8ff31 | 2010-10-01 12:58:38 +0200 | [diff] [blame] | 189 | seq_printf(m, "%d\n", desc->irq_data.node); |
Dimitri Sivanich | 92d6b71 | 2010-03-11 14:08:56 -0800 | [diff] [blame] | 190 | return 0; |
| 191 | } |
| 192 | |
| 193 | static int irq_node_proc_open(struct inode *inode, struct file *file) |
| 194 | { |
| 195 | return single_open(file, irq_node_proc_show, PDE(inode)->data); |
| 196 | } |
| 197 | |
| 198 | static const struct file_operations irq_node_proc_fops = { |
| 199 | .open = irq_node_proc_open, |
| 200 | .read = seq_read, |
| 201 | .llseek = seq_lseek, |
| 202 | .release = single_release, |
| 203 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | #endif |
| 205 | |
Alexey Dobriyan | a1afb63 | 2009-08-28 22:19:33 +0400 | [diff] [blame] | 206 | static int irq_spurious_proc_show(struct seq_file *m, void *v) |
Andi Kleen | 96d97cf | 2008-01-30 13:32:48 +0100 | [diff] [blame] | 207 | { |
Alexey Dobriyan | a1afb63 | 2009-08-28 22:19:33 +0400 | [diff] [blame] | 208 | struct irq_desc *desc = irq_to_desc((long) m->private); |
| 209 | |
| 210 | seq_printf(m, "count %u\n" "unhandled %u\n" "last_unhandled %u ms\n", |
| 211 | desc->irq_count, desc->irqs_unhandled, |
| 212 | jiffies_to_msecs(desc->last_unhandled)); |
| 213 | return 0; |
Andi Kleen | 96d97cf | 2008-01-30 13:32:48 +0100 | [diff] [blame] | 214 | } |
| 215 | |
Alexey Dobriyan | a1afb63 | 2009-08-28 22:19:33 +0400 | [diff] [blame] | 216 | static int irq_spurious_proc_open(struct inode *inode, struct file *file) |
| 217 | { |
Kenji Kaneshige | 25c9170 | 2010-11-30 17:36:08 +0900 | [diff] [blame] | 218 | return single_open(file, irq_spurious_proc_show, PDE(inode)->data); |
Alexey Dobriyan | a1afb63 | 2009-08-28 22:19:33 +0400 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | static const struct file_operations irq_spurious_proc_fops = { |
| 222 | .open = irq_spurious_proc_open, |
| 223 | .read = seq_read, |
| 224 | .llseek = seq_lseek, |
| 225 | .release = single_release, |
| 226 | }; |
| 227 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | #define MAX_NAMELEN 128 |
| 229 | |
| 230 | static int name_unique(unsigned int irq, struct irqaction *new_action) |
| 231 | { |
Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 232 | struct irq_desc *desc = irq_to_desc(irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | struct irqaction *action; |
Dmitry Adamushko | d2d9433 | 2007-05-08 00:27:31 -0700 | [diff] [blame] | 234 | unsigned long flags; |
| 235 | int ret = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | |
Thomas Gleixner | 239007b | 2009-11-17 16:46:45 +0100 | [diff] [blame] | 237 | raw_spin_lock_irqsave(&desc->lock, flags); |
Dmitry Adamushko | d2d9433 | 2007-05-08 00:27:31 -0700 | [diff] [blame] | 238 | for (action = desc->action ; action; action = action->next) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | if ((action != new_action) && action->name && |
Dmitry Adamushko | d2d9433 | 2007-05-08 00:27:31 -0700 | [diff] [blame] | 240 | !strcmp(new_action->name, action->name)) { |
| 241 | ret = 0; |
| 242 | break; |
| 243 | } |
| 244 | } |
Thomas Gleixner | 239007b | 2009-11-17 16:46:45 +0100 | [diff] [blame] | 245 | raw_spin_unlock_irqrestore(&desc->lock, flags); |
Dmitry Adamushko | d2d9433 | 2007-05-08 00:27:31 -0700 | [diff] [blame] | 246 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | void register_handler_proc(unsigned int irq, struct irqaction *action) |
| 250 | { |
| 251 | char name [MAX_NAMELEN]; |
Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 252 | struct irq_desc *desc = irq_to_desc(irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | |
Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 254 | if (!desc->dir || action->dir || !action->name || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | !name_unique(irq, action)) |
| 256 | return; |
| 257 | |
| 258 | memset(name, 0, MAX_NAMELEN); |
| 259 | snprintf(name, MAX_NAMELEN, "%s", action->name); |
| 260 | |
| 261 | /* create /proc/irq/1234/handler/ */ |
Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 262 | action->dir = proc_mkdir(name, desc->dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | #undef MAX_NAMELEN |
| 266 | |
| 267 | #define MAX_NAMELEN 10 |
| 268 | |
Yinghai Lu | 2c6927a | 2008-08-19 20:50:11 -0700 | [diff] [blame] | 269 | void register_irq_proc(unsigned int irq, struct irq_desc *desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | { |
| 271 | char name [MAX_NAMELEN]; |
| 272 | |
Thomas Gleixner | 6b8ff31 | 2010-10-01 12:58:38 +0200 | [diff] [blame] | 273 | if (!root_irq_dir || (desc->irq_data.chip == &no_irq_chip) || desc->dir) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | return; |
| 275 | |
| 276 | memset(name, 0, MAX_NAMELEN); |
| 277 | sprintf(name, "%d", irq); |
| 278 | |
| 279 | /* create /proc/irq/1234 */ |
Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 280 | desc->dir = proc_mkdir(name, root_irq_dir); |
Cyrill Gorcunov | c82a43d | 2009-10-26 23:28:11 +0300 | [diff] [blame] | 281 | if (!desc->dir) |
| 282 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | |
| 284 | #ifdef CONFIG_SMP |
Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 285 | /* create /proc/irq/<irq>/smp_affinity */ |
Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 286 | proc_create_data("smp_affinity", 0600, desc->dir, |
Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 287 | &irq_affinity_proc_fops, (void *)(long)irq); |
Dimitri Sivanich | 92d6b71 | 2010-03-11 14:08:56 -0800 | [diff] [blame] | 288 | |
Peter P Waskiewicz Jr | e7a297b | 2010-04-30 14:44:50 -0700 | [diff] [blame] | 289 | /* create /proc/irq/<irq>/affinity_hint */ |
| 290 | proc_create_data("affinity_hint", 0400, desc->dir, |
| 291 | &irq_affinity_hint_proc_fops, (void *)(long)irq); |
| 292 | |
Dimitri Sivanich | 92d6b71 | 2010-03-11 14:08:56 -0800 | [diff] [blame] | 293 | proc_create_data("node", 0444, desc->dir, |
| 294 | &irq_node_proc_fops, (void *)(long)irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | #endif |
Andi Kleen | 96d97cf | 2008-01-30 13:32:48 +0100 | [diff] [blame] | 296 | |
Alexey Dobriyan | a1afb63 | 2009-08-28 22:19:33 +0400 | [diff] [blame] | 297 | proc_create_data("spurious", 0444, desc->dir, |
| 298 | &irq_spurious_proc_fops, (void *)(long)irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | } |
| 300 | |
Thomas Gleixner | 13bfe99 | 2010-09-30 02:46:07 +0200 | [diff] [blame] | 301 | void unregister_irq_proc(unsigned int irq, struct irq_desc *desc) |
| 302 | { |
| 303 | char name [MAX_NAMELEN]; |
| 304 | |
| 305 | if (!root_irq_dir || !desc->dir) |
| 306 | return; |
| 307 | #ifdef CONFIG_SMP |
| 308 | remove_proc_entry("smp_affinity", desc->dir); |
| 309 | remove_proc_entry("affinity_hint", desc->dir); |
| 310 | remove_proc_entry("node", desc->dir); |
| 311 | #endif |
| 312 | remove_proc_entry("spurious", desc->dir); |
| 313 | |
| 314 | memset(name, 0, MAX_NAMELEN); |
| 315 | sprintf(name, "%u", irq); |
| 316 | remove_proc_entry(name, root_irq_dir); |
| 317 | } |
| 318 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | #undef MAX_NAMELEN |
| 320 | |
| 321 | void unregister_handler_proc(unsigned int irq, struct irqaction *action) |
| 322 | { |
Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 323 | if (action->dir) { |
| 324 | struct irq_desc *desc = irq_to_desc(irq); |
Thomas Gleixner | d3c6004 | 2008-10-16 09:55:00 +0200 | [diff] [blame] | 325 | |
Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 326 | remove_proc_entry(action->dir->name, desc->dir); |
| 327 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | } |
| 329 | |
roel kluin | 3786fc7 | 2008-10-21 19:49:09 -0400 | [diff] [blame] | 330 | static void register_default_affinity_proc(void) |
Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 331 | { |
| 332 | #ifdef CONFIG_SMP |
Alexey Dobriyan | f18e439 | 2008-08-12 15:09:03 -0700 | [diff] [blame] | 333 | proc_create("irq/default_smp_affinity", 0600, NULL, |
| 334 | &default_affinity_proc_fops); |
Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 335 | #endif |
| 336 | } |
| 337 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | void init_irq_proc(void) |
| 339 | { |
Yinghai Lu | 2c6927a | 2008-08-19 20:50:11 -0700 | [diff] [blame] | 340 | unsigned int irq; |
| 341 | struct irq_desc *desc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | |
| 343 | /* create /proc/irq */ |
| 344 | root_irq_dir = proc_mkdir("irq", NULL); |
| 345 | if (!root_irq_dir) |
| 346 | return; |
| 347 | |
Max Krasnyansky | 1840475 | 2008-05-29 11:02:52 -0700 | [diff] [blame] | 348 | register_default_affinity_proc(); |
| 349 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | /* |
| 351 | * Create entries for all existing IRQs. |
| 352 | */ |
Yinghai Lu | 0b8f1ef | 2008-12-05 18:58:31 -0800 | [diff] [blame] | 353 | for_each_irq_desc(irq, desc) { |
| 354 | if (!desc) |
| 355 | continue; |
| 356 | |
Yinghai Lu | 2c6927a | 2008-08-19 20:50:11 -0700 | [diff] [blame] | 357 | register_irq_proc(irq, desc); |
Yinghai Lu | 0b8f1ef | 2008-12-05 18:58:31 -0800 | [diff] [blame] | 358 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | } |
| 360 | |
Thomas Gleixner | c78b9b6 | 2010-12-16 17:21:47 +0100 | [diff] [blame^] | 361 | #ifdef CONFIG_GENERIC_IRQ_SHOW |
| 362 | |
| 363 | int __weak arch_show_interrupts(struct seq_file *p, int prec) |
| 364 | { |
| 365 | return 0; |
| 366 | } |
| 367 | |
| 368 | int show_interrupts(struct seq_file *p, void *v) |
| 369 | { |
| 370 | static int prec; |
| 371 | |
| 372 | unsigned long flags, any_count = 0; |
| 373 | int i = *(loff_t *) v, j; |
| 374 | struct irqaction *action; |
| 375 | struct irq_desc *desc; |
| 376 | |
| 377 | if (i > nr_irqs) |
| 378 | return 0; |
| 379 | |
| 380 | if (i == nr_irqs) |
| 381 | return arch_show_interrupts(p, prec); |
| 382 | |
| 383 | /* print header and calculate the width of the first column */ |
| 384 | if (i == 0) { |
| 385 | for (prec = 3, j = 1000; prec < 10 && j <= nr_irqs; ++prec) |
| 386 | j *= 10; |
| 387 | |
| 388 | seq_printf(p, "%*s", prec + 8, ""); |
| 389 | for_each_online_cpu(j) |
| 390 | seq_printf(p, "CPU%-8d", j); |
| 391 | seq_putc(p, '\n'); |
| 392 | } |
| 393 | |
| 394 | desc = irq_to_desc(i); |
| 395 | if (!desc) |
| 396 | return 0; |
| 397 | |
| 398 | raw_spin_lock_irqsave(&desc->lock, flags); |
| 399 | for_each_online_cpu(j) |
| 400 | any_count |= kstat_irqs_cpu(i, j); |
| 401 | action = desc->action; |
| 402 | if (!action && !any_count) |
| 403 | goto out; |
| 404 | |
| 405 | seq_printf(p, "%*d: ", prec, i); |
| 406 | for_each_online_cpu(j) |
| 407 | seq_printf(p, "%10u ", kstat_irqs_cpu(i, j)); |
| 408 | seq_printf(p, " %8s", desc->irq_data.chip->name); |
| 409 | seq_printf(p, "-%-8s", desc->name); |
| 410 | |
| 411 | if (action) { |
| 412 | seq_printf(p, " %s", action->name); |
| 413 | while ((action = action->next) != NULL) |
| 414 | seq_printf(p, ", %s", action->name); |
| 415 | } |
| 416 | |
| 417 | seq_putc(p, '\n'); |
| 418 | out: |
| 419 | raw_spin_unlock_irqrestore(&desc->lock, flags); |
| 420 | return 0; |
| 421 | } |
| 422 | #endif |