diff options
author | Remy Noel <mocramis@gmail.com> | 2018-03-28 14:55:53 +0200 |
---|---|---|
committer | Remy Noel <mocramis@gmail.com> | 2018-04-21 00:04:20 +0200 |
commit | f6f54a518bb2f35b5f222de7288ebf2cae67fca2 (patch) | |
tree | cf07eb44b8cfffa939b6fc55dc9a071045c092ec | |
parent | 6b98275f3864ee6a413e99b9bddc7a3c029af2d2 (diff) |
cpu: Add cpu_get_msr64 helper
-rw-r--r-- | arch/x86/machine/cpu.h | 13 | ||||
-rw-r--r-- | arch/x86/machine/pmu_amd.c | 6 | ||||
-rw-r--r-- | arch/x86/machine/pmu_intel.c | 6 |
3 files changed, 16 insertions, 9 deletions
diff --git a/arch/x86/machine/cpu.h b/arch/x86/machine/cpu.h index 98c363f..d40760c 100644 --- a/arch/x86/machine/cpu.h +++ b/arch/x86/machine/cpu.h @@ -554,6 +554,19 @@ cpu_get_msr(uint32_t msr, uint32_t *high, uint32_t *low) } /* + * uint64 version of cpu_get_msr. + */ +static __always_inline uint64_t +cpu_get_msr64(uint32_t msr) +{ + uint32_t high, low; + + cpu_get_msr(msr, &high, &low); + + return (((uint64_t)high << 32) | low); +} + +/* * Implies a full memory barrier. */ static inline void diff --git a/arch/x86/machine/pmu_amd.c b/arch/x86/machine/pmu_amd.c index 49b8d7e..0f8b14a 100644 --- a/arch/x86/machine/pmu_amd.c +++ b/arch/x86/machine/pmu_amd.c @@ -192,13 +192,9 @@ pmu_amd_stop(unsigned int pmc_id) static uint64_t pmu_amd_read(unsigned int pmc_id) { - uint32_t high, low; - assert(pmc_id < PMU_AMD_NR_PMCS); - cpu_get_msr(PMU_AMD_MSR_PERCTR0 + pmc_id, &high, &low); - - return (((uint64_t)high << 32) | low); + return cpu_get_msr64(PMU_AMD_MSR_PERCTR0 + pmc_id); } static int __init diff --git a/arch/x86/machine/pmu_intel.c b/arch/x86/machine/pmu_intel.c index c47be6c..26647af 100644 --- a/arch/x86/machine/pmu_intel.c +++ b/arch/x86/machine/pmu_intel.c @@ -223,12 +223,10 @@ pmu_intel_stop(unsigned int pmc_id) static uint64_t pmu_intel_read(unsigned int pmc_id) { - uint32_t high, low; + return cpu_get_msr64(PMU_INTEL_MSR_PMC0 + pmc_id); +} - cpu_get_msr(PMU_INTEL_MSR_PMC0 + pmc_id, &high, &low); - return (((uint64_t)high << 32) | low); -} static int __init pmu_intel_setup(void) |