]> git.baikalelectronics.ru Git - kernel.git/commit
ntp: Use freezable workqueue for RTC synchronization
authorGeert Uytterhoeven <geert+renesas@glider.be>
Mon, 25 Jan 2021 14:30:39 +0000 (15:30 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 5 Feb 2021 17:03:13 +0000 (18:03 +0100)
commitcfdb82d69bf80104327ec23bec092661772c981f
tree3c41fe523dd93caf4f2679afbb8053753c3485a9
parent6636054d88db566ba3c25501bd75086043cc35f1
ntp: Use freezable workqueue for RTC synchronization

The bug fixed by commit b056b4a08d6adf40 ("ntp: Fix RTC synchronization on
32-bit platforms") revealed an underlying issue: RTC synchronization may
happen anytime, even while the system is partially suspended.

On systems where the RTC is connected to an I2C bus, the I2C bus controller
may already or still be suspended, triggering a WARNING during suspend or
resume from s2ram:

    WARNING: CPU: 0 PID: 124 at drivers/i2c/i2c-core.h:54 __i2c_transfer+0x634/0x680
    i2c i2c-6: Transfer while suspended
    [...]
    Workqueue: events_power_efficient sync_hw_clock
    [...]
      (__i2c_transfer)
      (i2c_transfer)
      (regmap_i2c_read)
      ...
      (da9063_rtc_set_time)
      (rtc_set_time)
      (sync_hw_clock)
      (process_one_work)

Fix this race condition by using the freezable instead of the normal
power-efficient workqueue.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Link: https://lore.kernel.org/r/20210125143039.1051912-1-geert+renesas@glider.be
kernel/time/ntp.c