linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/8] Add managed version of delayed work init
@ 2021-03-23 13:49 Matti Vaittinen
  2021-03-23 13:56 ` [PATCH v3 1/8] workqueue: Add resource " Matti Vaittinen
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Matti Vaittinen @ 2021-03-23 13:49 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: MyungJoo Ham, Chanwoo Choi, Andy Gross, Bjorn Andersson,
	Jean Delvare, Guenter Roeck, Hans de Goede, Mark Gross,
	Sebastian Reichel, Chen-Yu Tsai, Liam Girdwood, Mark Brown,
	Wim Van Sebroeck, Matti Vaittinen, gregkh, linux-kernel,
	linux-arm-msm, linux-hwmon, platform-driver-x86, linux-pm,
	linux-watchdog

It's not rare that device drivers need delayed work.
It's not rare that this work needs driver's data.

Often this means that driver must ensure the work is not queued when
driver is detached. Often it is done by ensuring new work is not added and
then calling cancel_delayed_work_sync() at remove(). In many cases this
may also require cleanup at probe error path - which is easy to forget.

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

It is not strange to see devm managed IRQs scheduling (delayed) work.
Mixing this with manua 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 delayed 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.

The series introduces include/linux/devm-helpers.h file which
hopefully works as a place where this kind of helpers can be inlined.

Please see previous discussion here:
RFC v1:
https://lore.kernel.org/lkml/cover.1613216412.git.matti.vaittinen@fi.rohmeurope.com/

Changelog v3:
  - Dropped RFC as advieced by Greg.
  - No functional changes.

Changelog RFC v2 resend:
  - rebased on 5.12-rc4

Changelog RFC v2:
  - used correct terminology ("driver detach" instead of "exit, ...")
  - inlined the devm_delayed_work_autocancel() in a header
  - added Hans as a maintainer for the new header + myself as a reviewer
  - used devm_add_action() instead of using plain devres_add()

---

Matti Vaittinen (8):
  workqueue: Add resource managed version of delayed work init
  MAINTAINERS: Add entry for devm helpers
  extconn: Clean-up few drivers by using managed work init
  hwmon: raspberry-pi: Clean-up few drivers by using managed work init
  platform/x86: gpd pocket fan: Clean-up by using managed work init
  power: supply: Clean-up few drivers by using managed work init
  regulator: qcom_spmi-regulator: Clean-up by using managed work init
  watchdog: retu_wdt: Clean-up by using managed work init

 MAINTAINERS                                  |  6 +++
 drivers/extcon/extcon-gpio.c                 | 15 ++----
 drivers/extcon/extcon-intel-int3496.c        | 16 ++----
 drivers/extcon/extcon-palmas.c               | 17 +++----
 drivers/extcon/extcon-qcom-spmi-misc.c       | 17 +++----
 drivers/hwmon/raspberrypi-hwmon.c            | 17 +++----
 drivers/platform/x86/gpd-pocket-fan.c        | 17 +++----
 drivers/power/supply/axp20x_usb_power.c      | 15 ++----
 drivers/power/supply/bq24735-charger.c       | 18 +++----
 drivers/power/supply/ltc2941-battery-gauge.c | 20 +++-----
 drivers/power/supply/sbs-battery.c           | 16 ++----
 drivers/regulator/qcom_spmi-regulator.c      | 34 +++----------
 drivers/watchdog/retu_wdt.c                  | 22 +++-----
 include/linux/devm-helpers.h                 | 53 ++++++++++++++++++++
 14 files changed, 128 insertions(+), 155 deletions(-)
 create mode 100644 include/linux/devm-helpers.h


base-commit: 0d02ec6b3136c73c09e7859f0d0e4e2c4c07b49b
-- 
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 =] 

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

* [PATCH v3 1/8] workqueue: Add resource managed version of delayed work init
  2021-03-23 13:49 [PATCH v3 0/8] Add managed version of delayed work init Matti Vaittinen
@ 2021-03-23 13:56 ` Matti Vaittinen
  2021-03-23 13:59   ` Hans de Goede
  2021-03-23 13:56 ` [PATCH v3 2/8] MAINTAINERS: Add entry for devm helpers Matti Vaittinen
  2021-03-23 13:58 ` [PATCH v3 8/8] watchdog: retu_wdt: Clean-up by using managed work init Matti Vaittinen
  2 siblings, 1 reply; 14+ messages in thread
From: Matti Vaittinen @ 2021-03-23 13:56 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: MyungJoo Ham, Chanwoo Choi, Andy Gross, Bjorn Andersson,
	Jean Delvare, Guenter Roeck, Hans de Goede, Mark Gross,
	Sebastian Reichel, Chen-Yu Tsai, Liam Girdwood, Mark Brown,
	Wim Van Sebroeck, Matti Vaittinen, gregkh, linux-kernel,
	linux-arm-msm, linux-hwmon, platform-driver-x86, linux-pm,
	linux-watchdog

A few drivers which need a delayed work-queue must cancel work at driver
detach. Some of those implement remove() solely for this purpose. Help
drivers to avoid unnecessary remove and error-branch implementation by
adding managed verision of delayed work initialization. This will also
help drivers to avoid mixing manual and devm based unwinding when other
resources are handled by devm.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---
Changelog from RFCv2:
 - RFC dropped. No functional changes.

 include/linux/devm-helpers.h | 53 ++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 include/linux/devm-helpers.h

diff --git a/include/linux/devm-helpers.h b/include/linux/devm-helpers.h
new file mode 100644
index 000000000000..f64e0c9f3763
--- /dev/null
+++ b/include/linux/devm-helpers.h
@@ -0,0 +1,53 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __LINUX_DEVM_HELPERS_H
+#define __LINUX_DEVM_HELPERS_H
+
+/*
+ * Functions which do automatically cancel operations or release resources upon
+ * driver detach.
+ *
+ * These should be helpful to avoid mixing the manual and devm-based resource
+ * management which can be source of annoying, rarely occurring,
+ * hard-to-reproduce bugs.
+ *
+ * Please take into account that devm based cancellation may be performed some
+ * time after the remove() is ran.
+ *
+ * Thus mixing devm and manual resource management can easily cause problems
+ * when unwinding operations with dependencies. IRQ scheduling a work in a queue
+ * is typical example where IRQs are often devm-managed and WQs are manually
+ * cleaned at remove(). If IRQs are not manually freed at remove() (and this is
+ * often the case when we use devm for IRQs) we have a period of time after
+ * remove() - and before devm managed IRQs are freed - where new IRQ may fire
+ * and schedule a work item which won't be cancelled because remove() was
+ * already ran.
+ */
+
+#include <linux/device.h>
+#include <linux/workqueue.h>
+
+static inline void devm_delayed_work_drop(void *res)
+{
+	cancel_delayed_work_sync(res);
+}
+
+/**
+ * devm_delayed_work_autocancel - Resource-managed work allocation
+ * @dev: Device which lifetime work is bound to
+ * @pdata: work to be cancelled when driver is detached
+ *
+ * Initialize work which is automatically cancelled when driver is detached.
+ * A few drivers need delayed work which must be cancelled before driver
+ * is detached to avoid accessing removed resources.
+ * devm_delayed_work_autocancel() can be used to omit the explicit
+ * cancelleation when driver is detached.
+ */
+static inline int devm_delayed_work_autocancel(struct device *dev,
+					       struct delayed_work *w,
+					       work_func_t worker)
+{
+	INIT_DELAYED_WORK(w, worker);
+	return devm_add_action(dev, devm_delayed_work_drop, w);
+}
+
+#endif
-- 
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 =] 

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

* [PATCH v3 2/8] MAINTAINERS: Add entry for devm helpers
  2021-03-23 13:49 [PATCH v3 0/8] Add managed version of delayed work init Matti Vaittinen
  2021-03-23 13:56 ` [PATCH v3 1/8] workqueue: Add resource " Matti Vaittinen
@ 2021-03-23 13:56 ` Matti Vaittinen
  2021-03-23 13:58   ` Hans de Goede
  2021-03-23 13:58 ` [PATCH v3 8/8] watchdog: retu_wdt: Clean-up by using managed work init Matti Vaittinen
  2 siblings, 1 reply; 14+ messages in thread
From: Matti Vaittinen @ 2021-03-23 13:56 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: MyungJoo Ham, Chanwoo Choi, Andy Gross, Bjorn Andersson,
	Jean Delvare, Guenter Roeck, Hans de Goede, Mark Gross,
	Sebastian Reichel, Chen-Yu Tsai, Liam Girdwood, Mark Brown,
	Wim Van Sebroeck, Matti Vaittinen, gregkh, linux-kernel,
	linux-arm-msm, linux-hwmon, platform-driver-x86, linux-pm,
	linux-watchdog

Devm helper header containing small inline helpers was added.
Hans promised to maintain it.

Add Hans as maintainer and myself as designated reviewer.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---
Changelog from RFCv2:
 - RFC dropped. No functional changes.

 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 9e876927c60d..fa5ac3164678 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5169,6 +5169,12 @@ M:	Torben Mathiasen <device@lanana.org>
 S:	Maintained
 W:	http://lanana.org/docs/device-list/index.html
 
+DEVICE RESOURCE MANAGEMENT HELPERS
+M:	Hans de Goede <hdegoede@redhat.com>
+R:	Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
+S:	Maintained
+F:	include/linux/devm-helpers.h
+
 DEVICE-MAPPER  (LVM)
 M:	Alasdair Kergon <agk@redhat.com>
 M:	Mike Snitzer <snitzer@redhat.com>
-- 
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 =] 

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

* [PATCH v3 8/8] watchdog: retu_wdt: Clean-up by using managed work init
  2021-03-23 13:49 [PATCH v3 0/8] Add managed version of delayed work init Matti Vaittinen
  2021-03-23 13:56 ` [PATCH v3 1/8] workqueue: Add resource " Matti Vaittinen
  2021-03-23 13:56 ` [PATCH v3 2/8] MAINTAINERS: Add entry for devm helpers Matti Vaittinen
@ 2021-03-23 13:58 ` Matti Vaittinen
  2 siblings, 0 replies; 14+ messages in thread
