From owner-dev-commits-src-main@freebsd.org Thu Aug 5 15:50:09 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6A96666600C; Thu, 5 Aug 2021 15:50:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GgY352QNWz3JFB; Thu, 5 Aug 2021 15:50:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3BCBE1CCEC; Thu, 5 Aug 2021 15:50:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 175Fo9U5018300; Thu, 5 Aug 2021 15:50:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 175Fo9GA018298; Thu, 5 Aug 2021 15:50:09 GMT (envelope-from git) Date: Thu, 5 Aug 2021 15:50:09 GMT Message-Id: <202108051550.175Fo9GA018298@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 4cc6fe1e5b73 - main - coretemp: use x86_msr_op for thermal MSR access MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4cc6fe1e5b73ce540882753d918bc8208849e9e9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Aug 2021 15:50:09 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=4cc6fe1e5b73ce540882753d918bc8208849e9e9 commit 4cc6fe1e5b73ce540882753d918bc8208849e9e9 Author: Konstantin Belousov AuthorDate: 2021-08-02 19:53:08 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-05 15:47:07 +0000 coretemp: use x86_msr_op for thermal MSR access Reviewed by: markj Discussed with: mav Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31386 --- 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