Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/ps3: Interrupt code cleanup

General code cleanup for PS3 interrupt.c:

o Fill out comments for structure members.
o Move variables ipi_debug_brk_mask and lock from struct ps3_bmp to
struct ps3_private.
o Fix pr_debug build errors when DEBUG is defined.
o Convert bit operation to set_bit().
o Convert DBG macro from pr_debug to pr_devel
o Add new macro FAIL to replace pr_debug calls

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Geoff Levand and committed by
Benjamin Herrenschmidt
32b9074b faa8bf88

+53 -50
+53 -50
arch/powerpc/platforms/ps3/interrupt.c
··· 31 31 32 32 #if defined(DEBUG) 33 33 #define DBG udbg_printf 34 + #define FAIL udbg_printf 34 35 #else 35 - #define DBG pr_debug 36 + #define DBG pr_devel 37 + #define FAIL pr_debug 36 38 #endif 37 39 38 40 /** 39 41 * struct ps3_bmp - a per cpu irq status and mask bitmap structure 40 42 * @status: 256 bit status bitmap indexed by plug 41 - * @unused_1: 43 + * @unused_1: Alignment 42 44 * @mask: 256 bit mask bitmap indexed by plug 43 - * @unused_2: 44 - * @lock: 45 - * @ipi_debug_brk_mask: 45 + * @unused_2: Alignment 46 46 * 47 47 * The HV maintains per SMT thread mappings of HV outlet to HV plug on 48 48 * behalf of the guest. These mappings are implemented as 256 bit guest ··· 73 73 unsigned long mask; 74 74 u64 unused_2[3]; 75 75 }; 76 - u64 ipi_debug_brk_mask; 77 - spinlock_t lock; 78 76 }; 79 77 80 78 /** 81 79 * struct ps3_private - a per cpu data structure 82 80 * @bmp: ps3_bmp structure 81 + * @bmp_lock: Syncronize access to bmp. 82 + * @ipi_debug_brk_mask: Mask for debug break IPIs 83 83 * @ppe_id: HV logical_ppe_id 84 84 * @thread_id: HV thread_id 85 + * @ipi_mask: Mask of IPI virqs 85 86 */ 86 87 87 88 struct ps3_private { 88 89 struct ps3_bmp bmp __attribute__ ((aligned (PS3_BMP_MINALIGN))); 90 + spinlock_t bmp_lock; 89 91 u64 ppe_id; 90 92 u64 thread_id; 93 + unsigned long ipi_debug_brk_mask; 91 94 unsigned long ipi_mask; 92 95 }; 93 96 ··· 108 105 struct ps3_private *pd = irq_data_get_irq_chip_data(d); 109 106 unsigned long flags; 110 107 111 - pr_debug("%s:%d: thread_id %llu, virq %d\n", __func__, __LINE__, 108 + DBG("%s:%d: thread_id %llu, virq %d\n", __func__, __LINE__, 112 109 pd->thread_id, d->irq); 113 110 114 111 local_irq_save(flags); ··· 129 126 struct ps3_private *pd = irq_data_get_irq_chip_data(d); 130 127 unsigned long flags; 131 128 132 - pr_debug("%s:%d: thread_id %llu, virq %d\n", __func__, __LINE__, 129 + DBG("%s:%d: thread_id %llu, virq %d\n", __func__, __LINE__, 133 130 pd->thread_id, d->irq); 134 131 135 132 local_irq_save(flags); ··· 193 190 *virq = irq_create_mapping(NULL, outlet); 194 191 195 192 if (*virq == NO_IRQ) { 196 - pr_debug("%s:%d: irq_create_mapping failed: outlet %lu\n", 193 + FAIL("%s:%d: irq_create_mapping failed: outlet %lu\n", 197 194 __func__, __LINE__, outlet); 198 195 result = -ENOMEM; 199 196 goto fail_create; 200 197 } 201 198 202 - pr_debug("%s:%d: outlet %lu => cpu %u, virq %u\n", __func__, __LINE__, 199 + DBG("%s:%d: outlet %lu => cpu %u, virq %u\n", __func__, __LINE__, 203 200 outlet, cpu, *virq); 204 201 205 202 result = irq_set_chip_data(*virq, pd); 206 203 207 204 if (result) { 208 - pr_debug("%s:%d: irq_set_chip_data failed\n", 205 + FAIL("%s:%d: irq_set_chip_data failed\n", 209 206 __func__, __LINE__); 210 207 goto fail_set; 211 208 } ··· 231 228 { 232 229 const struct ps3_private *pd = irq_get_chip_data(virq); 233 230 234 - pr_debug("%s:%d: ppe_id %llu, thread_id %llu, virq %u\n", __func__, 231 + DBG("%s:%d: ppe_id %llu, thread_id %llu, virq %u\n", __func__, 235 232 __LINE__, pd->ppe_id, pd->thread_id, virq); 236 233 237 234 irq_set_chip_data(virq, NULL); 238 235 irq_dispose_mapping(virq); 239 236 240 - pr_debug("%s:%d <-\n", __func__, __LINE__); 237 + DBG("%s:%d <-\n", __func__, __LINE__); 241 238 return 0; 242 239 } 243 240 ··· 260 257 result = ps3_virq_setup(cpu, outlet, virq); 261 258 262 259 if (result) { 263 - pr_debug("%s:%d: ps3_virq_setup failed\n", __func__, __LINE__); 260 + FAIL("%s:%d: ps3_virq_setup failed\n", __func__, __LINE__); 264 261 goto fail_setup; 265 262 } 266 263 ··· 272 269 outlet, 0); 273 270 274 271 if (result) { 275 - pr_info("%s:%d: lv1_connect_irq_plug_ext failed: %s\n", 272 + FAIL("%s:%d: lv1_connect_irq_plug_ext failed: %s\n", 276 273 __func__, __LINE__, ps3_result(result)); 277 274 result = -EPERM; 278 275 goto fail_connect; ··· 301 298 int result; 302 299 const struct ps3_private *pd = irq_get_chip_data(virq); 303 300 304 - pr_debug("%s:%d: ppe_id %llu, thread_id %llu, virq %u\n", __func__, 301 + DBG("%s:%d: ppe_id %llu, thread_id %llu, virq %u\n", __func__, 305 302 __LINE__, pd->ppe_id, pd->thread_id, virq); 306 303 307 304 ps3_chip_mask(irq_get_irq_data(virq)); ··· 309 306 result = lv1_disconnect_irq_plug_ext(pd->ppe_id, pd->thread_id, virq); 310 307 311 308 if (result) 312 - pr_info("%s:%d: lv1_disconnect_irq_plug_ext failed: %s\n", 309 + FAIL("%s:%d: lv1_disconnect_irq_plug_ext failed: %s\n", 313 310 __func__, __LINE__, ps3_result(result)); 314 311 315 312 ps3_virq_destroy(virq); ··· 337 334 result = lv1_construct_event_receive_port(&outlet); 338 335 339 336 if (result) { 340 - pr_debug("%s:%d: lv1_construct_event_receive_port failed: %s\n", 337 + FAIL("%s:%d: lv1_construct_event_receive_port failed: %s\n", 341 338 __func__, __LINE__, ps3_result(result)); 342 339 *virq = NO_IRQ; 343 340 return result; ··· 363 360 { 364 361 int result; 365 362 366 - pr_debug(" -> %s:%d virq %u\n", __func__, __LINE__, virq); 363 + DBG(" -> %s:%d virq %u\n", __func__, __LINE__, virq); 367 364 368 365 ps3_chip_mask(irq_get_irq_data(virq)); 369 366 370 367 result = lv1_destruct_event_receive_port(virq_to_hw(virq)); 371 368 372 369 if (result) 373 - pr_debug("%s:%d: lv1_destruct_event_receive_port failed: %s\n", 370 + FAIL("%s:%d: lv1_destruct_event_receive_port failed: %s\n", 374 371 __func__, __LINE__, ps3_result(result)); 375 372 376 373 /* ··· 378 375 * calls from interrupt context (smp_call_function) when kexecing. 379 376 */ 380 377 381 - pr_debug(" <- %s:%d\n", __func__, __LINE__); 378 + DBG(" <- %s:%d\n", __func__, __LINE__); 382 379 return result; 383 380 } 384 381 ··· 414 411 dev->dev_id, virq_to_hw(*virq), dev->interrupt_id); 415 412 416 413 if (result) { 417 - pr_debug("%s:%d: lv1_connect_interrupt_event_receive_port" 414 + FAIL("%s:%d: lv1_connect_interrupt_event_receive_port" 418 415 " failed: %s\n", __func__, __LINE__, 419 416 ps3_result(result)); 420 417 ps3_event_receive_port_destroy(*virq); ··· 422 419 return result; 423 420 } 424 421 425 - pr_debug("%s:%d: interrupt_id %u, virq %u\n", __func__, __LINE__, 422 + DBG("%s:%d: interrupt_id %u, virq %u\n", __func__, __LINE__, 426 423 dev->interrupt_id, *virq); 427 424 428 425 return 0; ··· 436 433 437 434 int result; 438 435 439 - pr_debug(" -> %s:%d: interrupt_id %u, virq %u\n", __func__, __LINE__, 436 + DBG(" -> %s:%d: interrupt_id %u, virq %u\n", __func__, __LINE__, 440 437 dev->interrupt_id, virq); 441 438 442 439 result = lv1_disconnect_interrupt_event_receive_port(dev->bus_id, 443 440 dev->dev_id, virq_to_hw(virq), dev->interrupt_id); 444 441 445 442 if (result) 446 - pr_debug("%s:%d: lv1_disconnect_interrupt_event_receive_port" 443 + FAIL("%s:%d: lv1_disconnect_interrupt_event_receive_port" 447 444 " failed: %s\n", __func__, __LINE__, 448 445 ps3_result(result)); 449 446 ··· 458 455 result = ps3_virq_destroy(virq); 459 456 BUG_ON(result); 460 457 461 - pr_debug(" <- %s:%d\n", __func__, __LINE__); 458 + DBG(" <- %s:%d\n", __func__, __LINE__); 462 459 return result; 463 460 } 464 461 EXPORT_SYMBOL(ps3_sb_event_receive_port_destroy); ··· 483 480 result = lv1_construct_io_irq_outlet(interrupt_id, &outlet); 484 481 485 482 if (result) { 486 - pr_debug("%s:%d: lv1_construct_io_irq_outlet failed: %s\n", 483 + FAIL("%s:%d: lv1_construct_io_irq_outlet failed: %s\n", 487 484 __func__, __LINE__, ps3_result(result)); 488 485 return result; 489 486 } ··· 513 510 result = lv1_destruct_io_irq_outlet(outlet); 514 511 515 512 if (result) 516 - pr_debug("%s:%d: lv1_destruct_io_irq_outlet failed: %s\n", 513 + FAIL("%s:%d: lv1_destruct_io_irq_outlet failed: %s\n", 517 514 __func__, __LINE__, ps3_result(result)); 518 515 519 516 return result; ··· 545 542 result = lv1_configure_virtual_uart_irq(lpar_addr, &outlet); 546 543 547 544 if (result) { 548 - pr_debug("%s:%d: lv1_configure_virtual_uart_irq failed: %s\n", 545 + FAIL("%s:%d: lv1_configure_virtual_uart_irq failed: %s\n", 549 546 __func__, __LINE__, ps3_result(result)); 550 547 return result; 551 548 } ··· 565 562 result = lv1_deconfigure_virtual_uart_irq(); 566 563 567 564 if (result) { 568 - pr_debug("%s:%d: lv1_configure_virtual_uart_irq failed: %s\n", 565 + FAIL("%s:%d: lv1_configure_virtual_uart_irq failed: %s\n", 569 566 __func__, __LINE__, ps3_result(result)); 570 567 return result; 571 568 } ··· 598 595 result = lv1_get_spe_irq_outlet(spe_id, class, &outlet); 599 596 600 597 if (result) { 601 - pr_debug("%s:%d: lv1_get_spe_irq_outlet failed: %s\n", 598 + FAIL("%s:%d: lv1_get_spe_irq_outlet failed: %s\n", 602 599 __func__, __LINE__, ps3_result(result)); 603 600 return result; 604 601 } ··· 629 626 static void _dump_64_bmp(const char *header, const u64 *p, unsigned cpu, 630 627 const char* func, int line) 631 628 { 632 - pr_debug("%s:%d: %s %u {%04lx_%04lx_%04lx_%04lx}\n", 629 + pr_debug("%s:%d: %s %u {%04llx_%04llx_%04llx_%04llx}\n", 633 630 func, line, header, cpu, 634 631 *p >> 48, (*p >> 32) & 0xffff, (*p >> 16) & 0xffff, 635 632 *p & 0xffff); ··· 638 635 static void __maybe_unused _dump_256_bmp(const char *header, 639 636 const u64 *p, unsigned cpu, const char* func, int line) 640 637 { 641 - pr_debug("%s:%d: %s %u {%016lx:%016lx:%016lx:%016lx}\n", 638 + pr_debug("%s:%d: %s %u {%016llx:%016llx:%016llx:%016llx}\n", 642 639 func, line, header, cpu, p[0], p[1], p[2], p[3]); 643 640 } 644 641 ··· 647 644 { 648 645 unsigned long flags; 649 646 650 - spin_lock_irqsave(&pd->bmp.lock, flags); 647 + spin_lock_irqsave(&pd->bmp_lock, flags); 651 648 _dump_64_bmp("stat", &pd->bmp.status, pd->thread_id, func, line); 652 - _dump_64_bmp("mask", &pd->bmp.mask, pd->thread_id, func, line); 653 - spin_unlock_irqrestore(&pd->bmp.lock, flags); 649 + _dump_64_bmp("mask", (u64*)&pd->bmp.mask, pd->thread_id, func, line); 650 + spin_unlock_irqrestore(&pd->bmp_lock, flags); 654 651 } 655 652 656 653 #define dump_mask(_x) _dump_mask(_x, __func__, __LINE__) ··· 659 656 { 660 657 unsigned long flags; 661 658 662 - spin_lock_irqsave(&pd->bmp.lock, flags); 663 - _dump_64_bmp("mask", &pd->bmp.mask, pd->thread_id, func, line); 664 - spin_unlock_irqrestore(&pd->bmp.lock, flags); 659 + spin_lock_irqsave(&pd->bmp_lock, flags); 660 + _dump_64_bmp("mask", (u64*)&pd->bmp.mask, pd->thread_id, func, line); 661 + spin_unlock_irqrestore(&pd->bmp_lock, flags); 665 662 } 666 663 #else 667 664 static void dump_bmp(struct ps3_private* pd) {}; ··· 670 667 static int ps3_host_map(struct irq_host *h, unsigned int virq, 671 668 irq_hw_number_t hwirq) 672 669 { 673 - pr_debug("%s:%d: hwirq %lu, virq %u\n", __func__, __LINE__, hwirq, 670 + DBG("%s:%d: hwirq %lu, virq %u\n", __func__, __LINE__, hwirq, 674 671 virq); 675 672 676 673 irq_set_chip_and_handler(virq, &ps3_irq_chip, handle_fasteoi_irq); ··· 693 690 { 694 691 struct ps3_private *pd = &per_cpu(ps3_private, cpu); 695 692 696 - pd->bmp.ipi_debug_brk_mask = 0x8000000000000000UL >> virq; 693 + set_bit(63 - virq, &pd->ipi_debug_brk_mask); 697 694 698 - pr_debug("%s:%d: cpu %u, virq %u, mask %llxh\n", __func__, __LINE__, 699 - cpu, virq, pd->bmp.ipi_debug_brk_mask); 695 + DBG("%s:%d: cpu %u, virq %u, mask %lxh\n", __func__, __LINE__, 696 + cpu, virq, pd->ipi_debug_brk_mask); 700 697 } 701 698 702 699 void __init ps3_register_ipi_irq(unsigned int cpu, unsigned int virq) ··· 717 714 718 715 /* check for ipi break first to stop this cpu ASAP */ 719 716 720 - if (x & pd->bmp.ipi_debug_brk_mask) 721 - x &= pd->bmp.ipi_debug_brk_mask; 717 + if (x & pd->ipi_debug_brk_mask) 718 + x &= pd->ipi_debug_brk_mask; 722 719 723 720 asm volatile("cntlzd %0,%1" : "=r" (plug) : "r" (x)); 724 721 plug &= 0x3f; 725 722 726 723 if (unlikely(plug == NO_IRQ)) { 727 - pr_debug("%s:%d: no plug found: thread_id %llu\n", __func__, 724 + DBG("%s:%d: no plug found: thread_id %llu\n", __func__, 728 725 __LINE__, pd->thread_id); 729 726 dump_bmp(&per_cpu(ps3_private, 0)); 730 727 dump_bmp(&per_cpu(ps3_private, 1)); ··· 763 760 764 761 lv1_get_logical_ppe_id(&pd->ppe_id); 765 762 pd->thread_id = get_hard_smp_processor_id(cpu); 766 - spin_lock_init(&pd->bmp.lock); 763 + spin_lock_init(&pd->bmp_lock); 767 764 768 - pr_debug("%s:%d: ppe_id %llu, thread_id %llu, bmp %lxh\n", 765 + DBG("%s:%d: ppe_id %llu, thread_id %llu, bmp %lxh\n", 769 766 __func__, __LINE__, pd->ppe_id, pd->thread_id, 770 767 ps3_mm_phys_to_lpar(__pa(&pd->bmp))); 771 768 ··· 773 770 pd->thread_id, ps3_mm_phys_to_lpar(__pa(&pd->bmp))); 774 771 775 772 if (result) 776 - pr_debug("%s:%d: lv1_configure_irq_state_bitmap failed:" 773 + FAIL("%s:%d: lv1_configure_irq_state_bitmap failed:" 777 774 " %s\n", __func__, __LINE__, 778 775 ps3_result(result)); 779 776 }