On 2/25/22 1:56 PM, Shuah Khan wrote:
On 2/19/22 12:27 AM, Mateusz Jończyk wrote:
Some problems with reading the RTC time may happen rarely, for example while the RTC is updating. So read the RTC many times to catch these problems. For example, a previous attempt for my commit ea6fa4961aab ("rtc: mc146818-lib: fix RTC presence check") was incorrect and would have triggered this selftest.
To avoid the risk of damaging the hardware, wait 11ms before consecutive reads.
In rtc_time_to_timestamp I copied values manually instead of casting - just to be on the safe side. The 11ms wait period was chosen so that it is not a divisor of 1000ms.
Signed-off-by: Mateusz Jończyk mat.jonczyk@o2.pl Cc: Alessandro Zummo a.zummo@towertech.it Cc: Alexandre Belloni alexandre.belloni@bootlin.com Cc: Shuah Khan shuah@kernel.org
Also, before commit cdedc45c579f ("rtc: cmos: avoid UIP when reading alarm time") reading the RTC alarm time during RTC update produced incorrect results on many Intel platforms. Preparing a similar selftest for this case would be more difficult, though, because the RTC alarm time is cached by the kernel. Direct access would have to be exposed somehow, for example in debugfs. I may prepare a patch for it in the future.
Looks good to me. We end up tweaking the timeout=210 in settings every now and then. Not sure how we can avoid adjusting it as we find problems.
I will apply this in for Linux 5.18-rc1
Applied to linux-kselftest next for Linux 5.18-rc1
thanks, -- Shuah