[PATCH] power: supply: bq27xxx: synchronize work cancellation on suspend

Shengzhuo Wei posted 1 patch 1 month ago
drivers/power/supply/bq27xxx_battery.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] power: supply: bq27xxx: synchronize work cancellation on suspend
Posted by Shengzhuo Wei 1 month ago
The poll work requeues itself via mod_delayed_work() while the device
is not removed. cancel_delayed_work() does not wait for a callback
that is already running, so a poll racing with suspend can keep
issuing I2C transfers after suspend returns and requeue itself into
early resume.

Use cancel_delayed_work_sync() to quiesce polling before suspend
completes, as the teardown path already does.

Fixes: dfcb264a01a9 ("power: supply: bq27xxx: Stop and start delayed work in suspend and resume")
Cc: stable@vger.kernel.org
Signed-off-by: Shengzhuo Wei <me@cherr.cc>
---
Same class as 86a3a8a926aa ("power: supply: max17040: synchronize
work cancellation on suspend"): suspend is the only remaining site
using the non-synchronous cancel, the teardown path already uses
cancel_delayed_work_sync().
---
 drivers/power/supply/bq27xxx_battery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index 01c9ec1116fa..4d4809a70b62 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -2291,7 +2291,7 @@ static int bq27xxx_battery_suspend(struct device *dev)
 {
 	struct bq27xxx_device_info *di = dev_get_drvdata(dev);
 
-	cancel_delayed_work(&di->work);
+	cancel_delayed_work_sync(&di->work);
 	return 0;
 }
 

---
base-commit: 45c13f3f9e3bb15fd89ff2864c6f627a3b4b4229
change-id: 20260827-bq27xxx-suspend-cancel-sync-7c60fc384041

Best regards,
--  
Shengzhuo Wei <me@cherr.cc>
Re: [PATCH] power: supply: bq27xxx: synchronize work cancellation on suspend
Posted by Sebastian Reichel 2 weeks, 4 days ago
On Thu, 27 Aug 2026 05:22:29 +0800, Shengzhuo Wei wrote:
> The poll work requeues itself via mod_delayed_work() while the device
> is not removed. cancel_delayed_work() does not wait for a callback
> that is already running, so a poll racing with suspend can keep
> issuing I2C transfers after suspend returns and requeue itself into
> early resume.
> 
> Use cancel_delayed_work_sync() to quiesce polling before suspend
> completes, as the teardown path already does.
> 
> [...]

Applied, thanks!

[1/1] power: supply: bq27xxx: synchronize work cancellation on suspend
      commit: 5fa10f61bbe255011ca9368b8bd6352b7d724bd3

Best regards,
-- 
Sebastian Reichel <sebastian.reichel@collabora.com>