[PATCH] ppc64: Fix oprofile when compiled as a module

My recent changes to oprofile broke it when built as a module. Fix it by
using an enum instead of a function pointer. This way we still retain
the oprofile configuration in the cputable.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by

Anton Blanchard and committed by
Paul Mackerras
32a33994 9a699aef

+59 -82
+26 -78
arch/powerpc/kernel/cputable.c
··· 78 78 .dcache_bsize = 128, 79 79 .num_pmcs = 8, 80 80 .cpu_setup = __setup_cpu_power3, 81 - #ifdef CONFIG_OPROFILE 82 81 .oprofile_cpu_type = "ppc64/power3", 83 - .oprofile_model = &op_model_rs64, 84 - #endif 82 + .oprofile_type = RS64, 85 83 }, 86 84 { /* Power3+ */ 87 85 .pvr_mask = 0xffff0000, ··· 91 93 .dcache_bsize = 128, 92 94 .num_pmcs = 8, 93 95 .cpu_setup = __setup_cpu_power3, 94 - #ifdef CONFIG_OPROFILE 95 96 .oprofile_cpu_type = "ppc64/power3", 96 - .oprofile_model = &op_model_rs64, 97 - #endif 97 + .oprofile_type = RS64, 98 98 }, 99 99 { /* Northstar */ 100 100 .pvr_mask = 0xffff0000, ··· 104 108 .dcache_bsize = 128, 105 109 .num_pmcs = 8, 106 110 .cpu_setup = __setup_cpu_power3, 107 - #ifdef CONFIG_OPROFILE 108 111 .oprofile_cpu_type = "ppc64/rs64", 109 - .oprofile_model = &op_model_rs64, 110 - #endif 112 + .oprofile_type = RS64, 111 113 }, 112 114 { /* Pulsar */ 113 115 .pvr_mask = 0xffff0000, ··· 117 123 .dcache_bsize = 128, 118 124 .num_pmcs = 8, 119 125 .cpu_setup = __setup_cpu_power3, 120 - #ifdef CONFIG_OPROFILE 121 126 .oprofile_cpu_type = "ppc64/rs64", 122 - .oprofile_model = &op_model_rs64, 123 - #endif 127 + .oprofile_type = RS64, 124 128 }, 125 129 { /* I-star */ 126 130 .pvr_mask = 0xffff0000, ··· 130 138 .dcache_bsize = 128, 131 139 .num_pmcs = 8, 132 140 .cpu_setup = __setup_cpu_power3, 133 - #ifdef CONFIG_OPROFILE 134 141 .oprofile_cpu_type = "ppc64/rs64", 135 - .oprofile_model = &op_model_rs64, 136 - #endif 142 + .oprofile_type = RS64, 137 143 }, 138 144 { /* S-star */ 139 145 .pvr_mask = 0xffff0000, ··· 143 153 .dcache_bsize = 128, 144 154 .num_pmcs = 8, 145 155 .cpu_setup = __setup_cpu_power3, 146 - #ifdef CONFIG_OPROFILE 147 156 .oprofile_cpu_type = "ppc64/rs64", 148 - .oprofile_model = &op_model_rs64, 149 - #endif 157 + .oprofile_type = RS64, 150 158 }, 151 159 { /* Power4 */ 152 160 .pvr_mask = 0xffff0000, ··· 156 168 .dcache_bsize = 128, 157 169 .num_pmcs = 8, 158 170 .cpu_setup = __setup_cpu_power4, 159 - #ifdef CONFIG_OPROFILE 160 171 .oprofile_cpu_type = "ppc64/power4", 161 - .oprofile_model = &op_model_rs64, 162 - #endif 172 + .oprofile_type = POWER4, 163 173 }, 164 174 { /* Power4+ */ 165 175 .pvr_mask = 0xffff0000, ··· 169 183 .dcache_bsize = 128, 170 184 .num_pmcs = 8, 171 185 .cpu_setup = __setup_cpu_power4, 172 - #ifdef CONFIG_OPROFILE 173 186 .oprofile_cpu_type = "ppc64/power4", 174 - .oprofile_model = &op_model_power4, 175 - #endif 187 + .oprofile_type = POWER4, 176 188 }, 177 189 { /* PPC970 */ 178 190 .pvr_mask = 0xffff0000, ··· 183 199 .dcache_bsize = 128, 184 200 .num_pmcs = 8, 185 201 .cpu_setup = __setup_cpu_ppc970, 186 - #ifdef CONFIG_OPROFILE 187 202 .oprofile_cpu_type = "ppc64/970", 188 - .oprofile_model = &op_model_power4, 189 - #endif 203 + .oprofile_type = POWER4, 190 204 }, 191 205 #endif /* CONFIG_PPC64 */ 192 206 #if defined(CONFIG_PPC64) || defined(CONFIG_POWER4) ··· 203 221 .dcache_bsize = 128, 204 222 .num_pmcs = 8, 205 223 .cpu_setup = __setup_cpu_ppc970, 206 - #ifdef CONFIG_OPROFILE 207 224 .oprofile_cpu_type = "ppc64/970", 208 - .oprofile_model = &op_model_power4, 209 - #endif 225 + .oprofile_type = POWER4, 210 226 }, 211 227 #endif /* defined(CONFIG_PPC64) || defined(CONFIG_POWER4) */ 212 228 #ifdef CONFIG_PPC64 ··· 218 238 .icache_bsize = 128, 219 239 .dcache_bsize = 128, 220 240 .cpu_setup = __setup_cpu_ppc970, 221 - #ifdef CONFIG_OPROFILE 222 241 .oprofile_cpu_type = "ppc64/970", 223 - .oprofile_model = &op_model_power4, 224 - #endif 242 + .oprofile_type = POWER4, 225 243 }, 226 244 { /* Power5 GR */ 227 245 .pvr_mask = 0xffff0000, ··· 231 253 .dcache_bsize = 128, 232 254 .num_pmcs = 6, 233 255 .cpu_setup = __setup_cpu_power4, 234 - #ifdef CONFIG_OPROFILE 235 256 .oprofile_cpu_type = "ppc64/power5", 236 - .oprofile_model = &op_model_power4, 237 - #endif 257 + .oprofile_type = POWER4, 238 258 }, 239 259 { /* Power5 GS */ 240 260 .pvr_mask = 0xffff0000, ··· 244 268 .dcache_bsize = 128, 245 269 .num_pmcs = 6, 246 270 .cpu_setup = __setup_cpu_power4, 247 - #ifdef CONFIG_OPROFILE 248 271 .oprofile_cpu_type = "ppc64/power5", 249 - .oprofile_model = &op_model_power4, 250 - #endif 272 + .oprofile_type = POWER4, 251 273 }, 252 274 { /* Cell Broadband Engine */ 253 275 .pvr_mask = 0xffff0000, ··· 520 546 .dcache_bsize = 32, 521 547 .num_pmcs = 6, 522 548 .cpu_setup = __setup_cpu_745x, 523 - #ifdef CONFIG_OPROFILE 524 549 .oprofile_cpu_type = "ppc/7450", 525 - .oprofile_model = &op_model_7450, 526 - #endif 550 + .oprofile_type = G4, 527 551 }, 528 552 { /* 7450 2.1 */ 529 553 .pvr_mask = 0xffffffff, ··· 533 561 .dcache_bsize = 32, 534 562 .num_pmcs = 6, 535 563 .cpu_setup = __setup_cpu_745x, 536 - #ifdef CONFIG_OPROFILE 537 564 .oprofile_cpu_type = "ppc/7450", 538 - .oprofile_model = &op_model_7450, 539 - #endif 565 + .oprofile_type = G4, 540 566 }, 541 567 { /* 7450 2.3 and newer */ 542 568 .pvr_mask = 0xffff0000, ··· 546 576 .dcache_bsize = 32, 547 577 .num_pmcs = 6, 548 578 .cpu_setup = __setup_cpu_745x, 549 - #ifdef CONFIG_OPROFILE 550 579 .oprofile_cpu_type = "ppc/7450", 551 - .oprofile_model = &op_model_7450, 552 - #endif 580 + .oprofile_type = G4, 553 581 }, 554 582 { /* 7455 rev 1.x */ 555 583 .pvr_mask = 0xffffff00, ··· 559 591 .dcache_bsize = 32, 560 592 .num_pmcs = 6, 561 593 .cpu_setup = __setup_cpu_745x, 562 - #ifdef CONFIG_OPROFILE 563 594 .oprofile_cpu_type = "ppc/7450", 564 - .oprofile_model = &op_model_7450, 565 - #endif 595 + .oprofile_type = G4, 566 596 }, 567 597 { /* 7455 rev 2.0 */ 568 598 .pvr_mask = 0xffffffff, ··· 572 606 .dcache_bsize = 32, 573 607 .num_pmcs = 6, 574 608 .cpu_setup = __setup_cpu_745x, 575 - #ifdef CONFIG_OPROFILE 576 609 .oprofile_cpu_type = "ppc/7450", 577 - .oprofile_model = &op_model_7450, 578 - #endif 610 + .oprofile_type = G4, 579 611 }, 580 612 { /* 7455 others */ 581 613 .pvr_mask = 0xffff0000, ··· 585 621 .dcache_bsize = 32, 586 622 .num_pmcs = 6, 587 623 .cpu_setup = __setup_cpu_745x, 588 - #ifdef CONFIG_OPROFILE 589 624 .oprofile_cpu_type = "ppc/7450", 590 - .oprofile_model = &op_model_7450, 591 - #endif 625 + .oprofile_type = G4, 592 626 }, 593 627 { /* 7447/7457 Rev 1.0 */ 594 628 .pvr_mask = 0xffffffff, ··· 598 636 .dcache_bsize = 32, 599 637 .num_pmcs = 6, 600 638 .cpu_setup = __setup_cpu_745x, 601 - #ifdef CONFIG_OPROFILE 602 639 .oprofile_cpu_type = "ppc/7450", 603 - .oprofile_model = &op_model_7450, 604 - #endif 640 + .oprofile_type = G4, 605 641 }, 606 642 { /* 7447/7457 Rev 1.1 */ 607 643 .pvr_mask = 0xffffffff, ··· 611 651 .dcache_bsize = 32, 612 652 .num_pmcs = 6, 613 653 .cpu_setup = __setup_cpu_745x, 614 - #ifdef CONFIG_OPROFILE 615 654 .oprofile_cpu_type = "ppc/7450", 616 - .oprofile_model = &op_model_7450, 617 - #endif 655 + .oprofile_type = G4, 618 656 }, 619 657 { /* 7447/7457 Rev 1.2 and later */ 620 658 .pvr_mask = 0xffff0000, ··· 624 666 .dcache_bsize = 32, 625 667 .num_pmcs = 6, 626 668 .cpu_setup = __setup_cpu_745x, 627 - #ifdef CONFIG_OPROFILE 628 669 .oprofile_cpu_type = "ppc/7450", 629 - .oprofile_model = &op_model_7450, 630 - #endif 670 + .oprofile_type = G4, 631 671 }, 632 672 { /* 7447A */ 633 673 .pvr_mask = 0xffff0000, ··· 637 681 .dcache_bsize = 32, 638 682 .num_pmcs = 6, 639 683 .cpu_setup = __setup_cpu_745x, 640 - #ifdef CONFIG_OPROFILE 641 684 .oprofile_cpu_type = "ppc/7450", 642 - .oprofile_model = &op_model_7450, 643 - #endif 685 + .oprofile_type = G4, 644 686 }, 645 687 { /* 7448 */ 646 688 .pvr_mask = 0xffff0000, ··· 650 696 .dcache_bsize = 32, 651 697 .num_pmcs = 6, 652 698 .cpu_setup = __setup_cpu_745x, 653 - #ifdef CONFIG_OPROFILE 654 699 .oprofile_cpu_type = "ppc/7450", 655 - .oprofile_model = &op_model_7450, 656 - #endif 700 + .oprofile_type = G4, 657 701 }, 658 702 { /* 82xx (8240, 8245, 8260 are all 603e cores) */ 659 703 .pvr_mask = 0x7fff0000, ··· 975 1023 .icache_bsize = 32, 976 1024 .dcache_bsize = 32, 977 1025 .num_pmcs = 4, 978 - #ifdef CONFIG_OPROFILE 979 1026 .oprofile_cpu_type = "ppc/e500", 980 - .oprofile_model = &op_model_fsl_booke, 981 - #endif 1027 + .oprofile_type = BOOKE, 982 1028 }, 983 1029 { /* e500v2 */ 984 1030 .pvr_mask = 0xffff0000, ··· 990 1040 .icache_bsize = 32, 991 1041 .dcache_bsize = 32, 992 1042 .num_pmcs = 4, 993 - #ifdef CONFIG_OPROFILE 994 1043 .oprofile_cpu_type = "ppc/e500", 995 - .oprofile_model = &op_model_fsl_booke, 996 - #endif 1044 + .oprofile_type = BOOKE, 997 1045 }, 998 1046 #endif 999 1047 #if !CLASSIC_PPC
+24 -2
arch/powerpc/oprofile/common.c
··· 135 135 136 136 int __init oprofile_arch_init(struct oprofile_operations *ops) 137 137 { 138 - if (!cur_cpu_spec->oprofile_model || !cur_cpu_spec->oprofile_cpu_type) 138 + if (!cur_cpu_spec->oprofile_cpu_type) 139 139 return -ENODEV; 140 - model = cur_cpu_spec->oprofile_model; 140 + 141 + switch (cur_cpu_spec->oprofile_type) { 142 + #ifdef CONFIG_PPC64 143 + case RS64: 144 + model = &op_model_rs64; 145 + break; 146 + case POWER4: 147 + model = &op_model_power4; 148 + break; 149 + #else 150 + case G4: 151 + model = &op_model_7450; 152 + break; 153 + #endif 154 + #ifdef CONFIG_FSL_BOOKE 155 + case BOOKE: 156 + model = &op_model_fsl_booke; 157 + break; 158 + #endif 159 + default: 160 + return -ENODEV; 161 + } 162 + 141 163 model->num_counters = cur_cpu_spec->num_pmcs; 142 164 143 165 ops->cpu_type = cur_cpu_spec->oprofile_cpu_type;
+9 -2
include/asm-powerpc/cputable.h
··· 27 27 * via the mkdefs mechanism. 28 28 */ 29 29 struct cpu_spec; 30 - struct op_powerpc_model; 31 30 32 31 typedef void (*cpu_setup_t)(unsigned long offset, struct cpu_spec* spec); 32 + 33 + enum powerpc_oprofile_type { 34 + INVALID = 0, 35 + RS64 = 1, 36 + POWER4 = 2, 37 + G4 = 3, 38 + BOOKE = 4, 39 + }; 33 40 34 41 struct cpu_spec { 35 42 /* CPU is matched via (PVR & pvr_mask) == pvr_value */ ··· 63 56 char *oprofile_cpu_type; 64 57 65 58 /* Processor specific oprofile operations */ 66 - struct op_powerpc_model *oprofile_model; 59 + enum powerpc_oprofile_type oprofile_type; 67 60 }; 68 61 69 62 extern struct cpu_spec *cur_cpu_spec;