Skip to content

Commit 749da8c

Browse files
xieyuboKAGA-KOKO
authored andcommitted
clocksource/drivers/hyper-v: Make sched clock return nanoseconds correctly
The sched clock read functions return the HV clock (100ns granularity) without converting it to nanoseconds. Add the missing conversion. Fixes: bd00cd5 ("clocksource/drivers/hyperv: Add Hyper-V specific sched clock function") Signed-off-by: Yubo Xie <[email protected]> Signed-off-by: Tianyu Lan <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Vitaly Kuznetsov <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent 5ad0ec0 commit 749da8c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/clocksource/hyperv_timer.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@ static u64 notrace read_hv_clock_tsc_cs(struct clocksource *arg)
343343

344344
static u64 read_hv_sched_clock_tsc(void)
345345
{
346-
return read_hv_clock_tsc() - hv_sched_clock_offset;
346+
return (read_hv_clock_tsc() - hv_sched_clock_offset) *
347+
(NSEC_PER_SEC / HV_CLOCK_HZ);
347348
}
348349

349350
static void suspend_hv_clock_tsc(struct clocksource *arg)
@@ -398,7 +399,8 @@ static u64 notrace read_hv_clock_msr_cs(struct clocksource *arg)
398399

399400
static u64 read_hv_sched_clock_msr(void)
400401
{
401-
return read_hv_clock_msr() - hv_sched_clock_offset;
402+
return (read_hv_clock_msr() - hv_sched_clock_offset) *
403+
(NSEC_PER_SEC / HV_CLOCK_HZ);
402404
}
403405

404406
static struct clocksource hyperv_cs_msr = {

0 commit comments

Comments
 (0)