From mboxrd@z Thu Jan 1 00:00:00 1970 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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 00386C43381 for ; Thu, 18 Feb 2021 19:59:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 92D3664EB2 for ; Thu, 18 Feb 2021 19:59:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230227AbhBRT7Q (ORCPT ); Thu, 18 Feb 2021 14:59:16 -0500 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:38361 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231945AbhBRT4v (ORCPT ); Thu, 18 Feb 2021 14:56:51 -0500 X-Originating-IP: 86.211.141.229 Received: from localhost (lfbn-cor-1-49-229.w86-211.abo.wanadoo.fr [86.211.141.229]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id C50E624000A; Thu, 18 Feb 2021 19:56:06 +0000 (UTC) Date: Thu, 18 Feb 2021 20:56:06 +0100 From: Alexandre Belloni To: Dmitry Osipenko Cc: Alessandro Zummo , linux-rtc@vger.kernel.org, Linux Kernel Mailing List , "linux-tegra@vger.kernel.org" , Peter Geis , Nicolas Chauvet Subject: Re: [bug] RTC alarm vs system suspend race condition Message-ID: References: <0a82c37e-ba83-a853-1db8-ba267f7728d7@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0a82c37e-ba83-a853-1db8-ba267f7728d7@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-rtc@vger.kernel.org Hello, I just wanted to thank you for reporting this issue. I didn't yet have the time to work on that but this is on my radar. There is also another issue when resuming and I'm not yet sure how we can solve it for all platforms. On 12/01/2021 10:58:07+0300, Dmitry Osipenko wrote: > Hello RTC maintainers, > > A day ago we were testing RTC alarm on NVIDIA Tegra devices and noticed that there is a problem in the RTC core where it schedules __rtc_set_alarm work when alarm is set, but this work isn't flushed before RTC drivers are suspended. In general RTC devices can't be accessed once driver's suspend is invoked, creating the problem. > > Please see this example: > > # rtcwake -s15 -mmem > > On Ouya board: > > PM: suspend entry (deep) > Filesystems sync: 0.001 seconds > Freezing user space processes ... (elapsed 0.002 seconds) done. > OOM killer disabled. > Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done. > smsc95xx 1-1:1.0 enxb85af7003b21: entering SUSPEND2 mode > ------------[ cut here ]------------ > WARNING: CPU: 1 PID: 1337 at drivers/i2c/i2c-core.h:54 __i2c_transfer+0x6d0/0x6ec > i2c i2c-1: Transfer while suspended > Modules linked in: brcmfmac brcmutil > CPU: 1 PID: 1337 Comm: kworker/1:3 Not tainted 5.11.0-rc2-next-20210108-15881-g0baf1450b32d #196 > Hardware name: NVIDIA Tegra SoC (Flattened Device Tree) > Workqueue: events rtc_timer_do_work > [] (unwind_backtrace) from [] (show_stack+0x10/0x14) > [] (show_stack) from [] (dump_stack+0xc4/0xd8) > [] (dump_stack) from [] (__warn+0xec/0x104) > [] (__warn) from [] (warn_slowpath_fmt+0x98/0xc8) > [] (warn_slowpath_fmt) from [] (__i2c_transfer+0x6d0/0x6ec) > [] (__i2c_transfer) from [] (i2c_transfer+0x9c/0x108) > [] (i2c_transfer) from [] (regmap_i2c_read+0x60/0x9c) > [] (regmap_i2c_read) from [] (_regmap_raw_read+0x104/0x314) > [] (_regmap_raw_read) from [] (_regmap_bus_read+0x44/0x70) > Disabling non-boot CPUs ... > [] (_regmap_bus_read) from [] (_regmap_read+0x60/0x180) > [] (_regmap_read) from [] (_regmap_update_bits+0xbc/0xf8) > [] (_regmap_update_bits) from [] (regmap_update_bits_base+0x4c/0x70) > [] (regmap_update_bits_base) from [] (tps65910_rtc_read_time+0x50/0x134) > [] (tps65910_rtc_read_time) from [] (__rtc_read_time+0x48/0x94) > [] (__rtc_read_time) from [] (__rtc_set_alarm+0x80/0x1dc) > [] (__rtc_set_alarm) from [] (rtc_timer_do_work+0x254/0x448) > [] (rtc_timer_do_work) from [] (process_one_work+0x1dc/0x5a0) > [] (process_one_work) from [] (worker_thread+0x4c/0x520) > [] (worker_thread) from [] (kthread+0x18c/0x190) > [] (kthread) from [] (ret_from_fork+0x14/0x24) > Exception stack(0xc5709fb0 to 0xc5709ff8) > 9fa0: 00000000 00000000 00000000 00000000 > 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 > 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000 > ---[ end trace 2df194007d41e38b ]--- > tps65910-rtc tps65910-rtc: RTC CTRL reg update failed with err:-108 > tps65910-rtc tps65910-rtc: RTC CTRL reg update failed with err:-108 > tps65910-rtc tps65910-rtc: RTC CTRL reg update failed with err:-108 > tps65910-rtc tps65910-rtc: RTC CTRL reg update failed with err:-108 > rtc rtc0: __rtc_set_alarm: err=-108 > tps65910-rtc tps65910-rtc: RTC CTRL reg update failed with err:-108 > IRQ 26: no longer affine to CPU1 > IRQ 27: no longer affine to CPU2 > IRQ 28: no longer affine to CPU3 > Entering suspend state LP1 > Enabling non-boot CPUs ... > CPU1 is up > > On PAZ00 board: > > PM: suspend entry (deep) > Filesystems sync: 0.697 seconds > Freezing user space processes ... (elapsed 0.002 seconds) done. > OOM killer disabled. > Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done. > printk: Suspending console(s) (use no_console_suspend to debug) > Disabling non-boot CPUs ... > IRQ 26: no longer affine to CPU1 > Entering suspend state LP1 > ------------[ cut here ]------------ > WARNING: CPU: 0 PID: 83 at drivers/i2c/i2c-core.h:54 __i2c_transfer+0x400/0x458 > i2c i2c-2: Transfer while suspended > Modules linked in: rt2800usb rt2x00usb rt2800lib rt2x00lib xfs libcrc32c fuse crc32_generic f2fs tegra_drm gpu_sched panel_simple tegra20_emc ci_hdrc_tegra host1x_drv iova > CPU: 0 PID: 83 Comm: kworker/0:2 Not tainted 5.11.0-rc2-next-20210106-tegra+ #181 > Hardware name: NVIDIA Tegra SoC (Flattened Device Tree) > Workqueue: events_power_efficient sync_hw_clock > [] (unwind_backtrace) from [] (show_stack+0x10/0x14) > [] (show_stack) from [] (dump_stack+0xc0/0xd4) > [] (dump_stack) from [] (__warn+0xc0/0x11c) > [] (__warn) from [] (warn_slowpath_fmt+0x98/0xc0) > [] (warn_slowpath_fmt) from [] (__i2c_transfer+0x400/0x458) > [] (__i2c_transfer) from [] (i2c_transfer+0x9c/0x108) > [] (i2c_transfer) from [] (regmap_i2c_read+0x60/0x90) > [] (regmap_i2c_read) from [] (_regmap_raw_read+0xe0/0x160) > [] (_regmap_raw_read) from [] (_regmap_bus_read+0x44/0x70) > [] (_regmap_bus_read) from [] (_regmap_read+0x60/0xb8) > [] (_regmap_read) from [] (_regmap_update_bits+0xb0/0xec) > [] (_regmap_update_bits) from [] (regmap_update_bits_base+0x50/0x74) > [] (regmap_update_bits_base) from [] (tps6586x_clr_bits+0x24/0x2c) > [] (tps6586x_clr_bits) from [] (tps6586x_rtc_set_time+0x68/0x104) > [] (tps6586x_rtc_set_time) from [] (rtc_set_time+0xcc/0x178) > [] (rtc_set_time) from [] (sync_hw_clock+0x1d0/0x250) > [] (sync_hw_clock) from [] (process_one_work+0x1e8/0x44c) > [] (process_one_work) from [] (worker_thread+0x64/0x5a8) > [] (worker_thread) from [] (kthread+0x148/0x14c) > [] (kthread) from [] (ret_from_fork+0x14/0x24) > Exception stack(0xc59d5fb0 to 0xc59d5ff8) > 5fa0: 00000000 00000000 00000000 00000000 > 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 > 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 > ---[ end trace f97d91a3f84ea228 ]--- > tps6586x-rtc tps6586x-rtc: failed to clear RTC_ENABLE > tps6586x-rtc tps6586x-rtc: read counter failed with err -108 > tps6586x-rtc tps6586x-rtc: read counter failed with err -108 > tps6586x-rtc tps6586x-rtc: read counter failed with err -108 > tps6586x-rtc tps6586x-rtc: read counter failed with err -108 > tps6586x-rtc tps6586x-rtc: read counter failed with err -108 > rtc rtc0: __rtc_set_alarm: err=-108 > tps6586x-rtc tps6586x-rtc: read counter failed with err -108 > ------------[ cut here ]------------ > WARNING: CPU: 0 PID: 83 at drivers/mfd/tps6586x.c:266 tps6586x_irq_sync_unlock+0x6c/0x70 > Modules linked in: rt2800usb rt2x00usb rt2800lib rt2x00lib xfs libcrc32c fuse crc32_generic f2fs tegra_drm gpu_sched panel_simple tegra20_emc ci_hdrc_tegra host1x_drv iova > CPU: 0 PID: 83 Comm: kworker/0:2 Tainted: G W 5.11.0-rc2-next-20210106-tegra+ #181 > Hardware name: NVIDIA Tegra SoC (Flattened Device Tree) > Workqueue: events rtc_timer_do_work > [] (unwind_backtrace) from [] (show_stack+0x10/0x14) > [] (show_stack) from [] (dump_stack+0xc0/0xd4) > [] (dump_stack) from [] (__warn+0xc0/0x11c) > [] (__warn) from [] (warn_slowpath_fmt+0x64/0xc0) > [] (warn_slowpath_fmt) from [] (tps6586x_irq_sync_unlock+0x6c/0x70) > [] (tps6586x_irq_sync_unlock) from [] (__disable_irq_nosync+0x58/0x88) > [] (__disable_irq_nosync) from [] (disable_irq+0xc/0x20) > [] (disable_irq) from [] (tps6586x_rtc_alarm_irq_enable+0x4c/0x58) > [] (tps6586x_rtc_alarm_irq_enable) from [] (rtc_timer_do_work+0xfc/0x1dc) > [] (rtc_timer_do_work) from [] (process_one_work+0x1e8/0x44c) > [] (process_one_work) from [] (worker_thread+0x64/0x5a8) > [] (worker_thread) from [] (kthread+0x148/0x14c) > [] (kthread) from [] (ret_from_fork+0x14/0x24) > Exception stack(0xc59d5fb0 to 0xc59d5ff8) > 5fa0: 00000000 00000000 00000000 00000000 > 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 > 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 > ---[ end trace f97d91a3f84ea229 ]--- > ------------[ cut here ]------------ > WARNING: CPU: 0 PID: 83 at drivers/mfd/tps6586x.c:266 tps6586x_irq_sync_unlock+0x6c/0x70 > Modules linked in: rt2800usb rt2x00usb rt2800lib rt2x00lib xfs libcrc32c fuse crc32_generic f2fs tegra_drm gpu_sched panel_simple tegra20_emc ci_hdrc_tegra host1x_drv iova > CPU: 0 PID: 83 Comm: kworker/0:2 Tainted: G W 5.11.0-rc2-next-20210106-tegra+ #181 > Hardware name: NVIDIA Tegra SoC (Flattened Device Tree) > Workqueue: events rtc_timer_do_work > [] (unwind_backtrace) from [] (show_stack+0x10/0x14) > [] (show_stack) from [] (dump_stack+0xc0/0xd4) > [] (dump_stack) from [] (__warn+0xc0/0x11c) > [] (__warn) from [] (warn_slowpath_fmt+0x64/0xc0) > [] (warn_slowpath_fmt) from [] (tps6586x_irq_sync_unlock+0x6c/0x70) > [] (tps6586x_irq_sync_unlock) from [] (__disable_irq_nosync+0x58/0x88) > [] (__disable_irq_nosync) from [] (disable_irq+0xc/0x20) > [] (disable_irq) from [] (tps6586x_rtc_alarm_irq_enable+0x4c/0x58) > [] (tps6586x_rtc_alarm_irq_enable) from [] (rtc_timer_do_work+0xfc/0x1dc) > [] (rtc_timer_do_work) from [] (process_one_work+0x1e8/0x44c) > [] (process_one_work) from [] (worker_thread+0x64/0x5a8) > [] (worker_thread) from [] (kthread+0x148/0x14c) > [] (kthread) from [] (ret_from_fork+0x14/0x24) > Exception stack(0xc59d5fb0 to 0xc59d5ff8) > 5fa0: 00000000 00000000 00000000 00000000 > 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 > 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 > ---[ end trace f97d91a3f84ea22a ]--- > ------------[ cut here ]------------ > WARNING: CPU: 0 PID: 83 at drivers/mfd/tps6586x.c:266 tps6586x_irq_sync_unlock+0x6c/0x70 > Modules linked in: rt2800usb rt2x00usb rt2800lib rt2x00lib xfs libcrc32c fuse crc32_generic f2fs tegra_drm gpu_sched panel_simple tegra20_emc ci_hdrc_tegra host1x_drv iova > CPU: 0 PID: 83 Comm: kworker/0:2 Tainted: G W 5.11.0-rc2-next-20210106-tegra+ #181 > Hardware name: NVIDIA Tegra SoC (Flattened Device Tree) > Workqueue: events rtc_timer_do_work > [] (unwind_backtrace) from [] (show_stack+0x10/0x14) > [] (show_stack) from [] (dump_stack+0xc0/0xd4) > [] (dump_stack) from [] (__warn+0xc0/0x11c) > [] (__warn) from [] (warn_slowpath_fmt+0x64/0xc0) > [] (warn_slowpath_fmt) from [] (tps6586x_irq_sync_unlock+0x6c/0x70) > [] (tps6586x_irq_sync_unlock) from [] (__disable_irq_nosync+0x58/0x88) > [] (__disable_irq_nosync) from [] (disable_irq+0xc/0x20) > [] (disable_irq) from [] (tps6586x_rtc_alarm_irq_enable+0x4c/0x58) > [] (tps6586x_rtc_alarm_irq_enable) from [] (rtc_timer_do_work+0xfc/0x1dc) > [] (rtc_timer_do_work) from [] (process_one_work+0x1e8/0x44c) > [] (process_one_work) from [] (worker_thread+0x64/0x5a8) > [] (worker_thread) from [] (kthread+0x148/0x14c) > [] (kthread) from [] (ret_from_fork+0x14/0x24) > Exception stack(0xc59d5fb0 to 0xc59d5ff8) > 5fa0: 00000000 00000000 00000000 00000000 > 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 > 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 > ---[ end trace f97d91a3f84ea22b ]--- > ------------[ cut here ]------------ > WARNING: CPU: 0 PID: 83 at drivers/mfd/tps6586x.c:266 tps6586x_irq_sync_unlock+0x6c/0x70 > Modules linked in: rt2800usb rt2x00usb rt2800lib rt2x00lib xfs libcrc32c fuse crc32_generic f2fs tegra_drm gpu_sched panel_simple tegra20_emc ci_hdrc_tegra host1x_drv iova > CPU: 0 PID: 83 Comm: kworker/0:2 Tainted: G W 5.11.0-rc2-next-20210106-tegra+ #181 > Hardware name: NVIDIA Tegra SoC (Flattened Device Tree) > Workqueue: events rtc_timer_do_work > [] (unwind_backtrace) from [] (show_stack+0x10/0x14) > [] (show_stack) from [] (dump_stack+0xc0/0xd4) > [] (dump_stack) from [] (__warn+0xc0/0x11c) > [] (__warn) from [] (warn_slowpath_fmt+0x64/0xc0) > [] (warn_slowpath_fmt) from [] (tps6586x_irq_sync_unlock+0x6c/0x70) > [] (tps6586x_irq_sync_unlock) from [] (__disable_irq_nosync+0x58/0x88) > [] (__disable_irq_nosync) from [] (disable_irq+0xc/0x20) > [] (disable_irq) from [] (tps6586x_rtc_alarm_irq_enable+0x4c/0x58) > [] (tps6586x_rtc_alarm_irq_enable) from [] (rtc_timer_do_work+0xfc/0x1dc) > [] (rtc_timer_do_work) from [] (process_one_work+0x1e8/0x44c) > [] (process_one_work) from [] (worker_thread+0x64/0x5a8) > [] (worker_thread) from [] (kthread+0x148/0x14c) > [] (kthread) from [] (ret_from_fork+0x14/0x24) > Exception stack(0xc59d5fb0 to 0xc59d5ff8) > 5fa0: 00000000 00000000 00000000 00000000 > 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 > 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 > ---[ end trace f97d91a3f84ea22c ]--- > Enabling non-boot CPUs ... > ------------[ cut here ]------------ > WARNING: CPU: 0 PID: 83 at drivers/mfd/tps6586x.c:266 tps6586x_irq_sync_unlock+0x6c/0x70 > Modules linked in: rt2800usb rt2x00usb rt2800lib rt2x00lib xfs libcrc32c fuse crc32_generic f2fs tegra_drm gpu_sched panel_simple tegra20_emc ci_hdrc_tegra host1x_drv iova > CPU: 0 PID: 83 Comm: kworker/0:2 Tainted: G W 5.11.0-rc2-next-20210106-tegra+ #181 > Hardware name: NVIDIA Tegra SoC (Flattened Device Tree) > Workqueue: events rtc_timer_do_work > [] (unwind_backtrace) from [] (show_stack+0x10/0x14) > [] (show_stack) from [] (dump_stack+0xc0/0xd4) > [] (dump_stack) from [] (__warn+0xc0/0x11c) > [] (__warn) from [] (warn_slowpath_fmt+0x64/0xc0) > [] (warn_slowpath_fmt) from [] (tps6586x_irq_sync_unlock+0x6c/0x70) > [] (tps6586x_irq_sync_unlock) from [] (__disable_irq_nosync+0x58/0x88) > [] (__disable_irq_nosync) from [] (disable_irq+0xc/0x20) > [] (disable_irq) from [] (tps6586x_rtc_alarm_irq_enable+0x4c/0x58) > [] (tps6586x_rtc_alarm_irq_enable) from [] (rtc_timer_do_work+0xfc/0x1dc) > [] (rtc_timer_do_work) from [] (process_one_work+0x1e8/0x44c) > [] (process_one_work) from [] (worker_thread+0x64/0x5a8) > [] (worker_thread) from [] (kthread+0x148/0x14c) > [] (kthread) from [] (ret_from_fork+0x14/0x24) > Exception stack(0xc59d5fb0 to 0xc59d5ff8) > 5fa0: 00000000 00000000 00000000 00000000 > 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 > 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 > ---[ end trace f97d91a3f84ea22d ]--- -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com