提交 32a33994 编写于 作者: A Anton Blanchard 提交者: Paul Mackerras

[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: NAnton Blanchard <anton@samba.org>
Signed-off-by: NPaul Mackerras <paulus@samba.org>
上级 9a699aef
...@@ -78,10 +78,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -78,10 +78,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128, .dcache_bsize = 128,
.num_pmcs = 8, .num_pmcs = 8,
.cpu_setup = __setup_cpu_power3, .cpu_setup = __setup_cpu_power3,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/power3", .oprofile_cpu_type = "ppc64/power3",
.oprofile_model = &op_model_rs64, .oprofile_type = RS64,
#endif
}, },
{ /* Power3+ */ { /* Power3+ */
.pvr_mask = 0xffff0000, .pvr_mask = 0xffff0000,
...@@ -93,10 +91,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -93,10 +91,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128, .dcache_bsize = 128,
.num_pmcs = 8, .num_pmcs = 8,
.cpu_setup = __setup_cpu_power3, .cpu_setup = __setup_cpu_power3,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/power3", .oprofile_cpu_type = "ppc64/power3",
.oprofile_model = &op_model_rs64, .oprofile_type = RS64,
#endif
}, },
{ /* Northstar */ { /* Northstar */
.pvr_mask = 0xffff0000, .pvr_mask = 0xffff0000,
...@@ -108,10 +104,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -108,10 +104,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128, .dcache_bsize = 128,
.num_pmcs = 8, .num_pmcs = 8,
.cpu_setup = __setup_cpu_power3, .cpu_setup = __setup_cpu_power3,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/rs64", .oprofile_cpu_type = "ppc64/rs64",
.oprofile_model = &op_model_rs64, .oprofile_type = RS64,
#endif
}, },
{ /* Pulsar */ { /* Pulsar */
.pvr_mask = 0xffff0000, .pvr_mask = 0xffff0000,
...@@ -123,10 +117,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -123,10 +117,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128, .dcache_bsize = 128,
.num_pmcs = 8, .num_pmcs = 8,
.cpu_setup = __setup_cpu_power3, .cpu_setup = __setup_cpu_power3,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/rs64", .oprofile_cpu_type = "ppc64/rs64",
.oprofile_model = &op_model_rs64, .oprofile_type = RS64,
#endif
}, },
{ /* I-star */ { /* I-star */
.pvr_mask = 0xffff0000, .pvr_mask = 0xffff0000,
...@@ -138,10 +130,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -138,10 +130,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128, .dcache_bsize = 128,
.num_pmcs = 8, .num_pmcs = 8,
.cpu_setup = __setup_cpu_power3, .cpu_setup = __setup_cpu_power3,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/rs64", .oprofile_cpu_type = "ppc64/rs64",
.oprofile_model = &op_model_rs64, .oprofile_type = RS64,
#endif
}, },
{ /* S-star */ { /* S-star */
.pvr_mask = 0xffff0000, .pvr_mask = 0xffff0000,
...@@ -153,10 +143,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -153,10 +143,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128, .dcache_bsize = 128,
.num_pmcs = 8, .num_pmcs = 8,
.cpu_setup = __setup_cpu_power3, .cpu_setup = __setup_cpu_power3,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/rs64", .oprofile_cpu_type = "ppc64/rs64",
.oprofile_model = &op_model_rs64, .oprofile_type = RS64,
#endif
}, },
{ /* Power4 */ { /* Power4 */
.pvr_mask = 0xffff0000, .pvr_mask = 0xffff0000,
...@@ -168,10 +156,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -168,10 +156,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128, .dcache_bsize = 128,
.num_pmcs = 8, .num_pmcs = 8,
.cpu_setup = __setup_cpu_power4, .cpu_setup = __setup_cpu_power4,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/power4", .oprofile_cpu_type = "ppc64/power4",
.oprofile_model = &op_model_rs64, .oprofile_type = POWER4,
#endif
}, },
{ /* Power4+ */ { /* Power4+ */
.pvr_mask = 0xffff0000, .pvr_mask = 0xffff0000,
...@@ -183,10 +169,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -183,10 +169,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128, .dcache_bsize = 128,
.num_pmcs = 8, .num_pmcs = 8,
.cpu_setup = __setup_cpu_power4, .cpu_setup = __setup_cpu_power4,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/power4", .oprofile_cpu_type = "ppc64/power4",
.oprofile_model = &op_model_power4, .oprofile_type = POWER4,
#endif
}, },
{ /* PPC970 */ { /* PPC970 */
.pvr_mask = 0xffff0000, .pvr_mask = 0xffff0000,
...@@ -199,10 +183,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -199,10 +183,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128, .dcache_bsize = 128,
.num_pmcs = 8, .num_pmcs = 8,
.cpu_setup = __setup_cpu_ppc970, .cpu_setup = __setup_cpu_ppc970,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/970", .oprofile_cpu_type = "ppc64/970",
.oprofile_model = &op_model_power4, .oprofile_type = POWER4,
#endif
}, },
#endif /* CONFIG_PPC64 */ #endif /* CONFIG_PPC64 */
#if defined(CONFIG_PPC64) || defined(CONFIG_POWER4) #if defined(CONFIG_PPC64) || defined(CONFIG_POWER4)
...@@ -221,10 +203,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -221,10 +203,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128, .dcache_bsize = 128,
.num_pmcs = 8, .num_pmcs = 8,
.cpu_setup = __setup_cpu_ppc970, .cpu_setup = __setup_cpu_ppc970,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/970", .oprofile_cpu_type = "ppc64/970",
.oprofile_model = &op_model_power4, .oprofile_type = POWER4,
#endif
}, },
#endif /* defined(CONFIG_PPC64) || defined(CONFIG_POWER4) */ #endif /* defined(CONFIG_PPC64) || defined(CONFIG_POWER4) */
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
...@@ -238,10 +218,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -238,10 +218,8 @@ struct cpu_spec cpu_specs[] = {
.icache_bsize = 128, .icache_bsize = 128,
.dcache_bsize = 128, .dcache_bsize = 128,
.cpu_setup = __setup_cpu_ppc970, .cpu_setup = __setup_cpu_ppc970,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/970", .oprofile_cpu_type = "ppc64/970",
.oprofile_model = &op_model_power4, .oprofile_type = POWER4,
#endif
}, },
{ /* Power5 GR */ { /* Power5 GR */
.pvr_mask = 0xffff0000, .pvr_mask = 0xffff0000,
...@@ -253,10 +231,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -253,10 +231,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128, .dcache_bsize = 128,
.num_pmcs = 6, .num_pmcs = 6,
.cpu_setup = __setup_cpu_power4, .cpu_setup = __setup_cpu_power4,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/power5", .oprofile_cpu_type = "ppc64/power5",
.oprofile_model = &op_model_power4, .oprofile_type = POWER4,
#endif
}, },
{ /* Power5 GS */ { /* Power5 GS */
.pvr_mask = 0xffff0000, .pvr_mask = 0xffff0000,
...@@ -268,10 +244,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -268,10 +244,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128, .dcache_bsize = 128,
.num_pmcs = 6, .num_pmcs = 6,
.cpu_setup = __setup_cpu_power4, .cpu_setup = __setup_cpu_power4,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/power5", .oprofile_cpu_type = "ppc64/power5",
.oprofile_model = &op_model_power4, .oprofile_type = POWER4,
#endif
}, },
{ /* Cell Broadband Engine */ { /* Cell Broadband Engine */
.pvr_mask = 0xffff0000, .pvr_mask = 0xffff0000,
...@@ -546,10 +520,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -546,10 +520,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32, .dcache_bsize = 32,
.num_pmcs = 6, .num_pmcs = 6,
.cpu_setup = __setup_cpu_745x, .cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450", .oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450, .oprofile_type = G4,
#endif
}, },
{ /* 7450 2.1 */ { /* 7450 2.1 */
.pvr_mask = 0xffffffff, .pvr_mask = 0xffffffff,
...@@ -561,10 +533,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -561,10 +533,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32, .dcache_bsize = 32,
.num_pmcs = 6, .num_pmcs = 6,
.cpu_setup = __setup_cpu_745x, .cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450", .oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450, .oprofile_type = G4,
#endif
}, },
{ /* 7450 2.3 and newer */ { /* 7450 2.3 and newer */
.pvr_mask = 0xffff0000, .pvr_mask = 0xffff0000,
...@@ -576,10 +546,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -576,10 +546,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32, .dcache_bsize = 32,
.num_pmcs = 6, .num_pmcs = 6,
.cpu_setup = __setup_cpu_745x, .cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450", .oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450, .oprofile_type = G4,
#endif
}, },
{ /* 7455 rev 1.x */ { /* 7455 rev 1.x */
.pvr_mask = 0xffffff00, .pvr_mask = 0xffffff00,
...@@ -591,10 +559,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -591,10 +559,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32, .dcache_bsize = 32,
.num_pmcs = 6, .num_pmcs = 6,
.cpu_setup = __setup_cpu_745x, .cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450", .oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450, .oprofile_type = G4,
#endif
}, },
{ /* 7455 rev 2.0 */ { /* 7455 rev 2.0 */
.pvr_mask = 0xffffffff, .pvr_mask = 0xffffffff,
...@@ -606,10 +572,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -606,10 +572,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32, .dcache_bsize = 32,
.num_pmcs = 6, .num_pmcs = 6,
.cpu_setup = __setup_cpu_745x, .cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450", .oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450, .oprofile_type = G4,
#endif
}, },
{ /* 7455 others */ { /* 7455 others */
.pvr_mask = 0xffff0000, .pvr_mask = 0xffff0000,
...@@ -621,10 +585,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -621,10 +585,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32, .dcache_bsize = 32,
.num_pmcs = 6, .num_pmcs = 6,
.cpu_setup = __setup_cpu_745x, .cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450", .oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450, .oprofile_type = G4,
#endif
}, },
{ /* 7447/7457 Rev 1.0 */ { /* 7447/7457 Rev 1.0 */
.pvr_mask = 0xffffffff, .pvr_mask = 0xffffffff,
...@@ -636,10 +598,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -636,10 +598,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32, .dcache_bsize = 32,
.num_pmcs = 6, .num_pmcs = 6,
.cpu_setup = __setup_cpu_745x, .cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450", .oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450, .oprofile_type = G4,
#endif
}, },
{ /* 7447/7457 Rev 1.1 */ { /* 7447/7457 Rev 1.1 */
.pvr_mask = 0xffffffff, .pvr_mask = 0xffffffff,
...@@ -651,10 +611,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -651,10 +611,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32, .dcache_bsize = 32,
.num_pmcs = 6, .num_pmcs = 6,
.cpu_setup = __setup_cpu_745x, .cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450", .oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450, .oprofile_type = G4,
#endif
}, },
{ /* 7447/7457 Rev 1.2 and later */ { /* 7447/7457 Rev 1.2 and later */
.pvr_mask = 0xffff0000, .pvr_mask = 0xffff0000,
...@@ -666,10 +624,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -666,10 +624,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32, .dcache_bsize = 32,
.num_pmcs = 6, .num_pmcs = 6,
.cpu_setup = __setup_cpu_745x, .cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450", .oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450, .oprofile_type = G4,
#endif
}, },
{ /* 7447A */ { /* 7447A */
.pvr_mask = 0xffff0000, .pvr_mask = 0xffff0000,
...@@ -681,10 +637,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -681,10 +637,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32, .dcache_bsize = 32,
.num_pmcs = 6, .num_pmcs = 6,
.cpu_setup = __setup_cpu_745x, .cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450", .oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450, .oprofile_type = G4,
#endif
}, },
{ /* 7448 */ { /* 7448 */
.pvr_mask = 0xffff0000, .pvr_mask = 0xffff0000,
...@@ -696,10 +650,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -696,10 +650,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32, .dcache_bsize = 32,
.num_pmcs = 6, .num_pmcs = 6,
.cpu_setup = __setup_cpu_745x, .cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450", .oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450, .oprofile_type = G4,
#endif
}, },
{ /* 82xx (8240, 8245, 8260 are all 603e cores) */ { /* 82xx (8240, 8245, 8260 are all 603e cores) */
.pvr_mask = 0x7fff0000, .pvr_mask = 0x7fff0000,
...@@ -1023,10 +975,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -1023,10 +975,8 @@ struct cpu_spec cpu_specs[] = {
.icache_bsize = 32, .icache_bsize = 32,
.dcache_bsize = 32, .dcache_bsize = 32,
.num_pmcs = 4, .num_pmcs = 4,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/e500", .oprofile_cpu_type = "ppc/e500",
.oprofile_model = &op_model_fsl_booke, .oprofile_type = BOOKE,
#endif
}, },
{ /* e500v2 */ { /* e500v2 */
.pvr_mask = 0xffff0000, .pvr_mask = 0xffff0000,
...@@ -1040,10 +990,8 @@ struct cpu_spec cpu_specs[] = { ...@@ -1040,10 +990,8 @@ struct cpu_spec cpu_specs[] = {
.icache_bsize = 32, .icache_bsize = 32,
.dcache_bsize = 32, .dcache_bsize = 32,
.num_pmcs = 4, .num_pmcs = 4,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/e500", .oprofile_cpu_type = "ppc/e500",
.oprofile_model = &op_model_fsl_booke, .oprofile_type = BOOKE,
#endif
}, },
#endif #endif
#if !CLASSIC_PPC #if !CLASSIC_PPC
......
...@@ -135,9 +135,31 @@ static int op_powerpc_create_files(struct super_block *sb, struct dentry *root) ...@@ -135,9 +135,31 @@ static int op_powerpc_create_files(struct super_block *sb, struct dentry *root)
int __init oprofile_arch_init(struct oprofile_operations *ops) int __init oprofile_arch_init(struct oprofile_operations *ops)
{ {
if (!cur_cpu_spec->oprofile_model || !cur_cpu_spec->oprofile_cpu_type) if (!cur_cpu_spec->oprofile_cpu_type)
return -ENODEV; return -ENODEV;
model = cur_cpu_spec->oprofile_model;
switch (cur_cpu_spec->oprofile_type) {
#ifdef CONFIG_PPC64
case RS64:
model = &op_model_rs64;
break;
case POWER4:
model = &op_model_power4;
break;
#else
case G4:
model = &op_model_7450;
break;
#endif
#ifdef CONFIG_FSL_BOOKE
case BOOKE:
model = &op_model_fsl_booke;
break;
#endif
default:
return -ENODEV;
}
model->num_counters = cur_cpu_spec->num_pmcs; model->num_counters = cur_cpu_spec->num_pmcs;
ops->cpu_type = cur_cpu_spec->oprofile_cpu_type; ops->cpu_type = cur_cpu_spec->oprofile_cpu_type;
......
...@@ -27,10 +27,17 @@ ...@@ -27,10 +27,17 @@
* via the mkdefs mechanism. * via the mkdefs mechanism.
*/ */
struct cpu_spec; struct cpu_spec;
struct op_powerpc_model;
typedef void (*cpu_setup_t)(unsigned long offset, struct cpu_spec* spec); typedef void (*cpu_setup_t)(unsigned long offset, struct cpu_spec* spec);
enum powerpc_oprofile_type {
INVALID = 0,
RS64 = 1,
POWER4 = 2,
G4 = 3,
BOOKE = 4,
};
struct cpu_spec { struct cpu_spec {
/* CPU is matched via (PVR & pvr_mask) == pvr_value */ /* CPU is matched via (PVR & pvr_mask) == pvr_value */
unsigned int pvr_mask; unsigned int pvr_mask;
...@@ -56,7 +63,7 @@ struct cpu_spec { ...@@ -56,7 +63,7 @@ struct cpu_spec {
char *oprofile_cpu_type; char *oprofile_cpu_type;
/* Processor specific oprofile operations */ /* Processor specific oprofile operations */
struct op_powerpc_model *oprofile_model; enum powerpc_oprofile_type oprofile_type;
}; };
extern struct cpu_spec *cur_cpu_spec; extern struct cpu_spec *cur_cpu_spec;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册