Skip to content

Commit

Permalink
[PATCH] ppc64: Fix oprofile when compiled as a module
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Anton Blanchard authored and Paul Mackerras committed Jan 9, 2006
1 parent 9a699ae commit 32a3399
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 82 deletions.
104 changes: 26 additions & 78 deletions arch/powerpc/kernel/cputable.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128,
.num_pmcs = 8,
.cpu_setup = __setup_cpu_power3,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/power3",
.oprofile_model = &op_model_rs64,
#endif
.oprofile_type = RS64,
},
{ /* Power3+ */
.pvr_mask = 0xffff0000,
Expand All @@ -93,10 +91,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128,
.num_pmcs = 8,
.cpu_setup = __setup_cpu_power3,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/power3",
.oprofile_model = &op_model_rs64,
#endif
.oprofile_type = RS64,
},
{ /* Northstar */
.pvr_mask = 0xffff0000,
Expand All @@ -108,10 +104,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128,
.num_pmcs = 8,
.cpu_setup = __setup_cpu_power3,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/rs64",
.oprofile_model = &op_model_rs64,
#endif
.oprofile_type = RS64,
},
{ /* Pulsar */
.pvr_mask = 0xffff0000,
Expand All @@ -123,10 +117,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128,
.num_pmcs = 8,
.cpu_setup = __setup_cpu_power3,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/rs64",
.oprofile_model = &op_model_rs64,
#endif
.oprofile_type = RS64,
},
{ /* I-star */
.pvr_mask = 0xffff0000,
Expand All @@ -138,10 +130,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128,
.num_pmcs = 8,
.cpu_setup = __setup_cpu_power3,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/rs64",
.oprofile_model = &op_model_rs64,
#endif
.oprofile_type = RS64,
},
{ /* S-star */
.pvr_mask = 0xffff0000,
Expand All @@ -153,10 +143,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128,
.num_pmcs = 8,
.cpu_setup = __setup_cpu_power3,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/rs64",
.oprofile_model = &op_model_rs64,
#endif
.oprofile_type = RS64,
},
{ /* Power4 */
.pvr_mask = 0xffff0000,
Expand All @@ -168,10 +156,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128,
.num_pmcs = 8,
.cpu_setup = __setup_cpu_power4,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/power4",
.oprofile_model = &op_model_rs64,
#endif
.oprofile_type = POWER4,
},
{ /* Power4+ */
.pvr_mask = 0xffff0000,
Expand All @@ -183,10 +169,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128,
.num_pmcs = 8,
.cpu_setup = __setup_cpu_power4,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/power4",
.oprofile_model = &op_model_power4,
#endif
.oprofile_type = POWER4,
},
{ /* PPC970 */
.pvr_mask = 0xffff0000,
Expand All @@ -199,10 +183,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128,
.num_pmcs = 8,
.cpu_setup = __setup_cpu_ppc970,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/970",
.oprofile_model = &op_model_power4,
#endif
.oprofile_type = POWER4,
},
#endif /* CONFIG_PPC64 */
#if defined(CONFIG_PPC64) || defined(CONFIG_POWER4)
Expand All @@ -221,10 +203,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128,
.num_pmcs = 8,
.cpu_setup = __setup_cpu_ppc970,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/970",
.oprofile_model = &op_model_power4,
#endif
.oprofile_type = POWER4,
},
#endif /* defined(CONFIG_PPC64) || defined(CONFIG_POWER4) */
#ifdef CONFIG_PPC64
Expand All @@ -238,10 +218,8 @@ struct cpu_spec cpu_specs[] = {
.icache_bsize = 128,
.dcache_bsize = 128,
.cpu_setup = __setup_cpu_ppc970,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/970",
.oprofile_model = &op_model_power4,
#endif
.oprofile_type = POWER4,
},
{ /* Power5 GR */
.pvr_mask = 0xffff0000,
Expand All @@ -253,10 +231,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128,
.num_pmcs = 6,
.cpu_setup = __setup_cpu_power4,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/power5",
.oprofile_model = &op_model_power4,
#endif
.oprofile_type = POWER4,
},
{ /* Power5 GS */
.pvr_mask = 0xffff0000,
Expand All @@ -268,10 +244,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 128,
.num_pmcs = 6,
.cpu_setup = __setup_cpu_power4,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc64/power5",
.oprofile_model = &op_model_power4,
#endif
.oprofile_type = POWER4,
},
{ /* Cell Broadband Engine */
.pvr_mask = 0xffff0000,
Expand Down Expand Up @@ -546,10 +520,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32,
.num_pmcs = 6,
.cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450,
#endif
.oprofile_type = G4,
},
{ /* 7450 2.1 */
.pvr_mask = 0xffffffff,
Expand All @@ -561,10 +533,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32,
.num_pmcs = 6,
.cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450,
#endif
.oprofile_type = G4,
},
{ /* 7450 2.3 and newer */
.pvr_mask = 0xffff0000,
Expand All @@ -576,10 +546,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32,
.num_pmcs = 6,
.cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450,
#endif
.oprofile_type = G4,
},
{ /* 7455 rev 1.x */
.pvr_mask = 0xffffff00,
Expand All @@ -591,10 +559,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32,
.num_pmcs = 6,
.cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450,
#endif
.oprofile_type = G4,
},
{ /* 7455 rev 2.0 */
.pvr_mask = 0xffffffff,
Expand All @@ -606,10 +572,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32,
.num_pmcs = 6,
.cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450,
#endif
.oprofile_type = G4,
},
{ /* 7455 others */
.pvr_mask = 0xffff0000,
Expand All @@ -621,10 +585,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32,
.num_pmcs = 6,
.cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450,
#endif
.oprofile_type = G4,
},
{ /* 7447/7457 Rev 1.0 */
.pvr_mask = 0xffffffff,
Expand All @@ -636,10 +598,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32,
.num_pmcs = 6,
.cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450,
#endif
.oprofile_type = G4,
},
{ /* 7447/7457 Rev 1.1 */
.pvr_mask = 0xffffffff,
Expand All @@ -651,10 +611,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32,
.num_pmcs = 6,
.cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450,
#endif
.oprofile_type = G4,
},
{ /* 7447/7457 Rev 1.2 and later */
.pvr_mask = 0xffff0000,
Expand All @@ -666,10 +624,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32,
.num_pmcs = 6,
.cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450,
#endif
.oprofile_type = G4,
},
{ /* 7447A */
.pvr_mask = 0xffff0000,
Expand All @@ -681,10 +637,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32,
.num_pmcs = 6,
.cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450,
#endif
.oprofile_type = G4,
},
{ /* 7448 */
.pvr_mask = 0xffff0000,
Expand All @@ -696,10 +650,8 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32,
.num_pmcs = 6,
.cpu_setup = __setup_cpu_745x,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/7450",
.oprofile_model = &op_model_7450,
#endif
.oprofile_type = G4,
},
{ /* 82xx (8240, 8245, 8260 are all 603e cores) */
.pvr_mask = 0x7fff0000,
Expand Down Expand Up @@ -1023,10 +975,8 @@ struct cpu_spec cpu_specs[] = {
.icache_bsize = 32,
.dcache_bsize = 32,
.num_pmcs = 4,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/e500",
.oprofile_model = &op_model_fsl_booke,
#endif
.oprofile_type = BOOKE,
},
{ /* e500v2 */
.pvr_mask = 0xffff0000,
Expand All @@ -1040,10 +990,8 @@ struct cpu_spec cpu_specs[] = {
.icache_bsize = 32,
.dcache_bsize = 32,
.num_pmcs = 4,
#ifdef CONFIG_OPROFILE
.oprofile_cpu_type = "ppc/e500",
.oprofile_model = &op_model_fsl_booke,
#endif
.oprofile_type = BOOKE,
},
#endif
#if !CLASSIC_PPC
Expand Down
26 changes: 24 additions & 2 deletions arch/powerpc/oprofile/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
if (!cur_cpu_spec->oprofile_model || !cur_cpu_spec->oprofile_cpu_type)
if (!cur_cpu_spec->oprofile_cpu_type)
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;

ops->cpu_type = cur_cpu_spec->oprofile_cpu_type;
Expand Down
11 changes: 9 additions & 2 deletions include/asm-powerpc/cputable.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@
* via the mkdefs mechanism.
*/
struct cpu_spec;
struct op_powerpc_model;

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 {
/* CPU is matched via (PVR & pvr_mask) == pvr_value */
unsigned int pvr_mask;
Expand All @@ -56,7 +63,7 @@ struct cpu_spec {
char *oprofile_cpu_type;

/* Processor specific oprofile operations */
struct op_powerpc_model *oprofile_model;
enum powerpc_oprofile_type oprofile_type;
};

extern struct cpu_spec *cur_cpu_spec;
Expand Down

0 comments on commit 32a3399

Please sign in to comment.