blob: 4108ef48af942504bca50006e86c2c5e1c204aff [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Heo5a0e3ad2010-03-24 17:04:11 +090010#include <linux/gfp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/proc_fs.h>
Alexey Dobriyanf18e4392008-08-12 15:09:03 -070012#include <linux/seq_file.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/interrupt.h>
Thomas Gleixnerc78b9b62010-12-16 17:21:47 +010014#include <linux/kernel_stat.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
Adrian Bunk97a41e22006-01-08 01:02:17 -080016#include "internals.h"
17
Ingo Molnar4a733ee2006-06-29 02:24:42 -070018static struct proc_dir_entry *root_irq_dir;
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
20#ifdef CONFIG_SMP
21
Mike Travis4b060422011-05-24 17:13:12 -070022static int show_irq_affinity(int type, struct seq_file *m, void *v)
Linus Torvalds1da177e2005-04-16 15:20:36 -070023{
Yinghai Lu08678b02008-08-19 20:50:05 -070024 struct irq_desc *desc = irq_to_desc((long)m->private);
Thomas Gleixner6b8ff312010-10-01 12:58:38 +020025 const struct cpumask *mask = desc->irq_data.affinity;
Andi Kleen42ee2b72007-07-21 17:09:54 +020026
27#ifdef CONFIG_GENERIC_PENDING_IRQ
Thomas Gleixnerf230b6d2011-02-05 15:20:04 +010028 if (irqd_is_setaffinity_pending(&desc->irq_data))
Mike Travis7f7ace02009-01-10 21:58:08 -080029 mask = desc->pending_mask;
Andi Kleen42ee2b72007-07-21 17:09:54 +020030#endif
Mike Travis4b060422011-05-24 17:13:12 -070031 if (type)
32 seq_cpumask_list(m, mask);
33 else
34 seq_cpumask(m, mask);
Alexey Dobriyanf18e4392008-08-12 15:09:03 -070035 seq_putc(m, '\n');
36 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070037}
38
Peter P Waskiewicz Jre7a297b2010-04-30 14:44:50 -070039static int irq_affinity_hint_proc_show(struct seq_file *m, void *v)
40{
41 struct irq_desc *desc = irq_to_desc((long)m->private);
42 unsigned long flags;
43 cpumask_var_t mask;
44
Peter P Waskiewicz Jr4308ad82010-05-05 13:56:42 -070045 if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
Peter P Waskiewicz Jre7a297b2010-04-30 14:44:50 -070046 return -ENOMEM;
47
48 raw_spin_lock_irqsave(&desc->lock, flags);
49 if (desc->affinity_hint)
50 cpumask_copy(mask, desc->affinity_hint);
Peter P Waskiewicz Jre7a297b2010-04-30 14:44:50 -070051 raw_spin_unlock_irqrestore(&desc->lock, flags);
52
53 seq_cpumask(m, mask);
54 seq_putc(m, '\n');
55 free_cpumask_var(mask);
56
57 return 0;
58}
59
John Keller25d61572007-05-10 22:42:44 -070060#ifndef is_affinity_mask_valid
61#define is_affinity_mask_valid(val) 1
62#endif
63
Linus Torvalds1da177e2005-04-16 15:20:36 -070064int no_irq_affinity;
Mike Travis4b060422011-05-24 17:13:12 -070065static int irq_affinity_proc_show(struct seq_file *m, void *v)
66{
67 return show_irq_affinity(0, m, v);
68}
69
70static int irq_affinity_list_proc_show(struct seq_file *m, void *v)
71{
72 return show_irq_affinity(1, m, v);
73}
74
75
76static ssize_t write_irq_affinity(int type, struct file *file,
Alexey Dobriyanf18e4392008-08-12 15:09:03 -070077 const char __user *buffer, size_t count, loff_t *pos)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078{
Alexey Dobriyanf18e4392008-08-12 15:09:03 -070079 unsigned int irq = (int)(long)PDE(file->f_path.dentry->d_inode)->data;
Rusty Russell0de26522008-12-13 21:20:26 +103080 cpumask_var_t new_value;
Alexey Dobriyanf18e4392008-08-12 15:09:03 -070081 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
Thomas Gleixnerbce43032011-02-10 22:37:41 +010083 if (!irq_can_set_affinity(irq) || no_irq_affinity)
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 return -EIO;
85
Rusty Russell0de26522008-12-13 21:20:26 +103086 if (!alloc_cpumask_var(&new_value, GFP_KERNEL))
87 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
Mike Travis4b060422011-05-24 17:13:12 -070089 if (type)
90 err = cpumask_parselist_user(buffer, count, new_value);
91 else
92 err = cpumask_parse_user(buffer, count, new_value);
Rusty Russell0de26522008-12-13 21:20:26 +103093 if (err)
94 goto free_cpumask;
95
Ingo Molnar6bdf1972009-01-03 12:50:46 +010096 if (!is_affinity_mask_valid(new_value)) {
Rusty Russell0de26522008-12-13 21:20:26 +103097 err = -EINVAL;
98 goto free_cpumask;
99 }
John Keller25d61572007-05-10 22:42:44 -0700100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 /*
102 * Do not allow disabling IRQs completely - it's a too easy
103 * way to make the system unusable accidentally :-) At least
104 * one online CPU still has to be targeted.
105 */
Rusty Russell0de26522008-12-13 21:20:26 +1030106 if (!cpumask_intersects(new_value, cpu_online_mask)) {
Ivan Kokshayskyeee45262006-01-06 00:12:21 -0800107 /* Special case for empty set - allow the architecture
108 code to set default SMP affinity. */
Thomas Gleixner3b8249e2011-02-07 16:02:20 +0100109 err = irq_select_affinity_usr(irq, new_value) ? -EINVAL : count;
Rusty Russell0de26522008-12-13 21:20:26 +1030110 } else {
111 irq_set_affinity(irq, new_value);
112 err = count;
113 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
Rusty Russell0de26522008-12-13 21:20:26 +1030115free_cpumask:
116 free_cpumask_var(new_value);
117 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118}
119
Mike Travis4b060422011-05-24 17:13:12 -0700120static ssize_t irq_affinity_proc_write(struct file *file,
121 const char __user *buffer, size_t count, loff_t *pos)
122{
123 return write_irq_affinity(0, file, buffer, count, pos);
124}
125
126static ssize_t irq_affinity_list_proc_write(struct file *file,
127 const char __user *buffer, size_t count, loff_t *pos)
128{
129 return write_irq_affinity(1, file, buffer, count, pos);
130}
131
Alexey Dobriyanf18e4392008-08-12 15:09:03 -0700132static int irq_affinity_proc_open(struct inode *inode, struct file *file)
Max Krasnyansky18404752008-05-29 11:02:52 -0700133{
Alexey Dobriyanf18e4392008-08-12 15:09:03 -0700134 return single_open(file, irq_affinity_proc_show, PDE(inode)->data);
Max Krasnyansky18404752008-05-29 11:02:52 -0700135}
136
Mike Travis4b060422011-05-24 17:13:12 -0700137static int irq_affinity_list_proc_open(struct inode *inode, struct file *file)
138{
139 return single_open(file, irq_affinity_list_proc_show, PDE(inode)->data);
140}
141
Peter P Waskiewicz Jre7a297b2010-04-30 14:44:50 -0700142static int irq_affinity_hint_proc_open(struct inode *inode, struct file *file)
143{
144 return single_open(file, irq_affinity_hint_proc_show, PDE(inode)->data);
145}
146
Alexey Dobriyanf18e4392008-08-12 15:09:03 -0700147static const struct file_operations irq_affinity_proc_fops = {
148 .open = irq_affinity_proc_open,
149 .read = seq_read,
150 .llseek = seq_lseek,
151 .release = single_release,
152 .write = irq_affinity_proc_write,
153};
154
Peter P Waskiewicz Jre7a297b2010-04-30 14:44:50 -0700155static const struct file_operations irq_affinity_hint_proc_fops = {
156 .open = irq_affinity_hint_proc_open,
157 .read = seq_read,
158 .llseek = seq_lseek,
159 .release = single_release,
160};
161
Mike Travis4b060422011-05-24 17:13:12 -0700162static const struct file_operations irq_affinity_list_proc_fops = {
163 .open = irq_affinity_list_proc_open,
164 .read = seq_read,
165 .llseek = seq_lseek,
166 .release = single_release,
167 .write = irq_affinity_list_proc_write,
168};
169
Alexey Dobriyanf18e4392008-08-12 15:09:03 -0700170static int default_affinity_show(struct seq_file *m, void *v)
Max Krasnyansky18404752008-05-29 11:02:52 -0700171{
Rusty Russelld036e672009-01-01 10:12:26 +1030172 seq_cpumask(m, irq_default_affinity);
Alexey Dobriyanf18e4392008-08-12 15:09:03 -0700173 seq_putc(m, '\n');
174 return 0;
175}
176
177static ssize_t default_affinity_write(struct file *file,
178 const char __user *buffer, size_t count, loff_t *ppos)
179{
Rusty Russelld036e672009-01-01 10:12:26 +1030180 cpumask_var_t new_value;
Alexey Dobriyanf18e4392008-08-12 15:09:03 -0700181 int err;
Max Krasnyansky18404752008-05-29 11:02:52 -0700182
Rusty Russelld036e672009-01-01 10:12:26 +1030183 if (!alloc_cpumask_var(&new_value, GFP_KERNEL))
184 return -ENOMEM;
Max Krasnyansky18404752008-05-29 11:02:52 -0700185
Rusty Russelld036e672009-01-01 10:12:26 +1030186 err = cpumask_parse_user(buffer, count, new_value);
187 if (err)
188 goto out;
189
190 if (!is_affinity_mask_valid(new_value)) {
191 err = -EINVAL;
192 goto out;
193 }
Max Krasnyansky18404752008-05-29 11:02:52 -0700194
195 /*
196 * Do not allow disabling IRQs completely - it's a too easy
197 * way to make the system unusable accidentally :-) At least
198 * one online CPU still has to be targeted.
199 */
Rusty Russelld036e672009-01-01 10:12:26 +1030200 if (!cpumask_intersects(new_value, cpu_online_mask)) {
201 err = -EINVAL;
202 goto out;
203 }
Max Krasnyansky18404752008-05-29 11:02:52 -0700204
Rusty Russelld036e672009-01-01 10:12:26 +1030205 cpumask_copy(irq_default_affinity, new_value);
206 err = count;
Max Krasnyansky18404752008-05-29 11:02:52 -0700207
Rusty Russelld036e672009-01-01 10:12:26 +1030208out:
209 free_cpumask_var(new_value);
210 return err;
Max Krasnyansky18404752008-05-29 11:02:52 -0700211}
Alexey Dobriyanf18e4392008-08-12 15:09:03 -0700212
213static int default_affinity_open(struct inode *inode, struct file *file)
214{
Thomas Gleixner34769942009-11-20 11:46:21 +0100215 return single_open(file, default_affinity_show, PDE(inode)->data);
Alexey Dobriyanf18e4392008-08-12 15:09:03 -0700216}
217
218static const struct file_operations default_affinity_proc_fops = {
219 .open = default_affinity_open,
220 .read = seq_read,
221 .llseek = seq_lseek,
222 .release = single_release,
223 .write = default_affinity_write,
224};
Dimitri Sivanich92d6b712010-03-11 14:08:56 -0800225
226static int irq_node_proc_show(struct seq_file *m, void *v)
227{
228 struct irq_desc *desc = irq_to_desc((long) m->private);
229
Thomas Gleixner6b8ff312010-10-01 12:58:38 +0200230 seq_printf(m, "%d\n", desc->irq_data.node);
Dimitri Sivanich92d6b712010-03-11 14:08:56 -0800231 return 0;
232}
233
234static int irq_node_proc_open(struct inode *inode, struct file *file)
235{
236 return single_open(file, irq_node_proc_show, PDE(inode)->data);
237}
238
239static const struct file_operations irq_node_proc_fops = {
240 .open = irq_node_proc_open,
241 .read = seq_read,
242 .llseek = seq_lseek,
243 .release = single_release,
244};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245#endif
246
Alexey Dobriyana1afb632009-08-28 22:19:33 +0400247static int irq_spurious_proc_show(struct seq_file *m, void *v)
Andi Kleen96d97cf2008-01-30 13:32:48 +0100248{
Alexey Dobriyana1afb632009-08-28 22:19:33 +0400249 struct irq_desc *desc = irq_to_desc((long) m->private);
250
251 seq_printf(m, "count %u\n" "unhandled %u\n" "last_unhandled %u ms\n",
252 desc->irq_count, desc->irqs_unhandled,
253 jiffies_to_msecs(desc->last_unhandled));
254 return 0;
Andi Kleen96d97cf2008-01-30 13:32:48 +0100255}
256
Alexey Dobriyana1afb632009-08-28 22:19:33 +0400257static int irq_spurious_proc_open(struct inode *inode, struct file *file)
258{
Kenji Kaneshige25c91702010-11-30 17:36:08 +0900259 return single_open(file, irq_spurious_proc_show, PDE(inode)->data);
Alexey Dobriyana1afb632009-08-28 22:19:33 +0400260}
261
262static const struct file_operations irq_spurious_proc_fops = {
263 .open = irq_spurious_proc_open,
264 .read = seq_read,
265 .llseek = seq_lseek,
266 .release = single_release,
267};
268
Abhijeet Dharmapurikar3bb998f2013-08-07 20:17:07 -0700269static int irq_wake_depth_proc_show(struct seq_file *m, void *v)
270{
271 struct irq_desc *desc = irq_to_desc((long) m->private);
272
273 seq_printf(m, "wake_depth %u\n", desc->wake_depth);
274 return 0;
275}
276
277static int irq_wake_depth_proc_open(struct inode *inode, struct file *file)
278{
279 return single_open(file, irq_wake_depth_proc_show, PDE(inode)->data);
280}
281
282static const struct file_operations irq_wake_depth_proc_fops = {
283 .open = irq_wake_depth_proc_open,
284 .read = seq_read,
285 .llseek = seq_lseek,
286 .release = single_release,
287};
288
289static int irq_disable_depth_proc_show(struct seq_file *m, void *v)
290{
291 struct irq_desc *desc = irq_to_desc((long) m->private);
292
293 seq_printf(m, "disable_depth %u\n", desc->depth);
294 return 0;
295}
296
297static int irq_disable_depth_proc_open(struct inode *inode, struct file *file)
298{
299 return single_open(file, irq_disable_depth_proc_show, PDE(inode)->data);
300}
301
302static const struct file_operations irq_disable_depth_proc_fops = {
303 .open = irq_disable_depth_proc_open,
304 .read = seq_read,
305 .llseek = seq_lseek,
306 .release = single_release,
307};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308#define MAX_NAMELEN 128
309
310static int name_unique(unsigned int irq, struct irqaction *new_action)
311{
Yinghai Lu08678b02008-08-19 20:50:05 -0700312 struct irq_desc *desc = irq_to_desc(irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 struct irqaction *action;
Dmitry Adamushkod2d94332007-05-08 00:27:31 -0700314 unsigned long flags;
315 int ret = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316
Thomas Gleixner239007b2009-11-17 16:46:45 +0100317 raw_spin_lock_irqsave(&desc->lock, flags);
Dmitry Adamushkod2d94332007-05-08 00:27:31 -0700318 for (action = desc->action ; action; action = action->next) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 if ((action != new_action) && action->name &&
Dmitry Adamushkod2d94332007-05-08 00:27:31 -0700320 !strcmp(new_action->name, action->name)) {
321 ret = 0;
322 break;
323 }
324 }
Thomas Gleixner239007b2009-11-17 16:46:45 +0100325 raw_spin_unlock_irqrestore(&desc->lock, flags);
Dmitry Adamushkod2d94332007-05-08 00:27:31 -0700326 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327}
328
329void register_handler_proc(unsigned int irq, struct irqaction *action)
330{
331 char name [MAX_NAMELEN];
Yinghai Lu08678b02008-08-19 20:50:05 -0700332 struct irq_desc *desc = irq_to_desc(irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333
Yinghai Lu08678b02008-08-19 20:50:05 -0700334 if (!desc->dir || action->dir || !action->name ||
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 !name_unique(irq, action))
336 return;
337
338 memset(name, 0, MAX_NAMELEN);
339 snprintf(name, MAX_NAMELEN, "%s", action->name);
340
341 /* create /proc/irq/1234/handler/ */
Yinghai Lu08678b02008-08-19 20:50:05 -0700342 action->dir = proc_mkdir(name, desc->dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343}
344
345#undef MAX_NAMELEN
346
347#define MAX_NAMELEN 10
348
Yinghai Lu2c6927a2008-08-19 20:50:11 -0700349void register_irq_proc(unsigned int irq, struct irq_desc *desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350{
351 char name [MAX_NAMELEN];
352
Thomas Gleixner6b8ff312010-10-01 12:58:38 +0200353 if (!root_irq_dir || (desc->irq_data.chip == &no_irq_chip) || desc->dir)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 return;
355
356 memset(name, 0, MAX_NAMELEN);
357 sprintf(name, "%d", irq);
358
359 /* create /proc/irq/1234 */
Yinghai Lu08678b02008-08-19 20:50:05 -0700360 desc->dir = proc_mkdir(name, root_irq_dir);
Cyrill Gorcunovc82a43d2009-10-26 23:28:11 +0300361 if (!desc->dir)
362 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363
364#ifdef CONFIG_SMP
Alexey Dobriyanf18e4392008-08-12 15:09:03 -0700365 /* create /proc/irq/<irq>/smp_affinity */
Yinghai Lu08678b02008-08-19 20:50:05 -0700366 proc_create_data("smp_affinity", 0600, desc->dir,
Alexey Dobriyanf18e4392008-08-12 15:09:03 -0700367 &irq_affinity_proc_fops, (void *)(long)irq);
Dimitri Sivanich92d6b712010-03-11 14:08:56 -0800368
Peter P Waskiewicz Jre7a297b2010-04-30 14:44:50 -0700369 /* create /proc/irq/<irq>/affinity_hint */
370 proc_create_data("affinity_hint", 0400, desc->dir,
371 &irq_affinity_hint_proc_fops, (void *)(long)irq);
372
Mike Travis4b060422011-05-24 17:13:12 -0700373 /* create /proc/irq/<irq>/smp_affinity_list */
374 proc_create_data("smp_affinity_list", 0600, desc->dir,
375 &irq_affinity_list_proc_fops, (void *)(long)irq);
376
Dimitri Sivanich92d6b712010-03-11 14:08:56 -0800377 proc_create_data("node", 0444, desc->dir,
378 &irq_node_proc_fops, (void *)(long)irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379#endif
Andi Kleen96d97cf2008-01-30 13:32:48 +0100380
Alexey Dobriyana1afb632009-08-28 22:19:33 +0400381 proc_create_data("spurious", 0444, desc->dir,
382 &irq_spurious_proc_fops, (void *)(long)irq);
Abhijeet Dharmapurikar3bb998f2013-08-07 20:17:07 -0700383 proc_create_data("disable_depth", 0444, desc->dir,
384 &irq_disable_depth_proc_fops, (void *)(long)irq);
385 proc_create_data("wake_depth", 0444, desc->dir,
386 &irq_wake_depth_proc_fops, (void *)(long)irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387}
388
Thomas Gleixner13bfe992010-09-30 02:46:07 +0200389void unregister_irq_proc(unsigned int irq, struct irq_desc *desc)
390{
391 char name [MAX_NAMELEN];
392
393 if (!root_irq_dir || !desc->dir)
394 return;
395#ifdef CONFIG_SMP
396 remove_proc_entry("smp_affinity", desc->dir);
397 remove_proc_entry("affinity_hint", desc->dir);
Yinghai Ludef945e2011-05-25 22:09:40 -0700398 remove_proc_entry("smp_affinity_list", desc->dir);
Thomas Gleixner13bfe992010-09-30 02:46:07 +0200399 remove_proc_entry("node", desc->dir);
400#endif
401 remove_proc_entry("spurious", desc->dir);
402
403 memset(name, 0, MAX_NAMELEN);
404 sprintf(name, "%u", irq);
405 remove_proc_entry(name, root_irq_dir);
406}
407
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408#undef MAX_NAMELEN
409
410void unregister_handler_proc(unsigned int irq, struct irqaction *action)
411{
Yinghai Lu08678b02008-08-19 20:50:05 -0700412 if (action->dir) {
413 struct irq_desc *desc = irq_to_desc(irq);
Thomas Gleixnerd3c60042008-10-16 09:55:00 +0200414
Yinghai Lu08678b02008-08-19 20:50:05 -0700415 remove_proc_entry(action->dir->name, desc->dir);
416 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417}
418
roel kluin3786fc72008-10-21 19:49:09 -0400419static void register_default_affinity_proc(void)
Max Krasnyansky18404752008-05-29 11:02:52 -0700420{
421#ifdef CONFIG_SMP
Alexey Dobriyanf18e4392008-08-12 15:09:03 -0700422 proc_create("irq/default_smp_affinity", 0600, NULL,
423 &default_affinity_proc_fops);
Max Krasnyansky18404752008-05-29 11:02:52 -0700424#endif
425}
426
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427void init_irq_proc(void)
428{
Yinghai Lu2c6927a2008-08-19 20:50:11 -0700429 unsigned int irq;
430 struct irq_desc *desc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431
432 /* create /proc/irq */
433 root_irq_dir = proc_mkdir("irq", NULL);
434 if (!root_irq_dir)
435 return;
436
Max Krasnyansky18404752008-05-29 11:02:52 -0700437 register_default_affinity_proc();
438
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 /*
440 * Create entries for all existing IRQs.
441 */
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800442 for_each_irq_desc(irq, desc) {
443 if (!desc)
444 continue;
445
Yinghai Lu2c6927a2008-08-19 20:50:11 -0700446 register_irq_proc(irq, desc);
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800447 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448}
449
Thomas Gleixnerc78b9b62010-12-16 17:21:47 +0100450#ifdef CONFIG_GENERIC_IRQ_SHOW
451
452int __weak arch_show_interrupts(struct seq_file *p, int prec)
453{
454 return 0;
455}
456
Thomas Gleixnera6e120e2011-03-25 22:20:51 +0100457#ifndef ACTUAL_NR_IRQS
458# define ACTUAL_NR_IRQS nr_irqs
459#endif
460
Thomas Gleixnerc78b9b62010-12-16 17:21:47 +0100461int show_interrupts(struct seq_file *p, void *v)
462{
463 static int prec;
464
465 unsigned long flags, any_count = 0;
466 int i = *(loff_t *) v, j;
467 struct irqaction *action;
468 struct irq_desc *desc;
469
Thomas Gleixnera6e120e2011-03-25 22:20:51 +0100470 if (i > ACTUAL_NR_IRQS)
Thomas Gleixnerc78b9b62010-12-16 17:21:47 +0100471 return 0;
472
Thomas Gleixnera6e120e2011-03-25 22:20:51 +0100473 if (i == ACTUAL_NR_IRQS)
Thomas Gleixnerc78b9b62010-12-16 17:21:47 +0100474 return arch_show_interrupts(p, prec);
475
476 /* print header and calculate the width of the first column */
477 if (i == 0) {
478 for (prec = 3, j = 1000; prec < 10 && j <= nr_irqs; ++prec)
479 j *= 10;
480
481 seq_printf(p, "%*s", prec + 8, "");
482 for_each_online_cpu(j)
483 seq_printf(p, "CPU%-8d", j);
484 seq_putc(p, '\n');
485 }
486
487 desc = irq_to_desc(i);
488 if (!desc)
489 return 0;
490
491 raw_spin_lock_irqsave(&desc->lock, flags);
492 for_each_online_cpu(j)
493 any_count |= kstat_irqs_cpu(i, j);
494 action = desc->action;
495 if (!action && !any_count)
496 goto out;
497
498 seq_printf(p, "%*d: ", prec, i);
499 for_each_online_cpu(j)
500 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
Thomas Gleixnerab7798f2011-03-25 16:48:50 +0100501
502 if (desc->irq_data.chip) {
503 if (desc->irq_data.chip->irq_print_chip)
504 desc->irq_data.chip->irq_print_chip(&desc->irq_data, p);
505 else if (desc->irq_data.chip->name)
506 seq_printf(p, " %8s", desc->irq_data.chip->name);
507 else
508 seq_printf(p, " %8s", "-");
509 } else {
510 seq_printf(p, " %8s", "None");
511 }
Geert Uytterhoeven94b2c362011-04-30 22:56:20 +0200512#ifdef CONFIG_GENERIC_IRQ_SHOW_LEVEL
Thomas Gleixnerab7798f2011-03-25 16:48:50 +0100513 seq_printf(p, " %-8s", irqd_is_level_type(&desc->irq_data) ? "Level" : "Edge");
514#endif
Thomas Gleixneree0401e2011-03-17 13:36:57 +0100515 if (desc->name)
516 seq_printf(p, "-%-8s", desc->name);
Thomas Gleixnerc78b9b62010-12-16 17:21:47 +0100517
518 if (action) {
519 seq_printf(p, " %s", action->name);
520 while ((action = action->next) != NULL)
521 seq_printf(p, ", %s", action->name);
522 }
523
524 seq_putc(p, '\n');
525out:
526 raw_spin_unlock_irqrestore(&desc->lock, flags);
527 return 0;
528}
529#endif