linux-stable/drivers/clocksource
Joe Korty 839a973988 clocksource/drivers/arm_arch_timer: Fix XGene-1 TVAL register math error
The TVAL register is 32 bit signed.  Thus only the lower 31 bits are
available to specify when an interrupt is to occur at some time in the
near future.  Attempting to specify a larger interval with TVAL results
in a negative time delta which means the timer fires immediately upon
being programmed, rather than firing at that expected future time.

The solution is for Linux to declare that TVAL is a 31 bit register rather
than give its true size of 32 bits.  This prevents Linux from programming
TVAL with a too-large value.  Note that, prior to 5.16, this little trick
was the standard way to handle TVAL in Linux, so there is nothing new
happening here on that front.

The softlockup detector hides the issue, because it keeps generating
short timer deadlines that are within the scope of the broken timer.

Disabling it, it starts using NO_HZ with much longer timer deadlines, which
turns into an interrupt flood:

 11: 1124855130  949168462  758009394   76417474  104782230   30210281
         310890 1734323687     GICv2  29 Level     arch_timer

And "much longer" isn't that long: it takes less than 43s to underflow
TVAL at 50MHz (the frequency of the counter on XGene-1).

Some comments on the v1 version of this patch by Marc Zyngier:

  XGene implements CVAL (a 64bit comparator) in terms of TVAL (a countdown
  register) instead of the other way around. TVAL being a 32bit register,
  the width of the counter should equally be 32.  However, TVAL is a
  *signed* value, and keeps counting down in the negative range once the
  timer fires.

  It means that any TVAL value with bit 31 set will fire immediately,
  as it cannot be distinguished from an already expired timer. Reducing
  the timer range back to a paltry 31 bits papers over the issue.

  Another problem cannot be fixed though, which is that the timer interrupt
  *must* be handled within the negative countdown period, or the interrupt
  will be lost (TVAL will rollover to a positive value, indicative of a
  new timer deadline).

Fixes: 012f188504 ("clocksource/drivers/arm_arch_timer: Work around broken CVAL implementations")
Signed-off-by: Joe Korty <joe.korty@concurrent-rt.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20221024165422.GA51107@zipoli.concurrent-rt.com
Link: https://lore.kernel.org/r/20221121145343.896018-1-maz@kernel.org

