Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1998117rwi; Thu, 3 Nov 2022 11:23:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7R3fEcrhRBkt3DxNmj0p//hVtwbV/dxOHZw4qBjENjPfRoYutQ7R7rKYq9ijoxLrTWRXxF X-Received: by 2002:a17:90b:4f45:b0:213:ccc6:87df with SMTP id pj5-20020a17090b4f4500b00213ccc687dfmr26984224pjb.227.1667499823906; Thu, 03 Nov 2022 11:23:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667499823; cv=none; d=google.com; s=arc-20160816; b=jHn4mnoN80hCgXx/YNJYC1/WPg0SSN6yuB7cfovlRyz1n+Qt0vaxE8HRaX4iAEH7EL iU6KOhggS9wOHOVqHcfNvV5Dv6l+RgVM+dlvTAOtNB/E0FLY4lV6IfcYV8ZNkid44jj9 +EgYKafivKqpvndUs7AgKhSXVHu7r/RIGPm9rGrcneGsgZpTWyumNT/ynHDn1SKOKOIu dzpj6T8lCmR9+jg9xoIgpjNbpKC0SV0xL0u6i+Ufc1JkLvUwBucXmHp5sOrkmDBRTe4e k4chq2uzk+nut6uOHaLxA+z6dRkk1DB01ICPysgZNxy02HVtBFolThKB05fbeJqR4qfW A6VA== 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=2oxuhDe5kV6GjYNF8LuxN2eAqqYyKVRUxh3NgSYoyro=; b=HT6YUBOJnI5wdhApr3TbeQCAbvh86ATLsYUwn2WDIzTiVm//kEsI4ZV2/hB+oHuOy0 2/DYKoztxrqy7MfwUHekMMx15x0UihxdNqVC3tawuMmlV/URuH9OIBjBkGxsYobzG327 +Mh94lNH20GBd7YZv4ssvx7Zow19ePFTZ1O0oJC/iP7G6BhO7k/owSw4tbG+JfORfQvD lJ9CockCmzEjBisox0T5gL31CZQq+un+EnImWYmHnTvSFz9lmXe47eW1H78fkpZJMVXL PlzGVaeL8IGGJbYtH7UsLsAkD6Qvjno+G6P+SOavFMLRwE0sRigp43vYmZNawjYhb/lS WRTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=JtO1ihxo; 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 v30-20020a63151e000000b0044034efb2aesi1921213pgl.869.2022.11.03.11.23.30; Thu, 03 Nov 2022 11:23:43 -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=JtO1ihxo; 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 S231817AbiKCR67 (ORCPT + 97 others); Thu, 3 Nov 2022 13:58:59 -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: 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 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); 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) { @@ -409,13 +415,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 = HVPFN_DOWN(phys_addr); + tsc_msr.pfn = tsc_pfn; hv_set_register(HV_REGISTER_REFERENCE_TSC, tsc_msr.as_uint64); } @@ -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; if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE)) return false; @@ -524,7 +528,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 = HVPFN_DOWN(virt_to_phys(tsc_page)); /* * 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 = hv_get_register(HV_REGISTER_REFERENCE_TSC); tsc_msr.enable = 1; - tsc_msr.pfn = HVPFN_DOWN(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);