From: Matti Vaittinen @ 2021-03-23 13:58 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: Guenter Roeck, Hans de Goede, Wim Van Sebroeck, Matti Vaittinen,
	gregkh, linux-kernel, linux-watchdog

Few drivers implement remove call-back only for ensuring a delayed
work gets cancelled prior driver removal. Clean-up these by switching
to use devm_delayed_work_autocancel() instead.

This change is compile-tested only. All testing is appreciated.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
---
Changelog from RFCv2:
 - RFC dropped. No functional changes.

 drivers/watchdog/retu_wdt.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/watchdog/retu_wdt.c b/drivers/watchdog/retu_wdt.c
index 258dfcf9cbda..2b9017e1cd91 100644
--- a/drivers/watchdog/retu_wdt.c
+++ b/drivers/watchdog/retu_wdt.c
@@ -8,6 +8,7 @@
  * Rewritten by Aaro Koskinen.
  */
 
+#include <linux/devm-helpers.h>
 #include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/device.h>
@@ -127,9 +128,12 @@ static int retu_wdt_probe(struct platform_device *pdev)
 	wdev->rdev		= rdev;
 	wdev->dev		= &pdev->dev;
 
-	INIT_DELAYED_WORK(&wdev->ping_work, retu_wdt_ping_work);
+	ret = devm_delayed_work_autocancel(&pdev->dev, &wdev->ping_work,
+					   retu_wdt_ping_work);
+	if (ret)
+		return ret;
 
-	ret = watchdog_register_device(retu_wdt);
+	ret = devm_watchdog_register_device(&pdev->dev, retu_wdt);
 	if (ret < 0)
 		return ret;
 
@@ -138,25 +142,11 @@ static int retu_wdt_probe(struct platform_device *pdev)
 	else
 		retu_wdt_ping_enable(wdev);
 
-	platform_set_drvdata(pdev, retu_wdt);
-
-	return 0;
-}
-
-static int retu_wdt_remove(struct platform_device *pdev)
-{
-	struct watchdog_device *wdog = platform_get_drvdata(pdev);
-	struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
-
-	watchdog_unregister_device(wdog);
-	cancel_delayed_work_sync(&wdev->ping_work);
-
 	return 0;
 }
 
 static struct platform_driver retu_wdt_driver = {
 	.probe		= retu_wdt_probe,
-	.remove		= retu_wdt_remove,
 	.driver		= {
 		.name	= "retu-wdt",
 	},
-- 
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 =] 

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

* Re: [PATCH v3 2/8] MAINTAINERS: Add entry for devm helpers
  2021-03-23 13:56 ` [PATCH v3 2/8] MAINTAINERS: Add entry for devm helpers Matti Vaittinen
@ 2021-03-23 13:58   ` Hans de Goede
  2021-03-23 14:19     ` Greg KH
  0 siblings, 1 reply; 14+ messages in thread
From: Hans de Goede @ 2021-03-23 13:58 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: MyungJoo Ham, Chanwoo Choi, Andy Gross, Bjorn Andersson,
	Jean Delvare, Guenter Roeck, Mark Gross, Sebastian Reichel,
	Chen-Yu Tsai, Liam Girdwood, Mark Brown, Wim Van Sebroeck,
	gregkh, linux-kernel, linux-arm-msm, linux-hwmon,
	platform-driver-x86, linux-pm, linux-watchdog

Hi,

On 3/23/21 2:56 PM, Matti Vaittinen wrote:
> Devm helper header containing small inline helpers was added.
> Hans promised to maintain it.
> 
> Add Hans as maintainer and myself as designated reviewer.
> 
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>

Yes I did promise that, didn't I?  FWIW going this route is still
fine by me, assuming that having someone else maintain this makes
this easier on / more acceptable to Greg.

Ultimately this is up to Greg though, so lets wait and see what
Greg has to say about this.

Regards,

Hans



> ---
> Changelog from RFCv2:
>  - RFC dropped. No functional changes.
> 
>  MAINTAINERS | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 9e876927c60d..fa5ac3164678 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5169,6 +5169,12 @@ M:	Torben Mathiasen <device@lanana.org>
>  S:	Maintained
>  W:	http://lanana.org/docs/device-list/index.html
>  
> +DEVICE RESOURCE MANAGEMENT HELPERS
> +M:	Hans de Goede <hdegoede@redhat.com>
> +R:	Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
> +S:	Maintained
> +F:	include/linux/devm-helpers.h
> +
>  DEVICE-MAPPER  (LVM)
>  M:	Alasdair Kergon <agk@redhat.com>
>  M:	Mike Snitzer <snitzer@redhat.com>
> 


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

* Re: [PATCH v3 1/8] workqueue: Add resource managed version of delayed work init
  2021-03-23 13:56 ` [PATCH v3 1/8] workqueue: Add resource " Matti Vaittinen