[maz: revamped the commit message]
2022-11-21 16:01:56 +01:00
..
acpi_pm.c clocksource: acpi_pm: fix return value of __setup handler 2022-03-18 14:59:27 +01:00
arc_timer.c clocksource/drivers/arc_timer: Eliminate redefined macro error 2021-10-16 22:15:01 +02:00
arm_arch_timer.c clocksource/drivers/arm_arch_timer: Fix XGene-1 TVAL register math error 2022-11-21 16:01:56 +01:00
arm_global_timer.c clocksource/drivers/arm_global_timer: Remove duplicated argument in arm_global_timer 2021-06-16 17:33:04 +02:00
armv7m_systick.c
asm9260_timer.c
bcm2835_timer.c clocksource: Replace setup_irq() by request_irq() 2020-02-27 12:15:24 +01:00
bcm_kona_timer.c clocksource/drivers/bcm_kona: Convert to SPDX identifier 2022-05-18 11:08:59 +02:00
clksrc-dbx500-prcmu.c timekeeping, clocksource: Fix various typos in comments 2021-03-22 23:06:48 +01:00
clksrc_st_lpc.c
clps711x-timer.c
dummy_timer.c
dw_apb_timer.c clocksource: dw_apb_timer: Make CPU-affiliation being optional 2020-05-23 00:02:41 +02:00
dw_apb_timer_of.c clocksource/drivers/dw_apb_timer_of: Fix probe failure 2021-12-10 17:46:54 +01:00
em_sti.c
exynos_mct.c clocksource/drivers/exynos_mct: Support local-timers property 2022-09-20 10:49:45 +02:00
hyperv_timer.c clocksource/drivers/hyperv: add data structure for reference TSC MSR 2022-11-03 15:50:28 +00:00
i8253.c
ingenic-ost.c clocksource/drivers/ingenic_ost: Fix return value check in ingenic_ost_probe() 2021-04-08 13:24:15 +02:00
ingenic-sysost.c clocksource/drivers/ingenic: Use bitfield macro helpers 2021-08-14 02:44:35 +02:00
ingenic-timer.c clocksource/drivers/ingenic: Add support for the JZ4760 2021-04-08 13:23:22 +02:00
jcore-pit.c clocksource/drivers/jcore: Convert to SPDX identifier 2022-05-18 11:08:59 +02:00
Kconfig clocksource/drivers/exynos_mct: Enable building on ARTPEC 2022-09-20 10:49:45 +02:00
Makefile - Add the missing DT bindings for the MTU nomadik timer (Linus 2022-07-28 12:33:34 +02:00
mips-gic-timer.c clocksource/drivers/mips-gic-timer: Convert to SPDX identifier 2022-05-18 11:08:59 +02:00
mmio.c
mps2-timer.c clocksource/drivers/mps2-timer: Use semicolons rather than commas to separate statements 2020-10-01 10:07:26 +02:00
mxs_timer.c clocksource/drivers/mxs_timer: Add missing semicolon when DEBUG is defined 2021-01-18 22:28:59 +01:00
nomadik-mtu.c clocksource/drivers/nomadik-mtu: Handle 32kHz clock 2020-07-23 16:57:43 +02:00
numachip.c
renesas-ostm.c clocksource/drivers/renesas-ostm: Add support for RZ/V2L SoC 2022-09-07 10:12:56 +02:00
samsung_pwm_timer.c clocksource/drivers/samsung_pwm: Constify source IO memory 2021-06-04 10:12:13 +02:00
scx200_hrt.c
sh_cmt.c clocksource/drivers/sh_cmt: Add R-Car Gen4 support 2022-07-18 22:55:14 +02:00
sh_mtu2.c PM: domains: Rename pm_genpd_syscore_poweroff|poweron() 2020-11-10 20:42:01 +01:00
sh_tmu.c PM: domains: Rename pm_genpd_syscore_poweroff|poweron() 2020-11-10 20:42:01 +01:00
timer-armada-370-xp.c clocksource/drivers/armada-370-xp: Convert to SPDX identifier 2022-05-18 11:08:59 +02:00
timer-atmel-pit.c
timer-atmel-st.c clocksource/drivers/atmel-st: Remove useless 'status' 2020-04-15 10:57:15 +02:00
timer-atmel-tcb.c timekeeping, clocksource: Fix various typos in comments 2021-03-22 23:06:48 +01:00
timer-cadence-ttc.c clocksource/drivers/cadence_ttc: Fix memory leak in ttc_setup_clockevent() 2020-12-03 19:16:26 +01:00
timer-clint.c clocksource: clint: Export clint_time_val for modules 2020-09-29 23:55:27 -07:00
timer-cs5535.c clocksource/drivers/timer-cs5535: Request irq with non-NULL dev_id 2020-03-12 19:23:06 +01:00
timer-davinci.c clocksource/drivers/davinci: Move pr_fmt() before the includes 2021-01-18 16:31:39 +01:00
timer-digicolor.c clocksource/drivers/digicolor: Convert to SPDX identifier 2022-05-18 11:08:59 +02:00
timer-fsl-ftm.c timekeeping, clocksource: Fix various typos in comments 2021-03-22 23:06:48 +01:00
timer-fttmr010.c clocksource/drivers/fttmr010: Pass around less pointers 2021-08-14 10:49:49 +02:00
timer-goldfish.c clocksource/drivers: Add a goldfish-timer clocksource 2022-04-11 11:48:01 +02:00
timer-gx6605s.c clocksource/drivers/timer-gx6605s: Fixup counter reload 2020-08-24 13:01:39 +02:00
timer-gxp.c clocksource/drivers/timer-gxp: Add missing error handling in gxp_timer_probe 2022-09-20 10:49:45 +02:00
timer-imx-gpt.c clocksource: Replace setup_irq() by request_irq() 2020-02-27 12:15:24 +01:00
timer-imx-sysctr.c clocksource/drivers/imx-sysctr: handle nxp,no-divider property 2022-09-20 10:49:46 +02:00
timer-imx-tpm.c clocksource/drivers/imx-tpm: Move tpm_read_sched_clock() under CONFIG_ARM 2022-03-07 18:27:22 +01:00
timer-integrator-ap.c clocksource: Replace setup_irq() by request_irq() 2020-02-27 12:15:24 +01:00
timer-ixp4xx.c clocksource/drivers/ixp4xx: Drop boardfile probe path 2022-05-18 11:08:52 +02:00
timer-keystone.c
timer-lpc32xx.c clocksource/drivers/lpc32xx: Convert to SPDX identifier 2022-05-18 11:08:59 +02:00
timer-mediatek.c clocksource/drivers/timer-mediatek: Implement CPUXGPT timers 2022-07-16 00:41:51 +02:00
timer-meson6.c clocksource: Replace setup_irq() by request_irq() 2020-02-27 12:15:24 +01:00
timer-microchip-pit64b.c clocksource/drivers/timer-microchip-pit64b: Fix compilation warnings 2022-07-16 00:52:43 +02:00
timer-milbeaut.c
timer-mp-csky.c
timer-msc313e.c clocksource/drivers/msc313e: Add support for ssd20xd-based platforms 2021-12-20 13:28:39 +01:00
timer-npcm7xx.c clocksource/drivers/npcm: Add support for WPCM450 2021-04-08 13:24:16 +02:00
timer-of.c clocksource/drivers/timer-of: Check return value of of_iomap in timer_of_base_init() 2022-03-07 19:21:25 +01:00
timer-of.h
timer-orion.c clocksource/drivers/orion: Convert to SPDX identifier 2022-05-18 11:08:59 +02:00
timer-owl.c
timer-oxnas-rps.c clocksource/drivers/oxnas-rps: Fix irq_of_parse_and_map() return value 2022-05-24 09:16:29 +02:00
timer-pistachio.c clocksource/drivers/pistachio: Convert to SPDX identifier 2022-05-18 11:08:59 +02:00
timer-probe.c treewide: Convert macro and uses of __section(foo) to __section("foo") 2020-10-25 14:51:49 -07:00
timer-pxa.c clocksource: Replace setup_irq() by request_irq() 2020-02-27 12:15:24 +01:00
timer-qcom.c
timer-rda.c
timer-riscv.c RISC-V: Add Sstc extension support 2022-08-11 14:41:52 -07:00
timer-rockchip.c
timer-sp.h clocksource/drivers/sp804: Enable Hisilicon sp804 timer 64bit mode 2020-09-24 10:51:04 +02:00
timer-sp804.c clocksource/drivers/sp804: Avoid error on multiple instances 2022-05-18 11:08:52 +02:00
timer-sprd.c
timer-stm32-lp.c clocksource: Add Low Power STM32 timers driver 2020-06-18 11:19:58 +01:00
timer-stm32.c
timer-sun4i.c clocksource/drivers/sun4i: Add definition of clear interrupt 2022-09-20 10:49:39 +02:00
timer-sun5i.c clocksource/drivers/sun5i: Remove unnecessary (void*) conversions 2022-07-27 17:01:52 +02:00
timer-tegra.c
timer-tegra186.c clocksource/drivers/timer-tegra186: Add support for Tegra234 SoC 2022-07-16 00:38:50 +02:00
timer-ti-32k.c clocksource/drivers: Replace HTTP links with HTTPS ones 2020-07-23 16:57:43 +02:00
timer-ti-dm-systimer.c Timers and timekeeping updates: 2022-03-21 12:53:14 -07:00
timer-ti-dm.c clocksource/drivers/timer-ti-dm: Get clock in probe with devm_clk_get() 2022-09-20 10:49:46 +02:00
timer-versatile.c clocksource/drivers/timer-versatile: Clear OF_POPULATED flag 2020-05-23 00:03:25 +02:00
timer-vf-pit.c timekeeping, clocksource: Fix various typos in comments 2021-03-22 23:06:48 +01:00
timer-vt8500.c clocksource: Replace setup_irq() by request_irq() 2020-02-27 12:15:24 +01:00
timer-zevio.c clocksource: Replace setup_irq() by request_irq() 2020-02-27 12:15:24 +01:00