Received: by 10.213.65.68 with SMTP id h4csp2115937imn; Sun, 8 Apr 2018 20:06:43 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+j7A6rFfQQq+q+Iw1VZKLIJJEnOKCLV7BJ1zjbqRgzSdPOaxM7/3PSVSwYjGgCsE9Pv23I X-Received: by 10.98.150.198 with SMTP id s67mr27943518pfk.191.1523243203816; Sun, 08 Apr 2018 20:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243203; cv=none; d=google.com; s=arc-20160816; b=Srf8zA/nTjJkHOV8be0ljiuxla+DyvZUE3imztRD/IZTjDEdR67NcYjzgpwD6x1bhS SQzNZn/ZGyNmTwiDuEM7kWLe76i3QGtXK4Z3tRggIZtrFv67FCAjVL9wvRdFybqhm7PZ kcaZRytfeRnX1QE3yoVYUMVckgvoytbyahuZIUkr5gkRz0KlauAEo3D3tEpmosRZ7XkS nUjW8dYNHzuPbl0rnN0Tl4hxBI0Qiz8TXWgsOEaXGvCW9pxj0QwWobwRsucpWS8XGry/ 2u1TcgmYXUU7fJL0W1Xn4OAdwuH1YbGBkMBxzy5HsbMnQ7hF9C8U4waLMQX+4mmEy2oO Me6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=8hWPdG3N4/oGpGBYFb511GqCOPYGVrRcI0g2M7jRCxg=; b=gTeWjWQQfzLMxyZcHIN7ZHb57A9ALNr0KFpMXGWOT6hZkXSFwPh/S8uoCiVen+pf2I eoBNaodh5GVMCJVK2qH1vlygkkra1+DeJkRpYMAhXTJNUGHQ7lGASmFTgTD1zTPcCA93 rWkGIPrt+6l3nMuafjXaLFIqm8u+F/1MiGppu1jaf7/SF7OuEWDaviHldG8udpGD4tL2 yyohCSXAW0kVI8jkmNzEzFfioaw8UdRuSmqb92AjBGmokMPzU31po//AIvgyqaAXMJeQ T6i3mBbZGbsfhw7deDC1AVoiFqIhBkzz4MrEAVHYXxI2Gahb0nihnV2HkWatFyciBA6d Kodg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=YEYOngwb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n16-v6si13517230pll.66.2018.04.08.20.06.06; Sun, 08 Apr 2018 20:06:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=YEYOngwb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756537AbeDIAcv (ORCPT + 99 others); Sun, 8 Apr 2018 20:32:51 -0400 Received: from mail-by2nam01on0095.outbound.protection.outlook.com ([104.47.34.95]:38400 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755585AbeDIAcr (ORCPT ); Sun, 8 Apr 2018 20:32:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=8hWPdG3N4/oGpGBYFb511GqCOPYGVrRcI0g2M7jRCxg=; b=YEYOngwbSBDKuVsPcXALK3Nx49aooOyg2pybS3bPxtS7aEigvuFK6Kbhv1CJcTbTtP7tl3EjXwBuNcu9UjJK6UTLNNVeLc0nPOF3ID10Km1gKLLPpbk/q4alqzsQkiLSjn7mJS4kqoIe3aK5KwWMRkQ4MJNfT9XDgPJofzQlv1w= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0806.namprd21.prod.outlook.com (10.167.107.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.3; Mon, 9 Apr 2018 00:32:44 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:32:44 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Peter Zijlstra , Thomas Gleixner , "len.brown@intel.com" , "rui.zhang@intel.com" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 211/293] x86/tsc: Allow TSC calibration without PIT Thread-Topic: [PATCH AUTOSEL for 4.9 211/293] x86/tsc: Allow TSC calibration without PIT Thread-Index: AQHTz5lJ446hP3ITd0aMSrl1Ri9UZw== Date: Mon, 9 Apr 2018 00:25:38 +0000 Message-ID: <20180409002239.163177-211-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0806;7:gztrUmzl8vj636TkEVU1etTa+QGf5haOx63RnlKZJulxFSBnIi5vYTIc3LFh1ReSshFrIc05KnXJea8HQ5KmqUNT8M6p6WJyDENeza71QBc9DZU0xEVlXK5TJsf725c+TUDsZIP7vEJ1r4Tb832QtUt7KI0oVgP96G7Is4z0tCO9fvfE9zUGLxhLkLEttqRsuiJvsMsw964WkKtVIKuT/1NWpoZbIkzD7gMUC4cQIhw6P7ozJ4uobMMbvg0tOl7E;20:AGybD0WQTfHgdbfJL0m/nrfQ7Mx3PWUKA40BaftLAxIFk9Rj/9OXE0MRIhXDlQEIRW0ZSqPq1pdAXWLSHKvVTGyj8OC8ELu9agKGzyBMVmVe0gla4AwrpuTgwhOGuicSCepm6dY0jwlBytbih1SeYoGDEZByn8BUCBoaYmx28Ts= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 8b98badf-941f-44a4-7455-08d59db1693d x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0806; x-ms-traffictypediagnostic: DM5PR2101MB0806: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(42068640409301)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB0806;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0806; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(376002)(396003)(366004)(39380400002)(199004)(189003)(2906002)(25786009)(2501003)(10290500003)(476003)(11346002)(446003)(97736004)(5250100002)(68736007)(2616005)(102836004)(6506007)(3846002)(3660700001)(486006)(3280700002)(305945005)(6666003)(99286004)(5660300001)(76176011)(1076002)(186003)(26005)(7736002)(6116002)(81156014)(81166006)(86612001)(4326008)(105586002)(10090500001)(2900100001)(54906003)(22452003)(316002)(36756003)(110136005)(107886003)(8676002)(6436002)(478600001)(53936002)(66066001)(6486002)(6512007)(6306002)(86362001)(966005)(14454004)(72206003)(8936002)(106356001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0806;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: LTlB0tx6aHzzIhv01qTIbudi5mrV2aT2INhr7e3jeer7ue6P7XrpHCM0KBRBtNzvMhqf2kf3BRSyvtG/9d7QkJa9eRm2PnwQvijJQaEfKOn6QypjLhqPGbEl9ox91ng2LcRmIjSIv+thCRdpmCA7AI/aZU39isbvvAQOYwIm+/Yyyr0thYe4syLJprOrTv+cVooCbYje9wtKlIP9wvCK+Z3mZHVKYGm9rOTaP+8Ivbopycq3kogxe2Sfs3s64x5K+PkcJPDnFVbj4iKbdlQCRte7zkkg8peGZbLjVURmbnyfhZTZ+vqYEjfq32PMZwDUHqa2mv1EaFx240FHrQIbjSEu3/wECaevUUpHdvFsNvtnkEnvz19iKD++qT1/BniCxd3lDUVFzldGZDCHpEsnQV+Q0FABnQ8biXjjzxbqDMk= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b98badf-941f-44a4-7455-08d59db1693d X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:25:38.7534 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0806 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra [ Upstream commit 30c7e5b123673d5e570e238dbada2fb68a87212c ] Zhang Rui reported that a Surface Pro 4 will fail to boot with lapic=3Dnotscdeadline. Part of the problem is that that machine doesn't hav= e a PIT. If, for some reason, the TSC init has to fall back to TSC calibration, it relies on the PIT to be present. Allow TSC calibration to reliably fall back to HPET. The below results in an accurate TSC measurement when forced on a IVB: tsc: Unable to calibrate against PIT tsc: No reference (HPET/PMTIMER) available tsc: Unable to calibrate against PIT tsc: using HPET reference calibration tsc: Detected 2792.451 MHz processor Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Thomas Gleixner Cc: len.brown@intel.com Cc: rui.zhang@intel.com Link: https://lkml.kernel.org/r/20171222092243.333145937@infradead.org Signed-off-by: Sasha Levin --- arch/x86/include/asm/i8259.h | 5 +++++ arch/x86/kernel/tsc.c | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h index 39bcefc20de7..bb078786a323 100644 --- a/arch/x86/include/asm/i8259.h +++ b/arch/x86/include/asm/i8259.h @@ -68,6 +68,11 @@ struct legacy_pic { extern struct legacy_pic *legacy_pic; extern struct legacy_pic null_legacy_pic; =20 +static inline bool has_legacy_pic(void) +{ + return legacy_pic !=3D &null_legacy_pic; +} + static inline int nr_legacy_irqs(void) { return legacy_pic->nr_legacy_irqs; diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index d07a9390023e..1845b5dc5a81 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -24,6 +24,7 @@ #include #include #include +#include =20 unsigned int __read_mostly cpu_khz; /* TSC clocks / usec, not used here */ EXPORT_SYMBOL(cpu_khz); @@ -454,6 +455,20 @@ static unsigned long pit_calibrate_tsc(u32 latch, unsi= gned long ms, int loopmin) unsigned long tscmin, tscmax; int pitcnt; =20 + if (!has_legacy_pic()) { + /* + * Relies on tsc_early_delay_calibrate() to have given us semi + * usable udelay(), wait for the same 50ms we would have with + * the PIT loop below. + */ + udelay(10 * USEC_PER_MSEC); + udelay(10 * USEC_PER_MSEC); + udelay(10 * USEC_PER_MSEC); + udelay(10 * USEC_PER_MSEC); + udelay(10 * USEC_PER_MSEC); + return ULONG_MAX; + } + /* Set the Gate high, disable speaker */ outb((inb(0x61) & ~0x02) | 0x01, 0x61); =20 @@ -578,6 +593,9 @@ static unsigned long quick_pit_calibrate(void) u64 tsc, delta; unsigned long d1, d2; =20 + if (!has_legacy_pic()) + return 0; + /* Set the Gate high, disable speaker */ outb((inb(0x61) & ~0x02) | 0x01, 0x61); =20 --=20 2.15.1