Skip to content

workqueue / drivers: Add device-managed allocate workqueue

Krzysztof Kozlowski chrome-platform driver-core linux-arm-kernel linux-doc linux-mediatek linux-pm lkml stable 2 versions – Applied

Status from this message: Applied, thanks!

Get series with b4
b4 am [email protected] change-id 20260220-workqueue-devm-d9591e5e70eb

Versions newest first

  1. v2 Latest10 patches 8 repliesApplied
  2. v19 patches 15 repliesSuperseded

Changes in v2 from the cover letter

==============
- See individual patches
- Link to v1: https://patch.msgid.link/[email protected]

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/10workqueue: devres: Add device-managed allocate workqueueDocumentation/driver-api/driver-model/devres.rst include/linux/workqueue.h kernel/workqueue.c+54 -03 replies
2/10power: supply: cw2015: Free allocated workqueuedrivers/power/supply/cw2015_battery.c+2 -10 replies
3/10power: supply: max77705: Drop duplicated IRQ error messagedrivers/power/supply/max77705_charger.c+2 -60 replies
4/10power: supply: max77705: Free allocated workqueue and fix removal orderdrivers/power/supply/max77705_charger.c+9 -190 replies
5/10power: supply: mt6370: Simplify with devm_alloc_ordered_workqueue()drivers/power/supply/mt6370-charger.c+1 -120 replies
6/10power: supply: ipaq_micro: Simplify with devmdrivers/power/supply/ipaq_micro_battery.c+16 -340 replies
7/10mfd: ezx-pcap: Drop memory allocation error messagedrivers/mfd/ezx-pcap.c+0 -10 replies
8/10mfd: ezx-pcap: Return directly instead of empty gotosdrivers/mfd/ezx-pcap.c+7 -110 replies
9/10mfd: ezx-pcap: Avoid rescheduling after destroying workqueuedrivers/mfd/ezx-pcap.c+2 -60 replies
10/10platform/chrome: cros_usbpd_logger: Simplify with devmdrivers/platform/chrome/cros_usbpd_logger.c+7 -111 reply

Reviews trailers per patch

2 of 10 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchTejun HeoAndy ShevchenkoTzung-Bi Shih
SeriesR-b
1/10A-b
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 00/10] workqueue / drivers: Add device-managed allocate workqueue

Merging / Dependency
====================
All further patches depend on the first one, thus this probably should go via one tree, e.g. power supply. The first patch might be needed for other trees as well, e.g. if more drivers are discovered, so the best if it is on dedicated branch in case it has to be shared.

Changes in v2:
==============
- See individual patches
- Link to v1: https://patch.msgid.link/[email protected]

Description
===========
Add a Resource-managed version of alloc_workqueue() to fix common problem of drivers mixing devm() calls with destroy_workqueue. Such naive and discouraged driver approach leads to difficult to debug bugs when the driver:

1. Allocates workqueue in standard way and destroys it in driver remove() callback,
2. Sets work struct with devm_work_autocancel(),
3. Registers interrupt handler with devm_request_threaded_irq().

Which leads to following unbind/removal path:

1. destroy_workqueue() via driver remove(),
Any interrupt coming now would still execute the interrupt handler, which queues work on destroyed workqueue.
2. devm_irq_release(),
3. devm_work_drop() -> cancel_work_sync() on destroyed workqueue.

devm_alloc_workqueue() has two benefits:
1. Solves above problem of mix-and-match devres and non-devres code in driver,
2. Simplify any sane drivers which were correctly using alloc_workqueue() + devm_add_action_or_reset().

Best regards,
Krzysztof

---
Krzysztof Kozlowski (10):
workqueue: devres: Add device-managed allocate workqueue
power: supply: cw2015: Free allocated workqueue
power: supply: max77705: Drop duplicated IRQ error message
power: supply: max77705: Free allocated workqueue and fix removal order
power: supply: mt6370: Simplify with devm_alloc_ordered_workqueue()
power: supply: ipaq_micro: Simplify with devm
mfd: ezx-pcap: Drop memory allocation error message
mfd: ezx-pcap: Return directly instead of empty gotos
mfd: ezx-pcap: Avoid rescheduling after destroying workqueue platform/chrome: cros_usbpd_logger: Simplify with devm

 Documentation/driver-api/driver-model/devres.rst |  4 ++
 drivers/mfd/ezx-pcap.c                           | 27 +++++--------
 drivers/platform/chrome/cros_usbpd_logger.c      | 18 ++++-----
 drivers/power/supply/cw2015_battery.c            |  3 +-
 drivers/power/supply/ipaq_micro_battery.c        | 50 ++++++++----------------
 drivers/power/supply/max77705_charger.c          | 36 ++++++-----------
 drivers/power/supply/mt6370-charger.c            | 13 +-----
 include/linux/workqueue.h                        | 22 +++++++++++
 kernel/workqueue.c                               | 28 +++++++++++++
 9 files changed, 100 insertions(+), 101 deletions(-)

---
base-commit: 9739e59909e70058fab7a131d7bee60d447ab732
change-id: 20260220-workqueue-devm-d9591e5e70eb

Best regards,

Signature · 1 line
Krzysztof Kozlowski <[email protected]>