]> www.infradead.org Git - users/jedix/linux-maple.git/commit
rtc: pm8xxx: mitigate flash wear
authorJohan Hovold <johan+linaro@kernel.org>
Wed, 19 Feb 2025 13:41:15 +0000 (14:41 +0100)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Mon, 17 Mar 2025 10:53:42 +0000 (11:53 +0100)
commite853658de5ef87a6476987a30f38ce661270cb67
treed918a902d1718e991b9b6d11a3a5bbba6ca3af1a
parentbba38b874886b227283d56ecb2f7ebbaa01a781d
rtc: pm8xxx: mitigate flash wear

On many Qualcomm platforms the PMIC RTC control and time registers are
read-only so that the RTC time can not be updated. Instead an offset
needs be stored in some machine-specific non-volatile memory, which the
driver can take into account.

On machines like the Lenovo ThinkPad X13s the PMIC RTC drifts about one
second every 3.5 hours, something which leads to repeated updates of the
offset when NTP synchronisation is enabled.

Reduce wear of the underlying flash storage (used for UEFI variables) by
deferring writes until shutdown in case they appear to be due to clock
drift.

As an example, deferring writes when the new offset differs up to 30 s
from the previous one reduces the number of writes on the X13s during a
ten day session with the machine not suspending for more than four days
in a row from up to 68 writes (every 3.5 h) to at most two (boot and
shutdown).

Tested-by: Jens Glathe <jens.glathe@oldschoolsolutions.biz>
Tested-by: Steev Klimaszewski <steev@kali.org>
Tested-by: Joel Stanley <joel@jms.id.au>
Tested-by: Sebastian Reichel <sre@kernel.org> # Lenovo T14s Gen6
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20250219134118.31017-4-johan+linaro@kernel.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-pm8xxx.c