Skip to content

Commit 3d5c2f8

Browse files
JackyBaidlezcano
authored andcommitted
clocksource/drivers/imx-tpm: Fix next event not taking effect sometime
The value written into the TPM CnV can only be updated into the hardware when the counter increases. Additional writes to the CnV write buffer are ignored until the register has been updated. Therefore, we need to check if the CnV has been updated before continuing. This may require waiting for 1 counter cycle in the worst case. Cc: stable@vger.kernel.org Fixes: 059ab7b ("clocksource/drivers/imx-tpm: Add imx tpm timer support") Signed-off-by: Jacky Bai <ping.bai@nxp.com> Reviewed-by: Peng Fan <peng.fan@nxp.com> Reviewed-by: Ye Li <ye.li@nxp.com> Reviewed-by: Jason Liu <jason.hui.liu@nxp.com> Signed-off-by: Frank Li <Frank.Li@nxp.com> Link: https://lore.kernel.org/r/20240725193355.1436005-2-Frank.Li@nxp.com Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
1 parent 5b8843f commit 3d5c2f8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/clocksource/timer-imx-tpm.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ static int tpm_set_next_event(unsigned long delta,
9090
writel(next, timer_base + TPM_C0V);
9191
now = tpm_read_counter();
9292

93+
/*
94+
* Need to wait CNT increase at least 1 cycle to make sure
95+
* the C0V has been updated into HW.
96+
*/
97+
if ((next & 0xffffffff) != readl(timer_base + TPM_C0V))
98+
while (now == tpm_read_counter())
99+
;
100+
93101
/*
94102
* NOTE: We observed in a very small probability, the bus fabric
95103
* contention between GPU and A7 may results a few cycles delay

0 commit comments

Comments
 (0)