spi: cadence-quadspi: fix potential malfunction after ~49 days uptime
authorRonald Wahl <ronald.wahl@legrand.com>
Wed, 11 Dec 2024 20:51:04 +0000 (21:51 +0100)
committerTom Rini <trini@konsulko.com>
Wed, 22 Jan 2025 17:21:58 +0000 (11:21 -0600)
commit3d729838b3206c7c009bbc94f49c5265719198d0
tree2ab5d00e8ada1ab342aa0ae9ecca5f6da302a29b
parent82d262ae162d859d3b0bbcd40a9464e890b009da
spi: cadence-quadspi: fix potential malfunction after ~49 days uptime

The get_timer function returns an unsigned long which may be calculated
from the ARM system counter. This counter is reset only on a cold reset.
U-boot divides this counter down to a 1000 Hz counter that will cross
the 32bit barrier after a bit more than 49 days. Assigning the value to
an unsigned int will truncate it on 64bit systems.
Passing this truncated value back to the get_timer function will return
a very large value that is certainly larger than the timeout and so will
go down the error path and besides stopping U-Boot will lead to messages
like

    "SPI: QSPI is still busy after poll for 5000 ms."

Signed-off-by: Ronald Wahl <ronald.wahl@legrand.com>
Cc: Vignesh R <vigneshr@ti.com>
Cc: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Vignesh Raghavendra <vigneshr@ti.com>
drivers/spi/cadence_qspi_apb.c