diff options
| author | Ingo Molnar <mingo@elte.hu> | 2008-10-28 11:26:12 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2008-10-28 11:26:12 -0400 |
| commit | 7a9787e1eba95a166265e6a260cf30af04ef0a99 (patch) | |
| tree | e730a4565e0318140d2fbd2f0415d18a339d7336 /kernel/irq/proc.c | |
| parent | 41b9eb264c8407655db57b60b4457fe1b2ec9977 (diff) | |
| parent | 0173a3265b228da319ceb9c1ec6a5682fd1b2d92 (diff) | |
Merge commit 'v2.6.28-rc2' into x86/pci-ioapic-boot-irq-quirks
Diffstat (limited to 'kernel/irq/proc.c')
| -rw-r--r-- | kernel/irq/proc.c | 137 |
1 files changed, 73 insertions, 64 deletions
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index 6c6d35d68ee9..fac014a81b24 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | #include <linux/irq.h> | 9 | #include <linux/irq.h> |
| 10 | #include <linux/proc_fs.h> | 10 | #include <linux/proc_fs.h> |
| 11 | #include <linux/seq_file.h> | ||
| 11 | #include <linux/interrupt.h> | 12 | #include <linux/interrupt.h> |
| 12 | 13 | ||
| 13 | #include "internals.h" | 14 | #include "internals.h" |
| @@ -16,23 +17,18 @@ static struct proc_dir_entry *root_irq_dir; | |||
| 16 | 17 | ||
| 17 | #ifdef CONFIG_SMP | 18 | #ifdef CONFIG_SMP |
| 18 | 19 | ||
| 19 | static int irq_affinity_read_proc(char *page, char **start, off_t off, | 20 | static int irq_affinity_proc_show(struct seq_file *m, void *v) |
| 20 | int count, int *eof, void *data) | ||
| 21 | { | 21 | { |
| 22 | struct irq_desc *desc = irq_desc + (long)data; | 22 | struct irq_desc *desc = irq_to_desc((long)m->private); |
| 23 | cpumask_t *mask = &desc->affinity; | 23 | cpumask_t *mask = &desc->affinity; |
| 24 | int len; | ||
| 25 | 24 | ||
| 26 | #ifdef CONFIG_GENERIC_PENDING_IRQ | 25 | #ifdef CONFIG_GENERIC_PENDING_IRQ |
| 27 | if (desc->status & IRQ_MOVE_PENDING) | 26 | if (desc->status & IRQ_MOVE_PENDING) |
| 28 | mask = &desc->pending_mask; | 27 | mask = &desc->pending_mask; |
| 29 | #endif | 28 | #endif |
| 30 | len = cpumask_scnprintf(page, count, *mask); | 29 | seq_cpumask(m, mask); |
| 31 | 30 | seq_putc(m, '\n'); | |
| 32 | if (count - len < 2) | 31 | return 0; |
| 33 | return -EINVAL; | ||
| 34 | len += sprintf(page + len, "\n"); | ||
| 35 | return len; | ||
| 36 | } | 32 | } |
| 37 | 33 | ||
| 38 | #ifndef is_affinity_mask_valid | 34 | #ifndef is_affinity_mask_valid |
| @@ -40,13 +36,14 @@ static int irq_affinity_read_proc(char *page, char **start, off_t off, | |||
| 40 | #endif | 36 | #endif |
| 41 | 37 | ||
| 42 | int no_irq_affinity; | 38 | int no_irq_affinity; |
| 43 | static int irq_affinity_write_proc(struct file *file, const char __user *buffer, | 39 | static ssize_t irq_affinity_proc_write(struct file *file, |
| 44 | unsigned long count, void *data) | 40 | const char __user *buffer, size_t count, loff_t *pos) |
| 45 | { | 41 | { |
| 46 | unsigned int irq = (int)(long)data, full_count = count, err; | 42 | unsigned int irq = (int)(long)PDE(file->f_path.dentry->d_inode)->data; |
| 47 | cpumask_t new_value; | 43 | cpumask_t new_value; |
| 44 | int err; | ||
| 48 | 45 | ||
| 49 | if (!irq_desc[irq].chip->set_affinity || no_irq_affinity || | 46 | if (!irq_to_desc(irq)->chip->set_affinity || no_irq_affinity || |
| 50 | irq_balancing_disabled(irq)) | 47 | irq_balancing_disabled(irq)) |
| 51 | return -EIO; | 48 | return -EIO; |
| 52 | 49 | ||
| @@ -65,28 +62,38 @@ static int irq_affinity_write_proc(struct file *file, const char __user *buffer, | |||
| 65 | if (!cpus_intersects(new_value, cpu_online_map)) | 62 | if (!cpus_intersects(new_value, cpu_online_map)) |
| 66 | /* Special case for empty set - allow the architecture | 63 | /* Special case for empty set - allow the architecture |
| 67 | code to set default SMP affinity. */ | 64 | code to set default SMP affinity. */ |
| 68 | return irq_select_affinity(irq) ? -EINVAL : full_count; | 65 | return irq_select_affinity(irq) ? -EINVAL : count; |
| 69 | 66 | ||
| 70 | irq_set_affinity(irq, new_value); | 67 | irq_set_affinity(irq, new_value); |
| 71 | 68 | ||
| 72 | return full_count; | 69 | return count; |
| 73 | } | 70 | } |
| 74 | 71 | ||
| 75 | static int default_affinity_read(char *page, char **start, off_t off, | 72 | static int irq_affinity_proc_open(struct inode *inode, struct file *file) |
| 76 | int count, int *eof, void *data) | ||
| 77 | { | 73 | { |
| 78 | int len = cpumask_scnprintf(page, count, irq_default_affinity); | 74 | return single_open(file, irq_affinity_proc_show, PDE(inode)->data); |
| 79 | if (count - len < 2) | ||
| 80 | return -EINVAL; | ||
| 81 | len += sprintf(page + len, "\n"); | ||
| 82 | return len; | ||
| 83 | } | 75 | } |
| 84 | 76 | ||
| 85 | static int default_affinity_write(struct file *file, const char __user *buffer, | 77 | static const struct file_operations irq_affinity_proc_fops = { |
| 86 | unsigned long count, void *data) | 78 | .open = irq_affinity_proc_open, |
| 79 | .read = seq_read, | ||
| 80 | .llseek = seq_lseek, | ||
| 81 | .release = single_release, | ||
| 82 | .write = irq_affinity_proc_write, | ||
| 83 | }; | ||
| 84 | |||
| 85 | static int default_affinity_show(struct seq_file *m, void *v) | ||
| 86 | { | ||
| 87 | seq_cpumask(m, &irq_default_affinity); | ||
| 88 | seq_putc(m, '\n'); | ||
| 89 | return 0; | ||
| 90 | } | ||
| 91 | |||
| 92 | static ssize_t default_affinity_write(struct file *file, | ||
| 93 | const char __user *buffer, size_t count, loff_t *ppos) | ||
| 87 | { | 94 | { |
| 88 | unsigned int full_count = count, err; | ||
| 89 | cpumask_t new_value; | 95 | cpumask_t new_value; |
| 96 | int err; | ||
| 90 | 97 | ||
| 91 | err = cpumask_parse_user(buffer, count, new_value); | 98 | err = cpumask_parse_user(buffer, count, new_value); |
| 92 | if (err) | 99 | if (err) |
| @@ -105,27 +112,40 @@ static int default_affinity_write(struct file *file, const char __user *buffer, | |||
| 105 | 112 | ||
| 106 | irq_default_affinity = new_value; | 113 | irq_default_affinity = new_value; |
| 107 | 114 | ||
| 108 | return full_count; | 115 | return count; |
| 109 | } | 116 | } |
| 117 | |||
| 118 | static int default_affinity_open(struct inode *inode, struct file *file) | ||
| 119 | { | ||
| 120 | return single_open(file, default_affinity_show, NULL); | ||
| 121 | } | ||
| 122 | |||
| 123 | static const struct file_operations default_affinity_proc_fops = { | ||
| 124 | .open = default_affinity_open, | ||
| 125 | .read = seq_read, | ||
| 126 | .llseek = seq_lseek, | ||
| 127 | .release = single_release, | ||
| 128 | .write = default_affinity_write, | ||
| 129 | }; | ||
| 110 | #endif | 130 | #endif |
| 111 | 131 | ||
| 112 | static int irq_spurious_read(char *page, char **start, off_t off, | 132 | static int irq_spurious_read(char *page, char **start, off_t off, |
| 113 | int count, int *eof, void *data) | 133 | int count, int *eof, void *data) |
| 114 | { | 134 | { |
| 115 | struct irq_desc *d = &irq_desc[(long) data]; | 135 | struct irq_desc *desc = irq_to_desc((long) data); |
| 116 | return sprintf(page, "count %u\n" | 136 | return sprintf(page, "count %u\n" |
| 117 | "unhandled %u\n" | 137 | "unhandled %u\n" |
| 118 | "last_unhandled %u ms\n", | 138 | "last_unhandled %u ms\n", |
| 119 | d->irq_count, | 139 | desc->irq_count, |
| 120 | d->irqs_unhandled, | 140 | desc->irqs_unhandled, |
| 121 | jiffies_to_msecs(d->last_unhandled)); | 141 | jiffies_to_msecs(desc->last_unhandled)); |
| 122 | } | 142 | } |
| 123 | 143 | ||
| 124 | #define MAX_NAMELEN 128 | 144 | #define MAX_NAMELEN 128 |
| 125 | 145 | ||
| 126 | static int name_unique(unsigned int irq, struct irqaction *new_action) | 146 | static int name_unique(unsigned int irq, struct irqaction *new_action) |
| 127 | { | 147 | { |
| 128 | struct irq_desc *desc = irq_desc + irq; | 148 | struct irq_desc *desc = irq_to_desc(irq); |
| 129 | struct irqaction *action; | 149 | struct irqaction *action; |
| 130 | unsigned long flags; | 150 | unsigned long flags; |
| 131 | int ret = 1; | 151 | int ret = 1; |
| @@ -145,8 +165,9 @@ static int name_unique(unsigned int irq, struct irqaction *new_action) | |||
| 145 | void register_handler_proc(unsigned int irq, struct irqaction *action) | 165 | void register_handler_proc(unsigned int irq, struct irqaction *action) |
| 146 | { | 166 | { |
| 147 | char name [MAX_NAMELEN]; | 167 | char name [MAX_NAMELEN]; |
| 168 | struct irq_desc *desc = irq_to_desc(irq); | ||
| 148 | 169 | ||
| 149 | if (!irq_desc[irq].dir || action->dir || !action->name || | 170 | if (!desc->dir || action->dir || !action->name || |
| 150 | !name_unique(irq, action)) | 171 | !name_unique(irq, action)) |
| 151 | return; | 172 | return; |
| 152 | 173 | ||
| @@ -154,43 +175,34 @@ void register_handler_proc(unsigned int irq, struct irqaction *action) | |||
| 154 | snprintf(name, MAX_NAMELEN, "%s", action->name); | 175 | snprintf(name, MAX_NAMELEN, "%s", action->name); |
| 155 | 176 | ||
| 156 | /* create /proc/irq/1234/handler/ */ | 177 | /* create /proc/irq/1234/handler/ */ |
| 157 | action->dir = proc_mkdir(name, irq_desc[irq].dir); | 178 | action->dir = proc_mkdir(name, desc->dir); |
| 158 | } | 179 | } |
| 159 | 180 | ||
| 160 | #undef MAX_NAMELEN | 181 | #undef MAX_NAMELEN |
| 161 | 182 | ||
| 162 | #define MAX_NAMELEN 10 | 183 | #define MAX_NAMELEN 10 |
| 163 | 184 | ||
| 164 | void register_irq_proc(unsigned int irq) | 185 | void register_irq_proc(unsigned int irq, struct irq_desc *desc) |
| 165 | { | 186 | { |
| 166 | char name [MAX_NAMELEN]; | 187 | char name [MAX_NAMELEN]; |
| 167 | struct proc_dir_entry *entry; | 188 | struct proc_dir_entry *entry; |
| 168 | 189 | ||
| 169 | if (!root_irq_dir || | 190 | if (!root_irq_dir || (desc->chip == &no_irq_chip) || desc->dir) |
| 170 | (irq_desc[irq].chip == &no_irq_chip) || | ||
| 171 | irq_desc[irq].dir) | ||
| 172 | return; | 191 | return; |
| 173 | 192 | ||
| 174 | memset(name, 0, MAX_NAMELEN); | 193 | memset(name, 0, MAX_NAMELEN); |
| 175 | sprintf(name, "%d", irq); | 194 | sprintf(name, "%d", irq); |
| 176 | 195 | ||
| 177 | /* create /proc/irq/1234 */ | 196 | /* create /proc/irq/1234 */ |
| 178 | irq_desc[irq].dir = proc_mkdir(name, root_irq_dir); | 197 | desc->dir = proc_mkdir(name, root_irq_dir); |
| 179 | 198 | ||
| 180 | #ifdef CONFIG_SMP | 199 | #ifdef CONFIG_SMP |
| 181 | { | 200 | /* create /proc/irq/<irq>/smp_affinity */ |
| 182 | /* create /proc/irq/<irq>/smp_affinity */ | 201 | proc_create_data("smp_affinity", 0600, desc->dir, |
| 183 | entry = create_proc_entry("smp_affinity", 0600, irq_desc[irq].dir); | 202 | &irq_affinity_proc_fops, (void *)(long)irq); |
| 184 | |||
| 185 | if (entry) { | ||
| 186 | entry->data = (void *)(long)irq; | ||
| 187 | entry->read_proc = irq_affinity_read_proc; | ||
| 188 | entry->write_proc = irq_affinity_write_proc; | ||
| 189 | } | ||
| 190 | } | ||
| 191 | #endif | 203 | #endif |
| 192 | 204 | ||
| 193 | entry = create_proc_entry("spurious", 0444, irq_desc[irq].dir); | 205 | entry = create_proc_entry("spurious", 0444, desc->dir); |
| 194 | if (entry) { | 206 | if (entry) { |
| 195 | entry->data = (void *)(long)irq; | 207 | entry->data = (void *)(long)irq; |
| 196 | entry->read_proc = irq_spurious_read; | 208 | entry->read_proc = irq_spurious_read; |
| @@ -201,28 +213,25 @@ void register_irq_proc(unsigned int irq) | |||
| 201 | 213 | ||
| 202 | void unregister_handler_proc(unsigned int irq, struct irqaction *action) | 214 | void unregister_handler_proc(unsigned int irq, struct irqaction *action) |
| 203 | { | 215 | { |
| 204 | if (action->dir) | 216 | if (action->dir) { |
| 205 | remove_proc_entry(action->dir->name, irq_desc[irq].dir); | 217 | struct irq_desc *desc = irq_to_desc(irq); |
| 218 | |||
| 219 | remove_proc_entry(action->dir->name, desc->dir); | ||
| 220 | } | ||
| 206 | } | 221 | } |
| 207 | 222 | ||
| 208 | void register_default_affinity_proc(void) | 223 | void register_default_affinity_proc(void) |
| 209 | { | 224 | { |
| 210 | #ifdef CONFIG_SMP | 225 | #ifdef CONFIG_SMP |
| 211 | struct proc_dir_entry *entry; | 226 | proc_create("irq/default_smp_affinity", 0600, NULL, |
| 212 | 227 | &default_affinity_proc_fops); | |
| 213 | /* create /proc/irq/default_smp_affinity */ | ||
| 214 | entry = create_proc_entry("default_smp_affinity", 0600, root_irq_dir); | ||
| 215 | if (entry) { | ||
| 216 | entry->data = NULL; | ||
| 217 | entry->read_proc = default_affinity_read; | ||
| 218 | entry->write_proc = default_affinity_write; | ||
| 219 | } | ||
| 220 | #endif | 228 | #endif |
| 221 | } | 229 | } |
| 222 | 230 | ||
| 223 | void init_irq_proc(void) | 231 | void init_irq_proc(void) |
| 224 | { | 232 | { |
| 225 | int i; | 233 | unsigned int irq; |
| 234 | struct irq_desc *desc; | ||
| 226 | 235 | ||
| 227 | /* create /proc/irq */ | 236 | /* create /proc/irq */ |
| 228 | root_irq_dir = proc_mkdir("irq", NULL); | 237 | root_irq_dir = proc_mkdir("irq", NULL); |
| @@ -234,7 +243,7 @@ void init_irq_proc(void) | |||
| 234 | /* | 243 | /* |
| 235 | * Create entries for all existing IRQs. | 244 | * Create entries for all existing IRQs. |
| 236 | */ | 245 | */ |
| 237 | for (i = 0; i < NR_IRQS; i++) | 246 | for_each_irq_desc(irq, desc) |
| 238 | register_irq_proc(i); | 247 | register_irq_proc(irq, desc); |
| 239 | } | 248 | } |
| 240 | 249 | ||
