Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp592065rwi; Wed, 2 Nov 2022 15:54:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4PZKvLJBQQFueEhtEc3R/ZywEgyoLSUr+e5l2SbAAVxeWeOfe66KCwwPRpNRreSGyhcb4/ X-Received: by 2002:a17:90a:db93:b0:214:1671:a106 with SMTP id h19-20020a17090adb9300b002141671a106mr9862450pjv.4.1667429669208; Wed, 02 Nov 2022 15:54:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667429669; cv=none; d=google.com; s=arc-20160816; b=0flS4ttgKB62WKBqM8a/QDKm1nY1Dm8aOfOvtcwsvy7ntWc9QmlfLpsVpn/YHvkZco UBEnET4GLGKhYyMqgP1pmfzrdXywLC3llYkoc6APr6BbycMv0rbpkgH1orcvNaSJimz/ GXxfHwQVDeaL7eWceUjFBoz0otL9nV5SVvbE5N6uRYyyYJ4nd15ju+HvYG4+b3+IEBvb kI+Bq7EwLS9TaOYkPIC+GmSgbREpp0UOb0444U7/ou9gA/t4h5Qoz1gS4ChcpYNrheIM 1i1UMundvsYon8H7s4mqj90Zrs555dgHKAzQK2U7JQcL0G34w0WXBzyICSEI8HkFMbSk 39lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:from:subject :dkim-signature:dkim-filter; bh=kY+BUE9K0z7WzM/4fFPpfyIF7753x1wgzUWR7hXp/x0=; b=OEOkZzUuHoyXr89L2ZnP/dtW/ih+seO0Ece2T3cDjSjO5yLbO4c9v3Pa4ZL8l4z3Bt RZhyUJ4i2cQs9FdsUl1EPDX+Jh5LnNX57j5gqESilGyuGR8CR3BUK+JSaek7a/d18nIf iHonIwaa/g6k9oetOTEld95xTOuKjQhJW7dSsH7iB2f/CLZ44ICAv8Vv4w7/yYUNec8w 2jHBtqxGLkl5O37ZMuQ+aXF9aqLwKLJJvajHs/OZ3ldkCjPxK1KGBhTOHq2ekcbegNFE RE7XnyIhiT2Ir7qW6rSQ+tYbfwbbVeW52pT9LpqtQssTNkMhS2qT/cSxQBOWr/xL/iWR To0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="L4FuYqO/"; 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=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m18-20020a170902f21200b00186aee053fbsi14596192plc.287.2022.11.02.15.54.16; Wed, 02 Nov 2022 15:54:29 -0700 (PDT) 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=@linux.microsoft.com header.s=default header.b="L4FuYqO/"; 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=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231358AbiKBWHw (ORCPT + 97 others); Wed, 2 Nov 2022 18:07:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231351AbiKBWHh (ORCPT ); Wed, 2 Nov 2022 18:07:37 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C904495BE; Wed, 2 Nov 2022 15:07:29 -0700 (PDT) Received: from skinsburskii-cloud-desktop.internal.cloudapp.net (unknown [20.120.152.163]) by linux.microsoft.com (Postfix) with ESMTPSA id 9A4E520C3338; Wed, 2 Nov 2022 15:07:29 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9A4E520C3338 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1667426849; bh=kY+BUE9K0z7WzM/4fFPpfyIF7753x1wgzUWR7hXp/x0=; h=Subject:From:Cc:Date:In-Reply-To:References:From; b=L4FuYqO/vqafsHv/73V3g0T0SCIp+a7+bQ8cFrMEbqI37gNSJWXzZFSbzEVb/5Bma SG79tXdxgL2fPsvVMzAvsqTCtUPzjNQ8TCq7lY43flCGio3Tmzt8ae5BEf8dbYymvz fYqtXCOibXzgziqh7Z4BvKaKws7yUvF4OiueZFyk= Subject: [PATCH v2 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 Date: Wed, 02 Nov 2022 22:07:29 +0000 Message-ID: <166742684944.205987.13495997217797904022.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net> In-Reply-To: <166742670556.205987.18227942188746093700.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net> References: <166742670556.205987.18227942188746093700.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: 7bit X-Spam-Status: No, score=-18.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,MISSING_HEADERS, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 --- drivers/clocksource/hyperv_timer.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c index c4dbf40a3d3e..d447bc99a399 100644 --- a/drivers/clocksource/hyperv_timer.c +++ b/drivers/clocksource/hyperv_timer.c @@ -367,6 +367,12 @@ static union { } tsc_pg __aligned(PAGE_SIZE); static struct ms_hyperv_tsc_page *tsc_page = &tsc_pg.page; +static unsigned long tsc_pfn; + +static unsigned long hv_get_tsc_pfn(void) +{ + return tsc_pfn; +} struct ms_hyperv_tsc_page *hv_get_tsc_page(void) { @@ -408,13 +414,12 @@ static void suspend_hv_clock_tsc(struct clocksource *arg) static void resume_hv_clock_tsc(struct clocksource *arg) { - phys_addr_t phys_addr = virt_to_phys(tsc_page); union hv_reference_tsc_msr tsc_msr; /* Re-enable the TSC page */ tsc_msr.as_uint64 = hv_get_register(HV_REGISTER_REFERENCE_TSC); tsc_msr.enable = 1; - tsc_msr.pfn = __phys_to_pfn(phys_addr); + tsc_msr.pfn = tsc_pfn; hv_set_register(HV_REGISTER_REFERENCE_TSC, tsc_msr.as_uint64); } @@ -498,7 +503,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; if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE)) return false; @@ -523,7 +527,7 @@ static bool __init hv_init_tsc_clocksource(void) } hv_read_reference_counter = read_hv_clock_tsc; - phys_addr = virt_to_phys(hv_get_tsc_page()); + tsc_pfn = __phys_to_pfn(virt_to_phys(tsc_page)); /* * The Hyper-V TLFS specifies to preserve the value of reserved @@ -534,7 +538,7 @@ static bool __init hv_init_tsc_clocksource(void) */ tsc_msr.as_uint64 = hv_get_register(HV_REGISTER_REFERENCE_TSC); tsc_msr.enable = 1; - tsc_msr.pfn = __phys_to_pfn(phys_addr); + tsc_msr.pfn = tsc_pfn; hv_set_register(HV_REGISTER_REFERENCE_TSC, tsc_msr.as_uint64); clocksource_register_hz(&hyperv_cs_tsc, NSEC_PER_SEC/100);