@ 2021-03-23 13:59   ` Hans de Goede
  0 siblings, 0 replies; 14+ messages in thread
From: Hans de Goede @ 2021-03-23 13:59 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: MyungJoo Ham, Chanwoo Choi, Andy Gross, Bjorn Andersson,
	Jean Delvare, Guenter Roeck, Mark Gross, Sebastian Reichel,
	Chen-Yu Tsai, Liam Girdwood, Mark Brown, Wim Van Sebroeck,
	gregkh, linux-kernel, linux-arm-msm, linux-hwmon,
	platform-driver-x86, linux-pm, linux-watchdog

Hi,

On 3/23/21 2:56 PM, Matti Vaittinen wrote:
> A few drivers which need a delayed work-queue must cancel work at driver
> detach. Some of those implement remove() solely for this purpose. Help
> drivers to avoid unnecessary remove and error-branch implementation by
> adding managed verision of delayed work initialization. This will also
> help drivers to avoid mixing manual and devm based unwinding when other
> resources are handled by devm.
> 
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
> Changelog from RFCv2:
>  - RFC dropped. No functional changes.
> 
>  include/linux/devm-helpers.h | 53 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 53 insertions(+)
>  create mode 100644 include/linux/devm-helpers.h
> 
> diff --git a/include/linux/devm-helpers.h b/include/linux/devm-helpers.h
> new file mode 100644
> index 000000000000..f64e0c9f3763
> --- /dev/null
> +++ b/include/linux/devm-helpers.h
> @@ -0,0 +1,53 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +#ifndef __LINUX_DEVM_HELPERS_H
> +#define __LINUX_DEVM_HELPERS_H
> +
> +/*
> + * Functions which do automatically cancel operations or release resources upon
> + * driver detach.
> + *
> + * These should be helpful to avoid mixing the manual and devm-based resource
> + * management which can be source of annoying, rarely occurring,
> + * hard-to-reproduce bugs.
> + *
> + * Please take into account that devm based cancellation may be performed some
> + * time after the remove() is ran.
> + *
> + * Thus mixing devm and manual resource management can easily cause problems
> + * when unwinding operations with dependencies. IRQ scheduling a work in a queue
> + * is typical example where IRQs are often devm-managed and WQs are manually
> + * cleaned at remove(). If IRQs are not manually freed at remove() (and this is
> + * often the case when we use devm for IRQs) we have a period of time after
> + * remove() - and before devm managed IRQs are freed - where new IRQ may fire
> + * and schedule a work item which won't be cancelled because remove() was
> + * already ran.
> + */
> +
> +#include <linux/device.h>
> +#include <linux/workqueue.h>
> +
> +static inline void devm_delayed_work_drop(void *res)
> +{
> +	cancel_delayed_work_sync(res);
> +}
> +
> +/**
> + * devm_delayed_work_autocancel - Resource-managed work allocation
> + * @dev: Device which lifetime work is bound to
> + * @pdata: work to be cancelled when driver is detached
> + *
> + * Initialize work which is automatically cancelled when driver is detached.
> + * A few drivers need delayed work which must be cancelled before driver
> + * is detached to avoid accessing removed resources.
> + * devm_delayed_work_autocancel() can be used to omit the explicit
> + * cancelleation when driver is detached.
> + */
> +static inline int devm_delayed_work_autocancel(struct device *dev,
> +					       struct delayed_work *w,
> +					       work_func_t worker)
> +{
> +	INIT_DELAYED_WORK(w, worker);
> +	return devm_add_action(dev, devm_delayed_work_drop, w);
> +}
> +
> +#endif
> 


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

* Re: [PATCH v3 2/8] MAINTAINERS: Add entry for devm helpers
  2021-03-23 13:58   ` Hans de Goede
@ 2021-03-23 14:19     ` Greg KH
  2021-04-21  7:51       ` Matti Vaittinen
  0 siblings, 1 reply; 14+ messages in thread
From: Greg KH @ 2021-03-23 14:19 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Matti Vaittinen, Matti Vaittinen, MyungJoo Ham, Chanwoo Choi,
	Andy Gross, Bjorn Andersson, Jean Delvare, Guenter Roeck,
	Mark Gross, Sebastian Reichel, Chen-Yu Tsai, Liam Girdwood,
	Mark Brown, Wim Van Sebroeck, linux-kernel, linux-arm-msm,
	linux-hwmon, platform-driver-x86, linux-pm, linux-watchdog

