mfd: freeze delayed I/O work during suspend
cover mfd: freeze delayed I/O work during suspend
The SI476x polling callback and TPS65010 event worker issue I2C transfers from delayed work. Their current workqueues remain active while devices are being suspended, allowing pending callbacks to reach an already suspended I2C adapter.
Move both callbacks to freezable workqueues. Preserve the TPS65010 worker's power-efficient property by using system_freezable_power_efficient_wq. Each patch is independent and can be applied separately.
Jiale Yao (2):
mfd: si476x: queue polling work on freezable workqueue
mfd: tps65010: queue I/O work on freezable workqueue
drivers/mfd/si476x-i2c.c | 5 +++-- drivers/mfd/tps65010.c | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/2 mfd: si476x: queue polling work on freezable workqueue
SI476x devices without an interrupt continuously poll their status over I2C. The polling callback runs on the non-freezable system workqueue and can issue a transfer after the adapter has been suspended.
Queue status polling on system_freezable_wq so it stops before device suspend and continues after resume.
--- drivers/mfd/si476x-i2c.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/mfd/si476x-i2c.c +3 -2
@@ -17,6 +17,7 @@#include <linux/regulator/consumer.h> #include <linux/i2c.h> #include <linux/err.h> +#include <linux/workqueue.h> #include <linux/mfd/si476x-core.h>
@@ -97,8 +98,8 @@ static int si476x_core_config_pinmux(struct si476x_core *core)static inline void si476x_core_schedule_polling_work (struct si476x_core *core) { -schedule_delayed_work (&core->status_monitor, -usecs_to_jiffies (SI476X_STATUS_POLL_US )); +queue_delayed_work (system_freezable_wq, &core->status_monitor, +usecs_to_jiffies (SI476X_STATUS_POLL_US )); }/**
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH 1/2] mfd: si476x: queue polling work on freezable workqueue
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] mfd: si476x: cross-device race on static io_errors_count - [Low] mfd: commit message description…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] mfd: si476x: cross-device race on static io_errors_count
- [Low] mfd: commit message description capitalization
--
commit 42712fe1738df7fa331aa622d7a9ed0967efc78f
Author: Jiale Yao <[email protected]>
mfd: si476x: queue polling work on freezable workqueue
This commit changes the polling work for SI476x devices to use the freezable system workqueue. This ensures that the continuous I2C polling stops before device suspend and properly resumes afterward, preventing transfers after the adapter has been suspended.
Quoted 1 line
mfd: si476x: queue polling work on freezable workqueue
[Severity: Low]
This isn't a bug, but the MFD subsystem requires capitalizing the description after the subsystem prefix. Should "queue" be "Queue"?
Quoted 4 lines
drivers/mfd/si476x-i2c.c +0
-0
[ ... ]
drivers/mfd/si476x-i2c.c static int si476x_core_config_pinmux(struct si476x_core *core) · line 103
Quoted 9 lines
drivers/mfd/si476x-i2c.c +2
-2@@ -97,8 +98,8 @@ static int si476x_core_config_pinmux(struct si476x_core *core)static inline void si476x_core_schedule_polling_work (struct si476x_core *core) { -schedule_delayed_work (&core->status_monitor, -usecs_to_jiffies (SI476X_STATUS_POLL_US )); +queue_delayed_work (system_freezable_wq, &core->status_monitor, +usecs_to_jiffies (SI476X_STATUS_POLL_US )); }
[Severity: Medium]
Will this polling work cause regressions if multiple si476x devices are present?
Looking at si476x_core_i2c_xfer(), which is called during the polling loop to check device status:
drivers/mfd/si476x-i2c.c:si476x_core_i2c_xfer() {
...
static int io_errors_count;
int err;
...
if (err < 0) {
if (io_errors_count++ > SI476X_MAX_IO_ERRORS)
si476x_core_pronounce_dead(core);
} else {
io_errors_count = 0;
}
...
}Because io_errors_count is static and accessed without locking, won't concurrent I2C transfers from different devices race to modify it?
A successful read on one device could falsely reset the error count for a failing device, preventing it from being pronounced dead. Conversely, concurrent errors across multiple devices could accumulate together and falsely trigger si476x_core_pronounce_dead() prematurely.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Lee Jones
maintainerRe: [PATCH 1/2] mfd: si476x: queue polling work on freezable workqueue
Quoted 2 lines · On Fri, 16 Oct 2026, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] mfd: si476x: cross-device race on staticio_errors_count
This needs an answer.
Quoted 66 lines
- [Low] mfd: commit message description capitalization --
commit
42712fe1738df7fa331aa622d7a9ed0967efc78f
Author: Jiale Yao <[email protected]>mfd: si476x: queue polling work on freezable workqueue
This commit changes the polling work for SI476x devices to use the freezable system workqueue. This ensures that the continuous I2C polling stops before device suspend and properly resumes afterward, preventing transfers after the adapter has been suspended.
Quoted 1 line
mfd: si476x: queue polling work on freezable workqueue
[Severity: Low]
This isn't a bug, but the MFD subsystem requires capitalizing the description after the subsystem prefix. Should "queue" be "Queue"?Quoted 4 lines
drivers/mfd/si476x-i2c.c +0
-0[ ... ]
drivers/mfd/si476x-i2c.c static int si476x_core_config_pinmux(struct si476x_core *core) · line 103
Quoted 9 lines
drivers/mfd/si476x-i2c.c +2
-2@@ -97,8 +98,8 @@ static int si476x_core_config_pinmux(struct si476x_core *core)static inline void si476x_core_schedule_polling_work (struct si476x_core *core) { -schedule_delayed_work (&core->status_monitor, -usecs_to_jiffies (SI476X_STATUS_POLL_US )); +queue_delayed_work (system_freezable_wq, &core->status_monitor, +usecs_to_jiffies (SI476X_STATUS_POLL_US )); }[Severity: Medium]
Will this polling work cause regressions if multiple si476x devices are present?Looking at
si476x_core_i2c_xfer(), which is called during the polling loop to check device status:drivers/mfd/si476x-i2c.c:si476x_core_i2c_xfer() { ... static int io_errors_count; int err; ... if (err < 0) { if (io_errors_count++ > SI476X_MAX_IO_ERRORS) si476x_core_pronounce_dead(core); } else { io_errors_count = 0; } ... }Because
io_errors_countis static and accessed without locking, won't concurrent I2C transfers from different devices race to modify it?A successful read on one device could falsely reset the error count for a failing device, preventing it from being pronounced dead. Conversely, concurrent errors across multiple devices could accumulate together and falsely trigger
si476x_core_pronounce_dead()prematurely.Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Signature · 1 line
Lee Jones
Re:[PATCH 1/2] mfd: si476x: queue polling work on freezable workqueue
In reply to Jiale YaoQuoted 7 lines · Jiale Yao
SI476x devices without an interrupt continuously poll their status over I2C. The polling callback runs on the non-freezable system workqueue and can issue a transfer after the adapter has been suspended.
Queue status polling on
system_freezable_wqso it stops before device suspend and continues after resume.
Quoted 30 lines
Signed-off-by Jiale Yao <[email protected]>---
drivers/mfd/si476x-i2c.c| 5 +++--1 file changed, 3 insertions(+), 2 deletions(-)drivers/mfd/si476x-i2c.c +3
-2@@ -17,6 +17,7 @@#include <linux/regulator/consumer.h> #include <linux/i2c.h> #include <linux/err.h> +#include <linux/workqueue.h> #include <linux/mfd/si476x-core.h> @@ -97,8 +98,8 @@ static int si476x_core_config_pinmux(struct si476x_core *core)static inline void si476x_core_schedule_polling_work (struct si476x_core *core) { -schedule_delayed_work (&core->status_monitor, -usecs_to_jiffies (SI476X_STATUS_POLL_US )); +queue_delayed_work (system_freezable_wq, &core->status_monitor, +usecs_to_jiffies (SI476X_STATUS_POLL_US )); }/** Signature · 1 line
2.34.1
PATCH 2/2 mfd: tps65010: queue I/O work on freezable workqueue
In reply to Jiale YaoThe TPS65010 event worker performs SMBus transfers and can reschedule itself to poll the charging state. The power-efficient system workqueue is not freezable, so pending work can access an I2C adapter after it has been suspended.
Use the freezable power-efficient workqueue for every scheduling path. This preserves the power-efficient behavior while freezing I/O across system suspend.
--- drivers/mfd/tps65010.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mfd/tps65010.c +5 -5
@@ -230,7 +230,7 @@ static int dbg_show(struct seq_file *s, void *_)seq_printf (s,"mask2 %s\n" , buf);/* ignore ackint2 */ -queue_delayed_work (system_power_efficient_wq, &tps->work, +queue_delayed_work (system_freezable_power_efficient_wq, &tps->work,POWER_POLL_DELAY );/* VMAIN voltage, enable lowpower, etc */
@@ -388,7 +388,7 @@ static void tps65010_interrupt(struct tps65010 *tps) && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC))) poll =1 ;if (poll) -queue_delayed_work (system_power_efficient_wq, &tps->work, +queue_delayed_work (system_freezable_power_efficient_wq, &tps->work,POWER_POLL_DELAY );/* also potentially gpio-in rise or fall */
@@ -436,7 +436,7 @@ static irqreturn_t tps65010_irq(int irq, void *_tps)disable_irq_nosync (irq);set_bit (FLAG_IRQ_ENABLE , &tps->flags); -queue_delayed_work (system_power_efficient_wq, &tps->work,0 ); +queue_delayed_work (system_freezable_power_efficient_wq, &tps->work,0 );return IRQ_HANDLED ; }
@@ -694,7 +694,8 @@ int tps65010_set_vbus_draw(unsigned mA) && test_and_set_bit( FLAG_VBUS_CHANGED, &the_tps->flags)) {/* gadget drivers call this in_irq() */ -queue_delayed_work (system_power_efficient_wq, &the_tps->work, +queue_delayed_work (system_freezable_power_efficient_wq, + &the_tps->work,0 ); }local_irq_restore (flags);
@@ -1052,4 +1053,3 @@ static void __exit tps_exit(void)i2c_del_driver (&tps65010_driver); }module_exit (tps_exit); -
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH 2/2] mfd: tps65010: queue I/O work on freezable workqueue
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines
The TPS65010 event worker performs SMBus transfers and can reschedule itself to poll the charging state. The power-efficient system workqueue is not freezable, so pending work can access an I2C adapter after it has been suspended.
Use the freezable power-efficient workqueue for every scheduling path. This preserves the power-efficient behavior while freezing I/O across system suspend.
Signed-off-by Jiale Yao <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re:[PATCH 2/2] mfd: tps65010: queue I/O work on freezable workqueue
In reply to Jiale YaoQuoted 9 lines · Jiale Yao
The TPS65010 event worker performs SMBus transfers and can reschedule itself to poll the charging state. The power-efficient system workqueue is not freezable, so pending work can access an I2C adapter after it has been suspended.
Use the freezable power-efficient workqueue for every scheduling path. This preserves the power-efficient behavior while freezing I/O across system suspend.
Quoted 53 lines
Signed-off-by Jiale Yao <[email protected]>---
drivers/mfd/tps65010.c| 10 +++++-----1 file changed, 5 insertions(+), 5 deletions(-)drivers/mfd/tps65010.c +5
-5@@ -230,7 +230,7 @@ static int dbg_show(struct seq_file *s, void *_)seq_printf (s,"mask2 %s\n" , buf);/* ignore ackint2 */ -queue_delayed_work (system_power_efficient_wq, &tps->work, +queue_delayed_work (system_freezable_power_efficient_wq, &tps->work,POWER_POLL_DELAY );/* VMAIN voltage, enable lowpower, etc */ @@ -388,7 +388,7 @@ static void tps65010_interrupt(struct tps65010 *tps) && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC))) poll =1 ;if (poll) -queue_delayed_work (system_power_efficient_wq, &tps->work, +queue_delayed_work (system_freezable_power_efficient_wq, &tps->work,POWER_POLL_DELAY );/* also potentially gpio-in rise or fall */ @@ -436,7 +436,7 @@ static irqreturn_t tps65010_irq(int irq, void *_tps)disable_irq_nosync (irq);set_bit (FLAG_IRQ_ENABLE , &tps->flags); -queue_delayed_work (system_power_efficient_wq, &tps->work,0 ); +queue_delayed_work (system_freezable_power_efficient_wq, &tps->work,0 );return IRQ_HANDLED ; }@@ -694,7 +694,8 @@ int tps65010_set_vbus_draw(unsigned mA) && test_and_set_bit( FLAG_VBUS_CHANGED, &the_tps->flags)) {/* gadget drivers call this in_irq() */ -queue_delayed_work (system_power_efficient_wq, &the_tps->work, +queue_delayed_work (system_freezable_power_efficient_wq, + &the_tps->work,0 ); }local_irq_restore (flags);@@ -1052,4 +1053,3 @@ static void __exit tps_exit(void)i2c_del_driver (&tps65010_driver); }module_exit (tps_exit); -Signature · 1 line
2.34.1
Lee Jones
maintainerRe: [PATCH 2/2] mfd: tps65010: queue I/O work on freezable workqueue
In reply to Jiale YaoQuoted 46 lines · Jiale Yao
The TPS65010 event worker performs SMBus transfers and can reschedule itself to poll the charging state. The power-efficient system workqueue is not freezable, so pending work can access an I2C adapter after it has been suspended.
Use the freezable power-efficient workqueue for every scheduling path. This preserves the power-efficient behavior while freezing I/O across system suspend.
Signed-off-by Jiale Yao <[email protected]>--- drivers/mfd/tps65010.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/mfd/tps65010.c +3
-3@@ -230,7 +230,7 @@ static int dbg_show(struct seq_file *s, void *_)seq_printf (s,"mask2 %s\n" , buf);/* ignore ackint2 */ -queue_delayed_work (system_power_efficient_wq, &tps->work, +queue_delayed_work (system_freezable_power_efficient_wq, &tps->work,POWER_POLL_DELAY );/* VMAIN voltage, enable lowpower, etc */ @@ -388,7 +388,7 @@ static void tps65010_interrupt(struct tps65010 *tps) && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC))) poll =1 ;if (poll) -queue_delayed_work (system_power_efficient_wq, &tps->work, +queue_delayed_work (system_freezable_power_efficient_wq, &tps->work,POWER_POLL_DELAY );/* also potentially gpio-in rise or fall */ @@ -436,7 +436,7 @@ static irqreturn_t tps65010_irq(int irq, void *_tps)disable_irq_nosync (irq);set_bit (FLAG_IRQ_ENABLE , &tps->flags); -queue_delayed_work (system_power_efficient_wq, &tps->work,0 ); +queue_delayed_work (system_freezable_power_efficient_wq, &tps->work,0 );return IRQ_HANDLED ; }
drivers/mfd/tps65010.c int tps65010_set_vbus_draw(unsigned mA) · line 699
Quoted 7 lines
drivers/mfd/tps65010.c +2
-1@@ -694,7 +694,8 @@ int tps65010_set_vbus_draw(unsigned mA) && test_and_set_bit( FLAG_VBUS_CHANGED, &the_tps->flags)) {/* gadget drivers call this in_irq() */ -queue_delayed_work (system_power_efficient_wq, &the_tps->work, +queue_delayed_work (system_freezable_power_efficient_wq, + &the_tps->work,0 );
Use 100-chars to prevent this crazy line-wrapping.
Quoted 10 lines
drivers/mfd/tps65010.c +0
-1}local_irq_restore (flags);@@ -1052,4 +1053,3 @@ static void __exit tps_exit(void)i2c_del_driver (&tps65010_driver); }module_exit (tps_exit); -Signature · 1 line
2.34.1
Signature · 1 line
Lee Jones