linux-stable/drivers/clocksource
Ronald Wahl 5c186bb85c clocksource/drivers/timer-atmel-tcb: Fix initialization on SAM9 hardware
[ Upstream commit 6d3bc4c02d ]

On SAM9 hardware two cascaded 16 bit timers are used to form a 32 bit
high resolution timer that is used as scheduler clock when the kernel
has been configured that way (CONFIG_ATMEL_CLOCKSOURCE_TCB).

The driver initially triggers a reset-to-zero of the two timers but this
reset is only performed on the next rising clock. For the first timer
this is ok - it will be in the next 60ns (16MHz clock). For the chained
second timer this will only happen after the first timer overflows, i.e.
after 2^16 clocks (~4ms with a 16MHz clock). So with other words the
scheduler clock resets to 0 after the first 2^16 clock cycles.

It looks like that the scheduler does not like this and behaves wrongly
over its lifetime, e.g. some tasks are scheduled with a long delay. Why
that is and if there are additional requirements for this behaviour has
not been further analysed.

There is a simple fix for resetting the second timer as well when the
first timer is reset and this is to set the ATMEL_TC_ASWTRG_SET bit in
the Channel Mode register (CMR) of the first timer. This will also rise
the TIOA line (clock input of the second timer) when a software trigger
respective SYNC is issued.

Signed-off-by: Ronald Wahl <ronald.wahl@raritan.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20231007161803.31342-1-rwahl@gmx.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-28 16:46:31 +00:00
..
Kconfig clocksource/drivers/timer-ti-dm: Select TIMER_OF 2021-11-26 11:36:10 +01:00
Makefile clocksource/drivers: Unify the names to timer-* format 2023-08-11 11:45:02 +02:00
acpi_pm.c clocksource: acpi_pm: fix return value of __setup handler 2022-04-15 14:14:44 +02:00
arc_timer.c
arm_arch_timer.c clocksource/arm_arch_timer: Improve Allwinner A64 timer workaround 2021-07-20 16:16:04 +02:00
arm_global_timer.c
armv7m_systick.c
asm9260_timer.c clocksource/drivers/asm9260: Add a check for of_clk_get 2020-01-04 19:12:44 +01:00
bcm2835_timer.c clocksource/drivers/bcm2835_timer: Fix memory leak of timer 2020-02-24 08:34:37 +01:00
bcm_kona_timer.c
clksrc-dbx500-prcmu.c
clksrc_st_lpc.c
clps711x-timer.c
cs5535-clockevt.c
dummy_timer.c
dw_apb_timer.c clocksource: dw_apb_timer: Make CPU-affiliation being optional 2020-06-22 09:05:11 +02:00
dw_apb_timer_of.c clocksource: dw_apb_timer_of: Fix missing clockevent timers 2020-06-22 09:05:11 +02:00
em_sti.c
exynos_mct.c clocksource/drivers/exynos_mct: Fix error path in timer resources initialization 2020-01-27 14:50:27 +01:00
h8300_timer8.c clocksource/drivers/h8300_timer8: Fix wrong return value in h8300_8timer_init() 2020-10-01 13:14:51 +02:00
h8300_timer16.c
h8300_tpu.c
i8253.c
jcore-pit.c
meson6_timer.c
mips-gic-timer.c
mmio.c
mps2-timer.c
mxs_timer.c clocksource/drivers/mxs_timer: Add missing semicolon when DEBUG is defined 2021-03-04 09:39:44 +01:00
nomadik-mtu.c
numachip.c
pxa_timer.c
renesas-ostm.c
riscv_timer.c clocksource/drivers/riscv: Events are stopped during CPU suspend 2022-06-14 16:59:32 +02:00
rockchip_timer.c
samsung_pwm_timer.c
scx200_hrt.c
sh_cmt.c clocksource/drivers/sh_cmt: Make sure channel clock supply is enabled 2023-01-18 11:30:06 +01:00
sh_mtu2.c
sh_tmu.c
sun4i_timer.c
tango_xtal.c
tcb_clksrc.c clocksource/drivers/timer-atmel-tcb: Fix initialization on SAM9 hardware 2023-11-28 16:46:31 +00:00
tegra20_timer.c
timer-armada-370-xp.c clocksource/drivers: Unify the names to timer-* format 2023-08-11 11:45:02 +02:00
timer-atcpit100.c
timer-atlas7.c
timer-atmel-pit.c
timer-atmel-st.c
timer-cadence-ttc.c clocksource/drivers/cadence-ttc: Fix memory leak in ttc_timer_probe 2023-08-11 11:45:02 +02:00
timer-digicolor.c
timer-efm32.c clocksource/drivers: Unify the names to timer-* format 2023-08-11 11:45:02 +02:00
timer-fsl-ftm.c clocksource/drivers: Unify the names to timer-* format 2023-08-11 11:45:02 +02:00
timer-fttmr010.c clocksource/drivers/fttmr010: Fix invalid interrupt register access 2019-12-05 09:20:38 +01:00
timer-imx-gpt.c clocksource/drivers/timer-imx-gpt: Fix potential memory leak 2023-11-28 16:46:30 +00:00
timer-imx-tpm.c
timer-integrator-ap.c
timer-keystone.c
timer-lpc32xx.c clocksource/drivers: Unify the names to timer-* format 2023-08-11 11:45:02 +02:00
timer-mediatek.c clocksource/drivers/mediatek: Fix error handling 2019-12-05 09:19:35 +01:00
timer-npcm7xx.c
timer-nps.c
timer-of.c clocksource/drivers/timer-of: Check return value of of_iomap in timer_of_base_init() 2022-04-15 14:14:43 +02:00
timer-of.h
timer-orion.c clocksource/drivers: Unify the names to timer-* format 2023-08-11 11:45:02 +02:00
timer-owl.c clocksource/drivers: Unify the names to timer-* format 2023-08-11 11:45:02 +02:00
timer-oxnas-rps.c clocksource/drivers/oxnas-rps: Fix irq_of_parse_and_map() return value 2022-06-14 16:59:33 +02:00
timer-pistachio.c clocksource/drivers: Unify the names to timer-* format 2023-08-11 11:45:02 +02:00
timer-prima2.c
timer-probe.c
timer-qcom.c clocksource/drivers: Unify the names to timer-* format 2023-08-11 11:45:02 +02:00
timer-sp.h
timer-sp804.c clocksource/drivers/sp804: Avoid error on multiple instances 2022-06-14 16:59:37 +02:00
timer-sprd.c
timer-stm32.c
timer-sun5i.c clocksource/drivers/sun5i: Fail gracefully when clock rate is unavailable 2020-01-27 14:50:27 +01:00
timer-ti-32k.c
timer-ti-dm.c bus: ti-sysc: Fix timer handling with drop pm_runtime_irq_safe() 2020-01-27 14:50:16 +01:00
timer-u300.c
timer-versatile.c clocksource/drivers: Unify the names to timer-* format 2023-08-11 11:45:02 +02:00
timer-vf-pit.c clocksource/drivers: Unify the names to timer-* format 2023-08-11 11:45:02 +02:00
timer-vt8500.c clocksource/drivers: Unify the names to timer-* format 2023-08-11 11:45:02 +02:00
timer-zevio.c clocksource/drivers: Unify the names to timer-* format 2023-08-11 11:45:02 +02:00