diff options
Diffstat (limited to 'arch/sparc64/kernel/irq.c')
| -rw-r--r-- | arch/sparc64/kernel/irq.c | 263 | 
1 files changed, 179 insertions, 84 deletions
diff --git a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c index f2668f2bed9c..49ad9cd0f8c8 100644 --- a/arch/sparc64/kernel/irq.c +++ b/arch/sparc64/kernel/irq.c  | |||
| @@ -70,7 +70,10 @@ struct ino_bucket ivector_table[NUM_IVECS] __attribute__ ((aligned (SMP_CACHE_BY | |||
| 70 | */ | 70 | */ | 
| 71 | #define irq_work(__cpu) &(trap_block[(__cpu)].irq_worklist) | 71 | #define irq_work(__cpu) &(trap_block[(__cpu)].irq_worklist) | 
| 72 | 72 | ||
| 73 | static struct irqaction *irq_action[NR_IRQS]; | 73 | static struct irqaction timer_irq_action = { | 
| 74 | .name = "timer", | ||
| 75 | }; | ||
| 76 | static struct irqaction *irq_action[NR_IRQS] = { &timer_irq_action, }; | ||
| 74 | 77 | ||
| 75 | /* This only synchronizes entities which modify IRQ handler | 78 | /* This only synchronizes entities which modify IRQ handler | 
| 76 | * state and some selected user-level spots that want to | 79 | * state and some selected user-level spots that want to | 
| @@ -79,6 +82,59 @@ static struct irqaction *irq_action[NR_IRQS]; | |||
| 79 | */ | 82 | */ | 
| 80 | static DEFINE_SPINLOCK(irq_action_lock); | 83 | static DEFINE_SPINLOCK(irq_action_lock); | 
| 81 | 84 | ||
| 85 | static unsigned int virt_to_real_irq_table[NR_IRQS]; | ||
| 86 | static unsigned char virt_irq_cur = 1; | ||
| 87 | |||
| 88 | static unsigned char virt_irq_alloc(unsigned int real_irq) | ||
| 89 | { | ||
| 90 | unsigned char ent; | ||
| 91 | |||
| 92 | BUILD_BUG_ON(NR_IRQS >= 256); | ||
| 93 | |||
| 94 | ent = virt_irq_cur; | ||
| 95 | if (ent >= NR_IRQS) { | ||
| 96 | printk(KERN_ERR "IRQ: Out of virtual IRQs.\n"); | ||
| 97 | return 0; | ||
| 98 | } | ||
| 99 | |||
| 100 | virt_irq_cur = ent + 1; | ||
| 101 | virt_to_real_irq_table[ent] = real_irq; | ||
| 102 | |||
| 103 | return ent; | ||
| 104 | } | ||
| 105 | |||
| 106 | #if 0 /* Currently unused. */ | ||
| 107 | static unsigned char real_to_virt_irq(unsigned int real_irq) | ||
| 108 | { | ||
| 109 | struct ino_bucket *bucket = __bucket(real_irq); | ||
| 110 | |||
| 111 | return bucket->virt_irq; | ||
| 112 | } | ||
| 113 | #endif | ||
| 114 | |||
| 115 | static unsigned int virt_to_real_irq(unsigned char virt_irq) | ||
| 116 | { | ||
| 117 | return virt_to_real_irq_table[virt_irq]; | ||
| 118 | } | ||
| 119 | |||
| 120 | void irq_install_pre_handler(int virt_irq, | ||
| 121 | void (*func)(struct ino_bucket *, void *, void *), | ||
| 122 | void *arg1, void *arg2) | ||
| 123 | { | ||
| 124 | unsigned int real_irq = virt_to_real_irq(virt_irq); | ||
| 125 | struct ino_bucket *bucket; | ||
| 126 | struct irq_desc *d; | ||
| 127 | |||
| 128 | if (unlikely(!real_irq)) | ||
| 129 | return; | ||
| 130 | |||
| 131 | bucket = __bucket(real_irq); | ||
| 132 | d = bucket->irq_info; | ||
| 133 | d->pre_handler = func; | ||
| 134 | d->pre_handler_arg1 = arg1; | ||
| 135 | d->pre_handler_arg2 = arg2; | ||
| 136 | } | ||
| 137 | |||
| 82 | static void register_irq_proc (unsigned int irq); | 138 | static void register_irq_proc (unsigned int irq); | 
| 83 | 139 | ||
| 84 | /* | 140 | /* | 
| @@ -164,14 +220,18 @@ static unsigned int sun4u_compute_tid(unsigned long imap, unsigned long cpuid) | |||
| 164 | return tid; | 220 | return tid; | 
| 165 | } | 221 | } | 
| 166 | 222 | ||
| 167 | /* Now these are always passed a true fully specified sun4u INO. */ | 223 | void enable_irq(unsigned int virt_irq) | 
| 168 | void enable_irq(unsigned int irq) | ||
| 169 | { | 224 | { | 
| 170 | struct ino_bucket *bucket = __bucket(irq); | 225 | unsigned int real_irq = virt_to_real_irq(virt_irq); | 
| 226 | struct ino_bucket *bucket; | ||
| 171 | unsigned long imap, cpuid; | 227 | unsigned long imap, cpuid; | 
| 172 | 228 | ||
| 229 | if (unlikely(!real_irq)) | ||
| 230 | return; | ||
| 231 | |||
| 232 | bucket = __bucket(real_irq); | ||
| 173 | imap = bucket->imap; | 233 | imap = bucket->imap; | 
| 174 | if (imap == 0UL) | 234 | if (unlikely(imap == 0UL)) | 
| 175 | return; | 235 | return; | 
| 176 | 236 | ||
| 177 | preempt_disable(); | 237 | preempt_disable(); | 
| @@ -182,7 +242,7 @@ void enable_irq(unsigned int irq) | |||
| 182 | cpuid = real_hard_smp_processor_id(); | 242 | cpuid = real_hard_smp_processor_id(); | 
| 183 | 243 | ||
| 184 | if (tlb_type == hypervisor) { | 244 | if (tlb_type == hypervisor) { | 
| 185 | unsigned int ino = __irq_ino(irq); | 245 | unsigned int ino = __irq_ino(real_irq); | 
| 186 | int err; | 246 | int err; | 
| 187 | 247 | ||
| 188 | err = sun4v_intr_settarget(ino, cpuid); | 248 | err = sun4v_intr_settarget(ino, cpuid); | 
| @@ -211,34 +271,39 @@ void enable_irq(unsigned int irq) | |||
| 211 | preempt_enable(); | 271 | preempt_enable(); | 
| 212 | } | 272 | } | 
| 213 | 273 | ||
| 214 | /* This now gets passed true ino's as well. */ | 274 | void disable_irq(unsigned int virt_irq) | 
| 215 | void disable_irq(unsigned int irq) | ||
| 216 | { | 275 | { | 
| 217 | struct ino_bucket *bucket = __bucket(irq); | 276 | unsigned int real_irq = virt_to_real_irq(virt_irq); | 
| 277 | struct ino_bucket *bucket; | ||
| 218 | unsigned long imap; | 278 | unsigned long imap; | 
| 219 | 279 | ||
| 280 | if (unlikely(!real_irq)) | ||
| 281 | return; | ||
| 282 | |||
| 283 | bucket = __bucket(real_irq); | ||
| 220 | imap = bucket->imap; | 284 | imap = bucket->imap; | 
| 221 | if (imap != 0UL) { | 285 | if (unlikely(imap == 0UL)) | 
| 222 | if (tlb_type == hypervisor) { | 286 | return; | 
| 223 | unsigned int ino = __irq_ino(irq); | 287 | |
| 224 | int err; | 288 | if (tlb_type == hypervisor) { | 
| 225 | 289 | unsigned int ino = __irq_ino(real_irq); | |
| 226 | err = sun4v_intr_setenabled(ino, HV_INTR_DISABLED); | 290 | int err; | 
| 227 | if (err != HV_EOK) | 291 | |
| 228 | printk("sun4v_intr_setenabled(%x): " | 292 | err = sun4v_intr_setenabled(ino, HV_INTR_DISABLED); | 
| 229 | "err(%d)\n", ino, err); | 293 | if (err != HV_EOK) | 
| 230 | } else { | 294 | printk("sun4v_intr_setenabled(%x): " | 
| 231 | u32 tmp; | 295 | "err(%d)\n", ino, err); | 
| 232 | 296 | } else { | |
| 233 | /* NOTE: We do not want to futz with the IRQ clear registers | 297 | u32 tmp; | 
| 234 | * and move the state to IDLE, the SCSI code does call | 298 | |
| 235 | * disable_irq() to assure atomicity in the queue cmd | 299 | /* NOTE: We do not want to futz with the IRQ clear registers | 
| 236 | * SCSI adapter driver code. Thus we'd lose interrupts. | 300 | * and move the state to IDLE, the SCSI code does call | 
| 237 | */ | 301 | * disable_irq() to assure atomicity in the queue cmd | 
| 238 | tmp = upa_readl(imap); | 302 | * SCSI adapter driver code. Thus we'd lose interrupts. | 
| 239 | tmp &= ~IMAP_VALID; | 303 | */ | 
| 240 | upa_writel(tmp, imap); | 304 | tmp = upa_readl(imap); | 
| 241 | } | 305 | tmp &= ~IMAP_VALID; | 
| 306 | upa_writel(tmp, imap); | ||
| 242 | } | 307 | } | 
| 243 | } | 308 | } | 
| 244 | 309 | ||
| @@ -253,14 +318,14 @@ static void build_irq_error(const char *msg, unsigned int ino, int inofixup, | |||
| 253 | prom_halt(); | 318 | prom_halt(); | 
| 254 | } | 319 | } | 
| 255 | 320 | ||
| 256 | unsigned int build_irq(int inofixup, unsigned long iclr, unsigned long imap) | 321 | unsigned int build_irq(int inofixup, unsigned long iclr, unsigned long imap, unsigned char flags) | 
| 257 | { | 322 | { | 
| 258 | struct ino_bucket *bucket; | 323 | struct ino_bucket *bucket; | 
| 259 | int ino; | 324 | int ino; | 
| 260 | 325 | ||
| 261 | BUG_ON(tlb_type == hypervisor); | 326 | BUG_ON(tlb_type == hypervisor); | 
| 262 | 327 | ||
| 263 | /* RULE: Both must be specified in all other cases. */ | 328 | /* RULE: Both must be specified. */ | 
| 264 | if (iclr == 0UL || imap == 0UL) { | 329 | if (iclr == 0UL || imap == 0UL) { | 
| 265 | prom_printf("Invalid build_irq %d %016lx %016lx\n", | 330 | prom_printf("Invalid build_irq %d %016lx %016lx\n", | 
| 266 | inofixup, iclr, imap); | 331 | inofixup, iclr, imap); | 
| @@ -298,10 +363,12 @@ unsigned int build_irq(int inofixup, unsigned long iclr, unsigned long imap) | |||
| 298 | */ | 363 | */ | 
| 299 | bucket->imap = imap; | 364 | bucket->imap = imap; | 
| 300 | bucket->iclr = iclr; | 365 | bucket->iclr = iclr; | 
| 301 | bucket->flags = 0; | 366 | if (!bucket->virt_irq) | 
| 367 | bucket->virt_irq = virt_irq_alloc(__irq(bucket)); | ||
| 368 | bucket->flags = flags; | ||
| 302 | 369 | ||
| 303 | out: | 370 | out: | 
| 304 | return __irq(bucket); | 371 | return bucket->virt_irq; | 
| 305 | } | 372 | } | 
| 306 | 373 | ||
| 307 | unsigned int sun4v_build_irq(u32 devhandle, unsigned int devino, unsigned char flags) | 374 | unsigned int sun4v_build_irq(u32 devhandle, unsigned int devino, unsigned char flags) | 
| @@ -322,7 +389,8 @@ unsigned int sun4v_build_irq(u32 devhandle, unsigned int devino, unsigned char f | |||
| 322 | */ | 389 | */ | 
| 323 | bucket->imap = ~0UL - sysino; | 390 | bucket->imap = ~0UL - sysino; | 
| 324 | bucket->iclr = ~0UL - sysino; | 391 | bucket->iclr = ~0UL - sysino; | 
| 325 | 392 | if (!bucket->virt_irq) | |
| 393 | bucket->virt_irq = virt_irq_alloc(__irq(bucket)); | ||
| 326 | bucket->flags = flags; | 394 | bucket->flags = flags; | 
| 327 | 395 | ||
| 328 | bucket->irq_info = kzalloc(sizeof(struct irq_desc), GFP_ATOMIC); | 396 | bucket->irq_info = kzalloc(sizeof(struct irq_desc), GFP_ATOMIC); | 
| @@ -331,7 +399,7 @@ unsigned int sun4v_build_irq(u32 devhandle, unsigned int devino, unsigned char f | |||
| 331 | prom_halt(); | 399 | prom_halt(); | 
| 332 | } | 400 | } | 
| 333 | 401 | ||
| 334 | return __irq(bucket); | 402 | return bucket->virt_irq; | 
| 335 | } | 403 | } | 
| 336 | 404 | ||
| 337 | static void atomic_bucket_insert(struct ino_bucket *bucket) | 405 | static void atomic_bucket_insert(struct ino_bucket *bucket) | 
| @@ -390,37 +458,42 @@ static struct irqaction *get_action_slot(struct ino_bucket *bucket) | |||
| 390 | return NULL; | 458 | return NULL; | 
| 391 | } | 459 | } | 
| 392 | 460 | ||
| 393 | int request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_regs *), | 461 | int request_irq(unsigned int virt_irq, | 
| 462 | irqreturn_t (*handler)(int, void *, struct pt_regs *), | ||
| 394 | unsigned long irqflags, const char *name, void *dev_id) | 463 | unsigned long irqflags, const char *name, void *dev_id) | 
| 395 | { | 464 | { | 
| 396 | struct irqaction *action; | 465 | struct irqaction *action; | 
| 397 | struct ino_bucket *bucket = __bucket(irq); | 466 | struct ino_bucket *bucket; | 
| 398 | unsigned long flags; | 467 | unsigned long flags; | 
| 468 | unsigned int real_irq; | ||
| 399 | int pending = 0; | 469 | int pending = 0; | 
| 400 | 470 | ||
| 471 | real_irq = virt_to_real_irq(virt_irq); | ||
| 472 | if (unlikely(!real_irq)) | ||
| 473 | return -EINVAL; | ||
| 474 | |||
| 401 | if (unlikely(!handler)) | 475 | if (unlikely(!handler)) | 
| 402 | return -EINVAL; | 476 | return -EINVAL; | 
| 403 | 477 | ||
| 478 | bucket = __bucket(real_irq); | ||
| 404 | if (unlikely(!bucket->irq_info)) | 479 | if (unlikely(!bucket->irq_info)) | 
| 405 | return -ENODEV; | 480 | return -ENODEV; | 
| 406 | 481 | ||
| 407 | if (irqflags & SA_SAMPLE_RANDOM) { | 482 | if (irqflags & SA_SAMPLE_RANDOM) { | 
| 408 | /* | 483 | /* | 
| 409 | * This function might sleep, we want to call it first, | 484 | * This function might sleep, we want to call it first, | 
| 410 | * outside of the atomic block. In SA_STATIC_ALLOC case, | 485 | * outside of the atomic block. | 
| 411 | * random driver's kmalloc will fail, but it is safe. | 486 | * Yes, this might clear the entropy pool if the wrong | 
| 412 | * If already initialized, random driver will not reinit. | 487 | * driver is attempted to be loaded, without actually | 
| 413 | * Yes, this might clear the entropy pool if the wrong | 488 | * installing a new handler, but is this really a problem, | 
| 414 | * driver is attempted to be loaded, without actually | 489 | * only the sysadmin is able to do this. | 
| 415 | * installing a new handler, but is this really a problem, | 490 | */ | 
| 416 | * only the sysadmin is able to do this. | 491 | rand_initialize_irq(virt_irq); | 
| 417 | */ | ||
| 418 | rand_initialize_irq(PIL_DEVICE_IRQ); | ||
| 419 | } | 492 | } | 
| 420 | 493 | ||
| 421 | spin_lock_irqsave(&irq_action_lock, flags); | 494 | spin_lock_irqsave(&irq_action_lock, flags); | 
| 422 | 495 | ||
| 423 | if (check_irq_sharing(PIL_DEVICE_IRQ, irqflags)) { | 496 | if (check_irq_sharing(virt_irq, irqflags)) { | 
| 424 | spin_unlock_irqrestore(&irq_action_lock, flags); | 497 | spin_unlock_irqrestore(&irq_action_lock, flags); | 
| 425 | return -EBUSY; | 498 | return -EBUSY; | 
| 426 | } | 499 | } | 
| @@ -441,12 +514,12 @@ int request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_ | |||
| 441 | action->name = name; | 514 | action->name = name; | 
| 442 | action->next = NULL; | 515 | action->next = NULL; | 
| 443 | action->dev_id = dev_id; | 516 | action->dev_id = dev_id; | 
| 444 | put_ino_in_irqaction(action, irq); | 517 | put_ino_in_irqaction(action, __irq_ino(real_irq)); | 
| 445 | put_smpaff_in_irqaction(action, CPU_MASK_NONE); | 518 | put_smpaff_in_irqaction(action, CPU_MASK_NONE); | 
| 446 | 519 | ||
| 447 | append_irq_action(PIL_DEVICE_IRQ, action); | 520 | append_irq_action(virt_irq, action); | 
| 448 | 521 | ||
| 449 | enable_irq(irq); | 522 | enable_irq(virt_irq); | 
| 450 | 523 | ||
| 451 | /* We ate the IVEC already, this makes sure it does not get lost. */ | 524 | /* We ate the IVEC already, this makes sure it does not get lost. */ | 
| 452 | if (pending) { | 525 | if (pending) { | 
| @@ -456,7 +529,7 @@ int request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_ | |||
| 456 | 529 | ||
| 457 | spin_unlock_irqrestore(&irq_action_lock, flags); | 530 | spin_unlock_irqrestore(&irq_action_lock, flags); | 
| 458 | 531 | ||
| 459 | register_irq_proc(__irq_ino(irq)); | 532 | register_irq_proc(virt_irq); | 
| 460 | 533 | ||
| 461 | #ifdef CONFIG_SMP | 534 | #ifdef CONFIG_SMP | 
| 462 | distribute_irqs(); | 535 | distribute_irqs(); | 
| @@ -466,17 +539,17 @@ int request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_ | |||
| 466 | 539 | ||
| 467 | EXPORT_SYMBOL(request_irq); | 540 | EXPORT_SYMBOL(request_irq); | 
| 468 | 541 | ||
| 469 | static struct irqaction *unlink_irq_action(unsigned int irq, void *dev_id) | 542 | static struct irqaction *unlink_irq_action(unsigned int virt_irq, void *dev_id) | 
| 470 | { | 543 | { | 
| 471 | struct irqaction *action, **pp; | 544 | struct irqaction *action, **pp; | 
| 472 | 545 | ||
| 473 | pp = irq_action + PIL_DEVICE_IRQ; | 546 | pp = irq_action + virt_irq; | 
| 474 | action = *pp; | 547 | action = *pp; | 
| 475 | if (unlikely(!action)) | 548 | if (unlikely(!action)) | 
| 476 | return NULL; | 549 | return NULL; | 
| 477 | 550 | ||
| 478 | if (unlikely(!action->handler)) { | 551 | if (unlikely(!action->handler)) { | 
| 479 | printk("Freeing free IRQ %d\n", PIL_DEVICE_IRQ); | 552 | printk("Freeing free IRQ %d\n", virt_irq); | 
| 480 | return NULL; | 553 | return NULL; | 
| 481 | } | 554 | } | 
| 482 | 555 | ||
| @@ -491,28 +564,33 @@ static struct irqaction *unlink_irq_action(unsigned int irq, void *dev_id) | |||
| 491 | return action; | 564 | return action; | 
| 492 | } | 565 | } | 
| 493 | 566 | ||
| 494 | void free_irq(unsigned int irq, void *dev_id) | 567 | void free_irq(unsigned int virt_irq, void *dev_id) | 
| 495 | { | 568 | { | 
| 496 | struct irqaction *action; | 569 | struct irqaction *action; | 
| 497 | struct ino_bucket *bucket; | 570 | struct ino_bucket *bucket; | 
| 498 | struct irq_desc *desc; | 571 | struct irq_desc *desc; | 
| 499 | unsigned long flags; | 572 | unsigned long flags; | 
| 573 | unsigned int real_irq; | ||
| 500 | int ent, i; | 574 | int ent, i; | 
| 501 | 575 | ||
| 576 | real_irq = virt_to_real_irq(virt_irq); | ||
| 577 | if (unlikely(!real_irq)) | ||
| 578 | return; | ||
| 579 | |||
| 502 | spin_lock_irqsave(&irq_action_lock, flags); | 580 | spin_lock_irqsave(&irq_action_lock, flags); | 
| 503 | 581 | ||
| 504 | action = unlink_irq_action(irq, dev_id); | 582 | action = unlink_irq_action(virt_irq, dev_id); | 
| 505 | 583 | ||
| 506 | spin_unlock_irqrestore(&irq_action_lock, flags); | 584 | spin_unlock_irqrestore(&irq_action_lock, flags); | 
| 507 | 585 | ||
| 508 | if (unlikely(!action)) | 586 | if (unlikely(!action)) | 
| 509 | return; | 587 | return; | 
| 510 | 588 | ||
| 511 | synchronize_irq(irq); | 589 | synchronize_irq(virt_irq); | 
| 512 | 590 | ||
| 513 | spin_lock_irqsave(&irq_action_lock, flags); | 591 | spin_lock_irqsave(&irq_action_lock, flags); | 
| 514 | 592 | ||
| 515 | bucket = __bucket(irq); | 593 | bucket = __bucket(real_irq); | 
| 516 | desc = bucket->irq_info; | 594 | desc = bucket->irq_info; | 
| 517 | 595 | ||
| 518 | for (i = 0; i < MAX_IRQ_DESC_ACTION; i++) { | 596 | for (i = 0; i < MAX_IRQ_DESC_ACTION; i++) { | 
| @@ -545,7 +623,7 @@ void free_irq(unsigned int irq, void *dev_id) | |||
| 545 | * the same IMAP are active. | 623 | * the same IMAP are active. | 
| 546 | */ | 624 | */ | 
| 547 | if (ent == NUM_IVECS) | 625 | if (ent == NUM_IVECS) | 
| 548 | disable_irq(irq); | 626 | disable_irq(virt_irq); | 
| 549 | } | 627 | } | 
| 550 | 628 | ||
| 551 | spin_unlock_irqrestore(&irq_action_lock, flags); | 629 | spin_unlock_irqrestore(&irq_action_lock, flags); | 
| @@ -554,10 +632,15 @@ void free_irq(unsigned int irq, void *dev_id) | |||
| 554 | EXPORT_SYMBOL(free_irq); | 632 | EXPORT_SYMBOL(free_irq); | 
| 555 | 633 | ||
| 556 | #ifdef CONFIG_SMP | 634 | #ifdef CONFIG_SMP | 
| 557 | void synchronize_irq(unsigned int irq) | 635 | void synchronize_irq(unsigned int virt_irq) | 
| 558 | { | 636 | { | 
| 559 | struct ino_bucket *bucket = __bucket(irq); | 637 | unsigned int real_irq = virt_to_real_irq(virt_irq); | 
| 638 | struct ino_bucket *bucket; | ||
| 639 | |||
| 640 | if (unlikely(!real_irq)) | ||
| 641 | return; | ||
| 560 | 642 | ||
| 643 | bucket = __bucket(real_irq); | ||
| 561 | #if 0 | 644 | #if 0 | 
| 562 | /* The following is how I wish I could implement this. | 645 | /* The following is how I wish I could implement this. | 
| 563 | * Unfortunately the ICLR registers are read-only, you can | 646 | * Unfortunately the ICLR registers are read-only, you can | 
| @@ -616,7 +699,7 @@ static void process_bucket(struct ino_bucket *bp, struct pt_regs *regs) | |||
| 616 | 699 | ||
| 617 | action_mask &= ~mask; | 700 | action_mask &= ~mask; | 
| 618 | 701 | ||
| 619 | if (p->handler(__irq(bp), p->dev_id, regs) == IRQ_HANDLED) | 702 | if (p->handler(bp->virt_irq, p->dev_id, regs) == IRQ_HANDLED) | 
| 620 | random |= p->flags; | 703 | random |= p->flags; | 
| 621 | 704 | ||
| 622 | if (!action_mask) | 705 | if (!action_mask) | 
| @@ -637,7 +720,7 @@ static void process_bucket(struct ino_bucket *bp, struct pt_regs *regs) | |||
| 637 | 720 | ||
| 638 | /* Test and add entropy */ | 721 | /* Test and add entropy */ | 
| 639 | if (random & SA_SAMPLE_RANDOM) | 722 | if (random & SA_SAMPLE_RANDOM) | 
| 640 | add_interrupt_randomness(PIL_DEVICE_IRQ); | 723 | add_interrupt_randomness(bp->virt_irq); | 
| 641 | out: | 724 | out: | 
| 642 | bp->flags &= ~IBF_INPROGRESS; | 725 | bp->flags &= ~IBF_INPROGRESS; | 
| 643 | } | 726 | } | 
| @@ -657,7 +740,7 @@ void timer_irq(int irq, struct pt_regs *regs) | |||
| 657 | clear_softint(clr_mask); | 740 | clear_softint(clr_mask); | 
| 658 | 741 | ||
| 659 | irq_enter(); | 742 | irq_enter(); | 
| 660 | kstat_this_cpu.irqs[irq]++; | 743 | kstat_this_cpu.irqs[0]++; | 
| 661 | timer_interrupt(irq, NULL, regs); | 744 | timer_interrupt(irq, NULL, regs); | 
| 662 | irq_exit(); | 745 | irq_exit(); | 
| 663 | } | 746 | } | 
| @@ -1022,13 +1105,13 @@ void __init init_IRQ(void) | |||
| 1022 | : "g1"); | 1105 | : "g1"); | 
| 1023 | } | 1106 | } | 
| 1024 | 1107 | ||
| 1025 | static struct proc_dir_entry * root_irq_dir; | 1108 | static struct proc_dir_entry *root_irq_dir; | 
| 1026 | static struct proc_dir_entry * irq_dir [NUM_IVECS]; | 1109 | static struct proc_dir_entry *irq_dir[NR_IRQS]; | 
| 1027 | 1110 | ||
| 1028 | #ifdef CONFIG_SMP | 1111 | #ifdef CONFIG_SMP | 
| 1029 | 1112 | ||
| 1030 | static int irq_affinity_read_proc (char *page, char **start, off_t off, | 1113 | static int irq_affinity_read_proc(char *page, char **start, off_t off, | 
| 1031 | int count, int *eof, void *data) | 1114 | int count, int *eof, void *data) | 
| 1032 | { | 1115 | { | 
| 1033 | struct ino_bucket *bp = ivector_table + (long)data; | 1116 | struct ino_bucket *bp = ivector_table + (long)data; | 
| 1034 | struct irq_desc *desc = bp->irq_info; | 1117 | struct irq_desc *desc = bp->irq_info; | 
| @@ -1047,11 +1130,20 @@ static int irq_affinity_read_proc (char *page, char **start, off_t off, | |||
| 1047 | return len; | 1130 | return len; | 
| 1048 | } | 1131 | } | 
| 1049 | 1132 | ||
| 1050 | static inline void set_intr_affinity(int irq, cpumask_t hw_aff) | 1133 | static inline void set_intr_affinity(int virt_irq, cpumask_t hw_aff) | 
| 1051 | { | 1134 | { | 
| 1052 | struct ino_bucket *bp = ivector_table + irq; | 1135 | struct ino_bucket *bp; | 
| 1053 | struct irq_desc *desc = bp->irq_info; | 1136 | struct irq_desc *desc; | 
| 1054 | struct irqaction *ap = desc->action; | 1137 | struct irqaction *ap; | 
| 1138 | unsigned int real_irq; | ||
| 1139 | |||
| 1140 | real_irq = virt_to_real_irq(virt_irq); | ||
| 1141 | if (unlikely(!real_irq)) | ||
| 1142 | return; | ||
| 1143 | |||
| 1144 | bp = __bucket(real_irq); | ||
| 1145 | desc = bp->irq_info; | ||
| 1146 | ap = desc->action; | ||
| 1055 | 1147 | ||
| 1056 | /* Users specify affinity in terms of hw cpu ids. | 1148 | /* Users specify affinity in terms of hw cpu ids. | 
| 1057 | * As soon as we do this, handler_irq() might see and take action. | 1149 | * As soon as we do this, handler_irq() might see and take action. | 
| @@ -1060,13 +1152,16 @@ static inline void set_intr_affinity(int irq, cpumask_t hw_aff) | |||
| 1060 | 1152 | ||
| 1061 | /* Migration is simply done by the next cpu to service this | 1153 | /* Migration is simply done by the next cpu to service this | 
| 1062 | * interrupt. | 1154 | * interrupt. | 
| 1155 | * | ||
| 1156 | * XXX Broken, this doesn't happen anymore... | ||
| 1063 | */ | 1157 | */ | 
| 1064 | } | 1158 | } | 
| 1065 | 1159 | ||
| 1066 | static int irq_affinity_write_proc (struct file *file, const char __user *buffer, | 1160 | static int irq_affinity_write_proc(struct file *file, | 
| 1067 | unsigned long count, void *data) | 1161 | const char __user *buffer, | 
| 1162 | unsigned long count, void *data) | ||
| 1068 | { | 1163 | { | 
| 1069 | int irq = (long) data, full_count = count, err; | 1164 | int virt_irq = (long) data, full_count = count, err; | 
| 1070 | cpumask_t new_value; | 1165 | cpumask_t new_value; | 
| 1071 | 1166 | ||
| 1072 | err = cpumask_parse(buffer, count, new_value); | 1167 | err = cpumask_parse(buffer, count, new_value); | 
| @@ -1080,7 +1175,7 @@ static int irq_affinity_write_proc (struct file *file, const char __user *buffer | |||
| 1080 | if (cpus_empty(new_value)) | 1175 | if (cpus_empty(new_value)) | 
| 1081 | return -EINVAL; | 1176 | return -EINVAL; | 
| 1082 | 1177 | ||
| 1083 | set_intr_affinity(irq, new_value); | 1178 | set_intr_affinity(virt_irq, new_value); | 
| 1084 | 1179 | ||
| 1085 | return full_count; | 1180 | return full_count; | 
| 1086 | } | 1181 | } | 
| @@ -1089,18 +1184,18 @@ static int irq_affinity_write_proc (struct file *file, const char __user *buffer | |||
| 1089 | 1184 | ||
| 1090 | #define MAX_NAMELEN 10 | 1185 | #define MAX_NAMELEN 10 | 
| 1091 | 1186 | ||
| 1092 | static void register_irq_proc (unsigned int irq) | 1187 | static void register_irq_proc(unsigned int virt_irq) | 
| 1093 | { | 1188 | { | 
| 1094 | char name [MAX_NAMELEN]; | 1189 | char name [MAX_NAMELEN]; | 
| 1095 | 1190 | ||
| 1096 | if (!root_irq_dir || irq_dir[irq]) | 1191 | if (!root_irq_dir || irq_dir[virt_irq]) | 
| 1097 | return; | 1192 | return; | 
| 1098 | 1193 | ||
| 1099 | memset(name, 0, MAX_NAMELEN); | 1194 | memset(name, 0, MAX_NAMELEN); | 
| 1100 | sprintf(name, "%x", irq); | 1195 | sprintf(name, "%d", virt_irq); | 
| 1101 | 1196 | ||
| 1102 | /* create /proc/irq/1234 */ | 1197 | /* create /proc/irq/1234 */ | 
| 1103 | irq_dir[irq] = proc_mkdir(name, root_irq_dir); | 1198 | irq_dir[virt_irq] = proc_mkdir(name, root_irq_dir); | 
| 1104 | 1199 | ||
| 1105 | #ifdef CONFIG_SMP | 1200 | #ifdef CONFIG_SMP | 
| 1106 | /* XXX SMP affinity not supported on starfire yet. */ | 1201 | /* XXX SMP affinity not supported on starfire yet. */ | 
| @@ -1112,7 +1207,7 @@ static void register_irq_proc (unsigned int irq) | |||
| 1112 | 1207 | ||
| 1113 | if (entry) { | 1208 | if (entry) { | 
| 1114 | entry->nlink = 1; | 1209 | entry->nlink = 1; | 
| 1115 | entry->data = (void *)(long)irq; | 1210 | entry->data = (void *)(long)virt_irq; | 
| 1116 | entry->read_proc = irq_affinity_read_proc; | 1211 | entry->read_proc = irq_affinity_read_proc; | 
| 1117 | entry->write_proc = irq_affinity_write_proc; | 1212 | entry->write_proc = irq_affinity_write_proc; | 
| 1118 | } | 1213 | } | 
| @@ -1120,7 +1215,7 @@ static void register_irq_proc (unsigned int irq) | |||
| 1120 | #endif | 1215 | #endif | 
| 1121 | } | 1216 | } | 
| 1122 | 1217 | ||
| 1123 | void init_irq_proc (void) | 1218 | void init_irq_proc(void) | 
| 1124 | { | 1219 | { | 
| 1125 | /* create /proc/irq */ | 1220 | /* create /proc/irq */ | 
| 1126 | root_irq_dir = proc_mkdir("irq", NULL); | 1221 | root_irq_dir = proc_mkdir("irq", NULL); | 
