kernel_samsung_a53x/drivers/clocksource
Naman Jain a5135d9c45 x86/hyperv: Fix hv tsc page based sched_clock for hibernation
commit bcc80dec91ee745b3d66f3e48f0ec2efdea97149 upstream.

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 e5313f1c5404 ("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: 1349401ff1aa ("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>
Signed-off-by: Naman Jain <namjain@linux.microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-01-15 16:29:52 +01:00
..
acpi_pm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
arc_timer.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
arm_arch_timer.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
arm_global_timer.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
armv7m_systick.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
asm9260_timer.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bcm2835_timer.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bcm_kona_timer.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
clksrc-dbx500-prcmu.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
clksrc_st_lpc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
clps711x-timer.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dummy_timer.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dw_apb_timer.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dw_apb_timer_of.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
em_sti.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
exynos_mct.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
exynos_mct_v2.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
exynos_mct_v2.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
h8300_timer8.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
h8300_timer16.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
h8300_tpu.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hyperv_timer.c x86/hyperv: Fix hv tsc page based sched_clock for hibernation 2025-01-15 16:29:52 +01:00
i8253.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ingenic-ost.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ingenic-sysost.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ingenic-timer.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
jcore-pit.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig Revert "clkdev: remove CONFIG_CLKDEV_LOOKUP" 2025-01-02 17:01:18 +01:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mips-gic-timer.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmio.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mps2-timer.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mxs_timer.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nomadik-mtu.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
numachip.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
renesas-ostm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
samsung_pwm_timer.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scx200_hrt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sh_cmt.c clocksource/drivers/sh_cmt: Address race condition for clock events 2024-11-23 23:20:23 +01:00
sh_mtu2.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sh_tmu.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-armada-370-xp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-atcpit100.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-atlas7.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-atmel-pit.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-atmel-st.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-atmel-tcb.c clocksource/drivers/timer-atmel-tcb: Fix initialization on SAM9 hardware 2024-11-18 11:43:12 +01:00
timer-cadence-ttc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-clint.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-cs5535.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-davinci.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-digicolor.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-efm32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-fsl-ftm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-fttmr010.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-gx6605s.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-imx-gpt.c clocksource/drivers/timer-imx-gpt: Fix potential memory leak 2024-11-18 11:43:12 +01:00
timer-imx-sysctr.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-imx-tpm.c Revert "clocksource/drivers/imx-tpm: Fix return -ETIME when delta exceeds INT_MAX" 2024-11-24 00:23:37 +01:00
timer-integrator-ap.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-ixp4xx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-keystone.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-lpc32xx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-mediatek.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-meson6.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-microchip-pit64b.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-milbeaut.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-mp-csky.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-npcm7xx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-nps.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-of.c Revert "clocksource/drivers/timer-of: Remove percpu irq related code" 2024-11-24 00:23:37 +01:00
timer-of.h Revert "clocksource/drivers/timer-of: Remove percpu irq related code" 2024-11-24 00:23:37 +01:00
timer-orion.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-owl.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-oxnas-rps.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-pistachio.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-prima2.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-probe.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-pxa.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-qcom.c Revert "clocksource/drivers/qcom: Add missing iounmap() on errors in msm_dt_timer_init()" 2024-11-24 00:23:27 +01:00
timer-rda.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-riscv.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-rockchip.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-sp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-sp804.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-sprd.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-stm32-lp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-stm32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-sun4i.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-sun5i.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-tango-xtal.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-tegra.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-ti-32k.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-ti-dm-systimer.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-ti-dm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-u300.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-versatile.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-vf-pit.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-vt8500.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timer-zevio.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00