1
0
Fork 0
mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-01-22 16:06:04 -05:00
linux/drivers/clocksource
Naman Jain bcc80dec91 x86/hyperv: Fix hv tsc page based sched_clock for hibernation
read_hv_sched_clock_tsc() assumes that the Hyper-V clock counter is
bigger than the variable hv_sched_clock_offset, which is cached during
early boot, but depending on the timing this assumption may be false
when a hibernated VM starts again (the clock counter starts from 0
again) and is resuming back (Note: hv_init_tsc_clocksource() is not
called during hibernation/resume); consequently,
read_hv_sched_clock_tsc() may return a negative integer (which is
interpreted as a huge positive integer since the return type is u64)
and new kernel messages are prefixed with huge timestamps before
read_hv_sched_clock_tsc() grows big enough (which typically takes
several seconds).

Fix the issue by saving the Hyper-V clock counter just before the
suspend, and using it to correct the hv_sched_clock_offset in
resume. This makes hv tsc page based sched_clock continuous and ensures
that post resume, it starts from where it left off during suspend.
Override x86_platform.save_sched_clock_state and
x86_platform.restore_sched_clock_state routines to correct this as soon
as possible.

Note: if Invariant TSC is available, the issue doesn't happen because
1) we don't register read_hv_sched_clock_tsc() for sched clock:
See commit e5313f1c54 ("clocksource/drivers/hyper-v: Rework
clocksource and sched clock setup");
2) the common x86 code adjusts TSC similarly: see
__restore_processor_state() ->  tsc_verify_tsc_adjust(true) and
x86_platform.restore_sched_clock_state().

Cc: stable@vger.kernel.org
Fixes: 1349401ff1 ("clocksource/drivers/hyper-v: Suspend/resume Hyper-V clocksource for hibernation")
Co-developed-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Naman Jain <namjain@linux.microsoft.com>
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Link: https://lore.kernel.org/r/20240917053917.76787-1-namjain@linux.microsoft.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Message-ID: <20240917053917.76787-1-namjain@linux.microsoft.com>
2024-12-09 18:42:42 +00:00
..
acpi_pm.c
arc_timer.c
arm_arch_timer.c clocksource/drivers/arm_arch_timer: Use of_property_present() for non-boolean properties 2024-11-13 13:49:33 +01:00
arm_global_timer.c clocksource/drivers/arm_global_timer: Remove clockevents shutdown call on offlining 2024-10-31 10:41:42 +01:00
armv7m_systick.c
asm9260_timer.c
bcm2835_timer.c
bcm_kona_timer.c
clksrc-dbx500-prcmu.c
clksrc_st_lpc.c
clps711x-timer.c
dummy_timer.c
dw_apb_timer.c clocksource/drivers/dw_apb: Remove unused dw_apb_clockevent functions 2024-11-13 13:49:33 +01:00
dw_apb_timer_of.c
em_sti.c
exynos_mct.c clocksource/drivers/exynos_mct: Remove clockevents shutdown call on offlining 2024-10-31 10:41:43 +01:00
hyperv_timer.c x86/hyperv: Fix hv tsc page based sched_clock for hibernation 2024-12-09 18:42:42 +00:00
i8253.c
ingenic-ost.c
ingenic-sysost.c
ingenic-timer.c
jcore-pit.c
Kconfig clocksource/drivers/ralink: Add Ralink System Tick Counter driver 2024-11-13 13:49:33 +01:00
Makefile clocksource/drivers/ralink: Add Ralink System Tick Counter driver 2024-11-13 13:49:33 +01:00
mips-gic-timer.c clocksource/drivers/mips-gic-timer: Always use cluster 0 counter as clocksource 2024-11-13 13:49:33 +01:00
mmio.c
mps2-timer.c
mxs_timer.c
nomadik-mtu.c
numachip.c
renesas-ostm.c
samsung_pwm_timer.c
scx200_hrt.c
sh_cmt.c
sh_mtu2.c
sh_tmu.c
timer-armada-370-xp.c clocksource/drivers/armada-370-xp: Remove clockevents shutdown call on offlining 2024-10-31 10:41:43 +01:00
timer-atmel-pit.c
timer-atmel-st.c
timer-atmel-tcb.c
timer-cadence-ttc.c
timer-clint.c
timer-cs5535.c
timer-davinci.c
timer-digicolor.c
timer-ep93xx.c
timer-fsl-ftm.c
timer-fttmr010.c
timer-goldfish.c
timer-gx6605s.c
timer-gxp.c clocksource/drivers/gpx: Remove redundant casts 2024-11-13 13:49:33 +01:00
timer-imx-gpt.c
timer-imx-sysctr.c
timer-imx-tpm.c
timer-integrator-ap.c
timer-ixp4xx.c
timer-keystone.c
timer-loongson1-pwm.c
timer-lpc32xx.c
timer-mediatek-cpux.c
timer-mediatek.c
timer-meson6.c
timer-microchip-pit64b.c
timer-milbeaut.c
timer-mp-csky.c
timer-msc313e.c
timer-npcm7xx.c
timer-of.c
timer-of.h
timer-orion.c
timer-owl.c
timer-pistachio.c
timer-probe.c
timer-pxa.c
timer-qcom.c clocksource/drivers/qcom: Remove clockevents shutdown call on offlining 2024-10-31 10:41:43 +01:00
timer-ralink.c clocksource/drivers/ralink: Add Ralink System Tick Counter driver 2024-11-13 13:49:33 +01:00
timer-rda.c
timer-riscv.c
timer-rockchip.c
timer-rtl-otto.c
timer-sp.h
timer-sp804.c
timer-sprd.c
timer-stm32-lp.c
timer-stm32.c
timer-sun4i.c
timer-sun5i.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
timer-tegra.c clocksource/drivers/timer-tegra: Remove clockevents shutdown call on offlining 2024-10-31 10:41:43 +01:00
timer-tegra186.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
timer-ti-32k.c
timer-ti-dm-systimer.c clocksource/drivers/arm_arch_timer: Use of_property_present() for non-boolean properties 2024-11-13 13:49:33 +01:00
timer-ti-dm.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
timer-versatile.c
timer-vf-pit.c
timer-vt8500.c
timer-zevio.c