From patchwork Mon Jan 25 14:30:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 12045567 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6494CC433E0 for ; Tue, 26 Jan 2021 05:48:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 22DF622ADF for ; Tue, 26 Jan 2021 05:48:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728976AbhAZFr5 (ORCPT ); Tue, 26 Jan 2021 00:47:57 -0500 Received: from leibniz.telenet-ops.be ([195.130.137.77]:51970 "EHLO leibniz.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729710AbhAYOmG (ORCPT ); Mon, 25 Jan 2021 09:42:06 -0500 X-Greylist: delayed 515 seconds by postgrey-1.27 at vger.kernel.org; Mon, 25 Jan 2021 09:42:04 EST Received: from xavier.telenet-ops.be (xavier.telenet-ops.be [IPv6:2a02:1800:120:4::f00:14]) by leibniz.telenet-ops.be (Postfix) with ESMTPS id 4DPXPS00Z3zMsJct for ; Mon, 25 Jan 2021 15:31:55 +0100 (CET) Received: from ramsan.of.borg ([84.195.186.194]) by xavier.telenet-ops.be with bizsmtp id M2Wi240034C55Sk012WiV4; Mon, 25 Jan 2021 15:30:54 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1l42t7-000emF-Gs; Mon, 25 Jan 2021 15:30:41 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1l42t6-004PfB-P9; Mon, 25 Jan 2021 15:30:40 +0100 From: Geert Uytterhoeven To: John Stultz , Thomas Gleixner Cc: Stephen Boyd , Alexandre Belloni , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Wolfram Sang , Viresh Kumar , Tejun Heo , Lai Jiangshan , Alessandro Zummo , linux-rtc@vger.kernel.org, linux-pm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] ntp: Use freezable workqueue for RTC synchronization Date: Mon, 25 Jan 2021 15:30:39 +0100 Message-Id: <20210125143039.1051912-1-geert+renesas@glider.be> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The bug fixed by commit e3fab2f3de081e98 ("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) from [] (i2c_transfer+0x58/0xf8) [] (i2c_transfer) from [] (regmap_i2c_read+0x58/0x94) [] (regmap_i2c_read) from [] (_regmap_raw_read+0x19c/0x2f4) [] (_regmap_raw_read) from [] (_regmap_bus_read+0x44/0x68) [] (_regmap_bus_read) from [] (_regmap_read+0x84/0x1a4) [] (_regmap_read) from [] (_regmap_update_bits+0xa8/0xf4) [] (_regmap_update_bits) from [] (_regmap_select_page+0xe4/0x100) [] (_regmap_select_page) from [] (_regmap_raw_write_impl+0xd4/0x6c4) [] (_regmap_raw_write_impl) from [] (_regmap_raw_write+0xd8/0x114) [] (_regmap_raw_write) from [] (regmap_raw_write+0x58/0x7c) [] (regmap_raw_write) from [] (regmap_bulk_write+0x118/0x13c) [] (regmap_bulk_write) from [] (da9063_rtc_set_time+0x44/0x8c) [] (da9063_rtc_set_time) from [] (rtc_set_time+0xc8/0x228) [] (rtc_set_time) from [] (sync_hw_clock+0x128/0x1fc) [] (sync_hw_clock) from [] (process_one_work+0x330/0x550) [] (process_one_work) from [] (worker_thread+0x22c/0x2ec) Fix this race condition by using the freezable instead of the normal power-efficient workqueue. Signed-off-by: Geert Uytterhoeven Acked-by: Rafael J. Wysocki --- kernel/time/ntp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 54d52fab201d283e..6310328fe398406a 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -502,7 +502,7 @@ static struct hrtimer sync_hrtimer; static enum hrtimer_restart sync_timer_callback(struct hrtimer *timer) { - queue_work(system_power_efficient_wq, &sync_work); + queue_work(system_freezable_power_efficient_wq, &sync_work); return HRTIMER_NORESTART; } @@ -668,7 +668,7 @@ void ntp_notify_cmos_timer(void) * just a pointless work scheduled. */ if (ntp_synced() && !hrtimer_is_queued(&sync_hrtimer)) - queue_work(system_power_efficient_wq, &sync_work); + queue_work(system_freezable_power_efficient_wq, &sync_work); } static void __init ntp_init_cmos_sync(void)