On Tue, Mar 23, 2021 at 02:58:28PM +0100, Hans de Goede wrote:
> Hi,
> 
> On 3/23/21 2:56 PM, Matti Vaittinen wrote:
> > Devm helper header containing small inline helpers was added.
> > Hans promised to maintain it.
> > 
> > Add Hans as maintainer and myself as designated reviewer.
> > 
> > Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
> 
> Yes I did promise that, didn't I?  FWIW going this route is still
> fine by me, assuming that having someone else maintain this makes
> this easier on / more acceptable to Greg.
> 
> Ultimately this is up to Greg though, so lets wait and see what
> Greg has to say about this.

Can we move some of the devm_* calls in include/device.h into here as
well so that you all can be in charge of them instead of me?

If so, I'm happy :)

Anyway, this looks sane, I'll queue it up and let's see what breaks in
linux-next...

thanks,

greg k-h

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

* Re: [PATCH v3 2/8] MAINTAINERS: Add entry for devm helpers
  2021-03-23 14:19     ` Greg KH
@ 2021-04-21  7:51       ` Matti Vaittinen
  2021-04-21 11:58         ` Hans de Goede
  0 siblings, 1 reply; 14+ messages in thread
From: Matti Vaittinen @ 2021-04-21  7:51 UTC (permalink / raw)
  To: Greg KH, Hans de Goede
  Cc: MyungJoo Ham, Chanwoo Choi, Andy Gross, Bjorn Andersson,
	Jean Delvare, Guenter Roeck, Mark Gross, Sebastian Reichel,
	Chen-Yu Tsai, Liam Girdwood, Mark Brown, Wim Van Sebroeck,
	linux-kernel, linux-arm-msm, linux-hwmon, platform-driver-x86,
	linux-pm, linux-watchdog


On Tue, 2021-03-23 at 15:19 +0100, Greg KH wrote:
> On Tue, Mar 23, 2021 at 02:58:28PM +0100, Hans de Goede wrote:
> > Hi,
> > 
> > On 3/23/21 2:56 PM, Matti Vaittinen wrote:
> > > Devm helper header containing small inline helpers was added.
> > > Hans promised to maintain it.
> > > 
> > > Add Hans as maintainer and myself as designated reviewer.
> > > 
> > Ultimately this is up to Greg though, so lets wait and see what
> > Greg has to say about this.
> 
> Can we move some of the devm_* calls in include/device.h into here as
> well so that you all can be in charge of them instead of me?

Seems like this was left w/o answer. I guess the question was pointed
to Hans - but what comes to my (not always so humble) opinion - most of
the devm functions in device.h are tightly related to the device
interface or devres. Thus the device.h feels like appropriate place for
most of those. OTOH, the kmalloc/kfree related functions, strdub and
kmemdub might be candidates for move - those are not really "device
things".

But this is really not my call :)

Best Regards
	Matti Vaittinen

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



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

* Re: [PATCH v3 2/8] MAINTAINERS: Add entry for devm helpers
  2021-04-21  7:51       ` Matti Vaittinen
@ 2021-04-21 11:58         ` Hans de Goede
  2021-04-21 12:09           ` Greg KH
  2021-04-21 12:17           ` Vaittinen, Matti
  0 siblings, 2 replies; 14+ messages in thread
From: Hans de Goede @ 2021-04-21 11:58 UTC (permalink / raw)
  To: matti.vaittinen, Greg KH
  Cc: MyungJoo Ham, Chanwoo Choi, Andy Gross, Bjorn Andersson,
	Jean Delvare, Guenter Roeck, Mark Gross, Sebastian Reichel,
	Chen-Yu Tsai, Liam Girdwood, Mark Brown, Wim Van Sebroeck,
	linux-kernel, linux-arm-msm, linux-hwmon, platform-driver-x86,
	linux-pm, linux-watchdog

Hi,

On 4/21/21 9:51 AM, Matti Vaittinen wrote:
> 
> On Tue, 2021-03-23 at 15:19 +0100, Greg KH wrote:
>> On Tue, Mar 23, 2021 at 02:58:28PM +0100, Hans de Goede wrote:
>>> Hi,
>>>
>>> On 3/23/21 2:56 PM, Matti Vaittinen wrote:
>>>> Devm helper header containing small inline helpers was added.
>>>> Hans promised to maintain it.
>>>>
>>>> Add Hans as maintainer and myself as designated reviewer.
>>>>
>>> Ultimately this is up to Greg though, so lets wait and see what
>>> Greg has to say about this.
>>
>> Can we move some of the devm_* calls in include/device.h into here as
>> well so that you all can be in charge of them instead of me?
> 
> Seems like this was left w/o answer. I guess the question was pointed
> to Hans

I believe that Greg was (mostly) joking here. At least that is how
I interpreted Greg's reply,which is why I did not answer.

Also note that Greg merged this series, but not this patch,
so the new devm-helpers.h file will presumably be maintained by Greg.

Regards,

Hans


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

* Re: [PATCH v3 2/8] MAINTAINERS: Add entry for devm helpers
  2021-04-21 11:58         ` Hans de Goede
@ 2021-04-21 12:09           ` Greg KH
  2021-04-21 12:39             ` Matti Vaittinen
  2021-04-21 12:17           ` Vaittinen, Matti
  1 sibling, 1 reply; 14+ messages in thread
From: Greg KH @ 2021-04-21 12:09 UTC (permalink / raw)
  To: Hans de Goede
  Cc: matti.vaittinen, MyungJoo Ham, Chanwoo Choi, Andy Gross,
	Bjorn Andersson, Jean Delvare, Guenter Roeck, Mark Gross,
	Sebastian Reichel, Chen-Yu Tsai, Liam Girdwood, Mark Brown,
	Wim Van Sebroeck, linux-kernel, linux-arm-msm, linux-hwmon,
	platform-driver-x86, linux-pm, linux-watchdog

On Wed, Apr 21, 2021 at 01:58:29PM +0200, Hans de Goede wrote:
> Hi,
> 
> On 4/21/21 9:51 AM, Matti Vaittinen wrote:
> > 
> > On Tue, 2021-03-23 at 15:19 +0100, Greg KH wrote:
> >> On Tue, Mar 23, 2021 at 02:58:28PM +0100, Hans de Goede wrote:
> >>> Hi,
> >>>
> >>> On 3/23/21 2:56 PM, Matti Vaittinen wrote:
> >>>> Devm helper header containing small inline helpers was added.
> >>>> Hans promised to maintain it.
> >>>>
> >>>> Add Hans as maintainer and myself as designated reviewer.
> >>>>
> >>> Ultimately this is up to Greg though, so lets wait and see what
> >>> Greg has to say about this.
> >>
> >> Can we move some of the devm_* calls in include/device.h into here as
> >> well so that you all can be in charge of them instead of me?
> > 
> > Seems like this was left w/o answer. I guess the question was pointed
> > to Hans
> 
> I believe that Greg was (mostly) joking here. At least that is how
> I interpreted Greg's reply,which is why I did not answer.

I have no idea what this thread was about anymore, sorry :)

> Also note that Greg merged this series, but not this patch,
> so the new devm-helpers.h file will presumably be maintained by Greg.

What's one more file...

thanks,

greg k-h

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

* Re: [PATCH v3 2/8] MAINTAINERS: Add entry for devm helpers
  2021-04-21 11:58         ` Hans de Goede
  2021-04-21 12:09           ` Greg KH
@ 2021-04-21 12:17           ` Vaittinen, Matti
  2021-04-21 12:26             ` Hans de Goede
  1 sibling, 1 reply; 14+ messages in thread
From: Vaittinen, Matti @ 2021-04-21 12:17 UTC (permalink / raw)
  To: hdegoede, gregkh
  Cc: linux-hwmon, wim, sre, linux-arm-msm, jdelvare, mgross,
	bjorn.andersson, lgirdwood, linux, platform-driver-x86, wens,
	linux-kernel, linux-pm, myungjoo.ham, linux-watchdog, agross,
	cw00.choi, broonie


On Wed, 2021-04-21 at 13:58 +0200, Hans de Goede wrote:
> Hi,
> 
> On 4/21/21 9:51 AM, Matti Vaittinen wrote:
> > On Tue, 2021-03-23 at 15:19 +0100, Greg KH wrote:
> > > On Tue, Mar 23, 2021 at 02:58:28PM +0100, Hans de Goede wrote:
> > > > Hi,
> > > > 
> > > > On 3/23/21 2:56 PM, Matti Vaittinen wrote:
> > > > > Devm helper header containing small inline helpers was added.
> > > > > Hans promised to maintain it.
> > > > > 
> > > > > Add Hans as maintainer and myself as designated reviewer.
> > > > > 
> > > > Ultimately this is up to Greg though, so lets wait and see what
> > > > Greg has to say about this.
> > > 
> > > Can we move some of the devm_* calls in include/device.h into
> > > here as
> > > well so that you all can be in charge of them instead of me?
> > 
> > Seems like this was left w/o answer. I guess the question was
> > pointed
> > to Hans
> 
> I believe that Greg was (mostly) joking here. At least that is how
> I interpreted Greg's reply,which is why I did not answer.

Ah. I missed the sarcastic tone of typing. I should've noted that by
the font :]

> Also note that Greg merged this series, but not this patch,
> so the new devm-helpers.h file will presumably be maintained by Greg.

Hmm. Are you sure?
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=driver-core-next&id=2077ca682169afb212d8a887c70057a660290df9


Best Regards
	Matti Vaittinen

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

* Re: [PATCH v3 2/8] MAINTAINERS: Add entry for devm helpers
  2021-04-21 12:17           ` Vaittinen, Matti
@ 2021-04-21 12:26             ` Hans de Goede
  2021-04-21 12:54               ` Vaittinen, Matti
  0 siblings, 1 reply; 14+ messages in thread
From: Hans de Goede @ 2021-04-21 12:26 UTC (permalink / raw)
  To: Vaittinen, Matti, gregkh
  Cc: linux-hwmon, wim, sre, linux-arm-msm, jdelvare, mgross,
	bjorn.andersson, lgirdwood, linux, platform-driver-x86, wens,
	linux-kernel, linux-pm, myungjoo.ham, linux-watchdog, agross,
	cw00.choi, broonie

Hi,

On 4/21/21 2:17 PM, Vaittinen, Matti wrote:
> 
> On Wed, 2021-04-21 at 13:58 +0200, Hans de Goede wrote:
>> Hi,
>>
>> On 4/21/21 9:51 AM, Matti Vaittinen wrote:
>>> On Tue, 2021-03-23 at 15:19 +0100, Greg KH wrote:
>>>> On Tue, Mar 23, 2021 at 02:58:28PM +0100, Hans de Goede wrote:
>>>>> Hi,
>>>>>
>>>>> On 3/23/21 2:56 PM, Matti Vaittinen wrote:
>>>>>> Devm helper header containing small inline helpers was added.
>>>>>> Hans promised to maintain it.
>>>>>>
>>>>>> Add Hans as maintainer and myself as designated reviewer.
>>>>>>
>>>>> Ultimately this is up to Greg though, so lets wait and see what
>>>>> Greg has to say about this.
>>>>
>>>> Can we move some of the devm_* calls in include/device.h into
>>>> here as
>>>> well so that you all can be in charge of them instead of me?
>>>
>>> Seems like this was left w/o answer. I guess the question was
>>> pointed
>>> to Hans
>>
>> I believe that Greg was (mostly) joking here. At least that is how
>> I interpreted Greg's reply,which is why I did not answer.
> 
> Ah. I missed the sarcastic tone of typing. I should've noted that by
> the font :]
> 
>> Also note that Greg merged this series, but not this patch,
>> so the new devm-helpers.h file will presumably be maintained by Greg.
> 
> Hmm. Are you sure?
> https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=driver-core-next&id=2077ca682169afb212d8a887c70057a660290df9

Ah, you're right.

I was looking at the wrong branch, sorry about the confusion.

Ok, so I guess I do maintain the new devm-helpers.h file, that is fine.

Which makes your email from earlier today more relevant:

> but what comes to my (not always so humble) opinion - most of
> the devm functions in device.h are tightly related to the device
> interface or devres. Thus the device.h feels like appropriate place for
> most of those.

I agree with you that most devm_ functions in device.h are probably
left there. Moving them will also mean modifying all the drivers
which use them to include the new devm-helpers.h include file
which seems like needless churn.

> OTOH, the kmalloc/kfree related functions, strdub and
> kmemdub might be candidates for move - those are not really "device
> things".

I'm certainly open to moving some functions to devm-helpers.h, but
also see above about needless churn.

Regards,

Hans


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

* Re: [PATCH v3 2/8] MAINTAINERS: Add entry for devm helpers
  2021-04-21 12:09           ` Greg KH
@ 2021-04-21 12:39             ` Matti Vaittinen
  0 siblings, 0 replies; 14+ messages in thread
From: Matti Vaittinen @ 2021-04-21 12:39 UTC (permalink / raw)
  To: Greg KH, Hans de Goede
  Cc: MyungJoo Ham, Chanwoo Choi, Andy Gross, Bjorn Andersson,
	Jean Delvare, Guenter Roeck, Mark Gross, Sebastian Reichel,
	Chen-Yu Tsai, Liam Girdwood, Mark Brown, Wim Van Sebroeck,
	linux-kernel, linux-arm-msm, linux-hwmon, platform-driver-x86,
	linux-pm, linux-watchdog


On Wed, 2021-04-21 at 14:09 +0200, Greg KH wrote:
> On Wed, Apr 21, 2021 at 01:58:29PM +0200, Hans de Goede wrote:
> > Hi,
> > 
> > On 4/21/21 9:51 AM, Matti Vaittinen wrote:
> > > On Tue, 2021-03-23 at 15:19 +0100, Greg KH wrote:
> > > > On Tue, Mar 23, 2021 at 02:58:28PM +0100, Hans de Goede wrote:
> > > > > Hi,
> > > > > 
> > > > > On 3/23/21 2:56 PM, Matti Vaittinen wrote:
> > > > > > Devm helper header containing small inline helpers was
> > > > > > added.
> > > > > > Hans promised to maintain it.
> > > > > > 
> > > > > > Add Hans as maintainer and myself as designated reviewer.
> > > > > > 
> > > > > Ultimately this is up to Greg though, so lets wait and see
> > > > > what
> > > > > Greg has to say about this.
> > > > 
> > > > Can we move some of the devm_* calls in include/device.h into
> > > > here as
> > > > well so that you all can be in charge of them instead of me?
> > > 
> > > Seems like this was left w/o answer. I guess the question was
> > > pointed
> > > to Hans
> > 
> > I believe that Greg was (mostly) joking here. At least that is how
> > I interpreted Greg's reply,which is why I did not answer.
> 
> I have no idea what this thread was about anymore, sorry :)

Need more B12 ;) Can't remember a minor discussion just a few thousand
other patch mails ago? Huh, that's what the age does, right :p

Well,
this is not urgent in any way but here's some context:

> This series implements delayed 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.
> 
> The series introduces include/linux/devm-helpers.h file which
> hopefully works as a place where this kind of helpers can be inlined.

and your reply:

>  Can we move some of the devm_* calls in include/device.h into here
> as well ...

I thought you meant that literally, Hans assumed you were joking - and
you don't remember how it was :] So - if no further suggestions, then
we keep the devm stuff which is currently in device.h still in
device.h. Although the malloc/free stuff is not really strictly device
thing.


Best Regards
	Matti Vaittinen


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

* Re: [PATCH v3 2/8] MAINTAINERS: Add entry for devm helpers
  2021-04-21 12:26             ` Hans de Goede
@ 2021-04-21 12:54               ` Vaittinen, Matti
  0 siblings, 0 replies; 14+ messages in thread
From: Vaittinen, Matti @ 2021-04-21 12:54 UTC (permalink / raw)
  To: hdegoede, gregkh
  Cc: linux-hwmon, wim, linux-arm-msm, sre, jdelvare, mgross,
	bjorn.andersson, lgirdwood, linux, platform-driver-x86, wens,
	linux-kernel, linux-pm, myungjoo.ham, linux-watchdog, agross,
	cw00.choi, broonie

On Wed, 2021-04-21 at 14:26 +0200, Hans de Goede wrote:
> Hi,
> 
> On 4/21/21 2:17 PM, Vaittinen, Matti wrote:
> > On Wed, 2021-04-21 at 13:58 +0200, Hans de Goede wrote:
> > > Hi,
> > > 
> > > On 4/21/21 9:51 AM, Matti Vaittinen wrote:
> > > > On Tue, 2021-03-23 at 15:19 +0100, Greg KH wrote:
> > > > > On Tue, Mar 23, 2021 at 02:58:28PM +0100, Hans de Goede
> > > > > wrote:
> > > > > > Hi,
> > > > > > 
> > > > > > On 3/23/21 2:56 PM, Matti Vaittinen wrote:
> > > > > > > Devm helper header containing small inline helpers was
> > > > > > > added.
> > > > > > > Hans promised to maintain it.
> > > > > > > 
> > > > > > > Add Hans as maintainer and myself as designated reviewer.
> > > > > > > 
> > > > > > Ultimately this is up to Greg though, so lets wait and see
> > > > > > what
> > > > > > Greg has to say about this.
> > > > > 
> > > > > Can we move some of the devm_* calls in include/device.h into
> > > > > here as
> > > > > well so that you all can be in charge of them instead of me?

...

> > but what comes to my (not always so humble) opinion - most of
> > the devm functions in device.h are tightly related to the device
> > interface or devres. Thus the device.h feels like appropriate place
> > for
> > most of those.
> 
> I agree with you that most devm_ functions in device.h are probably
> left there. Moving them will also mean modifying all the drivers
> which use them to include the new devm-helpers.h include file
> which seems like needless churn.
> 
> > OTOH, the kmalloc/kfree related functions, strdub and
> > kmemdub might be candidates for move - those are not really "device
> > things".
> 
> I'm certainly open to moving some functions to devm-helpers.h, but
> also see above about needless churn.

I agree. Whether the move is worth all the hassle depends on how much
Greg _really_ wishes to get rid of those devm functions. Especially the
allocs are used _a lot_.

Best Regards
	--Matti


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

end of thread, other threads:[~2021-04-21 12:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23 13:49 [PATCH v3 0/8] Add managed version of delayed work init Matti Vaittinen
2021-03-23 13:56 ` [PATCH v3 1/8] workqueue: Add resource " Matti Vaittinen
2021-03-23 13:59   ` Hans de Goede
2021-03-23 13:56 ` [PATCH v3 2/8] MAINTAINERS: Add entry for devm helpers Matti Vaittinen
2021-03-23 13:58   ` Hans de Goede
2021-03-23 14:19     ` Greg KH
2021-04-21  7:51       ` Matti Vaittinen
2021-04-21 11:58         ` Hans de Goede
2021-04-21 12:09           ` Greg KH
2021-04-21 12:39             ` Matti Vaittinen
2021-04-21 12:17           ` Vaittinen, Matti
2021-04-21 12:26             ` Hans de Goede
2021-04-21 12:54               ` Vaittinen, Matti
2021-03-23 13:58 ` [PATCH v3 8/8] watchdog: retu_wdt: Clean-up by using managed work init Matti Vaittinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).