From nobody Thu Jan 06 13:46:48 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E352B1935EF9; Thu, 6 Jan 2022 13:46:48 +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 4JV71h4bTxz4lZK; Thu, 6 Jan 2022 13:46:48 +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 7DDEE20F05; Thu, 6 Jan 2022 13:46:48 +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 206Dkm83025055; Thu, 6 Jan 2022 13:46:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 206DkmpB025054; Thu, 6 Jan 2022 13:46:48 GMT (envelope-from git) Date: Thu, 6 Jan 2022 13:46:48 GMT Message-Id: <202201061346.206DkmpB025054@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 08161fd3b207 - stable/13 - x86: Skip late calibration if our reference timer has low quality List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 08161fd3b207105847bdd1dd8729ea4cbda6e537 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641476808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uUmjEFnFDAW80+xpyzJEgWthmGx6gn6JkOdC3/7udug=; b=aIag0FRVSGs8N6XJEm++0x2d/a1RjjtaHXlO1//uMqW+aD73cbraJulz9mEsuxa4eNw6Yz ySd4S6FGXLCRYU2bYZu3PJXskcH7zeOhqFyW5fRqGbMxDtUdy/OR44YbQl8LNnSjgV7/pk ihFhXoVTLQYZi4t/F8oWxtKJbTLIz/tvKX+RrZ1sBm2I865FqFeWVqTDqgv2Ieg2YXAOtq B7ZrHvuZt9saEId0fh5lLcUUibGJZxHGF2NWAs5NAzPyYd+oHInRwzIOQn+s6HTaxjjidp 5MdB91I6h+4nT2zwIHwsJ6rHnTZD4PFIkaMErkgvjlK99lxmB9eFa3ICJqaimQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641476808; a=rsa-sha256; cv=none; b=a81GMMh6/MpQoMyEgvPpa6TAnabm6A9OXiNUWHK9nO/JT9FMA3Mo0yp5ZOj2B8YE4Usy+t oeqwmfEAnqB4c+sln7SWrKlEptMsfAB753tUmggsKUFOAjfefyQYYgTTMTZfMAN4PR5hWb pjZZeKLLheaPwygnzg9LQyvqN9OqUZDximXO0GBODo7gxPjp/yasfZis6LJHvM5PxaihRe U8uStfSBvu8ulyBMlxak7vjZHfeHhLrMS8HlUhqmmKqqS8h6b/hDV+WwcZZN/4cs3vWtCe uYOGK5L8I6d+9eyjQdJ+qCtUivUS5AmY6Z2vxP+Xg/Q8+wY6tE7WDxsVOK5JRA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=08161fd3b207105847bdd1dd8729ea4cbda6e537 commit 08161fd3b207105847bdd1dd8729ea4cbda6e537 Author: Mark Johnston AuthorDate: 2022-01-03 15:14:41 +0000 Commit: Mark Johnston CommitDate: 2022-01-06 13:46:33 +0000 x86: Skip late calibration if our reference timer has low quality Some AMD Geode-based systems end up using the 8254 PIT to calibrate the TSC during late calibration, which doesn't work because that timecounter's mask (65535) is much smaller than its frequency (1193182). Moreover, early calibration is done against the 8254 timer anyway. Work around the problem by simply using early calibration results if no high-quality timecounters exist. PR: 260868 Fixes: 22875f88799e ("x86: Implement deferred TSC calibration") Reported and tested by: mike@sentex.net, Stefan Hegnauer Reviewed by: imp, kib Sponsored by: The FreeBSD Foundation (cherry picked from commit 0e494a9e3fd86ef54899dcbe0268866629096c1e) --- sys/x86/x86/tsc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c index 6debe3ecca6d..6f0ef697cb2f 100644 --- a/sys/x86/x86/tsc.c +++ b/sys/x86/x86/tsc.c @@ -708,7 +708,14 @@ tsc_calibrate(void) if (tsc_disabled) return; + /* + * Avoid using a low-quality timecounter to re-calibrate. In + * particular, old 32-bit platforms might only have the 8254 timer to + * calibrate against. + */ tc = atomic_load_ptr(&timecounter); + if (tc->tc_quality <= 0) + goto calibrated; flags = intr_disable(); cpu = curcpu;