Re: [PATCH v1] rtc: mpfs: fix counter upload completion condition
From: Conor Dooley
Date: Tue Jun 02 2026 - 05:27:18 EST
Hey Alexandrew,
On Wed, May 13, 2026 at 06:55:55PM +0100, Conor Dooley wrote:
> From: Conor Dooley <conor.dooley@xxxxxxxxxxxxx>
>
> The condition that needs to be checked for upload completion is the
> UPLOAD bit in the completion register going low. The original iterations
> of this driver used a do-while and this was converted to a
> read_poll_timeout() during upstreaming without the condition being
> inverted as it should have been.
>
> I suspect that this went unnoticed until now because a) the first read
> was done when the bit was still set, immediately completing the
> read_poll_timeout() and b) because the RTC doesn't hold time when power
> is removed from the SoC reducing its utility (I for one keep it
> disabled). If my first suspicion was true when the driver was
> upstreamed, it's not true any longer though, hence the detection of the
> problem.
>
> Fixes: 0b31d703598dc ("rtc: Add driver for Microchip PolarFire SoC")
> CC: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Conor Dooley <conor.dooley@xxxxxxxxxxxxx>
Any chance this could be applied as 7.1 fixes material?
Apologies if I missed an application mail somewhere,
Conor.
> ---
> CC: Valentina.FernandezAlanis@xxxxxxxxxxxxx
> CC: Conor Dooley <conor.dooley@xxxxxxxxxxxxx>
> CC: Daire McNamara <daire.mcnamara@xxxxxxxxxxxxx>
> CC: Alexandre Belloni <alexandre.belloni@xxxxxxxxxxx>
> CC: linux-riscv@xxxxxxxxxxxxxxxxxxx
> CC: linux-rtc@xxxxxxxxxxxxxxx
> CC: linux-kernel@xxxxxxxxxxxxxxx
> ---
> drivers/rtc/rtc-mpfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/rtc-mpfs.c b/drivers/rtc/rtc-mpfs.c
> index 6aa3eae575d2a..ece6de4a6adbd 100644
> --- a/drivers/rtc/rtc-mpfs.c
> +++ b/drivers/rtc/rtc-mpfs.c
> @@ -112,7 +112,7 @@ static int mpfs_rtc_settime(struct device *dev, struct rtc_time *tm)
> ctrl |= CONTROL_UPLOAD_BIT;
> writel(ctrl, rtcdev->base + CONTROL_REG);
>
> - ret = read_poll_timeout(readl, prog, prog & CONTROL_UPLOAD_BIT, 0, UPLOAD_TIMEOUT_US,
> + ret = read_poll_timeout(readl, prog, !(prog & CONTROL_UPLOAD_BIT), 0, UPLOAD_TIMEOUT_US,
> false, rtcdev->base + CONTROL_REG);
> if (ret) {
> dev_err(dev, "timed out uploading time to rtc");
> --
> 2.53.0
>
Attachment:
signature.asc
Description: PGP signature