From patchwork Tue Nov 29 09:40:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Li X-Patchwork-Id: 27127 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp231014wrr; Tue, 29 Nov 2022 01:36:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf570duyQTuJXVryiyAM2GL2ZeneyWUnWtQAONXmmOyxNQMC8bGW26ZOxIM+sNA8f/y1nc0o X-Received: by 2002:a17:90b:2542:b0:1fb:e7a:79b with SMTP id nw2-20020a17090b254200b001fb0e7a079bmr65822850pjb.93.1669714567144; Tue, 29 Nov 2022 01:36:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669714567; cv=none; d=google.com; s=arc-20160816; b=wR0vohZXNNooJkhpxxK6J6W8OYIqxXc3nBTF0Qu78/FE5mZvVBvh7b1vLZhg7ae02E xosiKhJvPnMvnh8vm0GTHYy2AmaqzjPeSLXUojBoA/2NyrviAOgaPnucH0Ii11nNz5yI 8HpSjKZWrotfa9aFVoyoMb2wAPENyNo859f1BADfxddrYyzoL81+E2i0TOmNnMflmsre 9e8JIPrRvx/cSsmt+5B/Mw58V9x8LHw6STuD1wH+95ZZLjZ1N+kDKdVktTniJ1DsXP4o TeunaQDfKUVjw4sKkNCqWOx9LX7SgBboIFYC9uLTGn5Tb8LnceE4tJxvVadvbUOpJjOF Ss0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=PhGo3knCZXGt9WL5tWopDAkxG4eDvMMeiC+1TRMj/9Y=; b=SQABZYiu9Q9tgIb+7FuISILMDgy1fSxijdihGGmA66hezhKzuHVoSB3mlpot+2tjdD z+V370Eeu3eNZfZp8he/DjvlYaugHMeuGyuJUQQoQ8TIlQ+tb+RZzCNdyKfh+V+NQ0eR nUnGzqGwwHCScfzFNnr6Mc2lbnNBMJMBrJwUC2GqJ86OTvh07+eNJd9sw6ny7qz+mJqQ 4PiwqNCqwUstZ1LzzJrucGBhs5OF+NVfj0vXIpUYK4x4HvQxKAFBE9J7n0OjWpQMwYJI Q1b5MdAKe2rPGon3XlvLIn1ZxXuXfZ80o0TzZxgBiCcftNKTdNN6aX6YJDA0zfSnfuB2 S49g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZwIOuJmV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h5-20020a170902f7c500b00188fd934f6fsi12938158plw.162.2022.11.29.01.35.53; Tue, 29 Nov 2022 01:36:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZwIOuJmV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231171AbiK2JbL (ORCPT + 99 others); Tue, 29 Nov 2022 04:31:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230243AbiK2JbI (ORCPT ); Tue, 29 Nov 2022 04:31:08 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA9645BD78 for ; Tue, 29 Nov 2022 01:31:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669714267; x=1701250267; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=zn3TgpOyCXFjKnPgeNLXh/qa7scJstQOq8wptR6uaRs=; b=ZwIOuJmVRSftgKimfFx42E5ofmTP29mP/LNyR12jCuOwyyQPjpwdIfgd rp+TQuzRLDd8k5mSAokt9bPqPkb+rgl+JPRbhAgvpzCQdQX4bq9kKFduj gfmKIp45/KOKtozL6ssk4zxJirjCzS6+K/p2YsXHxTHKW2tzj9ghFbMLE j0Q9zlaiWmJgaYcMNt+wH2dcUNe9APDFSXyyK9l05sEtqtrA7Xg55ffQy 34dCHhmuDQhLEfNY9M0P0z+MIifhzUq3UkMGoqyIwcon062e6iNtn+JEk THV38e6z8/ZciZ5uvi738KROIfCmyJkYTOl4jF9fP3pxVHpvCKGWnCTp+ g==; X-IronPort-AV: E=McAfee;i="6500,9779,10545"; a="313768965" X-IronPort-AV: E=Sophos;i="5.96,202,1665471600"; d="scan'208";a="313768965" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 01:31:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10545"; a="785974964" X-IronPort-AV: E=Sophos;i="5.96,202,1665471600"; d="scan'208";a="785974964" Received: from louislifei-optiplex-7090.sh.intel.com ([10.239.146.218]) by fmsmga001.fm.intel.com with ESMTP; 29 Nov 2022 01:31:04 -0800 From: Fei Li To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: bp@alien8.de, peterz@infradead.org, dave.hansen@intel.com, gregkh@linuxfoundation.org, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, hpa@zytor.com, yu1.wang@intel.com, conghui.chen@intel.com, fengwei.yin@intel.com, junjie.mao@intel.com Subject: [PATCH v3] x86/acrn: Set X86_FEATURE_TSC_KNOWN_FREQ Date: Tue, 29 Nov 2022 17:40:25 +0800 Message-Id: <20221129094025.907760-1-fei1.li@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750822621967207036?= X-GMAIL-MSGID: =?utf-8?q?1750822621967207036?= Using hypervisor-provided TSC frequency is common practice for guests. However, for a Linux guest, it may still to reclibrate the ACRN-specific TSC frequency if X86_FEATURE_TSC_KNOWN_FREQ flag is not set. When TSC frequency is known (retrieved from ACRN hypervisor), skip TSC refined calibration by setting X86_FEATURE_TSC_KNOWN_FREQ. Also remove `inline` for acrn_get_tsc_khz() since it doesn't make sense. Signed-off-by: Fei Li Reviewed-by: Yin, Fengwei --- v3: Update the commit message base on Borislav's comments v2: Detail the commit message --- arch/x86/include/asm/acrn.h | 5 ----- arch/x86/kernel/cpu/acrn.c | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) base-commit: b7b275e60bcd5f89771e865a8239325f86d9927d diff --git a/arch/x86/include/asm/acrn.h b/arch/x86/include/asm/acrn.h index 1dd14381bcb6..aa12c74ea959 100644 --- a/arch/x86/include/asm/acrn.h +++ b/arch/x86/include/asm/acrn.h @@ -30,11 +30,6 @@ static inline u32 acrn_cpuid_base(void) return 0; } -static inline unsigned long acrn_get_tsc_khz(void) -{ - return cpuid_eax(ACRN_CPUID_TIMING_INFO); -} - /* * Hypercalls for ACRN * diff --git a/arch/x86/kernel/cpu/acrn.c b/arch/x86/kernel/cpu/acrn.c index 485441b7f030..c5ff75b6a949 100644 --- a/arch/x86/kernel/cpu/acrn.c +++ b/arch/x86/kernel/cpu/acrn.c @@ -24,6 +24,12 @@ static u32 __init acrn_detect(void) return acrn_cpuid_base(); } +static unsigned long acrn_get_tsc_khz(void) +{ + setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ); + return cpuid_eax(ACRN_CPUID_TIMING_INFO); +} + static void __init acrn_init_platform(void) { /* Setup the IDT for ACRN hypervisor callback */