Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3498849pxb; Mon, 25 Jan 2021 18:58:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4zZciX/6N6JImFBK4CY1EFrvC3DUZ9a8ekFnEz7f0Hnx9bwYnD9x75SZL+txYvpuFJc9i X-Received: by 2002:a05:6402:3116:: with SMTP id dc22mr2777397edb.325.1611629926852; Mon, 25 Jan 2021 18:58:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611629926; cv=none; d=google.com; s=arc-20160816; b=CjIZNEaCRraShCZICWf/mCzofQuxketaoWYywuvEeS3d30WXStVZ9sPgccWkV+yFbk aazSBOZcPNWSwwKsc54gDxDTswFDpS1Itaq1N6lvE+ZVEHBY8T3vcE/60xxXa9r+8Zng LVnoPihPFG+g8n8mEVAGOibvJuOcBaZ/gzrVTW8zSbNeohU5thmD39kfNONrLUJBXmWp Jv7rKsVA6y5TYKSIiZoaMGjn/6AAtULkl+UjbFoSMHQwGcvxtbm8gKEU1ZmLpyyYm9CD 2koZ7jF/LIjE9SAT/+ffnpZjODqy9gmhq0upIv/u7O/SauQWVnYfqkESdVz6O+Ct+bjL 5HoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=tnD1tUyAH94ef66LA3Hh2zR2A+pKVQYnVN+rRXKG/ws=; b=p+xYZ/CJygE+Sy5fLqjYBgdVK/SBIgFLjwzxhcUcYlLRT9We0yvtXiNLOisZUBsxNS YNRQKppOUNzq7sJVG/gchdyfFsLy41DBZpBZlxDWn9Y2RCw+yhbWdKQeRxh/kYLT82/9 6QZx2y3vhcRbfD79fi4a6COZyLTnZAqrkzG/0OWb6gYxkal1nvoZepc4lFB0QXJy5IuY EOqwlsGjUWeobLFkeonUtho8CrQ9v63IS7DaP6Ba3lt++WbKzOBwkOPDrU9uoo9g7jYR uToG1HLUqgFTWdXACuYJWUXGY1RCn9/H3YW1q2WwY1rh4AqACemSb2Ljv+UC7ag7sZ6P pNqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gb28si6470862ejc.510.2021.01.25.18.58.23; Mon, 25 Jan 2021 18:58:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729569AbhAYOnD (ORCPT + 99 others); Mon, 25 Jan 2021 09:43:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729491AbhAYOmE (ORCPT ); Mon, 25 Jan 2021 09:42:04 -0500 X-Greylist: delayed 545 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 25 Jan 2021 06:41:02 PST Received: from leibniz.telenet-ops.be (leibniz.telenet-ops.be [IPv6:2a02:1800:110:4::f00:d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8686C061574 for ; Mon, 25 Jan 2021 06:41:02 -0800 (PST) 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 4DPXPS00bJzMsJcv for ; Mon, 25 Jan 2021 15:31:56 +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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- 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) -- 2.25.1