Skip to content

Commit

Permalink
powerpc/perf: init pmu from core-book3s
Browse files Browse the repository at this point in the history
Currenty pmu driver file for each ppc64 generation processor
has a __init call in itself. Refactor the code by moving the
__init call to core-books.c. This also clean's up compat mode
pmu driver registration.

Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
[mpe: Use SPDX tag for license]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
  • Loading branch information
Madhavan Srinivasan authored and Michael Ellerman committed May 2, 2019
1 parent 1e49639 commit 708597d
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 19 deletions.
28 changes: 28 additions & 0 deletions arch/powerpc/perf/core-book3s.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include <asm/ptrace.h>
#include <asm/code-patching.h>

#ifdef CONFIG_PPC64
#include "internal.h"
#endif

#define BHRB_MAX_ENTRIES 32
#define BHRB_TARGET 0x0000000000000002
#define BHRB_PREDICTION 0x0000000000000001
Expand Down Expand Up @@ -2294,3 +2298,27 @@ int register_power_pmu(struct power_pmu *pmu)
power_pmu_prepare_cpu, NULL);
return 0;
}

#ifdef CONFIG_PPC64
static int __init init_ppc64_pmu(void)
{
/* run through all the pmu drivers one at a time */
if (!init_power5_pmu())
return 0;
else if (!init_power5p_pmu())
return 0;
else if (!init_power6_pmu())
return 0;
else if (!init_power7_pmu())
return 0;
else if (!init_power8_pmu())
return 0;
else if (!init_power9_pmu())
return 0;
else if (!init_ppc970_pmu())
return 0;
else
return -ENODEV;
}
early_initcall(init_ppc64_pmu);
#endif
11 changes: 11 additions & 0 deletions arch/powerpc/perf/internal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: GPL-2.0+
//
// Copyright 2019 Madhavan Srinivasan, IBM Corporation.

extern int init_ppc970_pmu(void);
extern int init_power5_pmu(void);
extern int init_power5p_pmu(void);
extern int init_power6_pmu(void);
extern int init_power7_pmu(void);
extern int init_power8_pmu(void);
extern int init_power9_pmu(void);
4 changes: 1 addition & 3 deletions arch/powerpc/perf/power5+-pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ static struct power_pmu power5p_pmu = {
.cache_events = &power5p_cache_events,
};

static int __init init_power5p_pmu(void)
int init_power5p_pmu(void)
{
if (!cur_cpu_spec->oprofile_cpu_type ||
(strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5+")
Expand All @@ -686,5 +686,3 @@ static int __init init_power5p_pmu(void)

return register_power_pmu(&power5p_pmu);
}

early_initcall(init_power5p_pmu);
4 changes: 1 addition & 3 deletions arch/powerpc/perf/power5-pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,13 +618,11 @@ static struct power_pmu power5_pmu = {
.flags = PPMU_HAS_SSLOT,
};

static int __init init_power5_pmu(void)
int init_power5_pmu(void)
{
if (!cur_cpu_spec->oprofile_cpu_type ||
strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5"))
return -ENODEV;

return register_power_pmu(&power5_pmu);
}

early_initcall(init_power5_pmu);
4 changes: 1 addition & 3 deletions arch/powerpc/perf/power6-pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,11 @@ static struct power_pmu power6_pmu = {
.cache_events = &power6_cache_events,
};

static int __init init_power6_pmu(void)
int init_power6_pmu(void)
{
if (!cur_cpu_spec->oprofile_cpu_type ||
strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power6"))
return -ENODEV;

return register_power_pmu(&power6_pmu);
}

early_initcall(init_power6_pmu);
4 changes: 1 addition & 3 deletions arch/powerpc/perf/power7-pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ static struct power_pmu power7_pmu = {
.cache_events = &power7_cache_events,
};

static int __init init_power7_pmu(void)
int init_power7_pmu(void)
{
if (!cur_cpu_spec->oprofile_cpu_type ||
strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power7"))
Expand All @@ -456,5 +456,3 @@ static int __init init_power7_pmu(void)

return register_power_pmu(&power7_pmu);
}

early_initcall(init_power7_pmu);
3 changes: 1 addition & 2 deletions arch/powerpc/perf/power8-pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ static struct power_pmu power8_pmu = {
.bhrb_nr = 32,
};

static int __init init_power8_pmu(void)
int init_power8_pmu(void)
{
int rc;

Expand All @@ -399,4 +399,3 @@ static int __init init_power8_pmu(void)

return 0;
}
early_initcall(init_power8_pmu);
3 changes: 1 addition & 2 deletions arch/powerpc/perf/power9-pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ static struct power_pmu power9_pmu = {
.bhrb_nr = 32,
};

static int __init init_power9_pmu(void)
int init_power9_pmu(void)
{
int rc = 0;
unsigned int pvr = mfspr(SPRN_PVR);
Expand Down Expand Up @@ -467,4 +467,3 @@ static int __init init_power9_pmu(void)

return 0;
}
early_initcall(init_power9_pmu);
4 changes: 1 addition & 3 deletions arch/powerpc/perf/ppc970-pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ static struct power_pmu ppc970_pmu = {
.flags = PPMU_NO_SIPR | PPMU_NO_CONT_SAMPLING,
};

static int __init init_ppc970_pmu(void)
int init_ppc970_pmu(void)
{
if (!cur_cpu_spec->oprofile_cpu_type ||
(strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/970")
Expand All @@ -499,5 +499,3 @@ static int __init init_ppc970_pmu(void)

return register_power_pmu(&ppc970_pmu);
}

early_initcall(init_ppc970_pmu);

0 comments on commit 708597d

Please sign in to comment.