From nobody Thu Apr 9 04:04:36 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C387C433FE for ; Thu, 3 Nov 2022 17:59:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231819AbiKCR7A (ORCPT ); Thu, 3 Nov 2022 13:59:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231625AbiKCR6z (ORCPT ); Thu, 3 Nov 2022 13:58:55 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8C152100C; Thu, 3 Nov 2022 10:58:54 -0700 (PDT) Received: from skinsburskii-cloud-desktop.internal.cloudapp.net (unknown [20.120.152.163]) by linux.microsoft.com (Postfix) with ESMTPSA id 4986520C28B1; Thu, 3 Nov 2022 10:58:54 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4986520C28B1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1667498334; bh=2oxuhDe5kV6GjYNF8LuxN2eAqqYyKVRUxh3NgSYoyro=; h=Subject:From:Cc:Date:In-Reply-To:References:From; b=JtO1ihxob+SsrhIVYTkWVTsjV7gq4+H3B+vaZm7VECZafo13jgTiSkJMxL4eMzgxl ysZwGbCvQQB0vqTrvA/roMYBcVli7TiT5gtv7f0ZW5vOPO0WzdUEGo0Lyx7WZLIMjR 2qB0HCpnLe3NKPPLYrTs6KrneWDt7cPfb1LZSZJU= Subject: [PATCH v3 2/4] drivers/clocksource/hyper-v: Introduce TSC PFN getter From: Stanislav Kinsburskii Cc: Stanislav Kinsburskiy , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Daniel Lezcano , Thomas Gleixner , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, mikelley@microsoft.com Date: Thu, 03 Nov 2022 17:58:54 +0000 Message-ID: <166749833420.218190.2102763345349472395.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net> In-Reply-To: <166749827889.218190.12775118554387271641.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net> References: <166749827889.218190.12775118554387271641.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stanislav Kinsburskiy And rework the code to use it instead of the physical address, which isn't required by itself. This is a cleanup and precursor patch for upcoming support for TSC page mapping into Microsoft Hypervisor root partition, where TSC PFN will be defined by the hypervisor and not by the kernel. Signed-off-by: Stanislav Kinsburskiy CC: "K. Y. Srinivasan" CC: Haiyang Zhang CC: Wei Liu CC: Dexuan Cui CC: Daniel Lezcano CC: Thomas Gleixner CC: linux-hyperv@vger.kernel.org CC: linux-kernel@vger.kernel.org Reviewed-by: Michael Kelley --- drivers/clocksource/hyperv_timer.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyper= v_timer.c index b0b5df576e17..b7af19d06b51 100644 --- a/drivers/clocksource/hyperv_timer.c +++ b/drivers/clocksource/hyperv_timer.c @@ -368,6 +368,12 @@ static union { } tsc_pg __aligned(PAGE_SIZE); =20 static struct ms_hyperv_tsc_page *tsc_page =3D &tsc_pg.page; +static unsigned long tsc_pfn; + +static unsigned long hv_get_tsc_pfn(void) +{ + return tsc_pfn; +} =20 struct ms_hyperv_tsc_page *hv_get_tsc_page(void) { @@ -409,13 +415,12 @@ static void suspend_hv_clock_tsc(struct clocksource *= arg) =20 static void resume_hv_clock_tsc(struct clocksource *arg) { - phys_addr_t phys_addr =3D virt_to_phys(tsc_page); union hv_reference_tsc_msr tsc_msr; =20 /* Re-enable the TSC page */ tsc_msr.as_uint64 =3D hv_get_register(HV_REGISTER_REFERENCE_TSC); tsc_msr.enable =3D 1; - tsc_msr.pfn =3D HVPFN_DOWN(phys_addr); + tsc_msr.pfn =3D tsc_pfn; hv_set_register(HV_REGISTER_REFERENCE_TSC, tsc_msr.as_uint64); } =20 @@ -499,7 +504,6 @@ static __always_inline void hv_setup_sched_clock(void *= sched_clock) {} static bool __init hv_init_tsc_clocksource(void) { union hv_reference_tsc_msr tsc_msr; - phys_addr_t phys_addr; =20 if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE)) return false; @@ -524,7 +528,7 @@ static bool __init hv_init_tsc_clocksource(void) } =20 hv_read_reference_counter =3D read_hv_clock_tsc; - phys_addr =3D virt_to_phys(hv_get_tsc_page()); + tsc_pfn =3D HVPFN_DOWN(virt_to_phys(tsc_page)); =20 /* * The Hyper-V TLFS specifies to preserve the value of reserved @@ -535,7 +539,7 @@ static bool __init hv_init_tsc_clocksource(void) */ tsc_msr.as_uint64 =3D hv_get_register(HV_REGISTER_REFERENCE_TSC); tsc_msr.enable =3D 1; - tsc_msr.pfn =3D HVPFN_DOWN(phys_addr); + tsc_msr.pfn =3D tsc_pfn; hv_set_register(HV_REGISTER_REFERENCE_TSC, tsc_msr.as_uint64); =20 clocksource_register_hz(&hyperv_cs_tsc, NSEC_PER_SEC/100);