[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <cover.1620633360.git.matti.vaittinen@fi.rohmeurope.com>
Date: Mon, 10 May 2021 11:09:42 +0300
From: Matti Vaittinen <matti.vaittinen@...rohmeurope.com>
To: Matti Vaittinen <matti.vaittinen@...rohmeurope.com>,
Matti Vaittinen <mazziesaccount@...il.com>
Cc: Chanwoo Choi <cw00.choi@...sung.com>,
Krzysztof Kozlowski <krzysztof.kozlowski@...onical.com>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>,
MyungJoo Ham <myungjoo.ham@...sung.com>,
Hans de Goede <hdegoede@...hat.com>,
Matti Vaittinen <matti.vaittinen@...rohmeurope.com>,
Marek Szyprowski <m.szyprowski@...sung.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH 0/4] Add devm helper for work-queue initialization
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.
---
Matti Vaittinen (4):
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
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: 6efb943b8616ec53a5e444193dccf1af9ad627b5
--
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 =]
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists