Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7515467pxb; Thu, 18 Feb 2021 12:08:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNrkol6VyHhrtrlGe2QhybY6jEBYADv18yJa50zSEhDwAkR4akCTNw9EE7aH9QQN+ZLkH9 X-Received: by 2002:a17:906:c1d9:: with SMTP id bw25mr5619292ejb.452.1613678896908; Thu, 18 Feb 2021 12:08:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613678896; cv=none; d=google.com; s=arc-20160816; b=P0LDXdwasGMt2QUJ31k+qiPO0WeO3l5Si8JsynQmb63yPHEs3y3ngWePtpkIOjn2wQ EhkpaSAqcBp9HQ0lK3EW7PtoC5Dz5PMPjXJVEeaUu98KLlPy9gARqpYaEj9WwNCWfmqW Pqg3PdBr5QnPdtEWggzTrWTtBa/Wz6668Nwe0OBkUOvLQG3evzZNU7jq64QXe2x1aeHX wi3GcESzCvsIboe1+ZYEgxzHwBO7cUvEfDy9Ihdo/QvYScpwyLNXKPbP4pg4YxlPMZ9+ fLUcFyGqa9fXsF00XNM5/sDT/bitAzNdlN41ak1UWQkn0yFtKK46GKMHr1sxxPKKt3gB rxeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=QxPloqSM+XlHa376igRC3bpTftqwQQk3enlRQ9CTJKI=; b=JnQCUYPcrSWUQRlq+8NdXIUzGiNFw4PiZObs0+2HDsr0+A8jBnwDvzB1f1+se6jVYL 0YYiianlor+UtTLeG9KNB4maYbsfYNmXjGNMahaKW39/I0YDy4Cef0RQw2nfapqdDNXx BK/UVjX+/Yj2Yj/yEYybnd+AOwJ4AX7yYkyaqZUBCZwZ7BDGVPnk/DzNKEyhD4hQcbaI tqDA2cEZ0SDAnGoEjS9W0jXP2fOvTsMNRkLnKN5LabDGrRYkWePUaorSV4cYGvdb/JQd 5gdGTOgUnkUwRbhllYuTn/OR/+FU/SWXhBw2UeIYcKcAKihl1GOAcSMmtHrwpOIP/6hP 9M8Q== 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 qn10si933571ejb.682.2021.02.18.12.07.51; Thu, 18 Feb 2021 12:08:16 -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 S232120AbhBRUFP (ORCPT + 99 others); Thu, 18 Feb 2021 15:05:15 -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-kernel@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