All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] Add devm helper for work-queue initialization
@ 2021-05-18 12:31 Matti Vaittinen
  2021-05-18 12:31 ` [PATCH v2 1/5] devm-helpers: Add resource managed version of work init Matti Vaittinen
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Matti Vaittinen @ 2021-05-18 12:31 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: hanwoo Choi, Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz,
	MyungJoo Ham, Hans de Goede, Matti Vaittinen, Marek Szyprowski,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2644 bytes --]

This series adds new devm_work_autocancel() helper.

Many drivers which use work-queues must ensure the work is not queued when
driver is detached. Often this is done by ensuring new work is not added and
then calling cancel_work_sync() at remove(). In many cases this also requires
cleanup at probe error path - which is easy to forget (or get wrong).

Also the "by ensuring new work is not added" has a gotcha.

It is not strange to see devm managed IRQs scheduling work.
Mixing this with manual wq clean-up is hard to do correctly because the
devm is likely to free the IRQ only after the remove() is ran. So manual
wq cancellation and devm-based IRQ management do not mix well - there is
a short(?) time-window after the wq clean-up when IRQs are still not
freed and may schedule new work.

When both WQs and IRQs are managed by devm things are likely to just
work. WQs should be initialized before IRQs (when IRQs need to schedule
work) and devm unwinds things in "FILO" order.

This series implements wq cancellation on top of devm and replaces
the obvious cases where only thing remove call-back in a driver does is
cancelling the work. There might be other cases where we could switch
more than just work cancellation to use managed version and thus get rid
of remove or mixed (manual and devm) resource management.

Changelog v2:
  - rebased on v5.13-rc2
  - split the extcon-max8997 change into two. First a simple,
    back-portable fix for omitting IRQ freeing at error path, second
    being the devm-simpification which does not need backporting.

---

Matti Vaittinen (5):
  devm-helpers: Add resource managed version of work init
  extcon: extcon-max14577: Fix potential work-queue cancellation race
  extcon: extcon-max77693.c: Fix potential work-queue cancellation race
  extcon: extcon-max8997: Fix IRQ freeing at error path
  extcon: extcon-max8997: Simplify driver using devm

 drivers/extcon/extcon-max14577.c | 16 ++++--------
 drivers/extcon/extcon-max77693.c | 17 ++++--------
 drivers/extcon/extcon-max8997.c  | 45 +++++++++++---------------------
 include/linux/devm-helpers.h     | 25 ++++++++++++++++++
 4 files changed, 50 insertions(+), 53 deletions(-)


base-commit: d07f6ca923ea0927a1024dfccafc5b53b61cfecc
-- 
2.25.4


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-05-27 11:07 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18 12:31 [PATCH v2 0/5] Add devm helper for work-queue initialization Matti Vaittinen
2021-05-18 12:31 ` [PATCH v2 1/5] devm-helpers: Add resource managed version of work init Matti Vaittinen
2021-05-18 12:32 ` [PATCH v2 2/5] extcon: extcon-max14577: Fix potential work-queue cancellation race Matti Vaittinen
2021-05-18 12:32 ` [PATCH v2 3/5] extcon: extcon-max77693.c: " Matti Vaittinen
2021-05-18 12:32 ` [PATCH v2 4/5] extcon: extcon-max8997: Fix IRQ freeing at error path Matti Vaittinen
2021-05-25 15:58   ` Krzysztof Kozlowski
2021-05-18 12:33 ` [PATCH v2 5/5] extcon: extcon-max8997: Simplify driver using devm Matti Vaittinen
2021-05-25 15:59   ` Krzysztof Kozlowski
2021-05-19  0:39 ` [PATCH v2 0/5] Add devm helper for work-queue initialization Rob Herring
2021-05-19  5:33   ` Matti Vaittinen
2021-05-27 11:07 ` Hans de Goede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.