Commit ec3eb9d9 authored by Rashmica Gupta's avatar Rashmica Gupta Committed by Michael Ellerman

powerpc/perf: Use PVR rather than oprofile field to determine CPU version

Currently the perf CPU backend drivers detect what CPU they're on using
cur_cpu_spec->oprofile_cpu_type.

Although that works, it's a bit crufty to be using oprofile related fields,
especially seeing as oprofile is more or less unused these days.

It also means perf is reliant on the fragile logic in setup_cpu_spec()
which detects when we're using a logical PVR and copies back the PMU
related fields from the raw CPU entry. So lets check the PVR directly.
Suggested-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Signed-off-by: default avatarRashmica Gupta <rashmica.g@gmail.com>
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: default avatarMadhavan Srinivasan <maddy@linux.vnet.ibm.com>
[chleroy: Added power10 and fixed checkpatch issues]
Reviewed-and-tested-by: default avatarAthira Rajeev <atrajeev@linux.vnet.ibm.com>
Reviewed-and-tested-By: Kajol Jain <kjain@linux.ibm.com> [For 24x7 side changes]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20c0ee7f99dbf0dbf8658df6b39f84753e6db1ef.1657204631.git.christophe.leroy@csgroup.eu
parent 6042a165
...@@ -118,12 +118,13 @@ static struct fsl_emb_pmu e500_pmu = { ...@@ -118,12 +118,13 @@ static struct fsl_emb_pmu e500_pmu = {
static int init_e500_pmu(void) static int init_e500_pmu(void)
{ {
if (!cur_cpu_spec->oprofile_cpu_type) unsigned int pvr = mfspr(SPRN_PVR);
return -ENODEV;
if (!strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc/e500mc")) /* ec500mc */
if (PVR_VER(pvr) == PVR_VER_E500MC || PVR_VER(pvr) == PVR_VER_E5500)
num_events = 256; num_events = 256;
else if (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc/e500")) /* e500 */
else if (PVR_VER(pvr) != PVR_VER_E500V1 && PVR_VER(pvr) != PVR_VER_E500V2)
return -ENODEV; return -ENODEV;
return register_fsl_emb_pmu(&e500_pmu); return register_fsl_emb_pmu(&e500_pmu);
......
...@@ -107,8 +107,9 @@ static struct fsl_emb_pmu e6500_pmu = { ...@@ -107,8 +107,9 @@ static struct fsl_emb_pmu e6500_pmu = {
static int init_e6500_pmu(void) static int init_e6500_pmu(void)
{ {
if (!cur_cpu_spec->oprofile_cpu_type || unsigned int pvr = mfspr(SPRN_PVR);
strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc/e6500"))
if (PVR_VER(pvr) != PVR_VER_E6500)
return -ENODEV; return -ENODEV;
return register_fsl_emb_pmu(&e6500_pmu); return register_fsl_emb_pmu(&e6500_pmu);
......
...@@ -1718,16 +1718,16 @@ static int hv_24x7_init(void) ...@@ -1718,16 +1718,16 @@ static int hv_24x7_init(void)
{ {
int r; int r;
unsigned long hret; unsigned long hret;
unsigned int pvr = mfspr(SPRN_PVR);
struct hv_perf_caps caps; struct hv_perf_caps caps;
if (!firmware_has_feature(FW_FEATURE_LPAR)) { if (!firmware_has_feature(FW_FEATURE_LPAR)) {
pr_debug("not a virtualized system, not enabling\n"); pr_debug("not a virtualized system, not enabling\n");
return -ENODEV; return -ENODEV;
} else if (!cur_cpu_spec->oprofile_cpu_type) }
return -ENODEV;
/* POWER8 only supports v1, while POWER9 only supports v2. */ /* POWER8 only supports v1, while POWER9 only supports v2. */
if (!strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power8")) if (PVR_VER(pvr) == PVR_POWER8)
interface_version = 1; interface_version = 1;
else { else {
interface_version = 2; interface_version = 2;
......
...@@ -417,8 +417,9 @@ struct power_pmu mpc7450_pmu = { ...@@ -417,8 +417,9 @@ struct power_pmu mpc7450_pmu = {
static int __init init_mpc7450_pmu(void) static int __init init_mpc7450_pmu(void)
{ {
if (!cur_cpu_spec->oprofile_cpu_type || unsigned int pvr = mfspr(SPRN_PVR);
strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc/7450"))
if (PVR_VER(pvr) != PVR_7450)
return -ENODEV; return -ENODEV;
return register_power_pmu(&mpc7450_pmu); return register_power_pmu(&mpc7450_pmu);
......
...@@ -607,12 +607,10 @@ int __init init_power10_pmu(void) ...@@ -607,12 +607,10 @@ int __init init_power10_pmu(void)
unsigned int pvr; unsigned int pvr;
int rc; int rc;
/* Comes from cpu_specs[] */ pvr = mfspr(SPRN_PVR);
if (!cur_cpu_spec->oprofile_cpu_type || if (PVR_VER(pvr) != PVR_POWER10)
strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power10"))
return -ENODEV; return -ENODEV;
pvr = mfspr(SPRN_PVR);
/* Add the ppmu flag for power10 DD1 */ /* Add the ppmu flag for power10 DD1 */
if ((PVR_CFG(pvr) == 1)) if ((PVR_CFG(pvr) == 1))
power10_pmu.flags |= PPMU_P10_DD1; power10_pmu.flags |= PPMU_P10_DD1;
......
...@@ -679,9 +679,9 @@ static struct power_pmu power5p_pmu = { ...@@ -679,9 +679,9 @@ static struct power_pmu power5p_pmu = {
int __init init_power5p_pmu(void) int __init init_power5p_pmu(void)
{ {
if (!cur_cpu_spec->oprofile_cpu_type || unsigned int pvr = mfspr(SPRN_PVR);
(strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5+")
&& strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5++"))) if (PVR_VER(pvr) != PVR_POWER5p)
return -ENODEV; return -ENODEV;
return register_power_pmu(&power5p_pmu); return register_power_pmu(&power5p_pmu);
......
...@@ -620,8 +620,9 @@ static struct power_pmu power5_pmu = { ...@@ -620,8 +620,9 @@ static struct power_pmu power5_pmu = {
int __init init_power5_pmu(void) int __init init_power5_pmu(void)
{ {
if (!cur_cpu_spec->oprofile_cpu_type || unsigned int pvr = mfspr(SPRN_PVR);
strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5"))
if (PVR_VER(pvr) != PVR_POWER5)
return -ENODEV; return -ENODEV;
return register_power_pmu(&power5_pmu); return register_power_pmu(&power5_pmu);
......
...@@ -541,8 +541,9 @@ static struct power_pmu power6_pmu = { ...@@ -541,8 +541,9 @@ static struct power_pmu power6_pmu = {
int __init init_power6_pmu(void) int __init init_power6_pmu(void)
{ {
if (!cur_cpu_spec->oprofile_cpu_type || unsigned int pvr = mfspr(SPRN_PVR);
strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power6"))
if (PVR_VER(pvr) != PVR_POWER6)
return -ENODEV; return -ENODEV;
return register_power_pmu(&power6_pmu); return register_power_pmu(&power6_pmu);
......
...@@ -447,11 +447,12 @@ static struct power_pmu power7_pmu = { ...@@ -447,11 +447,12 @@ static struct power_pmu power7_pmu = {
int __init init_power7_pmu(void) int __init init_power7_pmu(void)
{ {
if (!cur_cpu_spec->oprofile_cpu_type || unsigned int pvr = mfspr(SPRN_PVR);
strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power7"))
if (PVR_VER(pvr) != PVR_POWER7 && PVR_VER(pvr) != PVR_POWER7p)
return -ENODEV; return -ENODEV;
if (pvr_version_is(PVR_POWER7p)) if (PVR_VER(pvr) == PVR_POWER7p)
power7_pmu.flags |= PPMU_SIAR_VALID; power7_pmu.flags |= PPMU_SIAR_VALID;
return register_power_pmu(&power7_pmu); return register_power_pmu(&power7_pmu);
......
...@@ -391,9 +391,10 @@ static struct power_pmu power8_pmu = { ...@@ -391,9 +391,10 @@ static struct power_pmu power8_pmu = {
int __init init_power8_pmu(void) int __init init_power8_pmu(void)
{ {
int rc; int rc;
unsigned int pvr = mfspr(SPRN_PVR);
if (!cur_cpu_spec->oprofile_cpu_type || if (PVR_VER(pvr) != PVR_POWER8E && PVR_VER(pvr) != PVR_POWER8NVL &&
strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power8")) PVR_VER(pvr) != PVR_POWER8)
return -ENODEV; return -ENODEV;
rc = register_power_pmu(&power8_pmu); rc = register_power_pmu(&power8_pmu);
......
...@@ -467,9 +467,7 @@ int __init init_power9_pmu(void) ...@@ -467,9 +467,7 @@ int __init init_power9_pmu(void)
int rc = 0; int rc = 0;
unsigned int pvr = mfspr(SPRN_PVR); unsigned int pvr = mfspr(SPRN_PVR);
/* Comes from cpu_specs[] */ if (PVR_VER(pvr) != PVR_POWER9)
if (!cur_cpu_spec->oprofile_cpu_type ||
strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power9"))
return -ENODEV; return -ENODEV;
/* Blacklist events */ /* Blacklist events */
......
...@@ -491,9 +491,10 @@ static struct power_pmu ppc970_pmu = { ...@@ -491,9 +491,10 @@ static struct power_pmu ppc970_pmu = {
int __init init_ppc970_pmu(void) int __init init_ppc970_pmu(void)
{ {
if (!cur_cpu_spec->oprofile_cpu_type || unsigned int pvr = mfspr(SPRN_PVR);
(strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/970")
&& strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/970MP"))) if (PVR_VER(pvr) != PVR_970 && PVR_VER(pvr) != PVR_970MP &&
PVR_VER(pvr) != PVR_970FX && PVR_VER(pvr) != PVR_970GX)
return -ENODEV; return -ENODEV;
return register_power_pmu(&ppc970_pmu); return register_power_pmu(&ppc970_pmu);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment