summaryrefslogtreecommitdiff
path: root/arch/x86/machine/pmu_amd.c
diff options
context:
space:
mode:
authorRemy Noel <mocramis@gmail.com>2018-03-12 14:33:17 +0100
committerRemy Noel <mocramis@gmail.com>2018-03-12 14:33:17 +0100
commit8d22520daef80a2a0dfb27a636da17c9bafabd39 (patch)
tree36638dfe4df05fbbbd1e459c7a996fbea7e78284 /arch/x86/machine/pmu_amd.c
parentc8030a59c79846363587381a41f1d71f1bde5177 (diff)
perfmon: Coding style & cosmetic fixes
Diffstat (limited to 'arch/x86/machine/pmu_amd.c')
-rw-r--r--arch/x86/machine/pmu_amd.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/arch/x86/machine/pmu_amd.c b/arch/x86/machine/pmu_amd.c
index b8b4c78..49b8d7e 100644
--- a/arch/x86/machine/pmu_amd.c
+++ b/arch/x86/machine/pmu_amd.c
@@ -109,14 +109,16 @@ static void
pmu_amd_info(void)
{
log_info("pmu: driver: amd, nr_pmcs: %u, pmc_width: %u\n",
- PMU_AMD_NR_PMCS, PMU_AMD_PMC_WIDTH);
+ PMU_AMD_NR_PMCS, PMU_AMD_PMC_WIDTH);
}
static int
pmu_amd_translate(unsigned int *raw_event_idp, unsigned int event_id)
{
assert(event_id < ARRAY_SIZE(pmu_amd_generic_events));
+
*raw_event_idp = pmu_amd_generic_events[event_id];
+
return 0;
}
@@ -131,12 +133,14 @@ pmu_amd_alloc(unsigned int *pmc_idp, unsigned int raw_event_id)
pmu = pmu_amd_get();
- if (pmu->pmc_bm == 0)
+ if (pmu->pmc_bm == 0) {
return EAGAIN;
+ }
pmc_id = __builtin_ffs(pmu->pmc_bm) - 1;
pmu->pmc_bm &= ~(1U << pmc_id);
*pmc_idp = pmc_id;
+
return 0;
}
@@ -150,7 +154,9 @@ pmu_amd_free(unsigned int pmc_id)
pmu = pmu_amd_get();
mask = (1U << pmc_id);
+
assert(!(pmu->pmc_bm & mask));
+
pmu->pmc_bm |= mask;
}
@@ -179,6 +185,7 @@ static void
pmu_amd_stop(unsigned int pmc_id)
{
assert(pmc_id < PMU_AMD_NR_PMCS);
+
cpu_set_msr(PMU_AMD_MSR_PERFEVTSEL0 + pmc_id, 0, 0);
}
@@ -190,6 +197,7 @@ pmu_amd_read(unsigned int pmc_id)
assert(pmc_id < PMU_AMD_NR_PMCS);
cpu_get_msr(PMU_AMD_MSR_PERCTR0 + pmc_id, &high, &low);
+
return (((uint64_t)high << 32) | low);
}
@@ -207,8 +215,9 @@ pmu_amd_setup(void)
}
/* Support AMD Family 10h processors and later */
- if (cpu->family < 16)
+ if (cpu->family < 16) {
return ENODEV;
+ }
pmu = pmu_amd_get();
pmu->pmc_bm = (1U << PMU_AMD_NR_PMCS) - 1;