rtc: mpfs: fix counter upload completion condition
Subsystems (4)
PATCH 1/1 rtc: mpfs: fix counter upload completion condition
From: Conor Dooley <[email protected]>
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.
---
CC: [email protected]
CC: Conor Dooley <[email protected]>
CC: Daire McNamara <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- drivers/rtc/rtc-mpfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-mpfs.c +1 -1
@@ -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" );
Signature · 1 line
2.53.0
Hey Alexandrew,
Quoted 16 lines · Conor Dooley
From: Conor Dooley <[email protected]>
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.
Quoted 3 lines
Fixes 0b31d703598dc ("rtc: Add driver for Microchip PolarFire SoC")Signed-off-by Conor Dooley <[email protected]>
Any chance this could be applied as 7.1 fixes material?
Apologies if I missed an application mail somewhere, Conor.
Quoted 28 lines
---
CC: [email protected]
CC: Conor Dooley <[email protected]>
CC: Daire McNamara <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]--- drivers/rtc/rtc-mpfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/rtc-mpfs.c +1
-1@@ -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" );Signature · 1 line
2.53.0
Quoted 16 lines · Conor Dooley
From: Conor Dooley <[email protected]>
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.
Quoted 3 lines
Fixes 0b31d703598dc ("rtc: Add driver for Microchip PolarFire SoC")Signed-off-by Conor Dooley <[email protected]>
Quoted 25 lines
---
CC: [email protected]
CC: Conor Dooley <[email protected]>
CC: Daire McNamara <[email protected]>
CC: Alexandre Belloni <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]--- drivers/rtc/rtc-mpfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/rtc-mpfs.c +1
-1@@ -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" );
Quoted 14 lines · Conor Dooley
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.
Quoted 1 line
[...]
Applied, thanks!
[1/1] rtc: mpfs: fix counter upload completion condition
https://git.kernel.org/abelloni/c/9792ff8afa90
Best regards,
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Hi Conor,
Quoted 16 lines · Conor Dooley
From: Conor Dooley <[email protected]>
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.
Quoted 3 lines
Fixes 0b31d703598dc ("rtc: Add driver for Microchip PolarFire SoC")Signed-off-by Conor Dooley <[email protected]>
Thanks, this landed as commit 9792ff8afa9017fe ("rtc: mpfs: fix counter upload completion condition") in v7.2-rc1, and finally the endless stream of:
mpfs_rtc 20124000.rtc: timed out uploading time to rtc
is gone!
And no, it didn't go unnoticed, at least not for me, but you couldn't reproduce it reliably before:
https://lore.kernel.org/bce2ca405ef96b1363fd1370887409d9e8468422.1660659437.git.geert+renesas@glider.be/
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Quoted 27 lines · Geert Uytterhoeven
Hi Conor,
Quoted 16 lines · Conor Dooley
From: Conor Dooley <[email protected]>
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.Quoted 3 lines
Fixes 0b31d703598dc ("rtc: Add driver for Microchip PolarFire SoC")Signed-off-by Conor Dooley <[email protected]>Thanks, this landed as commit
9792ff8afa9017fe("rtc: mpfs: fix counter upload completion condition") in v7.2-rc1, and finally the endless stream of:
Quoted 7 lines
mpfs_rtc20124000.rtc: timed out uploading time to rtcis gone!
And no, it didn't go unnoticed, at least not for me, but you couldn't reproduce it reliably before:
https://lore.kernel.org/bce2ca405ef96b1363fd1370887409d9e8468422.1660659437.git.geert+renesas@glider.be/
Oh wow, old mystery solved and not "unnoticed" at all!
To be honest, there's a good chance it'd have been investigated more thoroughly sooner if I had the driver enabled, but I don't given it doesn't hold time powered off. I'm glad it's eventually been solved though.