Re: [PATCH 1/3] regulator: core: use system_freezable_wq for init complete work
From: Frank Li
Date: Thu Jul 16 2026 - 11:41:10 EST
On Thu, Jul 16, 2026 at 11:50:53AM +0800, Joy Zou wrote:
> schedule_delayed_work() uses system_wq, which is non-freezable, allowing
> regulator_init_complete_work to run concurrently with system suspend. This
> work fires ~30s after boot to disable unused regulators via I2C. When it
> races with PM suspend, the I2C adapter may already be suspended, triggering
> a -ESHUTDOWN warning dump.
>
> [ 33.707233] pc : __i2c_transfer+0x36c/0x3c8
> [ 33.707240] lr : __i2c_transfer+0x36c/0x3c8
> [ 33.707246] sp : ffff80008239ba50
> [ 33.707249] x29: ffff80008239ba50 x28: 0000000000000001 x27: 0000000000000000
> [ 33.707259] x26: 0000000000000000 x25: 0000000000000001 x24: ffff0000c025c0e0
> [ 33.707268] x23: 0000000000000000 x22: ffff0000c025c0e1 x21: 0000000000000001
> [ 33.707277] x20: ffff80008239bae8 x19: ffff0000c0f54880 x18: fffffffffffeb320
> [ 33.707287] x17: 000000040044ffff x16: 0000000000000000 x15: ffff800082086fd8
> [ 33.707296] x14: 0000000000000000 x13: 0a6465646e657073 x12: 757320656c696877
> [ 33.707305] x11: 0000000000000058 x10: 0000000000000018 x9 : ffff800082087060
> [ 33.707314] x8 : 0000000000057fa8 x7 : 000000000000027d x6 : 0000000000000000
> [ 33.707323] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 00000000ffffffff
> [ 33.707333] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff0000c0123480
> [ 33.707343] Call trace:
> [ 33.707346] __i2c_transfer+0x36c/0x3c8 (P)
> [ 33.707356] i2c_transfer+0x6c/0xf8
> [ 33.707364] i2c_transfer_buffer_flags+0x5c/0xa0
> [ 33.707372] regmap_i2c_write+0x20/0x60
> [ 33.707382] _regmap_raw_write_impl+0x5cc/0x660
> [ 33.707389] _regmap_bus_raw_write+0x60/0x80
> [ 33.707396] _regmap_write+0x58/0xc0
> [ 33.707403] _regmap_update_bits+0x11c/0x140
> [ 33.707409] regmap_update_bits_base+0x54/0x80
> [ 33.707416] regulator_disable_regmap+0x40/0x5c
> [ 33.707424] _regulator_do_disable+0x94/0xbc
> [ 33.707435] CPU2 is up
> [ 33.707433] regulator_late_cleanup+0xe0/0x1e8
> [ 33.707442] class_for_each_device+0x104/0x13c
> [ 33.707450] regulator_init_complete_work_function+0x54/0x80
> [ 33.707458] process_one_work+0x150/0x290
> [ 33.707467] worker_thread+0x180/0x2f4
> [ 33.707473] kthread+0x12c/0x204
> [ 33.707484] ret_from_fork+0x10/0x20
> [ 33.707493] ---[ end trace 0000000000000000 ]---
>
> Switch to system_freezable_wq so the work is frozen before any device
> is suspended, eliminating the race.
>
> Fixes: 55576cf18537 ("regulator: Defer init completion for a while after late_initcall")
> Signed-off-by: Joy Zou <joy.zou@xxxxxxxxxxx>
> ---
Reviewed-by: Frank Li <Frank.Li@xxxxxxx>
> drivers/regulator/core.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index 1797929dfe56..d5d24a940f31 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -27,6 +27,7 @@
> #include <linux/regulator/driver.h>
> #include <linux/regulator/machine.h>
> #include <linux/module.h>
> +#include <linux/workqueue.h>
>
> #define CREATE_TRACE_POINTS
> #include <trace/events/regulator.h>
> @@ -6882,8 +6883,9 @@ static int __init regulator_init_complete(void)
> * we'd only do this on systems that need it, and a kernel
> * command line option might be useful.
> */
> - schedule_delayed_work(®ulator_init_complete_work,
> - msecs_to_jiffies(30000));
> + queue_delayed_work(system_freezable_wq,
> + ®ulator_init_complete_work,
> + msecs_to_jiffies(30000));
>
> return 0;
> }
>
> --
> 2.34.1
>
>