Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: irq.c,v 1.114 2002/01/11 08:45:38 davem Exp $ |
| 2 | * irq.c: UltraSparc IRQ handling/init/registry. |
| 3 | * |
| 4 | * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu) |
| 5 | * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be) |
| 6 | * Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz) |
| 7 | */ |
| 8 | |
| 9 | #include <linux/config.h> |
| 10 | #include <linux/module.h> |
| 11 | #include <linux/sched.h> |
| 12 | #include <linux/ptrace.h> |
| 13 | #include <linux/errno.h> |
| 14 | #include <linux/kernel_stat.h> |
| 15 | #include <linux/signal.h> |
| 16 | #include <linux/mm.h> |
| 17 | #include <linux/interrupt.h> |
| 18 | #include <linux/slab.h> |
| 19 | #include <linux/random.h> |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/delay.h> |
| 22 | #include <linux/proc_fs.h> |
| 23 | #include <linux/seq_file.h> |
David S. Miller | b5a37e9 | 2006-02-11 23:07:13 -0800 | [diff] [blame] | 24 | #include <linux/bootmem.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| 26 | #include <asm/ptrace.h> |
| 27 | #include <asm/processor.h> |
| 28 | #include <asm/atomic.h> |
| 29 | #include <asm/system.h> |
| 30 | #include <asm/irq.h> |
Sven Hartge | 2e457ef | 2005-10-08 21:12:04 -0700 | [diff] [blame] | 31 | #include <asm/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <asm/sbus.h> |
| 33 | #include <asm/iommu.h> |
| 34 | #include <asm/upa.h> |
| 35 | #include <asm/oplib.h> |
| 36 | #include <asm/timer.h> |
| 37 | #include <asm/smp.h> |
| 38 | #include <asm/starfire.h> |
| 39 | #include <asm/uaccess.h> |
| 40 | #include <asm/cache.h> |
| 41 | #include <asm/cpudata.h> |
David S. Miller | 63b6145 | 2005-06-27 17:04:45 -0700 | [diff] [blame] | 42 | #include <asm/auxio.h> |
David S. Miller | 92704a1 | 2006-02-26 23:27:19 -0800 | [diff] [blame] | 43 | #include <asm/head.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
| 45 | #ifdef CONFIG_SMP |
| 46 | static void distribute_irqs(void); |
| 47 | #endif |
| 48 | |
| 49 | /* UPA nodes send interrupt packet to UltraSparc with first data reg |
| 50 | * value low 5 (7 on Starfire) bits holding the IRQ identifier being |
| 51 | * delivered. We must translate this into a non-vector IRQ so we can |
| 52 | * set the softint on this cpu. |
| 53 | * |
| 54 | * To make processing these packets efficient and race free we use |
| 55 | * an array of irq buckets below. The interrupt vector handler in |
| 56 | * entry.S feeds incoming packets into per-cpu pil-indexed lists. |
| 57 | * The IVEC handler does not need to act atomically, the PIL dispatch |
| 58 | * code uses CAS to get an atomic snapshot of the list and clear it |
| 59 | * at the same time. |
| 60 | */ |
| 61 | |
| 62 | struct ino_bucket ivector_table[NUM_IVECS] __attribute__ ((aligned (SMP_CACHE_BYTES))); |
| 63 | |
| 64 | /* This has to be in the main kernel image, it cannot be |
| 65 | * turned into per-cpu data. The reason is that the main |
| 66 | * kernel image is locked into the TLB and this structure |
| 67 | * is accessed from the vectored interrupt trap handler. If |
| 68 | * access to this structure takes a TLB miss it could cause |
| 69 | * the 5-level sparc v9 trap stack to overflow. |
| 70 | */ |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 71 | #define irq_work(__cpu) &(trap_block[(__cpu)].irq_worklist) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 73 | static struct irqaction *irq_action[NR_IRQS+1]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
| 75 | /* This only synchronizes entities which modify IRQ handler |
| 76 | * state and some selected user-level spots that want to |
| 77 | * read things in the table. IRQ handler processing orders |
| 78 | * its' accesses such that no locking is needed. |
| 79 | */ |
| 80 | static DEFINE_SPINLOCK(irq_action_lock); |
| 81 | |
| 82 | static void register_irq_proc (unsigned int irq); |
| 83 | |
| 84 | /* |
| 85 | * Upper 2b of irqaction->flags holds the ino. |
| 86 | * irqaction->mask holds the smp affinity information. |
| 87 | */ |
| 88 | #define put_ino_in_irqaction(action, irq) \ |
| 89 | action->flags &= 0xffffffffffffUL; \ |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 90 | action->flags |= __irq_ino(irq) << 48; |
| 91 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | #define get_ino_in_irqaction(action) (action->flags >> 48) |
| 93 | |
| 94 | #define put_smpaff_in_irqaction(action, smpaff) (action)->mask = (smpaff) |
| 95 | #define get_smpaff_in_irqaction(action) ((action)->mask) |
| 96 | |
| 97 | int show_interrupts(struct seq_file *p, void *v) |
| 98 | { |
| 99 | unsigned long flags; |
| 100 | int i = *(loff_t *) v; |
| 101 | struct irqaction *action; |
| 102 | #ifdef CONFIG_SMP |
| 103 | int j; |
| 104 | #endif |
| 105 | |
| 106 | spin_lock_irqsave(&irq_action_lock, flags); |
| 107 | if (i <= NR_IRQS) { |
| 108 | if (!(action = *(i + irq_action))) |
| 109 | goto out_unlock; |
| 110 | seq_printf(p, "%3d: ", i); |
| 111 | #ifndef CONFIG_SMP |
| 112 | seq_printf(p, "%10u ", kstat_irqs(i)); |
| 113 | #else |
Andrew Morton | 394e390 | 2006-03-23 03:01:05 -0800 | [diff] [blame] | 114 | for_each_online_cpu(j) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | seq_printf(p, "%10u ", |
| 116 | kstat_cpu(j).irqs[i]); |
| 117 | } |
| 118 | #endif |
| 119 | seq_printf(p, " %s:%lx", action->name, |
| 120 | get_ino_in_irqaction(action)); |
| 121 | for (action = action->next; action; action = action->next) { |
| 122 | seq_printf(p, ", %s:%lx", action->name, |
| 123 | get_ino_in_irqaction(action)); |
| 124 | } |
| 125 | seq_putc(p, '\n'); |
| 126 | } |
| 127 | out_unlock: |
| 128 | spin_unlock_irqrestore(&irq_action_lock, flags); |
| 129 | |
| 130 | return 0; |
| 131 | } |
| 132 | |
David S. Miller | ebd8c56 | 2006-02-17 08:38:06 -0800 | [diff] [blame] | 133 | extern unsigned long real_hard_smp_processor_id(void); |
| 134 | |
| 135 | static unsigned int sun4u_compute_tid(unsigned long imap, unsigned long cpuid) |
| 136 | { |
| 137 | unsigned int tid; |
| 138 | |
| 139 | if (this_is_starfire) { |
| 140 | tid = starfire_translate(imap, cpuid); |
| 141 | tid <<= IMAP_TID_SHIFT; |
| 142 | tid &= IMAP_TID_UPA; |
| 143 | } else { |
| 144 | if (tlb_type == cheetah || tlb_type == cheetah_plus) { |
| 145 | unsigned long ver; |
| 146 | |
| 147 | __asm__ ("rdpr %%ver, %0" : "=r" (ver)); |
| 148 | if ((ver >> 32UL) == __JALAPENO_ID || |
| 149 | (ver >> 32UL) == __SERRANO_ID) { |
| 150 | tid = cpuid << IMAP_TID_SHIFT; |
| 151 | tid &= IMAP_TID_JBUS; |
| 152 | } else { |
| 153 | unsigned int a = cpuid & 0x1f; |
| 154 | unsigned int n = (cpuid >> 5) & 0x1f; |
| 155 | |
| 156 | tid = ((a << IMAP_AID_SHIFT) | |
| 157 | (n << IMAP_NID_SHIFT)); |
| 158 | tid &= (IMAP_AID_SAFARI | |
| 159 | IMAP_NID_SAFARI);; |
| 160 | } |
| 161 | } else { |
| 162 | tid = cpuid << IMAP_TID_SHIFT; |
| 163 | tid &= IMAP_TID_UPA; |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | return tid; |
| 168 | } |
| 169 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | /* Now these are always passed a true fully specified sun4u INO. */ |
| 171 | void enable_irq(unsigned int irq) |
| 172 | { |
| 173 | struct ino_bucket *bucket = __bucket(irq); |
David S. Miller | ebd8c56 | 2006-02-17 08:38:06 -0800 | [diff] [blame] | 174 | unsigned long imap, cpuid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | |
| 176 | imap = bucket->imap; |
| 177 | if (imap == 0UL) |
| 178 | return; |
| 179 | |
| 180 | preempt_disable(); |
| 181 | |
David S. Miller | ebd8c56 | 2006-02-17 08:38:06 -0800 | [diff] [blame] | 182 | /* This gets the physical processor ID, even on uniprocessor, |
| 183 | * so we can always program the interrupt target correctly. |
| 184 | */ |
| 185 | cpuid = real_hard_smp_processor_id(); |
| 186 | |
David S. Miller | d82ace7 | 2006-02-09 02:52:44 -0800 | [diff] [blame] | 187 | if (tlb_type == hypervisor) { |
David S. Miller | 4bf447d | 2006-02-13 22:37:32 -0800 | [diff] [blame] | 188 | unsigned int ino = __irq_ino(irq); |
David S. Miller | c4bea28 | 2006-02-13 22:56:27 -0800 | [diff] [blame] | 189 | int err; |
David S. Miller | 10951ee | 2006-02-13 18:22:57 -0800 | [diff] [blame] | 190 | |
David S. Miller | ebd8c56 | 2006-02-17 08:38:06 -0800 | [diff] [blame] | 191 | err = sun4v_intr_settarget(ino, cpuid); |
David S. Miller | c4bea28 | 2006-02-13 22:56:27 -0800 | [diff] [blame] | 192 | if (err != HV_EOK) |
David S. Miller | ebd8c56 | 2006-02-17 08:38:06 -0800 | [diff] [blame] | 193 | printk("sun4v_intr_settarget(%x,%lu): err(%d)\n", |
| 194 | ino, cpuid, err); |
David S. Miller | abd92b2 | 2006-02-14 22:20:13 -0800 | [diff] [blame] | 195 | err = sun4v_intr_setenabled(ino, HV_INTR_ENABLED); |
David S. Miller | c4bea28 | 2006-02-13 22:56:27 -0800 | [diff] [blame] | 196 | if (err != HV_EOK) |
| 197 | printk("sun4v_intr_setenabled(%x): err(%d)\n", |
| 198 | ino, err); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | } else { |
David S. Miller | ebd8c56 | 2006-02-17 08:38:06 -0800 | [diff] [blame] | 200 | unsigned int tid = sun4u_compute_tid(imap, cpuid); |
David S. Miller | d82ace7 | 2006-02-09 02:52:44 -0800 | [diff] [blame] | 201 | |
| 202 | /* NOTE NOTE NOTE, IGN and INO are read-only, IGN is a product |
| 203 | * of this SYSIO's preconfigured IGN in the SYSIO Control |
| 204 | * Register, the hardware just mirrors that value here. |
| 205 | * However for Graphics and UPA Slave devices the full |
| 206 | * IMAP_INR field can be set by the programmer here. |
| 207 | * |
| 208 | * Things like FFB can now be handled via the new IRQ |
| 209 | * mechanism. |
| 210 | */ |
| 211 | upa_writel(tid | IMAP_VALID, imap); |
| 212 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | |
| 214 | preempt_enable(); |
| 215 | } |
| 216 | |
| 217 | /* This now gets passed true ino's as well. */ |
| 218 | void disable_irq(unsigned int irq) |
| 219 | { |
| 220 | struct ino_bucket *bucket = __bucket(irq); |
| 221 | unsigned long imap; |
| 222 | |
| 223 | imap = bucket->imap; |
| 224 | if (imap != 0UL) { |
David S. Miller | 10951ee | 2006-02-13 18:22:57 -0800 | [diff] [blame] | 225 | if (tlb_type == hypervisor) { |
David S. Miller | 4bf447d | 2006-02-13 22:37:32 -0800 | [diff] [blame] | 226 | unsigned int ino = __irq_ino(irq); |
David S. Miller | c4bea28 | 2006-02-13 22:56:27 -0800 | [diff] [blame] | 227 | int err; |
David S. Miller | 4bf447d | 2006-02-13 22:37:32 -0800 | [diff] [blame] | 228 | |
David S. Miller | c4bea28 | 2006-02-13 22:56:27 -0800 | [diff] [blame] | 229 | err = sun4v_intr_setenabled(ino, HV_INTR_DISABLED); |
| 230 | if (err != HV_EOK) |
| 231 | printk("sun4v_intr_setenabled(%x): " |
| 232 | "err(%d)\n", ino, err); |
David S. Miller | 10951ee | 2006-02-13 18:22:57 -0800 | [diff] [blame] | 233 | } else { |
| 234 | u32 tmp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | |
David S. Miller | 10951ee | 2006-02-13 18:22:57 -0800 | [diff] [blame] | 236 | /* NOTE: We do not want to futz with the IRQ clear registers |
| 237 | * and move the state to IDLE, the SCSI code does call |
| 238 | * disable_irq() to assure atomicity in the queue cmd |
| 239 | * SCSI adapter driver code. Thus we'd lose interrupts. |
| 240 | */ |
| 241 | tmp = upa_readl(imap); |
| 242 | tmp &= ~IMAP_VALID; |
| 243 | upa_writel(tmp, imap); |
| 244 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | } |
| 246 | } |
| 247 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 248 | static void build_irq_error(const char *msg, unsigned int ino, int pil, int inofixup, |
| 249 | unsigned long iclr, unsigned long imap, |
| 250 | struct ino_bucket *bucket) |
| 251 | { |
| 252 | prom_printf("IRQ: INO %04x (%d:%016lx:%016lx) --> " |
| 253 | "(%d:%d:%016lx:%016lx), halting...\n", |
| 254 | ino, bucket->pil, bucket->iclr, bucket->imap, |
| 255 | pil, inofixup, iclr, imap); |
| 256 | prom_halt(); |
| 257 | } |
| 258 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | unsigned int build_irq(int pil, int inofixup, unsigned long iclr, unsigned long imap) |
| 260 | { |
| 261 | struct ino_bucket *bucket; |
| 262 | int ino; |
| 263 | |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 264 | BUG_ON(pil == 0); |
David S. Miller | 10951ee | 2006-02-13 18:22:57 -0800 | [diff] [blame] | 265 | BUG_ON(tlb_type == hypervisor); |
| 266 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | /* RULE: Both must be specified in all other cases. */ |
| 268 | if (iclr == 0UL || imap == 0UL) { |
| 269 | prom_printf("Invalid build_irq %d %d %016lx %016lx\n", |
| 270 | pil, inofixup, iclr, imap); |
| 271 | prom_halt(); |
| 272 | } |
| 273 | |
| 274 | ino = (upa_readl(imap) & (IMAP_IGN | IMAP_INO)) + inofixup; |
| 275 | if (ino > NUM_IVECS) { |
| 276 | prom_printf("Invalid INO %04x (%d:%d:%016lx:%016lx)\n", |
| 277 | ino, pil, inofixup, iclr, imap); |
| 278 | prom_halt(); |
| 279 | } |
| 280 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 281 | bucket = &ivector_table[ino]; |
| 282 | if (bucket->flags & IBF_ACTIVE) |
| 283 | build_irq_error("IRQ: Trying to build active INO bucket.\n", |
| 284 | ino, pil, inofixup, iclr, imap, bucket); |
| 285 | |
| 286 | if (bucket->irq_info) { |
| 287 | if (bucket->imap != imap || bucket->iclr != iclr) |
| 288 | build_irq_error("IRQ: Trying to reinit INO bucket.\n", |
| 289 | ino, pil, inofixup, iclr, imap, bucket); |
| 290 | |
| 291 | goto out; |
| 292 | } |
| 293 | |
Eric Sesterhenn | 9132983 | 2006-03-06 13:48:40 -0800 | [diff] [blame] | 294 | bucket->irq_info = kzalloc(sizeof(struct irq_desc), GFP_ATOMIC); |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 295 | if (!bucket->irq_info) { |
| 296 | prom_printf("IRQ: Error, kmalloc(irq_desc) failed.\n"); |
| 297 | prom_halt(); |
| 298 | } |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 299 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | /* Ok, looks good, set it up. Don't touch the irq_chain or |
| 301 | * the pending flag. |
| 302 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | bucket->imap = imap; |
| 304 | bucket->iclr = iclr; |
| 305 | bucket->pil = pil; |
| 306 | bucket->flags = 0; |
| 307 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 308 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | return __irq(bucket); |
| 310 | } |
| 311 | |
David S. Miller | e399957 | 2006-02-13 18:16:10 -0800 | [diff] [blame] | 312 | unsigned int sun4v_build_irq(u32 devhandle, unsigned int devino, int pil, unsigned char flags) |
| 313 | { |
| 314 | struct ino_bucket *bucket; |
| 315 | unsigned long sysino; |
| 316 | |
| 317 | sysino = sun4v_devino_to_sysino(devhandle, devino); |
| 318 | |
David S. Miller | e399957 | 2006-02-13 18:16:10 -0800 | [diff] [blame] | 319 | bucket = &ivector_table[sysino]; |
| 320 | |
| 321 | /* Catch accidental accesses to these things. IMAP/ICLR handling |
| 322 | * is done by hypervisor calls on sun4v platforms, not by direct |
| 323 | * register accesses. |
David S. Miller | 22780e2 | 2006-02-16 14:37:05 -0800 | [diff] [blame] | 324 | * |
| 325 | * But we need to make them look unique for the disable_irq() logic |
| 326 | * in free_irq(). |
David S. Miller | e399957 | 2006-02-13 18:16:10 -0800 | [diff] [blame] | 327 | */ |
David S. Miller | 22780e2 | 2006-02-16 14:37:05 -0800 | [diff] [blame] | 328 | bucket->imap = ~0UL - sysino; |
| 329 | bucket->iclr = ~0UL - sysino; |
David S. Miller | e399957 | 2006-02-13 18:16:10 -0800 | [diff] [blame] | 330 | |
| 331 | bucket->pil = pil; |
| 332 | bucket->flags = flags; |
| 333 | |
Eric Sesterhenn | 9132983 | 2006-03-06 13:48:40 -0800 | [diff] [blame] | 334 | bucket->irq_info = kzalloc(sizeof(struct irq_desc), GFP_ATOMIC); |
David S. Miller | e399957 | 2006-02-13 18:16:10 -0800 | [diff] [blame] | 335 | if (!bucket->irq_info) { |
| 336 | prom_printf("IRQ: Error, kmalloc(irq_desc) failed.\n"); |
| 337 | prom_halt(); |
| 338 | } |
David S. Miller | e399957 | 2006-02-13 18:16:10 -0800 | [diff] [blame] | 339 | |
| 340 | return __irq(bucket); |
| 341 | } |
| 342 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | static void atomic_bucket_insert(struct ino_bucket *bucket) |
| 344 | { |
| 345 | unsigned long pstate; |
| 346 | unsigned int *ent; |
| 347 | |
| 348 | __asm__ __volatile__("rdpr %%pstate, %0" : "=r" (pstate)); |
| 349 | __asm__ __volatile__("wrpr %0, %1, %%pstate" |
| 350 | : : "r" (pstate), "i" (PSTATE_IE)); |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 351 | ent = irq_work(smp_processor_id()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | bucket->irq_chain = *ent; |
| 353 | *ent = __irq(bucket); |
| 354 | __asm__ __volatile__("wrpr %0, 0x0, %%pstate" : : "r" (pstate)); |
| 355 | } |
| 356 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 357 | static int check_irq_sharing(int pil, unsigned long irqflags) |
| 358 | { |
| 359 | struct irqaction *action, *tmp; |
| 360 | |
| 361 | action = *(irq_action + pil); |
| 362 | if (action) { |
| 363 | if ((action->flags & SA_SHIRQ) && (irqflags & SA_SHIRQ)) { |
| 364 | for (tmp = action; tmp->next; tmp = tmp->next) |
| 365 | ; |
| 366 | } else { |
| 367 | return -EBUSY; |
| 368 | } |
| 369 | } |
| 370 | return 0; |
| 371 | } |
| 372 | |
| 373 | static void append_irq_action(int pil, struct irqaction *action) |
| 374 | { |
| 375 | struct irqaction **pp = irq_action + pil; |
| 376 | |
| 377 | while (*pp) |
| 378 | pp = &((*pp)->next); |
| 379 | *pp = action; |
| 380 | } |
| 381 | |
| 382 | static struct irqaction *get_action_slot(struct ino_bucket *bucket) |
| 383 | { |
| 384 | struct irq_desc *desc = bucket->irq_info; |
| 385 | int max_irq, i; |
| 386 | |
| 387 | max_irq = 1; |
| 388 | if (bucket->flags & IBF_PCI) |
| 389 | max_irq = MAX_IRQ_DESC_ACTION; |
| 390 | for (i = 0; i < max_irq; i++) { |
| 391 | struct irqaction *p = &desc->action[i]; |
| 392 | u32 mask = (1 << i); |
| 393 | |
| 394 | if (desc->action_active_mask & mask) |
| 395 | continue; |
| 396 | |
| 397 | desc->action_active_mask |= mask; |
| 398 | return p; |
| 399 | } |
| 400 | return NULL; |
| 401 | } |
| 402 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | int request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_regs *), |
| 404 | unsigned long irqflags, const char *name, void *dev_id) |
| 405 | { |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 406 | struct irqaction *action; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | struct ino_bucket *bucket = __bucket(irq); |
| 408 | unsigned long flags; |
| 409 | int pending = 0; |
| 410 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 411 | if (unlikely(!handler)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | return -EINVAL; |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 413 | |
| 414 | if (unlikely(!bucket->irq_info)) |
| 415 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 417 | if (irqflags & SA_SAMPLE_RANDOM) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | /* |
| 419 | * This function might sleep, we want to call it first, |
| 420 | * outside of the atomic block. In SA_STATIC_ALLOC case, |
| 421 | * random driver's kmalloc will fail, but it is safe. |
| 422 | * If already initialized, random driver will not reinit. |
| 423 | * Yes, this might clear the entropy pool if the wrong |
| 424 | * driver is attempted to be loaded, without actually |
| 425 | * installing a new handler, but is this really a problem, |
| 426 | * only the sysadmin is able to do this. |
| 427 | */ |
| 428 | rand_initialize_irq(irq); |
| 429 | } |
| 430 | |
| 431 | spin_lock_irqsave(&irq_action_lock, flags); |
| 432 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 433 | if (check_irq_sharing(bucket->pil, irqflags)) { |
| 434 | spin_unlock_irqrestore(&irq_action_lock, flags); |
| 435 | return -EBUSY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | } |
| 437 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 438 | action = get_action_slot(bucket); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | if (!action) { |
| 440 | spin_unlock_irqrestore(&irq_action_lock, flags); |
| 441 | return -ENOMEM; |
| 442 | } |
| 443 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 444 | bucket->flags |= IBF_ACTIVE; |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 445 | pending = bucket->pending; |
| 446 | if (pending) |
| 447 | bucket->pending = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | |
| 449 | action->handler = handler; |
| 450 | action->flags = irqflags; |
| 451 | action->name = name; |
| 452 | action->next = NULL; |
| 453 | action->dev_id = dev_id; |
| 454 | put_ino_in_irqaction(action, irq); |
| 455 | put_smpaff_in_irqaction(action, CPU_MASK_NONE); |
| 456 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 457 | append_irq_action(bucket->pil, action); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | |
| 459 | enable_irq(irq); |
| 460 | |
| 461 | /* We ate the IVEC already, this makes sure it does not get lost. */ |
| 462 | if (pending) { |
| 463 | atomic_bucket_insert(bucket); |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 464 | set_softint(1 << PIL_DEVICE_IRQ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | } |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 466 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | spin_unlock_irqrestore(&irq_action_lock, flags); |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 468 | |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 469 | register_irq_proc(__irq_ino(irq)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | |
| 471 | #ifdef CONFIG_SMP |
| 472 | distribute_irqs(); |
| 473 | #endif |
| 474 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | } |
| 476 | |
| 477 | EXPORT_SYMBOL(request_irq); |
| 478 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 479 | static struct irqaction *unlink_irq_action(unsigned int irq, void *dev_id) |
| 480 | { |
| 481 | struct ino_bucket *bucket = __bucket(irq); |
| 482 | struct irqaction *action, **pp; |
| 483 | |
| 484 | pp = irq_action + bucket->pil; |
| 485 | action = *pp; |
| 486 | if (unlikely(!action)) |
| 487 | return NULL; |
| 488 | |
| 489 | if (unlikely(!action->handler)) { |
| 490 | printk("Freeing free IRQ %d\n", bucket->pil); |
| 491 | return NULL; |
| 492 | } |
| 493 | |
| 494 | while (action && action->dev_id != dev_id) { |
| 495 | pp = &action->next; |
| 496 | action = *pp; |
| 497 | } |
| 498 | |
| 499 | if (likely(action)) |
| 500 | *pp = action->next; |
| 501 | |
| 502 | return action; |
| 503 | } |
| 504 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | void free_irq(unsigned int irq, void *dev_id) |
| 506 | { |
| 507 | struct irqaction *action; |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 508 | struct ino_bucket *bucket; |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 509 | struct irq_desc *desc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | unsigned long flags; |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 511 | int ent, i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | spin_lock_irqsave(&irq_action_lock, flags); |
| 514 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 515 | action = unlink_irq_action(irq, dev_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | |
| 517 | spin_unlock_irqrestore(&irq_action_lock, flags); |
| 518 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 519 | if (unlikely(!action)) |
| 520 | return; |
| 521 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | synchronize_irq(irq); |
| 523 | |
| 524 | spin_lock_irqsave(&irq_action_lock, flags); |
| 525 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 526 | bucket = __bucket(irq); |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 527 | desc = bucket->irq_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 529 | for (i = 0; i < MAX_IRQ_DESC_ACTION; i++) { |
| 530 | struct irqaction *p = &desc->action[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 532 | if (p == action) { |
| 533 | desc->action_active_mask &= ~(1 << i); |
| 534 | break; |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | if (!desc->action_active_mask) { |
| 539 | unsigned long imap = bucket->imap; |
| 540 | |
| 541 | /* This unique interrupt source is now inactive. */ |
| 542 | bucket->flags &= ~IBF_ACTIVE; |
| 543 | |
| 544 | /* See if any other buckets share this bucket's IMAP |
| 545 | * and are still active. |
| 546 | */ |
| 547 | for (ent = 0; ent < NUM_IVECS; ent++) { |
| 548 | struct ino_bucket *bp = &ivector_table[ent]; |
| 549 | if (bp != bucket && |
| 550 | bp->imap == imap && |
| 551 | (bp->flags & IBF_ACTIVE) != 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | break; |
| 553 | } |
| 554 | |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 555 | /* Only disable when no other sub-irq levels of |
| 556 | * the same IMAP are active. |
| 557 | */ |
| 558 | if (ent == NUM_IVECS) |
| 559 | disable_irq(irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | } |
| 561 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | spin_unlock_irqrestore(&irq_action_lock, flags); |
| 563 | } |
| 564 | |
| 565 | EXPORT_SYMBOL(free_irq); |
| 566 | |
| 567 | #ifdef CONFIG_SMP |
| 568 | void synchronize_irq(unsigned int irq) |
| 569 | { |
| 570 | struct ino_bucket *bucket = __bucket(irq); |
| 571 | |
| 572 | #if 0 |
| 573 | /* The following is how I wish I could implement this. |
| 574 | * Unfortunately the ICLR registers are read-only, you can |
| 575 | * only write ICLR_foo values to them. To get the current |
| 576 | * IRQ status you would need to get at the IRQ diag registers |
| 577 | * in the PCI/SBUS controller and the layout of those vary |
| 578 | * from one controller to the next, sigh... -DaveM |
| 579 | */ |
| 580 | unsigned long iclr = bucket->iclr; |
| 581 | |
| 582 | while (1) { |
| 583 | u32 tmp = upa_readl(iclr); |
| 584 | |
| 585 | if (tmp == ICLR_TRANSMIT || |
| 586 | tmp == ICLR_PENDING) { |
| 587 | cpu_relax(); |
| 588 | continue; |
| 589 | } |
| 590 | break; |
| 591 | } |
| 592 | #else |
| 593 | /* So we have to do this with a INPROGRESS bit just like x86. */ |
| 594 | while (bucket->flags & IBF_INPROGRESS) |
| 595 | cpu_relax(); |
| 596 | #endif |
| 597 | } |
| 598 | #endif /* CONFIG_SMP */ |
| 599 | |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 600 | static void process_bucket(struct ino_bucket *bp, struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | { |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 602 | struct irq_desc *desc = bp->irq_info; |
| 603 | unsigned char flags = bp->flags; |
| 604 | u32 action_mask, i; |
| 605 | int random; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 607 | bp->flags |= IBF_INPROGRESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 609 | if (unlikely(!(flags & IBF_ACTIVE))) { |
| 610 | bp->pending = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | } |
| 613 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 614 | if (desc->pre_handler) |
| 615 | desc->pre_handler(bp, |
| 616 | desc->pre_handler_arg1, |
| 617 | desc->pre_handler_arg2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 619 | action_mask = desc->action_active_mask; |
| 620 | random = 0; |
| 621 | for (i = 0; i < MAX_IRQ_DESC_ACTION; i++) { |
| 622 | struct irqaction *p = &desc->action[i]; |
| 623 | u32 mask = (1 << i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 625 | if (!(action_mask & mask)) |
| 626 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 628 | action_mask &= ~mask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 630 | if (p->handler(__irq(bp), p->dev_id, regs) == IRQ_HANDLED) |
| 631 | random |= p->flags; |
| 632 | |
| 633 | if (!action_mask) |
| 634 | break; |
| 635 | } |
| 636 | if (bp->pil != 0) { |
David S. Miller | 10951ee | 2006-02-13 18:22:57 -0800 | [diff] [blame] | 637 | if (tlb_type == hypervisor) { |
David S. Miller | 4bf447d | 2006-02-13 22:37:32 -0800 | [diff] [blame] | 638 | unsigned int ino = __irq_ino(bp); |
David S. Miller | c4bea28 | 2006-02-13 22:56:27 -0800 | [diff] [blame] | 639 | int err; |
David S. Miller | 10951ee | 2006-02-13 18:22:57 -0800 | [diff] [blame] | 640 | |
David S. Miller | c4bea28 | 2006-02-13 22:56:27 -0800 | [diff] [blame] | 641 | err = sun4v_intr_setstate(ino, HV_INTR_STATE_IDLE); |
| 642 | if (err != HV_EOK) |
| 643 | printk("sun4v_intr_setstate(%x): " |
| 644 | "err(%d)\n", ino, err); |
David S. Miller | 10951ee | 2006-02-13 18:22:57 -0800 | [diff] [blame] | 645 | } else { |
| 646 | upa_writel(ICLR_IDLE, bp->iclr); |
David S. Miller | 10951ee | 2006-02-13 18:22:57 -0800 | [diff] [blame] | 647 | } |
David S. Miller | ab66a50 | 2006-02-15 01:18:19 -0800 | [diff] [blame] | 648 | |
| 649 | /* Test and add entropy */ |
| 650 | if (random & SA_SAMPLE_RANDOM) |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 651 | add_interrupt_randomness(bp->pil); |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 652 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | out: |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 654 | bp->flags &= ~IBF_INPROGRESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | } |
| 656 | |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 657 | #ifndef CONFIG_SMP |
| 658 | extern irqreturn_t timer_interrupt(int, void *, struct pt_regs *); |
| 659 | |
| 660 | void timer_irq(int irq, struct pt_regs *regs) |
| 661 | { |
| 662 | unsigned long clr_mask = 1 << irq; |
| 663 | unsigned long tick_mask = tick_ops->softint_mask; |
| 664 | |
| 665 | if (get_softint() & tick_mask) { |
| 666 | irq = 0; |
| 667 | clr_mask = tick_mask; |
| 668 | } |
| 669 | clear_softint(clr_mask); |
| 670 | |
| 671 | irq_enter(); |
| 672 | kstat_this_cpu.irqs[irq]++; |
| 673 | timer_interrupt(irq, NULL, regs); |
| 674 | irq_exit(); |
| 675 | } |
| 676 | #endif |
| 677 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | void handler_irq(int irq, struct pt_regs *regs) |
| 679 | { |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 680 | struct ino_bucket *bp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | int cpu = smp_processor_id(); |
| 682 | |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 683 | /* XXX at this point we should be able to assert that |
| 684 | * XXX irq is PIL_DEVICE_IRQ... |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | clear_softint(1 << irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | |
| 688 | irq_enter(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | |
| 690 | /* Sliiiick... */ |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 691 | bp = __bucket(xchg32(irq_work(cpu), 0)); |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 692 | while (bp) { |
| 693 | struct ino_bucket *nbp = __bucket(bp->irq_chain); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 695 | kstat_this_cpu.irqs[bp->pil]++; |
| 696 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | bp->irq_chain = 0; |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 698 | process_bucket(bp, regs); |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 699 | bp = nbp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | } |
| 701 | irq_exit(); |
| 702 | } |
| 703 | |
| 704 | #ifdef CONFIG_BLK_DEV_FD |
Alexey Dobriyan | 53b3531 | 2006-03-24 03:16:13 -0800 | [diff] [blame] | 705 | extern irqreturn_t floppy_interrupt(int, void *, struct pt_regs *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | |
David S. Miller | 63b6145 | 2005-06-27 17:04:45 -0700 | [diff] [blame] | 707 | /* XXX No easy way to include asm/floppy.h XXX */ |
| 708 | extern unsigned char *pdma_vaddr; |
| 709 | extern unsigned long pdma_size; |
| 710 | extern volatile int doing_pdma; |
| 711 | extern unsigned long fdc_status; |
| 712 | |
| 713 | irqreturn_t sparc_floppy_irq(int irq, void *dev_cookie, struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | { |
David S. Miller | 63b6145 | 2005-06-27 17:04:45 -0700 | [diff] [blame] | 715 | if (likely(doing_pdma)) { |
| 716 | void __iomem *stat = (void __iomem *) fdc_status; |
| 717 | unsigned char *vaddr = pdma_vaddr; |
| 718 | unsigned long size = pdma_size; |
| 719 | u8 val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | |
David S. Miller | 63b6145 | 2005-06-27 17:04:45 -0700 | [diff] [blame] | 721 | while (size) { |
| 722 | val = readb(stat); |
| 723 | if (unlikely(!(val & 0x80))) { |
| 724 | pdma_vaddr = vaddr; |
| 725 | pdma_size = size; |
| 726 | return IRQ_HANDLED; |
| 727 | } |
| 728 | if (unlikely(!(val & 0x20))) { |
| 729 | pdma_vaddr = vaddr; |
| 730 | pdma_size = size; |
| 731 | doing_pdma = 0; |
| 732 | goto main_interrupt; |
| 733 | } |
| 734 | if (val & 0x40) { |
| 735 | /* read */ |
| 736 | *vaddr++ = readb(stat + 1); |
| 737 | } else { |
| 738 | unsigned char data = *vaddr++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | |
David S. Miller | 63b6145 | 2005-06-27 17:04:45 -0700 | [diff] [blame] | 740 | /* write */ |
| 741 | writeb(data, stat + 1); |
| 742 | } |
| 743 | size--; |
| 744 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | |
David S. Miller | 63b6145 | 2005-06-27 17:04:45 -0700 | [diff] [blame] | 746 | pdma_vaddr = vaddr; |
| 747 | pdma_size = size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 748 | |
David S. Miller | 63b6145 | 2005-06-27 17:04:45 -0700 | [diff] [blame] | 749 | /* Send Terminal Count pulse to floppy controller. */ |
| 750 | val = readb(auxio_register); |
| 751 | val |= AUXIO_AUX1_FTCNT; |
| 752 | writeb(val, auxio_register); |
Bernhard R Link | 94bbc17 | 2006-03-10 01:23:13 -0800 | [diff] [blame] | 753 | val &= ~AUXIO_AUX1_FTCNT; |
David S. Miller | 63b6145 | 2005-06-27 17:04:45 -0700 | [diff] [blame] | 754 | writeb(val, auxio_register); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 755 | |
David S. Miller | 63b6145 | 2005-06-27 17:04:45 -0700 | [diff] [blame] | 756 | doing_pdma = 0; |
| 757 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | |
David S. Miller | 63b6145 | 2005-06-27 17:04:45 -0700 | [diff] [blame] | 759 | main_interrupt: |
| 760 | return floppy_interrupt(irq, dev_cookie, regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | } |
David S. Miller | 63b6145 | 2005-06-27 17:04:45 -0700 | [diff] [blame] | 762 | EXPORT_SYMBOL(sparc_floppy_irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | #endif |
| 764 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | /* We really don't need these at all on the Sparc. We only have |
| 766 | * stubs here because they are exported to modules. |
| 767 | */ |
| 768 | unsigned long probe_irq_on(void) |
| 769 | { |
| 770 | return 0; |
| 771 | } |
| 772 | |
| 773 | EXPORT_SYMBOL(probe_irq_on); |
| 774 | |
| 775 | int probe_irq_off(unsigned long mask) |
| 776 | { |
| 777 | return 0; |
| 778 | } |
| 779 | |
| 780 | EXPORT_SYMBOL(probe_irq_off); |
| 781 | |
| 782 | #ifdef CONFIG_SMP |
| 783 | static int retarget_one_irq(struct irqaction *p, int goal_cpu) |
| 784 | { |
| 785 | struct ino_bucket *bucket = get_ino_in_irqaction(p) + ivector_table; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 786 | |
| 787 | while (!cpu_online(goal_cpu)) { |
| 788 | if (++goal_cpu >= NR_CPUS) |
| 789 | goal_cpu = 0; |
| 790 | } |
| 791 | |
David S. Miller | 10951ee | 2006-02-13 18:22:57 -0800 | [diff] [blame] | 792 | if (tlb_type == hypervisor) { |
David S. Miller | 4bf447d | 2006-02-13 22:37:32 -0800 | [diff] [blame] | 793 | unsigned int ino = __irq_ino(bucket); |
David S. Miller | 10951ee | 2006-02-13 18:22:57 -0800 | [diff] [blame] | 794 | |
David S. Miller | 4bf447d | 2006-02-13 22:37:32 -0800 | [diff] [blame] | 795 | sun4v_intr_settarget(ino, goal_cpu); |
| 796 | sun4v_intr_setenabled(ino, HV_INTR_ENABLED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 797 | } else { |
David S. Miller | 22780e2 | 2006-02-16 14:37:05 -0800 | [diff] [blame] | 798 | unsigned long imap = bucket->imap; |
David S. Miller | ebd8c56 | 2006-02-17 08:38:06 -0800 | [diff] [blame] | 799 | unsigned int tid = sun4u_compute_tid(imap, goal_cpu); |
David S. Miller | 10951ee | 2006-02-13 18:22:57 -0800 | [diff] [blame] | 800 | |
David S. Miller | 10951ee | 2006-02-13 18:22:57 -0800 | [diff] [blame] | 801 | upa_writel(tid | IMAP_VALID, imap); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 802 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 803 | |
David S. Miller | cee2824 | 2005-05-03 22:04:36 -0700 | [diff] [blame] | 804 | do { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 805 | if (++goal_cpu >= NR_CPUS) |
| 806 | goal_cpu = 0; |
David S. Miller | cee2824 | 2005-05-03 22:04:36 -0700 | [diff] [blame] | 807 | } while (!cpu_online(goal_cpu)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | |
| 809 | return goal_cpu; |
| 810 | } |
| 811 | |
| 812 | /* Called from request_irq. */ |
| 813 | static void distribute_irqs(void) |
| 814 | { |
| 815 | unsigned long flags; |
| 816 | int cpu, level; |
| 817 | |
| 818 | spin_lock_irqsave(&irq_action_lock, flags); |
| 819 | cpu = 0; |
| 820 | |
| 821 | /* |
| 822 | * Skip the timer at [0], and very rare error/power intrs at [15]. |
| 823 | * Also level [12], it causes problems on Ex000 systems. |
| 824 | */ |
| 825 | for (level = 1; level < NR_IRQS; level++) { |
| 826 | struct irqaction *p = irq_action[level]; |
David S. Miller | 088dd1f | 2005-07-04 13:24:38 -0700 | [diff] [blame] | 827 | |
| 828 | if (level == 12) |
| 829 | continue; |
| 830 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | while(p) { |
| 832 | cpu = retarget_one_irq(p, cpu); |
| 833 | p = p->next; |
| 834 | } |
| 835 | } |
| 836 | spin_unlock_irqrestore(&irq_action_lock, flags); |
| 837 | } |
| 838 | #endif |
| 839 | |
David S. Miller | cdd5186 | 2005-07-24 19:36:13 -0700 | [diff] [blame] | 840 | struct sun5_timer { |
| 841 | u64 count0; |
| 842 | u64 limit0; |
| 843 | u64 count1; |
| 844 | u64 limit1; |
| 845 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | |
David S. Miller | cdd5186 | 2005-07-24 19:36:13 -0700 | [diff] [blame] | 847 | static struct sun5_timer *prom_timers; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 848 | static u64 prom_limit0, prom_limit1; |
| 849 | |
| 850 | static void map_prom_timers(void) |
| 851 | { |
| 852 | unsigned int addr[3]; |
| 853 | int tnode, err; |
| 854 | |
| 855 | /* PROM timer node hangs out in the top level of device siblings... */ |
| 856 | tnode = prom_finddevice("/counter-timer"); |
| 857 | |
| 858 | /* Assume if node is not present, PROM uses different tick mechanism |
| 859 | * which we should not care about. |
| 860 | */ |
| 861 | if (tnode == 0 || tnode == -1) { |
| 862 | prom_timers = (struct sun5_timer *) 0; |
| 863 | return; |
| 864 | } |
| 865 | |
| 866 | /* If PROM is really using this, it must be mapped by him. */ |
| 867 | err = prom_getproperty(tnode, "address", (char *)addr, sizeof(addr)); |
| 868 | if (err == -1) { |
| 869 | prom_printf("PROM does not have timer mapped, trying to continue.\n"); |
| 870 | prom_timers = (struct sun5_timer *) 0; |
| 871 | return; |
| 872 | } |
| 873 | prom_timers = (struct sun5_timer *) ((unsigned long)addr[0]); |
| 874 | } |
| 875 | |
| 876 | static void kill_prom_timer(void) |
| 877 | { |
| 878 | if (!prom_timers) |
| 879 | return; |
| 880 | |
| 881 | /* Save them away for later. */ |
| 882 | prom_limit0 = prom_timers->limit0; |
| 883 | prom_limit1 = prom_timers->limit1; |
| 884 | |
| 885 | /* Just as in sun4c/sun4m PROM uses timer which ticks at IRQ 14. |
| 886 | * We turn both off here just to be paranoid. |
| 887 | */ |
| 888 | prom_timers->limit0 = 0; |
| 889 | prom_timers->limit1 = 0; |
| 890 | |
| 891 | /* Wheee, eat the interrupt packet too... */ |
| 892 | __asm__ __volatile__( |
| 893 | " mov 0x40, %%g2\n" |
| 894 | " ldxa [%%g0] %0, %%g1\n" |
| 895 | " ldxa [%%g2] %1, %%g1\n" |
| 896 | " stxa %%g0, [%%g0] %0\n" |
| 897 | " membar #Sync\n" |
| 898 | : /* no outputs */ |
| 899 | : "i" (ASI_INTR_RECEIVE), "i" (ASI_INTR_R) |
| 900 | : "g1", "g2"); |
| 901 | } |
| 902 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 903 | void init_irqwork_curcpu(void) |
| 904 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 905 | int cpu = hard_smp_processor_id(); |
| 906 | |
David S. Miller | fd0504c3 | 2006-06-20 01:20:00 -0700 | [diff] [blame^] | 907 | trap_block[cpu].irq_worklist = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 908 | } |
| 909 | |
David S. Miller | b5a37e9 | 2006-02-11 23:07:13 -0800 | [diff] [blame] | 910 | static void __cpuinit register_one_mondo(unsigned long paddr, unsigned long type) |
David S. Miller | ac29c11 | 2006-02-08 00:08:23 -0800 | [diff] [blame] | 911 | { |
David S. Miller | 94f8762 | 2006-02-16 14:26:53 -0800 | [diff] [blame] | 912 | unsigned long num_entries = 128; |
| 913 | unsigned long status; |
David S. Miller | ac29c11 | 2006-02-08 00:08:23 -0800 | [diff] [blame] | 914 | |
David S. Miller | 94f8762 | 2006-02-16 14:26:53 -0800 | [diff] [blame] | 915 | status = sun4v_cpu_qconf(type, paddr, num_entries); |
| 916 | if (status != HV_EOK) { |
| 917 | prom_printf("SUN4V: sun4v_cpu_qconf(%lu:%lx:%lu) failed, " |
| 918 | "err %lu\n", type, paddr, num_entries, status); |
David S. Miller | ac29c11 | 2006-02-08 00:08:23 -0800 | [diff] [blame] | 919 | prom_halt(); |
| 920 | } |
| 921 | } |
| 922 | |
David S. Miller | b5a37e9 | 2006-02-11 23:07:13 -0800 | [diff] [blame] | 923 | static void __cpuinit sun4v_register_mondo_queues(int this_cpu) |
David S. Miller | 5b0c0572 | 2006-02-08 02:53:50 -0800 | [diff] [blame] | 924 | { |
David S. Miller | b5a37e9 | 2006-02-11 23:07:13 -0800 | [diff] [blame] | 925 | struct trap_per_cpu *tb = &trap_block[this_cpu]; |
| 926 | |
| 927 | register_one_mondo(tb->cpu_mondo_pa, HV_CPU_QUEUE_CPU_MONDO); |
| 928 | register_one_mondo(tb->dev_mondo_pa, HV_CPU_QUEUE_DEVICE_MONDO); |
| 929 | register_one_mondo(tb->resum_mondo_pa, HV_CPU_QUEUE_RES_ERROR); |
| 930 | register_one_mondo(tb->nonresum_mondo_pa, HV_CPU_QUEUE_NONRES_ERROR); |
| 931 | } |
| 932 | |
| 933 | static void __cpuinit alloc_one_mondo(unsigned long *pa_ptr, int use_bootmem) |
| 934 | { |
| 935 | void *page; |
| 936 | |
| 937 | if (use_bootmem) |
| 938 | page = alloc_bootmem_low_pages(PAGE_SIZE); |
| 939 | else |
| 940 | page = (void *) get_zeroed_page(GFP_ATOMIC); |
| 941 | |
| 942 | if (!page) { |
| 943 | prom_printf("SUN4V: Error, cannot allocate mondo queue.\n"); |
| 944 | prom_halt(); |
| 945 | } |
| 946 | |
| 947 | *pa_ptr = __pa(page); |
| 948 | } |
| 949 | |
| 950 | static void __cpuinit alloc_one_kbuf(unsigned long *pa_ptr, int use_bootmem) |
| 951 | { |
| 952 | void *page; |
| 953 | |
| 954 | if (use_bootmem) |
| 955 | page = alloc_bootmem_low_pages(PAGE_SIZE); |
| 956 | else |
| 957 | page = (void *) get_zeroed_page(GFP_ATOMIC); |
David S. Miller | 5b0c0572 | 2006-02-08 02:53:50 -0800 | [diff] [blame] | 958 | |
| 959 | if (!page) { |
| 960 | prom_printf("SUN4V: Error, cannot allocate kbuf page.\n"); |
| 961 | prom_halt(); |
| 962 | } |
| 963 | |
| 964 | *pa_ptr = __pa(page); |
| 965 | } |
| 966 | |
David S. Miller | b5a37e9 | 2006-02-11 23:07:13 -0800 | [diff] [blame] | 967 | static void __cpuinit init_cpu_send_mondo_info(struct trap_per_cpu *tb, int use_bootmem) |
David S. Miller | 1d2f1f9 | 2006-02-08 16:41:20 -0800 | [diff] [blame] | 968 | { |
| 969 | #ifdef CONFIG_SMP |
David S. Miller | b5a37e9 | 2006-02-11 23:07:13 -0800 | [diff] [blame] | 970 | void *page; |
David S. Miller | 1d2f1f9 | 2006-02-08 16:41:20 -0800 | [diff] [blame] | 971 | |
| 972 | BUILD_BUG_ON((NR_CPUS * sizeof(u16)) > (PAGE_SIZE - 64)); |
| 973 | |
David S. Miller | b5a37e9 | 2006-02-11 23:07:13 -0800 | [diff] [blame] | 974 | if (use_bootmem) |
| 975 | page = alloc_bootmem_low_pages(PAGE_SIZE); |
| 976 | else |
| 977 | page = (void *) get_zeroed_page(GFP_ATOMIC); |
| 978 | |
David S. Miller | 1d2f1f9 | 2006-02-08 16:41:20 -0800 | [diff] [blame] | 979 | if (!page) { |
| 980 | prom_printf("SUN4V: Error, cannot allocate cpu mondo page.\n"); |
| 981 | prom_halt(); |
| 982 | } |
| 983 | |
| 984 | tb->cpu_mondo_block_pa = __pa(page); |
| 985 | tb->cpu_list_pa = __pa(page + 64); |
| 986 | #endif |
| 987 | } |
| 988 | |
David S. Miller | b5a37e9 | 2006-02-11 23:07:13 -0800 | [diff] [blame] | 989 | /* Allocate and register the mondo and error queues for this cpu. */ |
David S. Miller | 72aff53 | 2006-02-17 01:29:17 -0800 | [diff] [blame] | 990 | void __cpuinit sun4v_init_mondo_queues(int use_bootmem, int cpu, int alloc, int load) |
David S. Miller | ac29c11 | 2006-02-08 00:08:23 -0800 | [diff] [blame] | 991 | { |
David S. Miller | ac29c11 | 2006-02-08 00:08:23 -0800 | [diff] [blame] | 992 | struct trap_per_cpu *tb = &trap_block[cpu]; |
| 993 | |
David S. Miller | 72aff53 | 2006-02-17 01:29:17 -0800 | [diff] [blame] | 994 | if (alloc) { |
| 995 | alloc_one_mondo(&tb->cpu_mondo_pa, use_bootmem); |
| 996 | alloc_one_mondo(&tb->dev_mondo_pa, use_bootmem); |
| 997 | alloc_one_mondo(&tb->resum_mondo_pa, use_bootmem); |
| 998 | alloc_one_kbuf(&tb->resum_kernel_buf_pa, use_bootmem); |
| 999 | alloc_one_mondo(&tb->nonresum_mondo_pa, use_bootmem); |
| 1000 | alloc_one_kbuf(&tb->nonresum_kernel_buf_pa, use_bootmem); |
David S. Miller | 1d2f1f9 | 2006-02-08 16:41:20 -0800 | [diff] [blame] | 1001 | |
David S. Miller | 72aff53 | 2006-02-17 01:29:17 -0800 | [diff] [blame] | 1002 | init_cpu_send_mondo_info(tb, use_bootmem); |
| 1003 | } |
David S. Miller | 1d2f1f9 | 2006-02-08 16:41:20 -0800 | [diff] [blame] | 1004 | |
David S. Miller | 72aff53 | 2006-02-17 01:29:17 -0800 | [diff] [blame] | 1005 | if (load) { |
| 1006 | if (cpu != hard_smp_processor_id()) { |
| 1007 | prom_printf("SUN4V: init mondo on cpu %d not %d\n", |
| 1008 | cpu, hard_smp_processor_id()); |
| 1009 | prom_halt(); |
| 1010 | } |
| 1011 | sun4v_register_mondo_queues(cpu); |
| 1012 | } |
David S. Miller | ac29c11 | 2006-02-08 00:08:23 -0800 | [diff] [blame] | 1013 | } |
| 1014 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1015 | /* Only invoked on boot processor. */ |
| 1016 | void __init init_IRQ(void) |
| 1017 | { |
| 1018 | map_prom_timers(); |
| 1019 | kill_prom_timer(); |
| 1020 | memset(&ivector_table[0], 0, sizeof(ivector_table)); |
| 1021 | |
David S. Miller | ac29c11 | 2006-02-08 00:08:23 -0800 | [diff] [blame] | 1022 | if (tlb_type == hypervisor) |
David S. Miller | 72aff53 | 2006-02-17 01:29:17 -0800 | [diff] [blame] | 1023 | sun4v_init_mondo_queues(1, hard_smp_processor_id(), 1, 1); |
David S. Miller | ac29c11 | 2006-02-08 00:08:23 -0800 | [diff] [blame] | 1024 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1025 | /* We need to clear any IRQ's pending in the soft interrupt |
| 1026 | * registers, a spurious one could be left around from the |
| 1027 | * PROM timer which we just disabled. |
| 1028 | */ |
| 1029 | clear_softint(get_softint()); |
| 1030 | |
| 1031 | /* Now that ivector table is initialized, it is safe |
| 1032 | * to receive IRQ vector traps. We will normally take |
| 1033 | * one or two right now, in case some device PROM used |
| 1034 | * to boot us wants to speak to us. We just ignore them. |
| 1035 | */ |
| 1036 | __asm__ __volatile__("rdpr %%pstate, %%g1\n\t" |
| 1037 | "or %%g1, %0, %%g1\n\t" |
| 1038 | "wrpr %%g1, 0x0, %%pstate" |
| 1039 | : /* No outputs */ |
| 1040 | : "i" (PSTATE_IE) |
| 1041 | : "g1"); |
| 1042 | } |
| 1043 | |
| 1044 | static struct proc_dir_entry * root_irq_dir; |
| 1045 | static struct proc_dir_entry * irq_dir [NUM_IVECS]; |
| 1046 | |
| 1047 | #ifdef CONFIG_SMP |
| 1048 | |
| 1049 | static int irq_affinity_read_proc (char *page, char **start, off_t off, |
| 1050 | int count, int *eof, void *data) |
| 1051 | { |
| 1052 | struct ino_bucket *bp = ivector_table + (long)data; |
Eddie C. Dost | 12cf649 | 2005-07-06 15:40:21 -0700 | [diff] [blame] | 1053 | struct irq_desc *desc = bp->irq_info; |
| 1054 | struct irqaction *ap = desc->action; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1055 | cpumask_t mask; |
| 1056 | int len; |
| 1057 | |
| 1058 | mask = get_smpaff_in_irqaction(ap); |
| 1059 | if (cpus_empty(mask)) |
| 1060 | mask = cpu_online_map; |
| 1061 | |
| 1062 | len = cpumask_scnprintf(page, count, mask); |
| 1063 | if (count - len < 2) |
| 1064 | return -EINVAL; |
| 1065 | len += sprintf(page + len, "\n"); |
| 1066 | return len; |
| 1067 | } |
| 1068 | |
| 1069 | static inline void set_intr_affinity(int irq, cpumask_t hw_aff) |
| 1070 | { |
| 1071 | struct ino_bucket *bp = ivector_table + irq; |
Eddie C. Dost | 12cf649 | 2005-07-06 15:40:21 -0700 | [diff] [blame] | 1072 | struct irq_desc *desc = bp->irq_info; |
| 1073 | struct irqaction *ap = desc->action; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1074 | |
| 1075 | /* Users specify affinity in terms of hw cpu ids. |
| 1076 | * As soon as we do this, handler_irq() might see and take action. |
| 1077 | */ |
Eddie C. Dost | 12cf649 | 2005-07-06 15:40:21 -0700 | [diff] [blame] | 1078 | put_smpaff_in_irqaction(ap, hw_aff); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1079 | |
| 1080 | /* Migration is simply done by the next cpu to service this |
| 1081 | * interrupt. |
| 1082 | */ |
| 1083 | } |
| 1084 | |
| 1085 | static int irq_affinity_write_proc (struct file *file, const char __user *buffer, |
| 1086 | unsigned long count, void *data) |
| 1087 | { |
| 1088 | int irq = (long) data, full_count = count, err; |
| 1089 | cpumask_t new_value; |
| 1090 | |
| 1091 | err = cpumask_parse(buffer, count, new_value); |
| 1092 | |
| 1093 | /* |
| 1094 | * Do not allow disabling IRQs completely - it's a too easy |
| 1095 | * way to make the system unusable accidentally :-) At least |
| 1096 | * one online CPU still has to be targeted. |
| 1097 | */ |
| 1098 | cpus_and(new_value, new_value, cpu_online_map); |
| 1099 | if (cpus_empty(new_value)) |
| 1100 | return -EINVAL; |
| 1101 | |
| 1102 | set_intr_affinity(irq, new_value); |
| 1103 | |
| 1104 | return full_count; |
| 1105 | } |
| 1106 | |
| 1107 | #endif |
| 1108 | |
| 1109 | #define MAX_NAMELEN 10 |
| 1110 | |
| 1111 | static void register_irq_proc (unsigned int irq) |
| 1112 | { |
| 1113 | char name [MAX_NAMELEN]; |
| 1114 | |
| 1115 | if (!root_irq_dir || irq_dir[irq]) |
| 1116 | return; |
| 1117 | |
| 1118 | memset(name, 0, MAX_NAMELEN); |
| 1119 | sprintf(name, "%x", irq); |
| 1120 | |
| 1121 | /* create /proc/irq/1234 */ |
| 1122 | irq_dir[irq] = proc_mkdir(name, root_irq_dir); |
| 1123 | |
| 1124 | #ifdef CONFIG_SMP |
| 1125 | /* XXX SMP affinity not supported on starfire yet. */ |
| 1126 | if (this_is_starfire == 0) { |
| 1127 | struct proc_dir_entry *entry; |
| 1128 | |
| 1129 | /* create /proc/irq/1234/smp_affinity */ |
| 1130 | entry = create_proc_entry("smp_affinity", 0600, irq_dir[irq]); |
| 1131 | |
| 1132 | if (entry) { |
| 1133 | entry->nlink = 1; |
| 1134 | entry->data = (void *)(long)irq; |
| 1135 | entry->read_proc = irq_affinity_read_proc; |
| 1136 | entry->write_proc = irq_affinity_write_proc; |
| 1137 | } |
| 1138 | } |
| 1139 | #endif |
| 1140 | } |
| 1141 | |
| 1142 | void init_irq_proc (void) |
| 1143 | { |
| 1144 | /* create /proc/irq */ |
| 1145 | root_irq_dir = proc_mkdir("irq", NULL); |
| 1146 | } |
| 1147 | |