git: 1ff28f8a0de5 - stable/13 - coretemp: use x86_msr_op for thermal MSR access
Konstantin Belousov
kib at FreeBSD.org
Mon Aug 23 09:25:04 UTC 2021
The branch stable/13 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=1ff28f8a0de5313ef8344b29ec44a3ab407970e8
commit 1ff28f8a0de5313ef8344b29ec44a3ab407970e8
Author: Konstantin Belousov <kib at FreeBSD.org>
AuthorDate: 2021-08-02 19:53:08 +0000
Commit: Konstantin Belousov <kib at FreeBSD.org>
CommitDate: 2021-08-23 09:24:40 +0000
coretemp: use x86_msr_op for thermal MSR access
(cherry picked from commit 4cc6fe1e5b73ce540882753d918bc8208849e9e9)
---
sys/dev/coretemp/coretemp.c | 57 +++++++++++++--------------------------------
1 file changed, 16 insertions(+), 41 deletions(-)
diff --git a/sys/dev/coretemp/coretemp.c b/sys/dev/coretemp/coretemp.c
index 53a2434254f6..bdc71b284ac7 100644
--- a/sys/dev/coretemp/coretemp.c
+++ b/sys/dev/coretemp/coretemp.c
@@ -315,56 +315,31 @@ struct coretemp_args {
uint64_t val;
};
-static void
-coretemp_rdmsr(void *arg)
-{
- struct coretemp_args *args = arg;
-
- args->val = rdmsr(args->msr);
-}
-
-static void
-coretemp_wrmsr(void *arg)
-{
- struct coretemp_args *args = arg;
-
- wrmsr(args->msr, args->val);
-}
-
+/*
+ * The digital temperature reading is located at bit 16
+ * of MSR_THERM_STATUS.
+ *
+ * There is a bit on that MSR that indicates whether the
+ * temperature is valid or not.
+ *
+ * The temperature is computed by subtracting the temperature
+ * reading by Tj(max).
+ */
static uint64_t
coretemp_get_thermal_msr(int cpu)
{
- struct coretemp_args args;
- cpuset_t cpus;
+ uint64_t res;
- /*
- * The digital temperature reading is located at bit 16
- * of MSR_THERM_STATUS.
- *
- * There is a bit on that MSR that indicates whether the
- * temperature is valid or not.
- *
- * The temperature is computed by subtracting the temperature
- * reading by Tj(max).
- */
- args.msr = MSR_THERM_STATUS;
- CPU_SETOF(cpu, &cpus);
- smp_rendezvous_cpus(cpus, smp_no_rendezvous_barrier, coretemp_rdmsr,
- smp_no_rendezvous_barrier, &args);
- return (args.val);
+ x86_msr_op(MSR_THERM_STATUS, MSR_OP_RENDEZVOUS_ONE | MSR_OP_READ |
+ MSR_OP_CPUID(cpu), 0, &res);
+ return (res);
}
static void
coretemp_clear_thermal_msr(int cpu)
{
- struct coretemp_args args;
- cpuset_t cpus;
-
- args.msr = MSR_THERM_STATUS;
- args.val = 0;
- CPU_SETOF(cpu, &cpus);
- smp_rendezvous_cpus(cpus, smp_no_rendezvous_barrier, coretemp_wrmsr,
- smp_no_rendezvous_barrier, &args);
+ x86_msr_op(MSR_THERM_STATUS, MSR_OP_RENDEZVOUS_ONE | MSR_OP_WRITE |
+ MSR_OP_CPUID(cpu), 0, NULL);
}
static int
More information about the dev-commits-src-all
mailing list