From owner-svn-src-all@freebsd.org Mon Jun 25 11:24:27 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DDF2B1007FBB; Mon, 25 Jun 2018 11:24:26 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8BBAD77CC7; Mon, 25 Jun 2018 11:24:26 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6CF402C845; Mon, 25 Jun 2018 11:24:26 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5PBOQoR022547; Mon, 25 Jun 2018 11:24:26 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5PBOQg6022546; Mon, 25 Jun 2018 11:24:26 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201806251124.w5PBOQg6022546@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 25 Jun 2018 11:24:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335634 - head/sys/x86/x86 X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/x86/x86 X-SVN-Commit-Revision: 335634 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jun 2018 11:24:27 -0000 Author: kib Date: Mon Jun 25 11:24:26 2018 New Revision: 335634 URL: https://svnweb.freebsd.org/changeset/base/335634 Log: Do not access ISA timer if BIOS reports that there is no legacy devices present. On at least one machine where it would matter since the ISA timer is power gated when booted in the UEFI mode, BIOS still reports that the legacy devices are present. That is, user still have to manually disable TSC calibration on such machines. Hopefully it will be more useful in the future. Discussed with: Ben Widawsky Reviewed by: royger Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D16004 MFC after: 1 week Modified: head/sys/x86/x86/tsc.c Modified: head/sys/x86/x86/tsc.c ============================================================================== --- head/sys/x86/x86/tsc.c Mon Jun 25 11:12:21 2018 (r335633) +++ head/sys/x86/x86/tsc.c Mon Jun 25 11:24:26 2018 (r335634) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "cpufreq_if.h" @@ -81,8 +82,9 @@ SYSCTL_INT(_machdep, OID_AUTO, disable_tsc, CTLFLAG_RD "Disable x86 Time Stamp Counter"); static int tsc_skip_calibration; -SYSCTL_INT(_machdep, OID_AUTO, disable_tsc_calibration, CTLFLAG_RDTUN, - &tsc_skip_calibration, 0, "Disable TSC frequency calibration"); +SYSCTL_INT(_machdep, OID_AUTO, disable_tsc_calibration, CTLFLAG_RDTUN | + CTLFLAG_NOFETCH, &tsc_skip_calibration, 0, + "Disable TSC frequency calibration"); static void tsc_freq_changed(void *arg, const struct cf_level *level, int status); @@ -213,6 +215,7 @@ probe_tsc_freq(void) { u_int regs[4]; uint64_t tsc1, tsc2; + uint16_t bootflags; if (cpu_high >= 6) { do_cpuid(6, regs); @@ -272,6 +275,25 @@ probe_tsc_freq(void) break; } + if (!TUNABLE_INT_FETCH("machdep.disable_tsc_calibration", + &tsc_skip_calibration)) { + /* + * User did not give the order about calibration. + * If he did, we do not try to guess. + * + * Otherwise, if ACPI FADT reports that the platform + * is legacy-free and CPUID provides TSC frequency, + * use it. The calibration could fail anyway since + * ISA timer can be absent or power gated. + */ + if (acpi_get_fadt_bootflags(&bootflags) && + (bootflags & ACPI_FADT_LEGACY_DEVICES) == 0 && + tsc_freq_cpuid()) { + printf("Skipping TSC calibration since no legacy " + "devices reported by FADT and CPUID works\n"); + tsc_skip_calibration = 1; + } + } if (tsc_skip_calibration) { if (tsc_freq_cpuid()) ;