diff options
author | Stanislav Kinsburskiy <stanislav.kinsburskiy@gmail.com> | 2022-11-03 20:58:54 +0300 |
---|---|---|
committer | Wei Liu <wei.liu@kernel.org> | 2022-11-28 19:48:20 +0300 |
commit | e1f5c66db85fb3e0a17b803fc2e868e9c59c193a (patch) | |
tree | 070a087ba87aebf69b913c6e3049590a52525f06 /drivers/clocksource/hyperv_timer.c | |
parent | 76be6331a81607359cb41ca20ec5388c68c855e3 (diff) | |
download | linux-e1f5c66db85fb3e0a17b803fc2e868e9c59c193a.tar.xz |
clocksource: hyper-v: Introduce TSC PFN getter
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 <stanislav.kinsburskiy@gmail.com>
CC: "K. Y. Srinivasan" <kys@microsoft.com>
CC: Haiyang Zhang <haiyangz@microsoft.com>
CC: Wei Liu <wei.liu@kernel.org>
CC: Dexuan Cui <decui@microsoft.com>
CC: Daniel Lezcano <daniel.lezcano@linaro.org>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: linux-hyperv@vger.kernel.org
CC: linux-kernel@vger.kernel.org
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Reviewed-by: Anirudh Rayabharam <anrayabh@linux.microsoft.com>
Link: https://lore.kernel.org/r/166749833420.218190.2102763345349472395.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Diffstat (limited to 'drivers/clocksource/hyperv_timer.c')
-rw-r--r-- | drivers/clocksource/hyperv_timer.c | 14 |
1 files 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); |