Received: by 10.213.65.68 with SMTP id h4csp2200845imn; Sun, 8 Apr 2018 22:21:19 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/FoMqUHr+s1Y/FkrSC2+VE9G1zF1BsbaxL1/tUKKs256DskW4F/6/Ezn8uCiFdtz9EpzcO X-Received: by 2002:a17:902:a501:: with SMTP id s1-v6mr37438306plq.201.1523251279562; Sun, 08 Apr 2018 22:21:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523251279; cv=none; d=google.com; s=arc-20160816; b=GEsWqCEkXt7aJ1NsT1pjqp/nY6wlK/bbgU/T1GHwLwIQ7cwbwT7tpTXpRUIXwNjrwA SvZH/W4S/HFx3P78PjzM5jddrgRB8r/KdI/d6Sr0TsjR6LGVbBrQaCN+goksDW0B8nyX vztCrso8SEOTxIHsyi1MGICPUZOr5OIcUR9OfOfTrSO88WwOB23KFC74naLL0ksb1hgV i1Fjj/qu2RYkpTrEc67WV7Po068MriZPI2QMcBHcdTVrWp+JaJJ6ZmpYmL2e8Wk53aD9 MZQHEXQuyd9Hr/yYO62XOrkW/rVe1kqDEYkcsfT8vI/ga0ihwzCTd6OyKd1c/rEf4KAT POWQ== 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=A2C2p/i3AEENc6QZtVr2gQFSgqsZbN43PdZQPZlfLVc=; b=u4yGBPqdrmaNxKsxRnmnpbgoyBfcWMgBPmvKCwRN5qu3r39EFLSvCqnZpJ+umHj4nb kkPU9oYbvfEJ92QT97otD/WJ4DxOvfSwfCgFCfqIIxwJNeoaBRYL1YvpNyVF7hnNSGHZ TxhYVeW3yjihBdGLhv6loPtDWwPBKy89l35nKc6AJL6tU4sAfCqYNAgEb8ysdmgtppSZ ZAEuctKBHJlFjKLgSmLKyPiTFAtgf9ly3dwAriJj8EomuRdgPQC6ffTU+nDMAXKOhEUF GTfrAxckFs3IgRUoIDKYk6jKTUGDJGtI3qgZycZUkNJ9xFUb3KsAG6Z3M0ztG5xQJuH+ jCCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=DboLxm3K; 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 h77si12244558pfh.290.2018.04.08.22.20.42; Sun, 08 Apr 2018 22:21:19 -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=DboLxm3K; 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 S1754594AbeDIAWD (ORCPT + 99 others); Sun, 8 Apr 2018 20:22:03 -0400 Received: from mail-sn1nam02on0111.outbound.protection.outlook.com ([104.47.36.111]:52845 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754538AbeDIAWA (ORCPT ); Sun, 8 Apr 2018 20:22:00 -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=A2C2p/i3AEENc6QZtVr2gQFSgqsZbN43PdZQPZlfLVc=; b=DboLxm3KJWPJNgNt5QtaeT+QxKVsPYSYq2IUGXUCRGbvubmmGKSb47ZCqFJ7gH7GwpO7cs/S7hRGHiNIRK1Q3kAK6X0/XsMIYwpeng5cNEy4EvvWDo2UoffqxVBqKgPulqDKQEmYsMzImMPXZHf22OQIWQISXrjL6FEaUrKidT4= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0936.namprd21.prod.outlook.com (52.132.131.166) 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:21:55 +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:21:55 +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.14 002/161] x86/tsc: Allow TSC calibration without PIT Thread-Topic: [PATCH AUTOSEL for 4.14 002/161] x86/tsc: Allow TSC calibration without PIT Thread-Index: AQHTz5h0119NV3tAKE6PTtmIxnKY7w== Date: Mon, 9 Apr 2018 00:19:42 +0000 Message-ID: <20180409001936.162706-2-alexander.levin@microsoft.com> References: <20180409001936.162706-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001936.162706-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;DM5PR2101MB0936;7:O4Li5O1XdEH0H5FrehgSnrU65li8EwglBl54D2MVk9btxhDeIX5vvJAHm+HXUEIi9IXyK+hfzYS+C7l4/NBDdOkoNi3BMLDlhbTWVShwGnKKrpFP9g0ZHSg3bWCrXbKPl8m+Xr4U/vujPdcTOqCmUvZMvEONtBzw47sRInem5r7ULSapZND5PG3AYwiONcBq0SucrPX8Grnq3T6nAiKDjRhZIHpeP6pcK0kVNMWYNEWFH7xzo+yfXOEeAH/d/ODu;20:NhbYBfADKoyRw1WsRJo2zNqBZL9DIapDaPHnX/oADIW/qnzmyxuRAORlcSR3jsJ3roKY3YlIpwjdGKLv2zYWnno7Ea43BWE3gHrQEI0+xVTUfQLwEg827AuhCdt3Dwp/9TEMYjLq15/te7znE75xOOe9G5B+6nUStzKKTL5eonk= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: b1b751e6-37e9-40c4-e9f0-08d59dafe639 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0936; x-ms-traffictypediagnostic: DM5PR2101MB0936: 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)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB0936;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0936; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39380400002)(39860400002)(396003)(376002)(366004)(199004)(189003)(3660700001)(36756003)(2501003)(76176011)(10290500003)(2616005)(5250100002)(3280700002)(478600001)(1076002)(72206003)(6436002)(53936002)(486006)(6306002)(476003)(4326008)(6486002)(107886003)(5660300001)(54906003)(110136005)(102836004)(2906002)(6116002)(3846002)(86612001)(81156014)(81166006)(6666003)(8936002)(305945005)(8676002)(2900100001)(6506007)(68736007)(14454004)(106356001)(105586002)(25786009)(966005)(6512007)(86362001)(99286004)(446003)(10090500001)(11346002)(316002)(26005)(7736002)(66066001)(186003)(22452003)(97736004)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0936;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: z1gvD50oZdfGag1p7a//dNRj4OyqsnZsVIVzkVhAwxOKAmCZNrn9mfM6/ylbrDa5WQF0/cb29P8I8EVcYvzC6NlaujmOMWPqEM78DsR3C9AOrkjZW6WL06GNQ+SpiahJdNgb4aDCXz/Ch3D1jHiGFdnQA1/gxnb2p+r6DmJHMyJoqcTa5TklaVGzWlJwYJzNxcf8lcaXa2yVPC8PMacNdAWzC+sRffqJCW9QRJn8POllSAaCkq0i3rPUgDKpyUXP3Ww1lBQEPnkErH0UuyiN7ZP5ZpNUQn+doTn5+HHO9xhnQmQY0ojmEpciB65DUyXmeBsDDaSoSfk7opfxKRZCe2RrXtjAFYD0A0p/RiKoBXMBCH/7k6ptT7ErJ8Bg7UW+PiYlAIPro4FGMg12szTBOEJX6yF0qPGBVYAjtw54of8= 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: b1b751e6-37e9-40c4-e9f0-08d59dafe639 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:19:42.6717 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0936 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 c8376b40e882..5cdcdbd4d892 100644 --- a/arch/x86/include/asm/i8259.h +++ b/arch/x86/include/asm/i8259.h @@ -69,6 +69,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 47506567435e..03d8e9204a6a 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -25,6 +25,7 @@ #include #include #include +#include =20 unsigned int __read_mostly cpu_khz; /* TSC clocks / usec, not used here */ EXPORT_SYMBOL(cpu_khz); @@ -363,6 +364,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 @@ -487,6 +502,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