diff options
author | Vitaly Kuznetsov <vkuznets@redhat.com> | 2017-02-04 11:57:13 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-02-10 09:40:19 -0500 |
commit | dee863b571b0a76e9c549ee99e8782bb4bc6502b (patch) | |
tree | c3f69821e106090e79c5a3c7e030616d72cfacd5 | |
parent | 9b06e1018abc65585b07c75c5b3f406dbabe7005 (diff) |
hv: export current Hyper-V clocksource
As a preparation to implementing Hyper-V PTP device supporting
.getcrosststamp we need to export a reference to the current Hyper-V
clocksource in use (MSR or TSC page).
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | arch/x86/hyperv/hv_init.c | 13 | ||||
-rw-r--r-- | arch/x86/include/asm/mshyperv.h | 3 |
2 files changed, 12 insertions, 4 deletions
diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c index b371d0e984a9..c224b7df4d21 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c | |||
@@ -99,6 +99,9 @@ static struct clocksource hyperv_cs_msr = { | |||
99 | }; | 99 | }; |
100 | 100 | ||
101 | static void *hypercall_pg; | 101 | static void *hypercall_pg; |
102 | struct clocksource *hyperv_cs; | ||
103 | EXPORT_SYMBOL_GPL(hyperv_cs); | ||
104 | |||
102 | /* | 105 | /* |
103 | * This function is to be invoked early in the boot sequence after the | 106 | * This function is to be invoked early in the boot sequence after the |
104 | * hypervisor has been detected. | 107 | * hypervisor has been detected. |
@@ -141,10 +144,10 @@ void hyperv_init(void) | |||
141 | union hv_x64_msr_hypercall_contents tsc_msr; | 144 | union hv_x64_msr_hypercall_contents tsc_msr; |
142 | 145 | ||
143 | tsc_pg = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL); | 146 | tsc_pg = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL); |
144 | if (!tsc_pg) { | 147 | if (!tsc_pg) |
145 | clocksource_register_hz(&hyperv_cs_msr, NSEC_PER_SEC/100); | 148 | goto register_msr_cs; |
146 | return; | 149 | |
147 | } | 150 | hyperv_cs = &hyperv_cs_tsc; |
148 | 151 | ||
149 | rdmsrl(HV_X64_MSR_REFERENCE_TSC, tsc_msr.as_uint64); | 152 | rdmsrl(HV_X64_MSR_REFERENCE_TSC, tsc_msr.as_uint64); |
150 | 153 | ||
@@ -161,6 +164,8 @@ void hyperv_init(void) | |||
161 | * the partition counter. | 164 | * the partition counter. |
162 | */ | 165 | */ |
163 | 166 | ||
167 | register_msr_cs: | ||
168 | hyperv_cs = &hyperv_cs_msr; | ||
164 | if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE) | 169 | if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE) |
165 | clocksource_register_hz(&hyperv_cs_msr, NSEC_PER_SEC/100); | 170 | clocksource_register_hz(&hyperv_cs_msr, NSEC_PER_SEC/100); |
166 | } | 171 | } |
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h index 56407c6d2397..7c9c895432a9 100644 --- a/arch/x86/include/asm/mshyperv.h +++ b/arch/x86/include/asm/mshyperv.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <linux/types.h> | 4 | #include <linux/types.h> |
5 | #include <linux/interrupt.h> | 5 | #include <linux/interrupt.h> |
6 | #include <linux/clocksource.h> | ||
6 | #include <asm/hyperv.h> | 7 | #include <asm/hyperv.h> |
7 | 8 | ||
8 | /* | 9 | /* |
@@ -168,6 +169,8 @@ void hv_setup_crash_handler(void (*handler)(struct pt_regs *regs)); | |||
168 | void hv_remove_crash_handler(void); | 169 | void hv_remove_crash_handler(void); |
169 | 170 | ||
170 | #if IS_ENABLED(CONFIG_HYPERV) | 171 | #if IS_ENABLED(CONFIG_HYPERV) |
172 | extern struct clocksource *hyperv_cs; | ||
173 | |||
171 | void hyperv_init(void); | 174 | void hyperv_init(void); |
172 | void hyperv_report_panic(struct pt_regs *regs); | 175 | void hyperv_report_panic(struct pt_regs *regs); |
173 | bool hv_is_hypercall_page_setup(void); | 176 | bool hv_is_hypercall_page_setup(void); |