All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] introduce devm_request_threaded_irq_emsg()
@ 2023-07-03  9:04 ` Yangtao Li
  0 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-03  9:04 UTC (permalink / raw)
  To: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, frank.li, wenst
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

There are more than 700 calls to the devm_request_threaded_irq method.
Most drivers only request one interrupt resource, and these error
messages are basically the same. If error messages are printed
everywhere, more than 1000 lines of code can be saved by removing the
msg in the driver.

And tglx point out that:

  If we actually look at the call sites of
  devm_request_threaded_irq() then the vast majority of them print more or
  less lousy error messages. A quick grep/sed/awk/sort/uniq revealed

     519 messages total (there are probably more)

     352 unique messages

     323 unique messages after lower casing

         Those 323 are mostly just variants of the same patterns with
         slight modifications in formatting and information provided.

     186 of these messages do not deliver any useful information,
         e.g. "no irq", "

     The most useful one of all is: "could request wakeup irq: %d"

  So there is certainly an argument to be made that this particular
  function should print a well formatted and informative error message.

  It's not a general allocator like kmalloc(). It's specialized and in the
  vast majority of cases failing to request the interrupt causes the
  device probe to fail. So having proper and consistent information why
  the device cannot be used _is_ useful.

So add devm_request_threaded_irq_emsg(), which ensure that all error
handling branches print error information. In this way, when this function
fails, the upper-layer functions can directly return an error code without
missing debugging information. Otherwise, the error message will be
printed redundantly or missing.

Yangtao Li (5):
  genirq/devres: Add devm_request_threaded_irq_emsg()
  thermal/drivers/armada: convert to use
    devm_request_threaded_irq_emsg()
  thermal/drivers/brcmstb_thermal: convert to use
    devm_request_threaded_irq_emsg()
  thermal/drivers/db8500: convert to use
    devm_request_threaded_irq_emsg()
  thermal/drivers/mediatek/lvts_thermal: convert to use
    devm_request_threaded_irq_emsg()

 drivers/thermal/armada_thermal.c           | 13 +++----
 drivers/thermal/broadcom/brcmstb_thermal.c | 12 +++----
 drivers/thermal/db8500_thermal.c           | 16 ++++-----
 drivers/thermal/mediatek/lvts_thermal.c    |  6 ++--
 include/linux/interrupt.h                  |  6 ++++
 kernel/irq/devres.c                        | 42 ++++++++++++++++++++++
 6 files changed, 67 insertions(+), 28 deletions(-)

-- 
2.39.0


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

* [PATCH v3 0/5] introduce devm_request_threaded_irq_emsg()
@ 2023-07-03  9:04 ` Yangtao Li
  0 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-03  9:04 UTC (permalink / raw)
  To: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, frank.li, wenst
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

There are more than 700 calls to the devm_request_threaded_irq method.
Most drivers only request one interrupt resource, and these error
messages are basically the same. If error messages are printed
everywhere, more than 1000 lines of code can be saved by removing the
msg in the driver.

And tglx point out that:

  If we actually look at the call sites of
  devm_request_threaded_irq() then the vast majority of them print more or
  less lousy error messages. A quick grep/sed/awk/sort/uniq revealed

     519 messages total (there are probably more)

     352 unique messages

     323 unique messages after lower casing

         Those 323 are mostly just variants of the same patterns with
         slight modifications in formatting and information provided.

     186 of these messages do not deliver any useful information,
         e.g. "no irq", "

     The most useful one of all is: "could request wakeup irq: %d"

  So there is certainly an argument to be made that this particular
  function should print a well formatted and informative error message.

  It's not a general allocator like kmalloc(). It's specialized and in the
  vast majority of cases failing to request the interrupt causes the
  device probe to fail. So having proper and consistent information why
  the device cannot be used _is_ useful.

So add devm_request_threaded_irq_emsg(), which ensure that all error
handling branches print error information. In this way, when this function
fails, the upper-layer functions can directly return an error code without
missing debugging information. Otherwise, the error message will be
printed redundantly or missing.

Yangtao Li (5):
  genirq/devres: Add devm_request_threaded_irq_emsg()
  thermal/drivers/armada: convert to use
    devm_request_threaded_irq_emsg()
  thermal/drivers/brcmstb_thermal: convert to use
    devm_request_threaded_irq_emsg()
  thermal/drivers/db8500: convert to use
    devm_request_threaded_irq_emsg()
  thermal/drivers/mediatek/lvts_thermal: convert to use
    devm_request_threaded_irq_emsg()

 drivers/thermal/armada_thermal.c           | 13 +++----
 drivers/thermal/broadcom/brcmstb_thermal.c | 12 +++----
 drivers/thermal/db8500_thermal.c           | 16 ++++-----
 drivers/thermal/mediatek/lvts_thermal.c    |  6 ++--
 include/linux/interrupt.h                  |  6 ++++
 kernel/irq/devres.c                        | 42 ++++++++++++++++++++++
 6 files changed, 67 insertions(+), 28 deletions(-)

-- 
2.39.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
  2023-07-03  9:04 ` Yangtao Li
@ 2023-07-03  9:04   ` Yangtao Li
  -1 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-03  9:04 UTC (permalink / raw)
  To: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, frank.li, wenst
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

There are more than 700 calls to the devm_request_threaded_irq method.
Most drivers only request one interrupt resource, and these error
messages are basically the same. If error messages are printed
everywhere, more than 1000 lines of code can be saved by removing the
msg in the driver.

And tglx point out that:

  If we actually look at the call sites of
  devm_request_threaded_irq() then the vast majority of them print more or
  less lousy error messages. A quick grep/sed/awk/sort/uniq revealed

     519 messages total (there are probably more)

     352 unique messages

     323 unique messages after lower casing

         Those 323 are mostly just variants of the same patterns with
         slight modifications in formatting and information provided.

     186 of these messages do not deliver any useful information,
         e.g. "no irq", "

     The most useful one of all is: "could request wakeup irq: %d"

  So there is certainly an argument to be made that this particular
  function should print a well formatted and informative error message.

  It's not a general allocator like kmalloc(). It's specialized and in the
  vast majority of cases failing to request the interrupt causes the
  device probe to fail. So having proper and consistent information why
  the device cannot be used _is_ useful.

So add devm_request_threaded_irq_emsg(), which ensure that all error
handling branches print error information. In this way, when this function
fails, the upper-layer functions can directly return an error code without
missing debugging information. Otherwise, the error message will be
printed redundantly or missing.

Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 include/linux/interrupt.h |  6 ++++++
 kernel/irq/devres.c       | 42 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index a92bce40b04b..cde034006e3e 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -201,6 +201,12 @@ extern void free_percpu_nmi(unsigned int irq, void __percpu *percpu_dev_id);
 
 struct device;
 
+extern int __must_check
+devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
+			      irq_handler_t handler, irq_handler_t thread_fn,
+			      unsigned long irqflags, const char *devname,
+			      void *dev_id, const char *emsg);
+
 extern int __must_check
 devm_request_threaded_irq(struct device *dev, unsigned int irq,
 			  irq_handler_t handler, irq_handler_t thread_fn,
diff --git a/kernel/irq/devres.c b/kernel/irq/devres.c
index f6e5515ee077..f2e669ccd5d4 100644
--- a/kernel/irq/devres.c
+++ b/kernel/irq/devres.c
@@ -79,6 +79,48 @@ int devm_request_threaded_irq(struct device *dev, unsigned int irq,
 }
 EXPORT_SYMBOL(devm_request_threaded_irq);
 
+/**
+ *	devm_request_threaded_irq_emsg - allocate an interrupt line for a managed device
+ *	@dev: device to request interrupt for
+ *	@irq: Interrupt line to allocate
+ *	@handler: Function to be called when the IRQ occurs
+ *	@thread_fn: function to be called in a threaded interrupt context. NULL
+ *		    for devices which handle everything in @handler
+ *	@irqflags: Interrupt type flags
+ *	@devname: An ascii name for the claiming device, dev_name(dev) if NULL
+ *	@dev_id: A cookie passed back to the handler function
+ *	@emsg: Optional additional error log
+ *
+ *	This is a variant of the devm_request_threaded_irq function.
+ *	It will print an error message by default when the request fails,
+ *	and the consumer can add a special error msg.
+ *
+ *	Except for the extra @dev argument, this function takes the
+ *	same arguments and performs the same function as
+ *	request_threaded_irq().  IRQs requested with this function will be
+ *	automatically freed on driver detach.
+ *
+ *	If an IRQ allocated with this function needs to be freed
+ *	separately, devm_free_irq() must be used.
+ */
+int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
+				   irq_handler_t handler, irq_handler_t thread_fn,
+				   unsigned long irqflags, const char *devname,
+				   void *dev_id, const char *emsg)
+{
+	int rc;
+
+	rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
+				       devname, dev_id);
+	if (rc && rc != -EPROBE_DEFER) {
+		dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
+			thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
+			emsg ? : "", ERR_PTR(rc));
+	}
+	return rc;
+}
+EXPORT_SYMBOL(devm_request_threaded_irq_emsg);
+
 /**
  *	devm_request_any_context_irq - allocate an interrupt line for a managed device
  *	@dev: device to request interrupt for
-- 
2.39.0


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

* [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
@ 2023-07-03  9:04   ` Yangtao Li
  0 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-03  9:04 UTC (permalink / raw)
  To: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, frank.li, wenst
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

There are more than 700 calls to the devm_request_threaded_irq method.
Most drivers only request one interrupt resource, and these error
messages are basically the same. If error messages are printed
everywhere, more than 1000 lines of code can be saved by removing the
msg in the driver.

And tglx point out that:

  If we actually look at the call sites of
  devm_request_threaded_irq() then the vast majority of them print more or
  less lousy error messages. A quick grep/sed/awk/sort/uniq revealed

     519 messages total (there are probably more)

     352 unique messages

     323 unique messages after lower casing

         Those 323 are mostly just variants of the same patterns with
         slight modifications in formatting and information provided.

     186 of these messages do not deliver any useful information,
         e.g. "no irq", "

     The most useful one of all is: "could request wakeup irq: %d"

  So there is certainly an argument to be made that this particular
  function should print a well formatted and informative error message.

  It's not a general allocator like kmalloc(). It's specialized and in the
  vast majority of cases failing to request the interrupt causes the
  device probe to fail. So having proper and consistent information why
  the device cannot be used _is_ useful.

So add devm_request_threaded_irq_emsg(), which ensure that all error
handling branches print error information. In this way, when this function
fails, the upper-layer functions can directly return an error code without
missing debugging information. Otherwise, the error message will be
printed redundantly or missing.

Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 include/linux/interrupt.h |  6 ++++++
 kernel/irq/devres.c       | 42 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index a92bce40b04b..cde034006e3e 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -201,6 +201,12 @@ extern void free_percpu_nmi(unsigned int irq, void __percpu *percpu_dev_id);
 
 struct device;
 
+extern int __must_check
+devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
+			      irq_handler_t handler, irq_handler_t thread_fn,
+			      unsigned long irqflags, const char *devname,
+			      void *dev_id, const char *emsg);
+
 extern int __must_check
 devm_request_threaded_irq(struct device *dev, unsigned int irq,
 			  irq_handler_t handler, irq_handler_t thread_fn,
diff --git a/kernel/irq/devres.c b/kernel/irq/devres.c
index f6e5515ee077..f2e669ccd5d4 100644
--- a/kernel/irq/devres.c
+++ b/kernel/irq/devres.c
@@ -79,6 +79,48 @@ int devm_request_threaded_irq(struct device *dev, unsigned int irq,
 }
 EXPORT_SYMBOL(devm_request_threaded_irq);
 
+/**
+ *	devm_request_threaded_irq_emsg - allocate an interrupt line for a managed device
+ *	@dev: device to request interrupt for
+ *	@irq: Interrupt line to allocate
+ *	@handler: Function to be called when the IRQ occurs
+ *	@thread_fn: function to be called in a threaded interrupt context. NULL
+ *		    for devices which handle everything in @handler
+ *	@irqflags: Interrupt type flags
+ *	@devname: An ascii name for the claiming device, dev_name(dev) if NULL
+ *	@dev_id: A cookie passed back to the handler function
+ *	@emsg: Optional additional error log
+ *
+ *	This is a variant of the devm_request_threaded_irq function.
+ *	It will print an error message by default when the request fails,
+ *	and the consumer can add a special error msg.
+ *
+ *	Except for the extra @dev argument, this function takes the
+ *	same arguments and performs the same function as
+ *	request_threaded_irq().  IRQs requested with this function will be
+ *	automatically freed on driver detach.
+ *
+ *	If an IRQ allocated with this function needs to be freed
+ *	separately, devm_free_irq() must be used.
+ */
+int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
+				   irq_handler_t handler, irq_handler_t thread_fn,
+				   unsigned long irqflags, const char *devname,
+				   void *dev_id, const char *emsg)
+{
+	int rc;
+
+	rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
+				       devname, dev_id);
+	if (rc && rc != -EPROBE_DEFER) {
+		dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
+			thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
+			emsg ? : "", ERR_PTR(rc));
+	}
+	return rc;
+}
+EXPORT_SYMBOL(devm_request_threaded_irq_emsg);
+
 /**
  *	devm_request_any_context_irq - allocate an interrupt line for a managed device
  *	@dev: device to request interrupt for
-- 
2.39.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v3 2/5] thermal/drivers/armada: convert to use devm_request_threaded_irq_emsg()
  2023-07-03  9:04 ` Yangtao Li
@ 2023-07-03  9:04   ` Yangtao Li
  -1 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-03  9:04 UTC (permalink / raw)
  To: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, frank.li, wenst
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

There are more than 700 calls to the devm_request_threaded_irq method.
Most drivers only request one interrupt resource, and these error
messages are basically the same. If error messages are printed
everywhere, more than 1000 lines of code can be saved by removing the
msg in the driver.

And tglx point out that:

  If we actually look at the call sites of
  devm_request_threaded_irq() then the vast majority of them print more or
  less lousy error messages. A quick grep/sed/awk/sort/uniq revealed

     519 messages total (there are probably more)

     352 unique messages

     323 unique messages after lower casing

         Those 323 are mostly just variants of the same patterns with
         slight modifications in formatting and information provided.

     186 of these messages do not deliver any useful information,
         e.g. "no irq", "

     The most useful one of all is: "could request wakeup irq: %d"

  So there is certainly an argument to be made that this particular
  function should print a well formatted and informative error message.

  It's not a general allocator like kmalloc(). It's specialized and in the
  vast majority of cases failing to request the interrupt causes the
  device probe to fail. So having proper and consistent information why
  the device cannot be used _is_ useful.

Let's use devm_request_threaded_irq_emsg(), which ensure that all error
handling branches print error information. In this way, when this function
fails, the upper-layer functions can directly return an error code without
missing debugging information. Otherwise, the error message will be
printed redundantly or missing.

Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/thermal/armada_thermal.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
index 9f6dc4fc9112..a5e140643f00 100644
--- a/drivers/thermal/armada_thermal.c
+++ b/drivers/thermal/armada_thermal.c
@@ -913,15 +913,12 @@ static int armada_thermal_probe(struct platform_device *pdev)
 
 	/* The overheat interrupt feature is not mandatory */
 	if (irq > 0) {
-		ret = devm_request_threaded_irq(&pdev->dev, irq,
-						armada_overheat_isr,
-						armada_overheat_isr_thread,
-						0, NULL, priv);
-		if (ret) {
-			dev_err(&pdev->dev, "Cannot request threaded IRQ %d\n",
-				irq);
+		ret = devm_request_threaded_irq_emsg(&pdev->dev, irq,
+						     armada_overheat_isr,
+						     armada_overheat_isr_thread,
+						     0, NULL, priv, NULL);
+		if (ret)
 			return ret;
-		}
 	}
 
 	/*
-- 
2.39.0


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

* [PATCH v3 2/5] thermal/drivers/armada: convert to use devm_request_threaded_irq_emsg()
@ 2023-07-03  9:04   ` Yangtao Li
  0 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-03  9:04 UTC (permalink / raw)
  To: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, frank.li, wenst
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

There are more than 700 calls to the devm_request_threaded_irq method.
Most drivers only request one interrupt resource, and these error
messages are basically the same. If error messages are printed
everywhere, more than 1000 lines of code can be saved by removing the
msg in the driver.

And tglx point out that:

  If we actually look at the call sites of
  devm_request_threaded_irq() then the vast majority of them print more or
  less lousy error messages. A quick grep/sed/awk/sort/uniq revealed

     519 messages total (there are probably more)

     352 unique messages

     323 unique messages after lower casing

         Those 323 are mostly just variants of the same patterns with
         slight modifications in formatting and information provided.

     186 of these messages do not deliver any useful information,
         e.g. "no irq", "

     The most useful one of all is: "could request wakeup irq: %d"

  So there is certainly an argument to be made that this particular
  function should print a well formatted and informative error message.

  It's not a general allocator like kmalloc(). It's specialized and in the
  vast majority of cases failing to request the interrupt causes the
  device probe to fail. So having proper and consistent information why
  the device cannot be used _is_ useful.

Let's use devm_request_threaded_irq_emsg(), which ensure that all error
handling branches print error information. In this way, when this function
fails, the upper-layer functions can directly return an error code without
missing debugging information. Otherwise, the error message will be
printed redundantly or missing.

Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/thermal/armada_thermal.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
index 9f6dc4fc9112..a5e140643f00 100644
--- a/drivers/thermal/armada_thermal.c
+++ b/drivers/thermal/armada_thermal.c
@@ -913,15 +913,12 @@ static int armada_thermal_probe(struct platform_device *pdev)
 
 	/* The overheat interrupt feature is not mandatory */
 	if (irq > 0) {
-		ret = devm_request_threaded_irq(&pdev->dev, irq,
-						armada_overheat_isr,
-						armada_overheat_isr_thread,
-						0, NULL, priv);
-		if (ret) {
-			dev_err(&pdev->dev, "Cannot request threaded IRQ %d\n",
-				irq);
+		ret = devm_request_threaded_irq_emsg(&pdev->dev, irq,
+						     armada_overheat_isr,
+						     armada_overheat_isr_thread,
+						     0, NULL, priv, NULL);
+		if (ret)
 			return ret;
-		}
 	}
 
 	/*
-- 
2.39.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v3 3/5] thermal/drivers/brcmstb_thermal: convert to use devm_request_threaded_irq_emsg()
  2023-07-03  9:04 ` Yangtao Li
@ 2023-07-03  9:04   ` Yangtao Li
  -1 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-03  9:04 UTC (permalink / raw)
  To: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, frank.li, wenst
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

There are more than 700 calls to the devm_request_threaded_irq method.
Most drivers only request one interrupt resource, and these error
messages are basically the same. If error messages are printed
everywhere, more than 1000 lines of code can be saved by removing the
msg in the driver.

And tglx point out that:

  If we actually look at the call sites of
  devm_request_threaded_irq() then the vast majority of them print more or
  less lousy error messages. A quick grep/sed/awk/sort/uniq revealed

     519 messages total (there are probably more)

     352 unique messages

     323 unique messages after lower casing

         Those 323 are mostly just variants of the same patterns with
         slight modifications in formatting and information provided.

     186 of these messages do not deliver any useful information,
         e.g. "no irq", "

     The most useful one of all is: "could request wakeup irq: %d"

  So there is certainly an argument to be made that this particular
  function should print a well formatted and informative error message.

  It's not a general allocator like kmalloc(). It's specialized and in the
  vast majority of cases failing to request the interrupt causes the
  device probe to fail. So having proper and consistent information why
  the device cannot be used _is_ useful.

Let's use devm_request_threaded_irq_emsg(), which ensure that all error
handling branches print error information. In this way, when this function
fails, the upper-layer functions can directly return an error code without
missing debugging information. Otherwise, the error message will be
printed redundantly or missing.

Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/thermal/broadcom/brcmstb_thermal.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/thermal/broadcom/brcmstb_thermal.c b/drivers/thermal/broadcom/brcmstb_thermal.c
index 72d1dbe60b8f..b922f8278f62 100644
--- a/drivers/thermal/broadcom/brcmstb_thermal.c
+++ b/drivers/thermal/broadcom/brcmstb_thermal.c
@@ -349,14 +349,12 @@ static int brcmstb_thermal_probe(struct platform_device *pdev)
 
 	irq = platform_get_irq_optional(pdev, 0);
 	if (irq >= 0) {
-		ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
-						brcmstb_tmon_irq_thread,
-						IRQF_ONESHOT,
-						DRV_NAME, priv);
-		if (ret < 0) {
-			dev_err(&pdev->dev, "could not request IRQ: %d\n", ret);
+		ret = devm_request_threaded_irq_emsg(&pdev->dev, irq, NULL,
+						     brcmstb_tmon_irq_thread,
+						     IRQF_ONESHOT,
+						     DRV_NAME, priv, NULL);
+		if (ret < 0)
 			return ret;
-		}
 	}
 
 	dev_info(&pdev->dev, "registered AVS TMON of-sensor driver\n");
-- 
2.39.0


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

* [PATCH v3 3/5] thermal/drivers/brcmstb_thermal: convert to use devm_request_threaded_irq_emsg()
@ 2023-07-03  9:04   ` Yangtao Li
  0 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-03  9:04 UTC (permalink / raw)
  To: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, frank.li, wenst
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

There are more than 700 calls to the devm_request_threaded_irq method.
Most drivers only request one interrupt resource, and these error
messages are basically the same. If error messages are printed
everywhere, more than 1000 lines of code can be saved by removing the
msg in the driver.

And tglx point out that:

  If we actually look at the call sites of
  devm_request_threaded_irq() then the vast majority of them print more or
  less lousy error messages. A quick grep/sed/awk/sort/uniq revealed

     519 messages total (there are probably more)

     352 unique messages

     323 unique messages after lower casing

         Those 323 are mostly just variants of the same patterns with
         slight modifications in formatting and information provided.

     186 of these messages do not deliver any useful information,
         e.g. "no irq", "

     The most useful one of all is: "could request wakeup irq: %d"

  So there is certainly an argument to be made that this particular
  function should print a well formatted and informative error message.

  It's not a general allocator like kmalloc(). It's specialized and in the
  vast majority of cases failing to request the interrupt causes the
  device probe to fail. So having proper and consistent information why
  the device cannot be used _is_ useful.

Let's use devm_request_threaded_irq_emsg(), which ensure that all error
handling branches print error information. In this way, when this function
fails, the upper-layer functions can directly return an error code without
missing debugging information. Otherwise, the error message will be
printed redundantly or missing.

Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/thermal/broadcom/brcmstb_thermal.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/thermal/broadcom/brcmstb_thermal.c b/drivers/thermal/broadcom/brcmstb_thermal.c
index 72d1dbe60b8f..b922f8278f62 100644
--- a/drivers/thermal/broadcom/brcmstb_thermal.c
+++ b/drivers/thermal/broadcom/brcmstb_thermal.c
@@ -349,14 +349,12 @@ static int brcmstb_thermal_probe(struct platform_device *pdev)
 
 	irq = platform_get_irq_optional(pdev, 0);
 	if (irq >= 0) {
-		ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
-						brcmstb_tmon_irq_thread,
-						IRQF_ONESHOT,
-						DRV_NAME, priv);
-		if (ret < 0) {
-			dev_err(&pdev->dev, "could not request IRQ: %d\n", ret);
+		ret = devm_request_threaded_irq_emsg(&pdev->dev, irq, NULL,
+						     brcmstb_tmon_irq_thread,
+						     IRQF_ONESHOT,
+						     DRV_NAME, priv, NULL);
+		if (ret < 0)
 			return ret;
-		}
 	}
 
 	dev_info(&pdev->dev, "registered AVS TMON of-sensor driver\n");
-- 
2.39.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v3 4/5] thermal/drivers/db8500: convert to use devm_request_threaded_irq_emsg()
  2023-07-03  9:04 ` Yangtao Li
@ 2023-07-03  9:04   ` Yangtao Li
  -1 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-03  9:04 UTC (permalink / raw)
  To: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, frank.li, wenst
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

There are more than 700 calls to the devm_request_threaded_irq method.
Most drivers only request one interrupt resource, and these error
messages are basically the same. If error messages are printed
everywhere, more than 1000 lines of code can be saved by removing the
msg in the driver.

And tglx point out that:

  If we actually look at the call sites of
  devm_request_threaded_irq() then the vast majority of them print more or
  less lousy error messages. A quick grep/sed/awk/sort/uniq revealed

     519 messages total (there are probably more)

     352 unique messages

     323 unique messages after lower casing

         Those 323 are mostly just variants of the same patterns with
         slight modifications in formatting and information provided.

     186 of these messages do not deliver any useful information,
         e.g. "no irq", "

     The most useful one of all is: "could request wakeup irq: %d"

  So there is certainly an argument to be made that this particular
  function should print a well formatted and informative error message.

  It's not a general allocator like kmalloc(). It's specialized and in the
  vast majority of cases failing to request the interrupt causes the
  device probe to fail. So having proper and consistent information why
  the device cannot be used _is_ useful.

Let's use devm_request_threaded_irq_emsg(), which ensure that all error
handling branches print error information. In this way, when this function
fails, the upper-layer functions can directly return an error code without
missing debugging information. Otherwise, the error message will be
printed redundantly or missing.

Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/thermal/db8500_thermal.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/thermal/db8500_thermal.c b/drivers/thermal/db8500_thermal.c
index fca5c2c93bf9..195caf954aca 100644
--- a/drivers/thermal/db8500_thermal.c
+++ b/drivers/thermal/db8500_thermal.c
@@ -164,25 +164,21 @@ static int db8500_thermal_probe(struct platform_device *pdev)
 	if (low_irq < 0)
 		return low_irq;
 
-	ret = devm_request_threaded_irq(dev, low_irq, NULL,
+	ret = devm_request_threaded_irq_emsg(dev, low_irq, NULL,
 		prcmu_low_irq_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT,
-		"dbx500_temp_low", th);
-	if (ret < 0) {
-		dev_err(dev, "failed to allocate temp low irq\n");
+		"dbx500_temp_low", th, "temp low");
+	if (ret < 0)
 		return ret;
-	}
 
 	high_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_HIGH");
 	if (high_irq < 0)
 		return high_irq;
 
-	ret = devm_request_threaded_irq(dev, high_irq, NULL,
+	ret = devm_request_threaded_irq_emsg(dev, high_irq, NULL,
 		prcmu_high_irq_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT,
-		"dbx500_temp_high", th);
-	if (ret < 0) {
-		dev_err(dev, "failed to allocate temp high irq\n");
+		"dbx500_temp_high", th, "temp high");
+	if (ret < 0)
 		return ret;
-	}
 
 	/* register of thermal sensor and get info from DT */
 	th->tz = devm_thermal_of_zone_register(dev, 0, th, &thdev_ops);
-- 
2.39.0


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

* [PATCH v3 4/5] thermal/drivers/db8500: convert to use devm_request_threaded_irq_emsg()
@ 2023-07-03  9:04   ` Yangtao Li
  0 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-03  9:04 UTC (permalink / raw)
  To: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, frank.li, wenst
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

There are more than 700 calls to the devm_request_threaded_irq method.
Most drivers only request one interrupt resource, and these error
messages are basically the same. If error messages are printed
everywhere, more than 1000 lines of code can be saved by removing the
msg in the driver.

And tglx point out that:

  If we actually look at the call sites of
  devm_request_threaded_irq() then the vast majority of them print more or
  less lousy error messages. A quick grep/sed/awk/sort/uniq revealed

     519 messages total (there are probably more)

     352 unique messages

     323 unique messages after lower casing

         Those 323 are mostly just variants of the same patterns with
         slight modifications in formatting and information provided.

     186 of these messages do not deliver any useful information,
         e.g. "no irq", "

     The most useful one of all is: "could request wakeup irq: %d"

  So there is certainly an argument to be made that this particular
  function should print a well formatted and informative error message.

  It's not a general allocator like kmalloc(). It's specialized and in the
  vast majority of cases failing to request the interrupt causes the
  device probe to fail. So having proper and consistent information why
  the device cannot be used _is_ useful.

Let's use devm_request_threaded_irq_emsg(), which ensure that all error
handling branches print error information. In this way, when this function
fails, the upper-layer functions can directly return an error code without
missing debugging information. Otherwise, the error message will be
printed redundantly or missing.

Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/thermal/db8500_thermal.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/thermal/db8500_thermal.c b/drivers/thermal/db8500_thermal.c
index fca5c2c93bf9..195caf954aca 100644
--- a/drivers/thermal/db8500_thermal.c
+++ b/drivers/thermal/db8500_thermal.c
@@ -164,25 +164,21 @@ static int db8500_thermal_probe(struct platform_device *pdev)
 	if (low_irq < 0)
 		return low_irq;
 
-	ret = devm_request_threaded_irq(dev, low_irq, NULL,
+	ret = devm_request_threaded_irq_emsg(dev, low_irq, NULL,
 		prcmu_low_irq_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT,
-		"dbx500_temp_low", th);
-	if (ret < 0) {
-		dev_err(dev, "failed to allocate temp low irq\n");
+		"dbx500_temp_low", th, "temp low");
+	if (ret < 0)
 		return ret;
-	}
 
 	high_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_HIGH");
 	if (high_irq < 0)
 		return high_irq;
 
-	ret = devm_request_threaded_irq(dev, high_irq, NULL,
+	ret = devm_request_threaded_irq_emsg(dev, high_irq, NULL,
 		prcmu_high_irq_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT,
-		"dbx500_temp_high", th);
-	if (ret < 0) {
-		dev_err(dev, "failed to allocate temp high irq\n");
+		"dbx500_temp_high", th, "temp high");
+	if (ret < 0)
 		return ret;
-	}
 
 	/* register of thermal sensor and get info from DT */
 	th->tz = devm_thermal_of_zone_register(dev, 0, th, &thdev_ops);
-- 
2.39.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v3 5/5] thermal/drivers/mediatek/lvts_thermal: convert to use devm_request_threaded_irq_emsg()
  2023-07-03  9:04 ` Yangtao Li
@ 2023-07-03  9:04   ` Yangtao Li
  -1 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-03  9:04 UTC (permalink / raw)
  To: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, frank.li, wenst
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

There are more than 700 calls to the devm_request_threaded_irq method.
Most drivers only request one interrupt resource, and these error
messages are basically the same. If error messages are printed
everywhere, more than 1000 lines of code can be saved by removing the
msg in the driver.

And tglx point out that:

  If we actually look at the call sites of
  devm_request_threaded_irq() then the vast majority of them print more or
  less lousy error messages. A quick grep/sed/awk/sort/uniq revealed

     519 messages total (there are probably more)

     352 unique messages

     323 unique messages after lower casing

         Those 323 are mostly just variants of the same patterns with
         slight modifications in formatting and information provided.

     186 of these messages do not deliver any useful information,
         e.g. "no irq", "

     The most useful one of all is: "could request wakeup irq: %d"

  So there is certainly an argument to be made that this particular
  function should print a well formatted and informative error message.

  It's not a general allocator like kmalloc(). It's specialized and in the
  vast majority of cases failing to request the interrupt causes the
  device probe to fail. So having proper and consistent information why
  the device cannot be used _is_ useful.

Let's use devm_request_threaded_irq_emsg(), which ensure that all error
handling branches print error information. In this way, when this function
fails, the upper-layer functions can directly return an error code without
missing debugging information. Otherwise, the error message will be
printed redundantly or missing.

Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/thermal/mediatek/lvts_thermal.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index b693fac2d677..b6403bf2300f 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -1148,10 +1148,10 @@ static int lvts_probe(struct platform_device *pdev)
 	 * At this point the LVTS is initialized and enabled. We can
 	 * safely enable the interrupt.
 	 */
-	ret = devm_request_threaded_irq(dev, irq, NULL, lvts_irq_handler,
-					IRQF_ONESHOT, dev_name(dev), lvts_td);
+	ret = devm_request_threaded_irq_emsg(dev, irq, NULL, lvts_irq_handler,
+					     IRQF_ONESHOT, dev_name(dev), lvts_td, NULL);
 	if (ret)
-		return dev_err_probe(dev, ret, "Failed to request interrupt\n");
+		return ret;
 
 	platform_set_drvdata(pdev, lvts_td);
 
-- 
2.39.0


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

* [PATCH v3 5/5] thermal/drivers/mediatek/lvts_thermal: convert to use devm_request_threaded_irq_emsg()
@ 2023-07-03  9:04   ` Yangtao Li
  0 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-03  9:04 UTC (permalink / raw)
  To: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, frank.li, wenst
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

There are more than 700 calls to the devm_request_threaded_irq method.
Most drivers only request one interrupt resource, and these error
messages are basically the same. If error messages are printed
everywhere, more than 1000 lines of code can be saved by removing the
msg in the driver.

And tglx point out that:

  If we actually look at the call sites of
  devm_request_threaded_irq() then the vast majority of them print more or
  less lousy error messages. A quick grep/sed/awk/sort/uniq revealed

     519 messages total (there are probably more)

     352 unique messages

     323 unique messages after lower casing

         Those 323 are mostly just variants of the same patterns with
         slight modifications in formatting and information provided.

     186 of these messages do not deliver any useful information,
         e.g. "no irq", "

     The most useful one of all is: "could request wakeup irq: %d"

  So there is certainly an argument to be made that this particular
  function should print a well formatted and informative error message.

  It's not a general allocator like kmalloc(). It's specialized and in the
  vast majority of cases failing to request the interrupt causes the
  device probe to fail. So having proper and consistent information why
  the device cannot be used _is_ useful.

Let's use devm_request_threaded_irq_emsg(), which ensure that all error
handling branches print error information. In this way, when this function
fails, the upper-layer functions can directly return an error code without
missing debugging information. Otherwise, the error message will be
printed redundantly or missing.

Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/thermal/mediatek/lvts_thermal.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index b693fac2d677..b6403bf2300f 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -1148,10 +1148,10 @@ static int lvts_probe(struct platform_device *pdev)
 	 * At this point the LVTS is initialized and enabled. We can
 	 * safely enable the interrupt.
 	 */
-	ret = devm_request_threaded_irq(dev, irq, NULL, lvts_irq_handler,
-					IRQF_ONESHOT, dev_name(dev), lvts_td);
+	ret = devm_request_threaded_irq_emsg(dev, irq, NULL, lvts_irq_handler,
+					     IRQF_ONESHOT, dev_name(dev), lvts_td, NULL);
 	if (ret)
-		return dev_err_probe(dev, ret, "Failed to request interrupt\n");
+		return ret;
 
 	platform_set_drvdata(pdev, lvts_td);
 
-- 
2.39.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 0/5] introduce devm_request_threaded_irq_emsg()
  2023-07-03  9:04 ` Yangtao Li
@ 2023-07-03 11:47   ` Yangtao Li
  -1 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-03 11:47 UTC (permalink / raw)
  To: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, wenst, Uwe Kleine-König,
	Krzysztof Kozlowski
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

+cc u.kleine-koenig@pengutronix.de, krzysztof.kozlowski@linaro.org

On 2023/7/3 17:04, Yangtao Li wrote:
> There are more than 700 calls to the devm_request_threaded_irq method.
> Most drivers only request one interrupt resource, and these error
> messages are basically the same. If error messages are printed
> everywhere, more than 1000 lines of code can be saved by removing the
> msg in the driver.
>
> And tglx point out that:
>
>    If we actually look at the call sites of
>    devm_request_threaded_irq() then the vast majority of them print more or
>    less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
>
>       519 messages total (there are probably more)
>
>       352 unique messages
>
>       323 unique messages after lower casing
>
>           Those 323 are mostly just variants of the same patterns with
>           slight modifications in formatting and information provided.
>
>       186 of these messages do not deliver any useful information,
>           e.g. "no irq", "
>
>       The most useful one of all is: "could request wakeup irq: %d"
>
>    So there is certainly an argument to be made that this particular
>    function should print a well formatted and informative error message.
>
>    It's not a general allocator like kmalloc(). It's specialized and in the
>    vast majority of cases failing to request the interrupt causes the
>    device probe to fail. So having proper and consistent information why
>    the device cannot be used _is_ useful.
>
> So add devm_request_threaded_irq_emsg(), which ensure that all error
> handling branches print error information. In this way, when this function
> fails, the upper-layer functions can directly return an error code without
> missing debugging information. Otherwise, the error message will be
> printed redundantly or missing.
>
> Yangtao Li (5):
>    genirq/devres: Add devm_request_threaded_irq_emsg()
>    thermal/drivers/armada: convert to use
>      devm_request_threaded_irq_emsg()
>    thermal/drivers/brcmstb_thermal: convert to use
>      devm_request_threaded_irq_emsg()
>    thermal/drivers/db8500: convert to use
>      devm_request_threaded_irq_emsg()
>    thermal/drivers/mediatek/lvts_thermal: convert to use
>      devm_request_threaded_irq_emsg()
>
>   drivers/thermal/armada_thermal.c           | 13 +++----
>   drivers/thermal/broadcom/brcmstb_thermal.c | 12 +++----
>   drivers/thermal/db8500_thermal.c           | 16 ++++-----
>   drivers/thermal/mediatek/lvts_thermal.c    |  6 ++--
>   include/linux/interrupt.h                  |  6 ++++
>   kernel/irq/devres.c                        | 42 ++++++++++++++++++++++
>   6 files changed, 67 insertions(+), 28 deletions(-)
>

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

* Re: [PATCH v3 0/5] introduce devm_request_threaded_irq_emsg()
@ 2023-07-03 11:47   ` Yangtao Li
  0 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-03 11:47 UTC (permalink / raw)
  To: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, wenst, Uwe Kleine-König,
	Krzysztof Kozlowski
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

+cc u.kleine-koenig@pengutronix.de, krzysztof.kozlowski@linaro.org

On 2023/7/3 17:04, Yangtao Li wrote:
> There are more than 700 calls to the devm_request_threaded_irq method.
> Most drivers only request one interrupt resource, and these error
> messages are basically the same. If error messages are printed
> everywhere, more than 1000 lines of code can be saved by removing the
> msg in the driver.
>
> And tglx point out that:
>
>    If we actually look at the call sites of
>    devm_request_threaded_irq() then the vast majority of them print more or
>    less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
>
>       519 messages total (there are probably more)
>
>       352 unique messages
>
>       323 unique messages after lower casing
>
>           Those 323 are mostly just variants of the same patterns with
>           slight modifications in formatting and information provided.
>
>       186 of these messages do not deliver any useful information,
>           e.g. "no irq", "
>
>       The most useful one of all is: "could request wakeup irq: %d"
>
>    So there is certainly an argument to be made that this particular
>    function should print a well formatted and informative error message.
>
>    It's not a general allocator like kmalloc(). It's specialized and in the
>    vast majority of cases failing to request the interrupt causes the
>    device probe to fail. So having proper and consistent information why
>    the device cannot be used _is_ useful.
>
> So add devm_request_threaded_irq_emsg(), which ensure that all error
> handling branches print error information. In this way, when this function
> fails, the upper-layer functions can directly return an error code without
> missing debugging information. Otherwise, the error message will be
> printed redundantly or missing.
>
> Yangtao Li (5):
>    genirq/devres: Add devm_request_threaded_irq_emsg()
>    thermal/drivers/armada: convert to use
>      devm_request_threaded_irq_emsg()
>    thermal/drivers/brcmstb_thermal: convert to use
>      devm_request_threaded_irq_emsg()
>    thermal/drivers/db8500: convert to use
>      devm_request_threaded_irq_emsg()
>    thermal/drivers/mediatek/lvts_thermal: convert to use
>      devm_request_threaded_irq_emsg()
>
>   drivers/thermal/armada_thermal.c           | 13 +++----
>   drivers/thermal/broadcom/brcmstb_thermal.c | 12 +++----
>   drivers/thermal/db8500_thermal.c           | 16 ++++-----
>   drivers/thermal/mediatek/lvts_thermal.c    |  6 ++--
>   include/linux/interrupt.h                  |  6 ++++
>   kernel/irq/devres.c                        | 42 ++++++++++++++++++++++
>   6 files changed, 67 insertions(+), 28 deletions(-)
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
  2023-07-03  9:04   ` Yangtao Li
@ 2023-07-03 12:31     ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 44+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-03 12:31 UTC (permalink / raw)
  To: Yangtao Li, miquel.raynal, rafael, daniel.lezcano, amitk,
	rui.zhang, mmayer, bcm-kernel-feedback-list, florian.fainelli,
	tglx, matthias.bgg, angelogioacchino.delregno, bchihi, wenst
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

On 03/07/2023 11:04, Yangtao Li wrote:
> There are more than 700 calls to the devm_request_threaded_irq method.
> Most drivers only request one interrupt resource, and these error
> messages are basically the same. If error messages are printed
> everywhere, more than 1000 lines of code can be saved by removing the
> msg in the driver.


...

> +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
> +				   irq_handler_t handler, irq_handler_t thread_fn,
> +				   unsigned long irqflags, const char *devname,
> +				   void *dev_id, const char *emsg)
> +{
> +	int rc;
> +
> +	rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
> +				       devname, dev_id);
> +	if (rc && rc != -EPROBE_DEFER) {
> +		dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
> +			thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
> +			emsg ? : "", ERR_PTR(rc));

It is open-coding dev_err_probe(). Just use dev_err_probe instead.

Best regards,
Krzysztof


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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
@ 2023-07-03 12:31     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 44+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-03 12:31 UTC (permalink / raw)
  To: Yangtao Li, miquel.raynal, rafael, daniel.lezcano, amitk,
	rui.zhang, mmayer, bcm-kernel-feedback-list, florian.fainelli,
	tglx, matthias.bgg, angelogioacchino.delregno, bchihi, wenst
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

On 03/07/2023 11:04, Yangtao Li wrote:
> There are more than 700 calls to the devm_request_threaded_irq method.
> Most drivers only request one interrupt resource, and these error
> messages are basically the same. If error messages are printed
> everywhere, more than 1000 lines of code can be saved by removing the
> msg in the driver.


...

> +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
> +				   irq_handler_t handler, irq_handler_t thread_fn,
> +				   unsigned long irqflags, const char *devname,
> +				   void *dev_id, const char *emsg)
> +{
> +	int rc;
> +
> +	rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
> +				       devname, dev_id);
> +	if (rc && rc != -EPROBE_DEFER) {
> +		dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
> +			thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
> +			emsg ? : "", ERR_PTR(rc));

It is open-coding dev_err_probe(). Just use dev_err_probe instead.

Best regards,
Krzysztof


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
  2023-07-03 12:31     ` Krzysztof Kozlowski
@ 2023-07-03 13:24       ` Yangtao Li
  -1 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-03 13:24 UTC (permalink / raw)
  To: Krzysztof Kozlowski, miquel.raynal, rafael, daniel.lezcano,
	amitk, rui.zhang, mmayer, bcm-kernel-feedback-list,
	florian.fainelli, tglx, matthias.bgg, angelogioacchino.delregno,
	bchihi, wenst
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek


On 2023/7/3 20:31, Krzysztof Kozlowski wrote:
> [你通常不会收到来自 krzk@kernel.org 的电子邮件。请访问 https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要]
>
> On 03/07/2023 11:04, Yangtao Li wrote:
>> There are more than 700 calls to the devm_request_threaded_irq method.
>> Most drivers only request one interrupt resource, and these error
>> messages are basically the same. If error messages are printed
>> everywhere, more than 1000 lines of code can be saved by removing the
>> msg in the driver.
>
> ...
>
>> +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
>> +                                irq_handler_t handler, irq_handler_t thread_fn,
>> +                                unsigned long irqflags, const char *devname,
>> +                                void *dev_id, const char *emsg)
>> +{
>> +     int rc;
>> +
>> +     rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
>> +                                    devname, dev_id);
>> +     if (rc && rc != -EPROBE_DEFER) {
>> +             dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
>> +                     thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
>> +                     emsg ? : "", ERR_PTR(rc));
> It is open-coding dev_err_probe(). Just use dev_err_probe instead.


How about the following? If possible, I would like to start modifying 
more drivers in the next version.


int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
                                    irq_handler_t handler, irq_handler_t 
thread_fn,
                                    unsigned long irqflags, const char 
*devname,
                                    void *dev_id, const char *emsg)
{
         int rc;

         rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
                                        devname, dev_id);
         if (rc) {
                 dev_err_probe(dev, rc, "Failed to request %sinterrupt 
%u %s %s\n",
                               thread_fn ? "threaded " : "", irq, 
devname ? : dev_name(dev),
                               emsg ? : "");
         }
         return rc;
}
EXPORT_SYMBOL(devm_request_threaded_irq_emsg);


Thx,

Yangtao


>
> Best regards,
> Krzysztof
>

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
@ 2023-07-03 13:24       ` Yangtao Li
  0 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-03 13:24 UTC (permalink / raw)
  To: Krzysztof Kozlowski, miquel.raynal, rafael, daniel.lezcano,
	amitk, rui.zhang, mmayer, bcm-kernel-feedback-list,
	florian.fainelli, tglx, matthias.bgg, angelogioacchino.delregno,
	bchihi, wenst
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek


On 2023/7/3 20:31, Krzysztof Kozlowski wrote:
> [你通常不会收到来自 krzk@kernel.org 的电子邮件。请访问 https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要]
>
> On 03/07/2023 11:04, Yangtao Li wrote:
>> There are more than 700 calls to the devm_request_threaded_irq method.
>> Most drivers only request one interrupt resource, and these error
>> messages are basically the same. If error messages are printed
>> everywhere, more than 1000 lines of code can be saved by removing the
>> msg in the driver.
>
> ...
>
>> +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
>> +                                irq_handler_t handler, irq_handler_t thread_fn,
>> +                                unsigned long irqflags, const char *devname,
>> +                                void *dev_id, const char *emsg)
>> +{
>> +     int rc;
>> +
>> +     rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
>> +                                    devname, dev_id);
>> +     if (rc && rc != -EPROBE_DEFER) {
>> +             dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
>> +                     thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
>> +                     emsg ? : "", ERR_PTR(rc));
> It is open-coding dev_err_probe(). Just use dev_err_probe instead.


How about the following? If possible, I would like to start modifying 
more drivers in the next version.


int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
                                    irq_handler_t handler, irq_handler_t 
thread_fn,
                                    unsigned long irqflags, const char 
*devname,
                                    void *dev_id, const char *emsg)
{
         int rc;

         rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
                                        devname, dev_id);
         if (rc) {
                 dev_err_probe(dev, rc, "Failed to request %sinterrupt 
%u %s %s\n",
                               thread_fn ? "threaded " : "", irq, 
devname ? : dev_name(dev),
                               emsg ? : "");
         }
         return rc;
}
EXPORT_SYMBOL(devm_request_threaded_irq_emsg);


Thx,

Yangtao


>
> Best regards,
> Krzysztof
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
  2023-07-03 13:24       ` Yangtao Li
@ 2023-07-03 13:37         ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 44+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-03 13:37 UTC (permalink / raw)
  To: Yangtao Li, miquel.raynal, rafael, daniel.lezcano, amitk,
	rui.zhang, mmayer, bcm-kernel-feedback-list, florian.fainelli,
	tglx, matthias.bgg, angelogioacchino.delregno, bchihi, wenst
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

On 03/07/2023 15:24, Yangtao Li wrote:
> 
> On 2023/7/3 20:31, Krzysztof Kozlowski wrote:
>> [你通常不会收到来自 krzk@kernel.org 的电子邮件。请访问 https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要]
>>
>> On 03/07/2023 11:04, Yangtao Li wrote:
>>> There are more than 700 calls to the devm_request_threaded_irq method.
>>> Most drivers only request one interrupt resource, and these error
>>> messages are basically the same. If error messages are printed
>>> everywhere, more than 1000 lines of code can be saved by removing the
>>> msg in the driver.
>>
>> ...
>>
>>> +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
>>> +                                irq_handler_t handler, irq_handler_t thread_fn,
>>> +                                unsigned long irqflags, const char *devname,
>>> +                                void *dev_id, const char *emsg)
>>> +{
>>> +     int rc;
>>> +
>>> +     rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
>>> +                                    devname, dev_id);
>>> +     if (rc && rc != -EPROBE_DEFER) {
>>> +             dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
>>> +                     thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
>>> +                     emsg ? : "", ERR_PTR(rc));
>> It is open-coding dev_err_probe(). Just use dev_err_probe instead.
> 
> 
> How about the following? If possible, I would like to start modifying 
> more drivers in the next version.
> 
> 
> int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
>                                     irq_handler_t handler, irq_handler_t 
> thread_fn,
>                                     unsigned long irqflags, const char 
> *devname,
>                                     void *dev_id, const char *emsg)
> {
>          int rc;
> 
>          rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
>                                         devname, dev_id);
>          if (rc) {
>                  dev_err_probe(dev, rc, "Failed to request %sinterrupt 
> %u %s %s\n",
>                                thread_fn ? "threaded " : "", irq, 
> devname ? : dev_name(dev),
>                                emsg ? : "");

That's not the syntax already used - see existing code with `git grep`.
Instead - return dev_err_probe().


Best regards,
Krzysztof


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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
@ 2023-07-03 13:37         ` Krzysztof Kozlowski
  0 siblings, 0 replies; 44+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-03 13:37 UTC (permalink / raw)
  To: Yangtao Li, miquel.raynal, rafael, daniel.lezcano, amitk,
	rui.zhang, mmayer, bcm-kernel-feedback-list, florian.fainelli,
	tglx, matthias.bgg, angelogioacchino.delregno, bchihi, wenst
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

On 03/07/2023 15:24, Yangtao Li wrote:
> 
> On 2023/7/3 20:31, Krzysztof Kozlowski wrote:
>> [你通常不会收到来自 krzk@kernel.org 的电子邮件。请访问 https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要]
>>
>> On 03/07/2023 11:04, Yangtao Li wrote:
>>> There are more than 700 calls to the devm_request_threaded_irq method.
>>> Most drivers only request one interrupt resource, and these error
>>> messages are basically the same. If error messages are printed
>>> everywhere, more than 1000 lines of code can be saved by removing the
>>> msg in the driver.
>>
>> ...
>>
>>> +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
>>> +                                irq_handler_t handler, irq_handler_t thread_fn,
>>> +                                unsigned long irqflags, const char *devname,
>>> +                                void *dev_id, const char *emsg)
>>> +{
>>> +     int rc;
>>> +
>>> +     rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
>>> +                                    devname, dev_id);
>>> +     if (rc && rc != -EPROBE_DEFER) {
>>> +             dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
>>> +                     thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
>>> +                     emsg ? : "", ERR_PTR(rc));
>> It is open-coding dev_err_probe(). Just use dev_err_probe instead.
> 
> 
> How about the following? If possible, I would like to start modifying 
> more drivers in the next version.
> 
> 
> int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
>                                     irq_handler_t handler, irq_handler_t 
> thread_fn,
>                                     unsigned long irqflags, const char 
> *devname,
>                                     void *dev_id, const char *emsg)
> {
>          int rc;
> 
>          rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
>                                         devname, dev_id);
>          if (rc) {
>                  dev_err_probe(dev, rc, "Failed to request %sinterrupt 
> %u %s %s\n",
>                                thread_fn ? "threaded " : "", irq, 
> devname ? : dev_name(dev),
>                                emsg ? : "");

That's not the syntax already used - see existing code with `git grep`.
Instead - return dev_err_probe().


Best regards,
Krzysztof


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
  2023-07-03 12:31     ` Krzysztof Kozlowski
@ 2023-07-03 17:43       ` Uwe Kleine-König
  -1 siblings, 0 replies; 44+ messages in thread
From: Uwe Kleine-König @ 2023-07-03 17:43 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Yangtao Li, miquel.raynal, rafael, daniel.lezcano, amitk,
	rui.zhang, mmayer, bcm-kernel-feedback-list, florian.fainelli,
	tglx, matthias.bgg, angelogioacchino.delregno, bchihi, wenst,
	linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

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

Hello Krzysztof,

On Mon, Jul 03, 2023 at 02:31:59PM +0200, Krzysztof Kozlowski wrote:
> On 03/07/2023 11:04, Yangtao Li wrote:
> > There are more than 700 calls to the devm_request_threaded_irq method.
> > Most drivers only request one interrupt resource, and these error
> > messages are basically the same. If error messages are printed
> > everywhere, more than 1000 lines of code can be saved by removing the
> > msg in the driver.
> 
> 
> ...
> 
> > +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
> > +				   irq_handler_t handler, irq_handler_t thread_fn,
> > +				   unsigned long irqflags, const char *devname,
> > +				   void *dev_id, const char *emsg)
> > +{
> > +	int rc;
> > +
> > +	rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
> > +				       devname, dev_id);
> > +	if (rc && rc != -EPROBE_DEFER) {
> > +		dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
> > +			thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
> > +			emsg ? : "", ERR_PTR(rc));
> 
> It is open-coding dev_err_probe(). Just use dev_err_probe instead.

dev_err_probe is supposed to be only called in probe functions, while
devm_request_threaded_irq might be called in other contexts (e.g. when a
device is opened). That's why I asked to not use dev_err_probe() in v2
(IIRC).

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
@ 2023-07-03 17:43       ` Uwe Kleine-König
  0 siblings, 0 replies; 44+ messages in thread
From: Uwe Kleine-König @ 2023-07-03 17:43 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Yangtao Li, miquel.raynal, rafael, daniel.lezcano, amitk,
	rui.zhang, mmayer, bcm-kernel-feedback-list, florian.fainelli,
	tglx, matthias.bgg, angelogioacchino.delregno, bchihi, wenst,
	linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek


[-- Attachment #1.1: Type: text/plain, Size: 1545 bytes --]

Hello Krzysztof,

On Mon, Jul 03, 2023 at 02:31:59PM +0200, Krzysztof Kozlowski wrote:
> On 03/07/2023 11:04, Yangtao Li wrote:
> > There are more than 700 calls to the devm_request_threaded_irq method.
> > Most drivers only request one interrupt resource, and these error
> > messages are basically the same. If error messages are printed
> > everywhere, more than 1000 lines of code can be saved by removing the
> > msg in the driver.
> 
> 
> ...
> 
> > +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
> > +				   irq_handler_t handler, irq_handler_t thread_fn,
> > +				   unsigned long irqflags, const char *devname,
> > +				   void *dev_id, const char *emsg)
> > +{
> > +	int rc;
> > +
> > +	rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
> > +				       devname, dev_id);
> > +	if (rc && rc != -EPROBE_DEFER) {
> > +		dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
> > +			thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
> > +			emsg ? : "", ERR_PTR(rc));
> 
> It is open-coding dev_err_probe(). Just use dev_err_probe instead.

dev_err_probe is supposed to be only called in probe functions, while
devm_request_threaded_irq might be called in other contexts (e.g. when a
device is opened). That's why I asked to not use dev_err_probe() in v2
(IIRC).

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 2/5] thermal/drivers/armada: convert to use devm_request_threaded_irq_emsg()
  2023-07-03  9:04   ` Yangtao Li
@ 2023-07-04  8:46     ` Miquel Raynal
  -1 siblings, 0 replies; 44+ messages in thread
From: Miquel Raynal @ 2023-07-04  8:46 UTC (permalink / raw)
  To: Yangtao Li
  Cc: rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, wenst, linux-pm, linux-kernel,
	linux-arm-kernel, linux-mediatek

Hi Yangtao,

frank.li@vivo.com wrote on Mon,  3 Jul 2023 17:04:51 +0800:

> There are more than 700 calls to the devm_request_threaded_irq method.
> Most drivers only request one interrupt resource, and these error
> messages are basically the same. If error messages are printed
> everywhere, more than 1000 lines of code can be saved by removing the
> msg in the driver.
> 
> And tglx point out that:
> 
>   If we actually look at the call sites of
>   devm_request_threaded_irq() then the vast majority of them print more or
>   less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
> 
>      519 messages total (there are probably more)
> 
>      352 unique messages
> 
>      323 unique messages after lower casing
> 
>          Those 323 are mostly just variants of the same patterns with
>          slight modifications in formatting and information provided.
> 
>      186 of these messages do not deliver any useful information,
>          e.g. "no irq", "
> 
>      The most useful one of all is: "could request wakeup irq: %d"
> 
>   So there is certainly an argument to be made that this particular
>   function should print a well formatted and informative error message.
> 
>   It's not a general allocator like kmalloc(). It's specialized and in the
>   vast majority of cases failing to request the interrupt causes the
>   device probe to fail. So having proper and consistent information why
>   the device cannot be used _is_ useful.
> 
> Let's use devm_request_threaded_irq_emsg(), which ensure that all error
> handling branches print error information. In this way, when this function
> fails, the upper-layer functions can directly return an error code without
> missing debugging information. Otherwise, the error message will be
> printed redundantly or missing.
> 
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>  drivers/thermal/armada_thermal.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
> index 9f6dc4fc9112..a5e140643f00 100644
> --- a/drivers/thermal/armada_thermal.c
> +++ b/drivers/thermal/armada_thermal.c
> @@ -913,15 +913,12 @@ static int armada_thermal_probe(struct platform_device *pdev)
>  
>  	/* The overheat interrupt feature is not mandatory */
>  	if (irq > 0) {
> -		ret = devm_request_threaded_irq(&pdev->dev, irq,
> -						armada_overheat_isr,
> -						armada_overheat_isr_thread,
> -						0, NULL, priv);
> -		if (ret) {
> -			dev_err(&pdev->dev, "Cannot request threaded IRQ %d\n",
> -				irq);
> +		ret = devm_request_threaded_irq_emsg(&pdev->dev, irq,
> +						     armada_overheat_isr,
> +						     armada_overheat_isr_thread,
> +						     0, NULL, priv, NULL);
> +		if (ret)

I don't see a patch renaming this helper with s/emsg//, do you plan to
keep it like that? I bet nobody outside of this series will notice the
new helper and will continue to add error messages because it kind
of feels "right" to do so.

I would rather prefer returning to the original function name which
everybody knows/uses.

Anyhow, I'm fine with the idea of dropping custom error messages, so
whatever the final solution:

Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl

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

* Re: [PATCH v3 2/5] thermal/drivers/armada: convert to use devm_request_threaded_irq_emsg()
@ 2023-07-04  8:46     ` Miquel Raynal
  0 siblings, 0 replies; 44+ messages in thread
From: Miquel Raynal @ 2023-07-04  8:46 UTC (permalink / raw)
  To: Yangtao Li
  Cc: rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, wenst, linux-pm, linux-kernel,
	linux-arm-kernel, linux-mediatek

Hi Yangtao,

frank.li@vivo.com wrote on Mon,  3 Jul 2023 17:04:51 +0800:

> There are more than 700 calls to the devm_request_threaded_irq method.
> Most drivers only request one interrupt resource, and these error
> messages are basically the same. If error messages are printed
> everywhere, more than 1000 lines of code can be saved by removing the
> msg in the driver.
> 
> And tglx point out that:
> 
>   If we actually look at the call sites of
>   devm_request_threaded_irq() then the vast majority of them print more or
>   less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
> 
>      519 messages total (there are probably more)
> 
>      352 unique messages
> 
>      323 unique messages after lower casing
> 
>          Those 323 are mostly just variants of the same patterns with
>          slight modifications in formatting and information provided.
> 
>      186 of these messages do not deliver any useful information,
>          e.g. "no irq", "
> 
>      The most useful one of all is: "could request wakeup irq: %d"
> 
>   So there is certainly an argument to be made that this particular
>   function should print a well formatted and informative error message.
> 
>   It's not a general allocator like kmalloc(). It's specialized and in the
>   vast majority of cases failing to request the interrupt causes the
>   device probe to fail. So having proper and consistent information why
>   the device cannot be used _is_ useful.
> 
> Let's use devm_request_threaded_irq_emsg(), which ensure that all error
> handling branches print error information. In this way, when this function
> fails, the upper-layer functions can directly return an error code without
> missing debugging information. Otherwise, the error message will be
> printed redundantly or missing.
> 
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>  drivers/thermal/armada_thermal.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
> index 9f6dc4fc9112..a5e140643f00 100644
> --- a/drivers/thermal/armada_thermal.c
> +++ b/drivers/thermal/armada_thermal.c
> @@ -913,15 +913,12 @@ static int armada_thermal_probe(struct platform_device *pdev)
>  
>  	/* The overheat interrupt feature is not mandatory */
>  	if (irq > 0) {
> -		ret = devm_request_threaded_irq(&pdev->dev, irq,
> -						armada_overheat_isr,
> -						armada_overheat_isr_thread,
> -						0, NULL, priv);
> -		if (ret) {
> -			dev_err(&pdev->dev, "Cannot request threaded IRQ %d\n",
> -				irq);
> +		ret = devm_request_threaded_irq_emsg(&pdev->dev, irq,
> +						     armada_overheat_isr,
> +						     armada_overheat_isr_thread,
> +						     0, NULL, priv, NULL);
> +		if (ret)

I don't see a patch renaming this helper with s/emsg//, do you plan to
keep it like that? I bet nobody outside of this series will notice the
new helper and will continue to add error messages because it kind
of feels "right" to do so.

I would rather prefer returning to the original function name which
everybody knows/uses.

Anyhow, I'm fine with the idea of dropping custom error messages, so
whatever the final solution:

Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
  2023-07-03 17:43       ` Uwe Kleine-König
@ 2023-07-04  8:48         ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 44+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-04  8:48 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Yangtao Li, miquel.raynal, rafael, daniel.lezcano, amitk,
	rui.zhang, mmayer, bcm-kernel-feedback-list, florian.fainelli,
	tglx, matthias.bgg, angelogioacchino.delregno, bchihi, wenst,
	linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

On 03/07/2023 19:43, Uwe Kleine-König wrote:
> Hello Krzysztof,
> 
> On Mon, Jul 03, 2023 at 02:31:59PM +0200, Krzysztof Kozlowski wrote:
>> On 03/07/2023 11:04, Yangtao Li wrote:
>>> There are more than 700 calls to the devm_request_threaded_irq method.
>>> Most drivers only request one interrupt resource, and these error
>>> messages are basically the same. If error messages are printed
>>> everywhere, more than 1000 lines of code can be saved by removing the
>>> msg in the driver.
>>
>>
>> ...
>>
>>> +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
>>> +				   irq_handler_t handler, irq_handler_t thread_fn,
>>> +				   unsigned long irqflags, const char *devname,
>>> +				   void *dev_id, const char *emsg)
>>> +{
>>> +	int rc;
>>> +
>>> +	rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
>>> +				       devname, dev_id);
>>> +	if (rc && rc != -EPROBE_DEFER) {
>>> +		dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
>>> +			thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
>>> +			emsg ? : "", ERR_PTR(rc));
>>
>> It is open-coding dev_err_probe(). Just use dev_err_probe instead.
> 
> dev_err_probe is supposed to be only called in probe functions, while
> devm_request_threaded_irq might be called in other contexts (e.g. when a
> device is opened). That's why I asked to not use dev_err_probe() in v2

True, but then all the callers of this function will forget to set
deferred probe reason.

Best regards,
Krzysztof


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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
@ 2023-07-04  8:48         ` Krzysztof Kozlowski
  0 siblings, 0 replies; 44+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-04  8:48 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Yangtao Li, miquel.raynal, rafael, daniel.lezcano, amitk,
	rui.zhang, mmayer, bcm-kernel-feedback-list, florian.fainelli,
	tglx, matthias.bgg, angelogioacchino.delregno, bchihi, wenst,
	linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek

On 03/07/2023 19:43, Uwe Kleine-König wrote:
> Hello Krzysztof,
> 
> On Mon, Jul 03, 2023 at 02:31:59PM +0200, Krzysztof Kozlowski wrote:
>> On 03/07/2023 11:04, Yangtao Li wrote:
>>> There are more than 700 calls to the devm_request_threaded_irq method.
>>> Most drivers only request one interrupt resource, and these error
>>> messages are basically the same. If error messages are printed
>>> everywhere, more than 1000 lines of code can be saved by removing the
>>> msg in the driver.
>>
>>
>> ...
>>
>>> +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
>>> +				   irq_handler_t handler, irq_handler_t thread_fn,
>>> +				   unsigned long irqflags, const char *devname,
>>> +				   void *dev_id, const char *emsg)
>>> +{
>>> +	int rc;
>>> +
>>> +	rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
>>> +				       devname, dev_id);
>>> +	if (rc && rc != -EPROBE_DEFER) {
>>> +		dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
>>> +			thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
>>> +			emsg ? : "", ERR_PTR(rc));
>>
>> It is open-coding dev_err_probe(). Just use dev_err_probe instead.
> 
> dev_err_probe is supposed to be only called in probe functions, while
> devm_request_threaded_irq might be called in other contexts (e.g. when a
> device is opened). That's why I asked to not use dev_err_probe() in v2

True, but then all the callers of this function will forget to set
deferred probe reason.

Best regards,
Krzysztof


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
  2023-07-04  8:48         ` Krzysztof Kozlowski
@ 2023-07-04  9:06           ` Yangtao Li
  -1 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-04  9:06 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Uwe Kleine-König, miquel.raynal
  Cc: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, wenst, linux-pm, linux-kernel,
	linux-arm-kernel, linux-mediatek

On 2023/7/4 16:48, Krzysztof Kozlowski wrote:

> [你通常不会收到来自 krzk@kernel.org 的电子邮件。请访问 https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要]
>
> On 03/07/2023 19:43, Uwe Kleine-König wrote:
>> Hello Krzysztof,
>>
>> On Mon, Jul 03, 2023 at 02:31:59PM +0200, Krzysztof Kozlowski wrote:
>>> On 03/07/2023 11:04, Yangtao Li wrote:
>>>> There are more than 700 calls to the devm_request_threaded_irq method.
>>>> Most drivers only request one interrupt resource, and these error
>>>> messages are basically the same. If error messages are printed
>>>> everywhere, more than 1000 lines of code can be saved by removing the
>>>> msg in the driver.
>>>
>>> ...
>>>
>>>> +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
>>>> +                              irq_handler_t handler, irq_handler_t thread_fn,
>>>> +                              unsigned long irqflags, const char *devname,
>>>> +                              void *dev_id, const char *emsg)
>>>> +{
>>>> +   int rc;
>>>> +
>>>> +   rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
>>>> +                                  devname, dev_id);
>>>> +   if (rc && rc != -EPROBE_DEFER) {
>>>> +           dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
>>>> +                   thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
>>>> +                   emsg ? : "", ERR_PTR(rc));
>>> It is open-coding dev_err_probe(). Just use dev_err_probe instead.
>> dev_err_probe is supposed to be only called in probe functions, while
>> devm_request_threaded_irq might be called in other contexts (e.g. when a
>> device is opened). That's why I asked to not use dev_err_probe() in v2
> True, but then all the callers of this function will forget to set
> deferred probe reason.


So let's use dev_err_probe?


BTW, any suggestions for names here, keep using 
devm_request_threaded_irq_emsg or change to a new name?

I am afraid that after more drivers are changed in the follow-up series, 
the name will need to be changed again.


Thx,

Yangtao


>
> Best regards,
> Krzysztof
>

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
@ 2023-07-04  9:06           ` Yangtao Li
  0 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-04  9:06 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Uwe Kleine-König, miquel.raynal
  Cc: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, wenst, linux-pm, linux-kernel,
	linux-arm-kernel, linux-mediatek

On 2023/7/4 16:48, Krzysztof Kozlowski wrote:

> [你通常不会收到来自 krzk@kernel.org 的电子邮件。请访问 https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要]
>
> On 03/07/2023 19:43, Uwe Kleine-König wrote:
>> Hello Krzysztof,
>>
>> On Mon, Jul 03, 2023 at 02:31:59PM +0200, Krzysztof Kozlowski wrote:
>>> On 03/07/2023 11:04, Yangtao Li wrote:
>>>> There are more than 700 calls to the devm_request_threaded_irq method.
>>>> Most drivers only request one interrupt resource, and these error
>>>> messages are basically the same. If error messages are printed
>>>> everywhere, more than 1000 lines of code can be saved by removing the
>>>> msg in the driver.
>>>
>>> ...
>>>
>>>> +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
>>>> +                              irq_handler_t handler, irq_handler_t thread_fn,
>>>> +                              unsigned long irqflags, const char *devname,
>>>> +                              void *dev_id, const char *emsg)
>>>> +{
>>>> +   int rc;
>>>> +
>>>> +   rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
>>>> +                                  devname, dev_id);
>>>> +   if (rc && rc != -EPROBE_DEFER) {
>>>> +           dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
>>>> +                   thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
>>>> +                   emsg ? : "", ERR_PTR(rc));
>>> It is open-coding dev_err_probe(). Just use dev_err_probe instead.
>> dev_err_probe is supposed to be only called in probe functions, while
>> devm_request_threaded_irq might be called in other contexts (e.g. when a
>> device is opened). That's why I asked to not use dev_err_probe() in v2
> True, but then all the callers of this function will forget to set
> deferred probe reason.


So let's use dev_err_probe?


BTW, any suggestions for names here, keep using 
devm_request_threaded_irq_emsg or change to a new name?

I am afraid that after more drivers are changed in the follow-up series, 
the name will need to be changed again.


Thx,

Yangtao


>
> Best regards,
> Krzysztof
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
  2023-07-04  9:06           ` Yangtao Li
@ 2023-07-04 14:19             ` Uwe Kleine-König
  -1 siblings, 0 replies; 44+ messages in thread
From: Uwe Kleine-König @ 2023-07-04 14:19 UTC (permalink / raw)
  To: Yangtao Li
  Cc: Krzysztof Kozlowski, miquel.raynal, rafael, daniel.lezcano,
	amitk, rui.zhang, mmayer, bcm-kernel-feedback-list,
	florian.fainelli, tglx, matthias.bgg, angelogioacchino.delregno,
	bchihi, wenst, linux-pm, linux-kernel, linux-arm-kernel,
	linux-mediatek

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

Hello,

On Tue, Jul 04, 2023 at 05:06:12PM +0800, Yangtao Li wrote:
> On 2023/7/4 16:48, Krzysztof Kozlowski wrote:
> 
> > [你通常不会收到来自 krzk@kernel.org 的电子邮件。请访问 https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要]
> > 
> > On 03/07/2023 19:43, Uwe Kleine-König wrote:
> > > Hello Krzysztof,
> > > 
> > > On Mon, Jul 03, 2023 at 02:31:59PM +0200, Krzysztof Kozlowski wrote:
> > > > On 03/07/2023 11:04, Yangtao Li wrote:
> > > > > There are more than 700 calls to the devm_request_threaded_irq method.
> > > > > Most drivers only request one interrupt resource, and these error
> > > > > messages are basically the same. If error messages are printed
> > > > > everywhere, more than 1000 lines of code can be saved by removing the
> > > > > msg in the driver.
> > > > 
> > > > ...
> > > > 
> > > > > +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
> > > > > +                              irq_handler_t handler, irq_handler_t thread_fn,
> > > > > +                              unsigned long irqflags, const char *devname,
> > > > > +                              void *dev_id, const char *emsg)
> > > > > +{
> > > > > +   int rc;
> > > > > +
> > > > > +   rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
> > > > > +                                  devname, dev_id);
> > > > > +   if (rc && rc != -EPROBE_DEFER) {
> > > > > +           dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
> > > > > +                   thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
> > > > > +                   emsg ? : "", ERR_PTR(rc));
> > > > It is open-coding dev_err_probe(). Just use dev_err_probe instead.
> > > dev_err_probe is supposed to be only called in probe functions, while
> > > devm_request_threaded_irq might be called in other contexts (e.g. when a
> > > device is opened). That's why I asked to not use dev_err_probe() in v2
> > True, but then all the callers of this function will forget to set
> > deferred probe reason.

That's another reason for letting the driver issue the error message and
not the request_irq function.
 
> So let's use dev_err_probe?
> 
> BTW, any suggestions for names here, keep using
> devm_request_threaded_irq_emsg or change to a new name?

I would have called it devm_request_threaded_irq_verbose() which I
consider easier to understand. But maybe that is just my (green)
bikeshed.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
@ 2023-07-04 14:19             ` Uwe Kleine-König
  0 siblings, 0 replies; 44+ messages in thread
From: Uwe Kleine-König @ 2023-07-04 14:19 UTC (permalink / raw)
  To: Yangtao Li
  Cc: Krzysztof Kozlowski, miquel.raynal, rafael, daniel.lezcano,
	amitk, rui.zhang, mmayer, bcm-kernel-feedback-list,
	florian.fainelli, tglx, matthias.bgg, angelogioacchino.delregno,
	bchihi, wenst, linux-pm, linux-kernel, linux-arm-kernel,
	linux-mediatek


[-- Attachment #1.1: Type: text/plain, Size: 2687 bytes --]

Hello,

On Tue, Jul 04, 2023 at 05:06:12PM +0800, Yangtao Li wrote:
> On 2023/7/4 16:48, Krzysztof Kozlowski wrote:
> 
> > [你通常不会收到来自 krzk@kernel.org 的电子邮件。请访问 https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要]
> > 
> > On 03/07/2023 19:43, Uwe Kleine-König wrote:
> > > Hello Krzysztof,
> > > 
> > > On Mon, Jul 03, 2023 at 02:31:59PM +0200, Krzysztof Kozlowski wrote:
> > > > On 03/07/2023 11:04, Yangtao Li wrote:
> > > > > There are more than 700 calls to the devm_request_threaded_irq method.
> > > > > Most drivers only request one interrupt resource, and these error
> > > > > messages are basically the same. If error messages are printed
> > > > > everywhere, more than 1000 lines of code can be saved by removing the
> > > > > msg in the driver.
> > > > 
> > > > ...
> > > > 
> > > > > +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
> > > > > +                              irq_handler_t handler, irq_handler_t thread_fn,
> > > > > +                              unsigned long irqflags, const char *devname,
> > > > > +                              void *dev_id, const char *emsg)
> > > > > +{
> > > > > +   int rc;
> > > > > +
> > > > > +   rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
> > > > > +                                  devname, dev_id);
> > > > > +   if (rc && rc != -EPROBE_DEFER) {
> > > > > +           dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
> > > > > +                   thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
> > > > > +                   emsg ? : "", ERR_PTR(rc));
> > > > It is open-coding dev_err_probe(). Just use dev_err_probe instead.
> > > dev_err_probe is supposed to be only called in probe functions, while
> > > devm_request_threaded_irq might be called in other contexts (e.g. when a
> > > device is opened). That's why I asked to not use dev_err_probe() in v2
> > True, but then all the callers of this function will forget to set
> > deferred probe reason.

That's another reason for letting the driver issue the error message and
not the request_irq function.
 
> So let's use dev_err_probe?
> 
> BTW, any suggestions for names here, keep using
> devm_request_threaded_irq_emsg or change to a new name?

I would have called it devm_request_threaded_irq_verbose() which I
consider easier to understand. But maybe that is just my (green)
bikeshed.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 2/5] thermal/drivers/armada: convert to use devm_request_threaded_irq_emsg()
  2023-07-04  8:46     ` Miquel Raynal
@ 2023-07-04 14:22       ` Uwe Kleine-König
  -1 siblings, 0 replies; 44+ messages in thread
From: Uwe Kleine-König @ 2023-07-04 14:22 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Yangtao Li, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, wenst, linux-pm, linux-kernel,
	linux-arm-kernel, linux-mediatek

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

Hello Miquel,

On Tue, Jul 04, 2023 at 10:46:08AM +0200, Miquel Raynal wrote:
> Hi Yangtao,
> 
> frank.li@vivo.com wrote on Mon,  3 Jul 2023 17:04:51 +0800:
> 
> > There are more than 700 calls to the devm_request_threaded_irq method.
> > Most drivers only request one interrupt resource, and these error
> > messages are basically the same. If error messages are printed
> > everywhere, more than 1000 lines of code can be saved by removing the
> > msg in the driver.
> > 
> > And tglx point out that:
> > 
> >   If we actually look at the call sites of
> >   devm_request_threaded_irq() then the vast majority of them print more or
> >   less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
> > 
> >      519 messages total (there are probably more)
> > 
> >      352 unique messages
> > 
> >      323 unique messages after lower casing
> > 
> >          Those 323 are mostly just variants of the same patterns with
> >          slight modifications in formatting and information provided.
> > 
> >      186 of these messages do not deliver any useful information,
> >          e.g. "no irq", "
> > 
> >      The most useful one of all is: "could request wakeup irq: %d"
> > 
> >   So there is certainly an argument to be made that this particular
> >   function should print a well formatted and informative error message.
> > 
> >   It's not a general allocator like kmalloc(). It's specialized and in the
> >   vast majority of cases failing to request the interrupt causes the
> >   device probe to fail. So having proper and consistent information why
> >   the device cannot be used _is_ useful.
> > 
> > Let's use devm_request_threaded_irq_emsg(), which ensure that all error
> > handling branches print error information. In this way, when this function
> > fails, the upper-layer functions can directly return an error code without
> > missing debugging information. Otherwise, the error message will be
> > printed redundantly or missing.
> > 
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Signed-off-by: Yangtao Li <frank.li@vivo.com>
> > ---
> >  drivers/thermal/armada_thermal.c | 13 +++++--------
> >  1 file changed, 5 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
> > index 9f6dc4fc9112..a5e140643f00 100644
> > --- a/drivers/thermal/armada_thermal.c
> > +++ b/drivers/thermal/armada_thermal.c
> > @@ -913,15 +913,12 @@ static int armada_thermal_probe(struct platform_device *pdev)
> >  
> >  	/* The overheat interrupt feature is not mandatory */
> >  	if (irq > 0) {
> > -		ret = devm_request_threaded_irq(&pdev->dev, irq,
> > -						armada_overheat_isr,
> > -						armada_overheat_isr_thread,
> > -						0, NULL, priv);
> > -		if (ret) {
> > -			dev_err(&pdev->dev, "Cannot request threaded IRQ %d\n",
> > -				irq);
> > +		ret = devm_request_threaded_irq_emsg(&pdev->dev, irq,
> > +						     armada_overheat_isr,
> > +						     armada_overheat_isr_thread,
> > +						     0, NULL, priv, NULL);
> > +		if (ret)
> 
> I don't see a patch renaming this helper with s/emsg//, do you plan to
> keep it like that? I bet nobody outside of this series will notice the
> new helper and will continue to add error messages because it kind
> of feels "right" to do so.
> 
> I would rather prefer returning to the original function name which
> everybody knows/uses.

See https://lore.kernel.org/lkml/87h6qpyzkd.ffs@tglx for why there is a
new function name.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

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

* Re: [PATCH v3 2/5] thermal/drivers/armada: convert to use devm_request_threaded_irq_emsg()
@ 2023-07-04 14:22       ` Uwe Kleine-König
  0 siblings, 0 replies; 44+ messages in thread
From: Uwe Kleine-König @ 2023-07-04 14:22 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Yangtao Li, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, wenst, linux-pm, linux-kernel,
	linux-arm-kernel, linux-mediatek


[-- Attachment #1.1: Type: text/plain, Size: 3725 bytes --]

Hello Miquel,

On Tue, Jul 04, 2023 at 10:46:08AM +0200, Miquel Raynal wrote:
> Hi Yangtao,
> 
> frank.li@vivo.com wrote on Mon,  3 Jul 2023 17:04:51 +0800:
> 
> > There are more than 700 calls to the devm_request_threaded_irq method.
> > Most drivers only request one interrupt resource, and these error
> > messages are basically the same. If error messages are printed
> > everywhere, more than 1000 lines of code can be saved by removing the
> > msg in the driver.
> > 
> > And tglx point out that:
> > 
> >   If we actually look at the call sites of
> >   devm_request_threaded_irq() then the vast majority of them print more or
> >   less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
> > 
> >      519 messages total (there are probably more)
> > 
> >      352 unique messages
> > 
> >      323 unique messages after lower casing
> > 
> >          Those 323 are mostly just variants of the same patterns with
> >          slight modifications in formatting and information provided.
> > 
> >      186 of these messages do not deliver any useful information,
> >          e.g. "no irq", "
> > 
> >      The most useful one of all is: "could request wakeup irq: %d"
> > 
> >   So there is certainly an argument to be made that this particular
> >   function should print a well formatted and informative error message.
> > 
> >   It's not a general allocator like kmalloc(). It's specialized and in the
> >   vast majority of cases failing to request the interrupt causes the
> >   device probe to fail. So having proper and consistent information why
> >   the device cannot be used _is_ useful.
> > 
> > Let's use devm_request_threaded_irq_emsg(), which ensure that all error
> > handling branches print error information. In this way, when this function
> > fails, the upper-layer functions can directly return an error code without
> > missing debugging information. Otherwise, the error message will be
> > printed redundantly or missing.
> > 
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Signed-off-by: Yangtao Li <frank.li@vivo.com>
> > ---
> >  drivers/thermal/armada_thermal.c | 13 +++++--------
> >  1 file changed, 5 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
> > index 9f6dc4fc9112..a5e140643f00 100644
> > --- a/drivers/thermal/armada_thermal.c
> > +++ b/drivers/thermal/armada_thermal.c
> > @@ -913,15 +913,12 @@ static int armada_thermal_probe(struct platform_device *pdev)
> >  
> >  	/* The overheat interrupt feature is not mandatory */
> >  	if (irq > 0) {
> > -		ret = devm_request_threaded_irq(&pdev->dev, irq,
> > -						armada_overheat_isr,
> > -						armada_overheat_isr_thread,
> > -						0, NULL, priv);
> > -		if (ret) {
> > -			dev_err(&pdev->dev, "Cannot request threaded IRQ %d\n",
> > -				irq);
> > +		ret = devm_request_threaded_irq_emsg(&pdev->dev, irq,
> > +						     armada_overheat_isr,
> > +						     armada_overheat_isr_thread,
> > +						     0, NULL, priv, NULL);
> > +		if (ret)
> 
> I don't see a patch renaming this helper with s/emsg//, do you plan to
> keep it like that? I bet nobody outside of this series will notice the
> new helper and will continue to add error messages because it kind
> of feels "right" to do so.
> 
> I would rather prefer returning to the original function name which
> everybody knows/uses.

See https://lore.kernel.org/lkml/87h6qpyzkd.ffs@tglx for why there is a
new function name.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 2/5] thermal/drivers/armada: convert to use devm_request_threaded_irq_emsg()
  2023-07-04 14:22       ` Uwe Kleine-König
@ 2023-07-04 14:29         ` Miquel Raynal
  -1 siblings, 0 replies; 44+ messages in thread
From: Miquel Raynal @ 2023-07-04 14:29 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Yangtao Li, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, wenst, linux-pm, linux-kernel,
	linux-arm-kernel, linux-mediatek

Hi Uwe,

u.kleine-koenig@pengutronix.de wrote on Tue, 4 Jul 2023 16:22:27 +0200:

> Hello Miquel,
> 
> On Tue, Jul 04, 2023 at 10:46:08AM +0200, Miquel Raynal wrote:
> > Hi Yangtao,
> > 
> > frank.li@vivo.com wrote on Mon,  3 Jul 2023 17:04:51 +0800:
> >   
> > > There are more than 700 calls to the devm_request_threaded_irq method.
> > > Most drivers only request one interrupt resource, and these error
> > > messages are basically the same. If error messages are printed
> > > everywhere, more than 1000 lines of code can be saved by removing the
> > > msg in the driver.
> > > 
> > > And tglx point out that:
> > > 
> > >   If we actually look at the call sites of
> > >   devm_request_threaded_irq() then the vast majority of them print more or
> > >   less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
> > > 
> > >      519 messages total (there are probably more)
> > > 
> > >      352 unique messages
> > > 
> > >      323 unique messages after lower casing
> > > 
> > >          Those 323 are mostly just variants of the same patterns with
> > >          slight modifications in formatting and information provided.
> > > 
> > >      186 of these messages do not deliver any useful information,
> > >          e.g. "no irq", "
> > > 
> > >      The most useful one of all is: "could request wakeup irq: %d"
> > > 
> > >   So there is certainly an argument to be made that this particular
> > >   function should print a well formatted and informative error message.
> > > 
> > >   It's not a general allocator like kmalloc(). It's specialized and in the
> > >   vast majority of cases failing to request the interrupt causes the
> > >   device probe to fail. So having proper and consistent information why
> > >   the device cannot be used _is_ useful.
> > > 
> > > Let's use devm_request_threaded_irq_emsg(), which ensure that all error
> > > handling branches print error information. In this way, when this function
> > > fails, the upper-layer functions can directly return an error code without
> > > missing debugging information. Otherwise, the error message will be
> > > printed redundantly or missing.
> > > 
> > > Cc: Thomas Gleixner <tglx@linutronix.de>
> > > Signed-off-by: Yangtao Li <frank.li@vivo.com>
> > > ---
> > >  drivers/thermal/armada_thermal.c | 13 +++++--------
> > >  1 file changed, 5 insertions(+), 8 deletions(-)
> > > 
> > > diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
> > > index 9f6dc4fc9112..a5e140643f00 100644
> > > --- a/drivers/thermal/armada_thermal.c
> > > +++ b/drivers/thermal/armada_thermal.c
> > > @@ -913,15 +913,12 @@ static int armada_thermal_probe(struct platform_device *pdev)
> > >  
> > >  	/* The overheat interrupt feature is not mandatory */
> > >  	if (irq > 0) {
> > > -		ret = devm_request_threaded_irq(&pdev->dev, irq,
> > > -						armada_overheat_isr,
> > > -						armada_overheat_isr_thread,
> > > -						0, NULL, priv);
> > > -		if (ret) {
> > > -			dev_err(&pdev->dev, "Cannot request threaded IRQ %d\n",
> > > -				irq);
> > > +		ret = devm_request_threaded_irq_emsg(&pdev->dev, irq,
> > > +						     armada_overheat_isr,
> > > +						     armada_overheat_isr_thread,
> > > +						     0, NULL, priv, NULL);
> > > +		if (ret)  
> > 
> > I don't see a patch renaming this helper with s/emsg//, do you plan to
> > keep it like that? I bet nobody outside of this series will notice the
> > new helper and will continue to add error messages because it kind
> > of feels "right" to do so.
> > 
> > I would rather prefer returning to the original function name which
> > everybody knows/uses.  
> 
> See https://lore.kernel.org/lkml/87h6qpyzkd.ffs@tglx for why there is a
> new function name.

Yes of course, I fully understand Thomas' concerns, but I am
questioning the usefulness of creating such helper if it's not the
default. People will continue to use [devm_]request_threaded_irq()
without noticing the new helper. If we want to make this change useful,
I believe we should:
- target all users
- at the end of the series: atomically include the error message in
  request_threaded_irq() and rename all callers of the _verbose variant
  which will eventually vanish.

Otherwise this is a lot of noise for very little progress, IMHO :)

Thanks,
Miquèl

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

* Re: [PATCH v3 2/5] thermal/drivers/armada: convert to use devm_request_threaded_irq_emsg()
@ 2023-07-04 14:29         ` Miquel Raynal
  0 siblings, 0 replies; 44+ messages in thread
From: Miquel Raynal @ 2023-07-04 14:29 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Yangtao Li, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, wenst, linux-pm, linux-kernel,
	linux-arm-kernel, linux-mediatek

Hi Uwe,

u.kleine-koenig@pengutronix.de wrote on Tue, 4 Jul 2023 16:22:27 +0200:

> Hello Miquel,
> 
> On Tue, Jul 04, 2023 at 10:46:08AM +0200, Miquel Raynal wrote:
> > Hi Yangtao,
> > 
> > frank.li@vivo.com wrote on Mon,  3 Jul 2023 17:04:51 +0800:
> >   
> > > There are more than 700 calls to the devm_request_threaded_irq method.
> > > Most drivers only request one interrupt resource, and these error
> > > messages are basically the same. If error messages are printed
> > > everywhere, more than 1000 lines of code can be saved by removing the
> > > msg in the driver.
> > > 
> > > And tglx point out that:
> > > 
> > >   If we actually look at the call sites of
> > >   devm_request_threaded_irq() then the vast majority of them print more or
> > >   less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
> > > 
> > >      519 messages total (there are probably more)
> > > 
> > >      352 unique messages
> > > 
> > >      323 unique messages after lower casing
> > > 
> > >          Those 323 are mostly just variants of the same patterns with
> > >          slight modifications in formatting and information provided.
> > > 
> > >      186 of these messages do not deliver any useful information,
> > >          e.g. "no irq", "
> > > 
> > >      The most useful one of all is: "could request wakeup irq: %d"
> > > 
> > >   So there is certainly an argument to be made that this particular
> > >   function should print a well formatted and informative error message.
> > > 
> > >   It's not a general allocator like kmalloc(). It's specialized and in the
> > >   vast majority of cases failing to request the interrupt causes the
> > >   device probe to fail. So having proper and consistent information why
> > >   the device cannot be used _is_ useful.
> > > 
> > > Let's use devm_request_threaded_irq_emsg(), which ensure that all error
> > > handling branches print error information. In this way, when this function
> > > fails, the upper-layer functions can directly return an error code without
> > > missing debugging information. Otherwise, the error message will be
> > > printed redundantly or missing.
> > > 
> > > Cc: Thomas Gleixner <tglx@linutronix.de>
> > > Signed-off-by: Yangtao Li <frank.li@vivo.com>
> > > ---
> > >  drivers/thermal/armada_thermal.c | 13 +++++--------
> > >  1 file changed, 5 insertions(+), 8 deletions(-)
> > > 
> > > diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
> > > index 9f6dc4fc9112..a5e140643f00 100644
> > > --- a/drivers/thermal/armada_thermal.c
> > > +++ b/drivers/thermal/armada_thermal.c
> > > @@ -913,15 +913,12 @@ static int armada_thermal_probe(struct platform_device *pdev)
> > >  
> > >  	/* The overheat interrupt feature is not mandatory */
> > >  	if (irq > 0) {
> > > -		ret = devm_request_threaded_irq(&pdev->dev, irq,
> > > -						armada_overheat_isr,
> > > -						armada_overheat_isr_thread,
> > > -						0, NULL, priv);
> > > -		if (ret) {
> > > -			dev_err(&pdev->dev, "Cannot request threaded IRQ %d\n",
> > > -				irq);
> > > +		ret = devm_request_threaded_irq_emsg(&pdev->dev, irq,
> > > +						     armada_overheat_isr,
> > > +						     armada_overheat_isr_thread,
> > > +						     0, NULL, priv, NULL);
> > > +		if (ret)  
> > 
> > I don't see a patch renaming this helper with s/emsg//, do you plan to
> > keep it like that? I bet nobody outside of this series will notice the
> > new helper and will continue to add error messages because it kind
> > of feels "right" to do so.
> > 
> > I would rather prefer returning to the original function name which
> > everybody knows/uses.  
> 
> See https://lore.kernel.org/lkml/87h6qpyzkd.ffs@tglx for why there is a
> new function name.

Yes of course, I fully understand Thomas' concerns, but I am
questioning the usefulness of creating such helper if it's not the
default. People will continue to use [devm_]request_threaded_irq()
without noticing the new helper. If we want to make this change useful,
I believe we should:
- target all users
- at the end of the series: atomically include the error message in
  request_threaded_irq() and rename all callers of the _verbose variant
  which will eventually vanish.

Otherwise this is a lot of noise for very little progress, IMHO :)

Thanks,
Miquèl

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
  2023-07-04 14:19             ` Uwe Kleine-König
@ 2023-07-05  2:15               ` Jonathan Cameron
  -1 siblings, 0 replies; 44+ messages in thread
From: Jonathan Cameron @ 2023-07-05  2:15 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Yangtao Li, Krzysztof Kozlowski, miquel.raynal, rafael,
	daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, wenst, linux-pm, linux-kernel,
	linux-arm-kernel, linux-mediatek

On Tue, 4 Jul 2023 16:19:54 +0200
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:

> Hello,
> 
> On Tue, Jul 04, 2023 at 05:06:12PM +0800, Yangtao Li wrote:
> > On 2023/7/4 16:48, Krzysztof Kozlowski wrote:
> >   
> > > [你通常不会收到来自 krzk@kernel.org 的电子邮件。请访问 https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要]
> > > 
> > > On 03/07/2023 19:43, Uwe Kleine-König wrote:  
> > > > Hello Krzysztof,
> > > > 
> > > > On Mon, Jul 03, 2023 at 02:31:59PM +0200, Krzysztof Kozlowski wrote:  
> > > > > On 03/07/2023 11:04, Yangtao Li wrote:  
> > > > > > There are more than 700 calls to the devm_request_threaded_irq method.
> > > > > > Most drivers only request one interrupt resource, and these error
> > > > > > messages are basically the same. If error messages are printed
> > > > > > everywhere, more than 1000 lines of code can be saved by removing the
> > > > > > msg in the driver.  
> > > > > 
> > > > > ...
> > > > >   
> > > > > > +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
> > > > > > +                              irq_handler_t handler, irq_handler_t thread_fn,
> > > > > > +                              unsigned long irqflags, const char *devname,
> > > > > > +                              void *dev_id, const char *emsg)
> > > > > > +{
> > > > > > +   int rc;
> > > > > > +
> > > > > > +   rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
> > > > > > +                                  devname, dev_id);
> > > > > > +   if (rc && rc != -EPROBE_DEFER) {
> > > > > > +           dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
> > > > > > +                   thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
> > > > > > +                   emsg ? : "", ERR_PTR(rc));  
> > > > > It is open-coding dev_err_probe(). Just use dev_err_probe instead.  
> > > > dev_err_probe is supposed to be only called in probe functions, while
> > > > devm_request_threaded_irq might be called in other contexts (e.g. when a
> > > > device is opened). That's why I asked to not use dev_err_probe() in v2  
> > > True, but then all the callers of this function will forget to set
> > > deferred probe reason.  
> 
> That's another reason for letting the driver issue the error message and
> not the request_irq function.
>  
> > So let's use dev_err_probe?
> > 
> > BTW, any suggestions for names here, keep using
> > devm_request_threaded_irq_emsg or change to a new name?  
> 
> I would have called it devm_request_threaded_irq_verbose() which I
> consider easier to understand. But maybe  is just my (green)
> bikeshed.

If going to use dev_err_probe() internally maybe can just use
devm_request_threaded_irq_probe() thus reflecting that and making
it different to the devm_request_threaded_irq()?

I'm not sure we need to call out the fact it prints an error message in
the naming.  Maybe the fact it should probably only be used in probe()
is the more relevant information?

Bikesheds should all be red!

Jonathan

> 
> Best regards
> Uwe
> 


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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
@ 2023-07-05  2:15               ` Jonathan Cameron
  0 siblings, 0 replies; 44+ messages in thread
From: Jonathan Cameron @ 2023-07-05  2:15 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Yangtao Li, Krzysztof Kozlowski, miquel.raynal, rafael,
	daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, wenst, linux-pm, linux-kernel,
	linux-arm-kernel, linux-mediatek

On Tue, 4 Jul 2023 16:19:54 +0200
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:

> Hello,
> 
> On Tue, Jul 04, 2023 at 05:06:12PM +0800, Yangtao Li wrote:
> > On 2023/7/4 16:48, Krzysztof Kozlowski wrote:
> >   
> > > [你通常不会收到来自 krzk@kernel.org 的电子邮件。请访问 https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要]
> > > 
> > > On 03/07/2023 19:43, Uwe Kleine-König wrote:  
> > > > Hello Krzysztof,
> > > > 
> > > > On Mon, Jul 03, 2023 at 02:31:59PM +0200, Krzysztof Kozlowski wrote:  
> > > > > On 03/07/2023 11:04, Yangtao Li wrote:  
> > > > > > There are more than 700 calls to the devm_request_threaded_irq method.
> > > > > > Most drivers only request one interrupt resource, and these error
> > > > > > messages are basically the same. If error messages are printed
> > > > > > everywhere, more than 1000 lines of code can be saved by removing the
> > > > > > msg in the driver.  
> > > > > 
> > > > > ...
> > > > >   
> > > > > > +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
> > > > > > +                              irq_handler_t handler, irq_handler_t thread_fn,
> > > > > > +                              unsigned long irqflags, const char *devname,
> > > > > > +                              void *dev_id, const char *emsg)
> > > > > > +{
> > > > > > +   int rc;
> > > > > > +
> > > > > > +   rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
> > > > > > +                                  devname, dev_id);
> > > > > > +   if (rc && rc != -EPROBE_DEFER) {
> > > > > > +           dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
> > > > > > +                   thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
> > > > > > +                   emsg ? : "", ERR_PTR(rc));  
> > > > > It is open-coding dev_err_probe(). Just use dev_err_probe instead.  
> > > > dev_err_probe is supposed to be only called in probe functions, while
> > > > devm_request_threaded_irq might be called in other contexts (e.g. when a
> > > > device is opened). That's why I asked to not use dev_err_probe() in v2  
> > > True, but then all the callers of this function will forget to set
> > > deferred probe reason.  
> 
> That's another reason for letting the driver issue the error message and
> not the request_irq function.
>  
> > So let's use dev_err_probe?
> > 
> > BTW, any suggestions for names here, keep using
> > devm_request_threaded_irq_emsg or change to a new name?  
> 
> I would have called it devm_request_threaded_irq_verbose() which I
> consider easier to understand. But maybe  is just my (green)
> bikeshed.

If going to use dev_err_probe() internally maybe can just use
devm_request_threaded_irq_probe() thus reflecting that and making
it different to the devm_request_threaded_irq()?

I'm not sure we need to call out the fact it prints an error message in
the naming.  Maybe the fact it should probably only be used in probe()
is the more relevant information?

Bikesheds should all be red!

Jonathan

> 
> Best regards
> Uwe
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
  2023-07-05  2:15               ` Jonathan Cameron
@ 2023-07-05  7:30                 ` Uwe Kleine-König
  -1 siblings, 0 replies; 44+ messages in thread
From: Uwe Kleine-König @ 2023-07-05  7:30 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Yangtao Li, Krzysztof Kozlowski, miquel.raynal, rafael,
	daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, wenst, linux-pm, linux-kernel,
	linux-arm-kernel, linux-mediatek

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

Hello,

On Wed, Jul 05, 2023 at 10:15:37AM +0800, Jonathan Cameron wrote:
> On Tue, 4 Jul 2023 16:19:54 +0200
> Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
> 
> > Hello,
> > 
> > On Tue, Jul 04, 2023 at 05:06:12PM +0800, Yangtao Li wrote:
> > > On 2023/7/4 16:48, Krzysztof Kozlowski wrote:
> > >   
> > > > [你通常不会收到来自 krzk@kernel.org 的电子邮件。请访问 https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要]
> > > > 
> > > > On 03/07/2023 19:43, Uwe Kleine-König wrote:  
> > > > > Hello Krzysztof,
> > > > > 
> > > > > On Mon, Jul 03, 2023 at 02:31:59PM +0200, Krzysztof Kozlowski wrote:  
> > > > > > On 03/07/2023 11:04, Yangtao Li wrote:  
> > > > > > > There are more than 700 calls to the devm_request_threaded_irq method.
> > > > > > > Most drivers only request one interrupt resource, and these error
> > > > > > > messages are basically the same. If error messages are printed
> > > > > > > everywhere, more than 1000 lines of code can be saved by removing the
> > > > > > > msg in the driver.  
> > > > > > 
> > > > > > ...
> > > > > >   
> > > > > > > +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
> > > > > > > +                              irq_handler_t handler, irq_handler_t thread_fn,
> > > > > > > +                              unsigned long irqflags, const char *devname,
> > > > > > > +                              void *dev_id, const char *emsg)
> > > > > > > +{
> > > > > > > +   int rc;
> > > > > > > +
> > > > > > > +   rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
> > > > > > > +                                  devname, dev_id);
> > > > > > > +   if (rc && rc != -EPROBE_DEFER) {
> > > > > > > +           dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
> > > > > > > +                   thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
> > > > > > > +                   emsg ? : "", ERR_PTR(rc));  
> > > > > > It is open-coding dev_err_probe(). Just use dev_err_probe instead.  
> > > > > dev_err_probe is supposed to be only called in probe functions, while
> > > > > devm_request_threaded_irq might be called in other contexts (e.g. when a
> > > > > device is opened). That's why I asked to not use dev_err_probe() in v2  
> > > > True, but then all the callers of this function will forget to set
> > > > deferred probe reason.  
> > 
> > That's another reason for letting the driver issue the error message and
> > not the request_irq function.
> >  
> > > So let's use dev_err_probe?
> > > 
> > > BTW, any suggestions for names here, keep using
> > > devm_request_threaded_irq_emsg or change to a new name?  
> > 
> > I would have called it devm_request_threaded_irq_verbose() which I
> > consider easier to understand. But maybe  is just my (green)
> > bikeshed.
> 
> If going to use dev_err_probe() internally maybe can just use
> devm_request_threaded_irq_probe() thus reflecting that and making
> it different to the devm_request_threaded_irq()?

I like devm_request_threaded_irq_probe(), thanks for that suggestion
(even though it's red :-)

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
@ 2023-07-05  7:30                 ` Uwe Kleine-König
  0 siblings, 0 replies; 44+ messages in thread
From: Uwe Kleine-König @ 2023-07-05  7:30 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Yangtao Li, Krzysztof Kozlowski, miquel.raynal, rafael,
	daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, tglx, matthias.bgg,
	angelogioacchino.delregno, bchihi, wenst, linux-pm, linux-kernel,
	linux-arm-kernel, linux-mediatek


[-- Attachment #1.1: Type: text/plain, Size: 3377 bytes --]

Hello,

On Wed, Jul 05, 2023 at 10:15:37AM +0800, Jonathan Cameron wrote:
> On Tue, 4 Jul 2023 16:19:54 +0200
> Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
> 
> > Hello,
> > 
> > On Tue, Jul 04, 2023 at 05:06:12PM +0800, Yangtao Li wrote:
> > > On 2023/7/4 16:48, Krzysztof Kozlowski wrote:
> > >   
> > > > [你通常不会收到来自 krzk@kernel.org 的电子邮件。请访问 https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要]
> > > > 
> > > > On 03/07/2023 19:43, Uwe Kleine-König wrote:  
> > > > > Hello Krzysztof,
> > > > > 
> > > > > On Mon, Jul 03, 2023 at 02:31:59PM +0200, Krzysztof Kozlowski wrote:  
> > > > > > On 03/07/2023 11:04, Yangtao Li wrote:  
> > > > > > > There are more than 700 calls to the devm_request_threaded_irq method.
> > > > > > > Most drivers only request one interrupt resource, and these error
> > > > > > > messages are basically the same. If error messages are printed
> > > > > > > everywhere, more than 1000 lines of code can be saved by removing the
> > > > > > > msg in the driver.  
> > > > > > 
> > > > > > ...
> > > > > >   
> > > > > > > +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
> > > > > > > +                              irq_handler_t handler, irq_handler_t thread_fn,
> > > > > > > +                              unsigned long irqflags, const char *devname,
> > > > > > > +                              void *dev_id, const char *emsg)
> > > > > > > +{
> > > > > > > +   int rc;
> > > > > > > +
> > > > > > > +   rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
> > > > > > > +                                  devname, dev_id);
> > > > > > > +   if (rc && rc != -EPROBE_DEFER) {
> > > > > > > +           dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
> > > > > > > +                   thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
> > > > > > > +                   emsg ? : "", ERR_PTR(rc));  
> > > > > > It is open-coding dev_err_probe(). Just use dev_err_probe instead.  
> > > > > dev_err_probe is supposed to be only called in probe functions, while
> > > > > devm_request_threaded_irq might be called in other contexts (e.g. when a
> > > > > device is opened). That's why I asked to not use dev_err_probe() in v2  
> > > > True, but then all the callers of this function will forget to set
> > > > deferred probe reason.  
> > 
> > That's another reason for letting the driver issue the error message and
> > not the request_irq function.
> >  
> > > So let's use dev_err_probe?
> > > 
> > > BTW, any suggestions for names here, keep using
> > > devm_request_threaded_irq_emsg or change to a new name?  
> > 
> > I would have called it devm_request_threaded_irq_verbose() which I
> > consider easier to understand. But maybe  is just my (green)
> > bikeshed.
> 
> If going to use dev_err_probe() internally maybe can just use
> devm_request_threaded_irq_probe() thus reflecting that and making
> it different to the devm_request_threaded_irq()?

I like devm_request_threaded_irq_probe(), thanks for that suggestion
(even though it's red :-)

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
  2023-07-05  7:30                 ` Uwe Kleine-König
@ 2023-07-05  7:43                   ` Yangtao Li
  -1 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-05  7:43 UTC (permalink / raw)
  To: Uwe Kleine-König, Jonathan Cameron
  Cc: Krzysztof Kozlowski, miquel.raynal, rafael, daniel.lezcano,
	amitk, rui.zhang, mmayer, bcm-kernel-feedback-list,
	florian.fainelli, tglx, matthias.bgg, angelogioacchino.delregno,
	bchihi, wenst, linux-pm, linux-kernel, linux-arm-kernel,
	linux-mediatek

On 2023/7/5 15:30, Uwe Kleine-König wrote:

> Hello,
>
> On Wed, Jul 05, 2023 at 10:15:37AM +0800, Jonathan Cameron wrote:
>> On Tue, 4 Jul 2023 16:19:54 +0200
>> Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
>>
>>> Hello,
>>>
>>> On Tue, Jul 04, 2023 at 05:06:12PM +0800, Yangtao Li wrote:
>>>> On 2023/7/4 16:48, Krzysztof Kozlowski wrote:
>>>>    
>>>>> [你通常不会收到来自 krzk@kernel.org 的电子邮件。请访问 https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要]
>>>>>
>>>>> On 03/07/2023 19:43, Uwe Kleine-König wrote:
>>>>>> Hello Krzysztof,
>>>>>>
>>>>>> On Mon, Jul 03, 2023 at 02:31:59PM +0200, Krzysztof Kozlowski wrote:
>>>>>>> On 03/07/2023 11:04, Yangtao Li wrote:
>>>>>>>> There are more than 700 calls to the devm_request_threaded_irq method.
>>>>>>>> Most drivers only request one interrupt resource, and these error
>>>>>>>> messages are basically the same. If error messages are printed
>>>>>>>> everywhere, more than 1000 lines of code can be saved by removing the
>>>>>>>> msg in the driver.
>>>>>>> ...
>>>>>>>    
>>>>>>>> +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
>>>>>>>> +                              irq_handler_t handler, irq_handler_t thread_fn,
>>>>>>>> +                              unsigned long irqflags, const char *devname,
>>>>>>>> +                              void *dev_id, const char *emsg)
>>>>>>>> +{
>>>>>>>> +   int rc;
>>>>>>>> +
>>>>>>>> +   rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
>>>>>>>> +                                  devname, dev_id);
>>>>>>>> +   if (rc && rc != -EPROBE_DEFER) {
>>>>>>>> +           dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
>>>>>>>> +                   thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
>>>>>>>> +                   emsg ? : "", ERR_PTR(rc));
>>>>>>> It is open-coding dev_err_probe(). Just use dev_err_probe instead.
>>>>>> dev_err_probe is supposed to be only called in probe functions, while
>>>>>> devm_request_threaded_irq might be called in other contexts (e.g. when a
>>>>>> device is opened). That's why I asked to not use dev_err_probe() in v2
>>>>> True, but then all the callers of this function will forget to set
>>>>> deferred probe reason.
>>> That's another reason for letting the driver issue the error message and
>>> not the request_irq function.
>>>   
>>>> So let's use dev_err_probe?
>>>>
>>>> BTW, any suggestions for names here, keep using
>>>> devm_request_threaded_irq_emsg or change to a new name?
>>> I would have called it devm_request_threaded_irq_verbose() which I
>>> consider easier to understand. But maybe  is just my (green)
>>> bikeshed.
>> If going to use dev_err_probe() internally maybe can just use
>> devm_request_threaded_irq_probe() thus reflecting that and making
>> it different to the devm_request_threaded_irq()?
> I like devm_request_threaded_irq_probe(), thanks for that suggestion
> (even though it's red :-)


devm_request_threaded_irq_probe() also sounds good to me, :-) If there 
is no objection, I think it's time to start working on switching the api.

int devm_request_threaded_irq_probe(struct device *dev, unsigned int 
irq, irq_handler_t handler, irq_handler_t thread_fn, unsigned long 
irqflags, const char *devname, void *dev_id, const char *info) { int rc; 
rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags, 
devname, dev_id); if (rc) return dev_err_probe(dev, rc, "Failed to 
request %sinterrupt %u %s %s\n", thread_fn ? "threaded " : "", irq, 
devname ? : dev_name(dev), info ? : ""); return 0; } 
EXPORT_SYMBOL(devm_request_threaded_irq_probe); MBR, Yangtao


>
> Best regards
> Uwe
>

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
@ 2023-07-05  7:43                   ` Yangtao Li
  0 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-05  7:43 UTC (permalink / raw)
  To: Uwe Kleine-König, Jonathan Cameron
  Cc: Krzysztof Kozlowski, miquel.raynal, rafael, daniel.lezcano,
	amitk, rui.zhang, mmayer, bcm-kernel-feedback-list,
	florian.fainelli, tglx, matthias.bgg, angelogioacchino.delregno,
	bchihi, wenst, linux-pm, linux-kernel, linux-arm-kernel,
	linux-mediatek

On 2023/7/5 15:30, Uwe Kleine-König wrote:

> Hello,
>
> On Wed, Jul 05, 2023 at 10:15:37AM +0800, Jonathan Cameron wrote:
>> On Tue, 4 Jul 2023 16:19:54 +0200
>> Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
>>
>>> Hello,
>>>
>>> On Tue, Jul 04, 2023 at 05:06:12PM +0800, Yangtao Li wrote:
>>>> On 2023/7/4 16:48, Krzysztof Kozlowski wrote:
>>>>    
>>>>> [你通常不会收到来自 krzk@kernel.org 的电子邮件。请访问 https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要]
>>>>>
>>>>> On 03/07/2023 19:43, Uwe Kleine-König wrote:
>>>>>> Hello Krzysztof,
>>>>>>
>>>>>> On Mon, Jul 03, 2023 at 02:31:59PM +0200, Krzysztof Kozlowski wrote:
>>>>>>> On 03/07/2023 11:04, Yangtao Li wrote:
>>>>>>>> There are more than 700 calls to the devm_request_threaded_irq method.
>>>>>>>> Most drivers only request one interrupt resource, and these error
>>>>>>>> messages are basically the same. If error messages are printed
>>>>>>>> everywhere, more than 1000 lines of code can be saved by removing the
>>>>>>>> msg in the driver.
>>>>>>> ...
>>>>>>>    
>>>>>>>> +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
>>>>>>>> +                              irq_handler_t handler, irq_handler_t thread_fn,
>>>>>>>> +                              unsigned long irqflags, const char *devname,
>>>>>>>> +                              void *dev_id, const char *emsg)
>>>>>>>> +{
>>>>>>>> +   int rc;
>>>>>>>> +
>>>>>>>> +   rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
>>>>>>>> +                                  devname, dev_id);
>>>>>>>> +   if (rc && rc != -EPROBE_DEFER) {
>>>>>>>> +           dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
>>>>>>>> +                   thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
>>>>>>>> +                   emsg ? : "", ERR_PTR(rc));
>>>>>>> It is open-coding dev_err_probe(). Just use dev_err_probe instead.
>>>>>> dev_err_probe is supposed to be only called in probe functions, while
>>>>>> devm_request_threaded_irq might be called in other contexts (e.g. when a
>>>>>> device is opened). That's why I asked to not use dev_err_probe() in v2
>>>>> True, but then all the callers of this function will forget to set
>>>>> deferred probe reason.
>>> That's another reason for letting the driver issue the error message and
>>> not the request_irq function.
>>>   
>>>> So let's use dev_err_probe?
>>>>
>>>> BTW, any suggestions for names here, keep using
>>>> devm_request_threaded_irq_emsg or change to a new name?
>>> I would have called it devm_request_threaded_irq_verbose() which I
>>> consider easier to understand. But maybe  is just my (green)
>>> bikeshed.
>> If going to use dev_err_probe() internally maybe can just use
>> devm_request_threaded_irq_probe() thus reflecting that and making
>> it different to the devm_request_threaded_irq()?
> I like devm_request_threaded_irq_probe(), thanks for that suggestion
> (even though it's red :-)


devm_request_threaded_irq_probe() also sounds good to me, :-) If there 
is no objection, I think it's time to start working on switching the api.

int devm_request_threaded_irq_probe(struct device *dev, unsigned int 
irq, irq_handler_t handler, irq_handler_t thread_fn, unsigned long 
irqflags, const char *devname, void *dev_id, const char *info) { int rc; 
rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags, 
devname, dev_id); if (rc) return dev_err_probe(dev, rc, "Failed to 
request %sinterrupt %u %s %s\n", thread_fn ? "threaded " : "", irq, 
devname ? : dev_name(dev), info ? : ""); return 0; } 
EXPORT_SYMBOL(devm_request_threaded_irq_probe); MBR, Yangtao


>
> Best regards
> Uwe
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
  2023-07-05  7:43                   ` Yangtao Li
@ 2023-07-05  7:49                     ` Yangtao Li
  -1 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-05  7:49 UTC (permalink / raw)
  To: frank.li
  Cc: Jonathan.Cameron, amitk, angelogioacchino.delregno, bchihi,
	bcm-kernel-feedback-list, daniel.lezcano, florian.fainelli, krzk,
	linux-arm-kernel, linux-kernel, linux-mediatek, linux-pm,
	matthias.bgg, miquel.raynal, mmayer, rafael, rui.zhang, tglx,
	u.kleine-koenig, wenst

I don't know what's wrong with the email client that caused the line break to be abnormal.
I used git send-email to resend this.

int devm_request_threaded_irq_probe(struct device *dev, unsigned int irq,
				    irq_handler_t handler, irq_handler_t thread_fn,
				    unsigned long irqflags, const char *devname,
				    void *dev_id, const char *info) 
{
	int rc;

	rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags, devname, dev_id);
	if (rc)
		return dev_err_probe(dev, rc, "Failed to request %sinterrupt %u %s %s\n",
				     thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
				     info ? : "");
	return 0; 
}
EXPORT_SYMBOL(devm_request_threaded_irq_probe);

Thx,
Yangtao

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
@ 2023-07-05  7:49                     ` Yangtao Li
  0 siblings, 0 replies; 44+ messages in thread
From: Yangtao Li @ 2023-07-05  7:49 UTC (permalink / raw)
  To: frank.li
  Cc: Jonathan.Cameron, amitk, angelogioacchino.delregno, bchihi,
	bcm-kernel-feedback-list, daniel.lezcano, florian.fainelli, krzk,
	linux-arm-kernel, linux-kernel, linux-mediatek, linux-pm,
	matthias.bgg, miquel.raynal, mmayer, rafael, rui.zhang, tglx,
	u.kleine-koenig, wenst

I don't know what's wrong with the email client that caused the line break to be abnormal.
I used git send-email to resend this.

int devm_request_threaded_irq_probe(struct device *dev, unsigned int irq,
				    irq_handler_t handler, irq_handler_t thread_fn,
				    unsigned long irqflags, const char *devname,
				    void *dev_id, const char *info) 
{
	int rc;

	rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags, devname, dev_id);
	if (rc)
		return dev_err_probe(dev, rc, "Failed to request %sinterrupt %u %s %s\n",
				     thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev),
				     info ? : "");
	return 0; 
}
EXPORT_SYMBOL(devm_request_threaded_irq_probe);

Thx,
Yangtao

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
  2023-07-05  7:43                   ` Yangtao Li
@ 2023-07-05 10:14                     ` AngeloGioacchino Del Regno
  -1 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-07-05 10:14 UTC (permalink / raw)
  To: Yangtao Li, Uwe Kleine-König, Jonathan Cameron
  Cc: Krzysztof Kozlowski, miquel.raynal, rafael, daniel.lezcano,
	amitk, rui.zhang, mmayer, bcm-kernel-feedback-list,
	florian.fainelli, tglx, matthias.bgg, bchihi, wenst, linux-pm,
	linux-kernel, linux-arm-kernel, linux-mediatek

Il 05/07/23 09:43, Yangtao Li ha scritto:
> On 2023/7/5 15:30, Uwe Kleine-König wrote:
> 
>> Hello,
>>
>> On Wed, Jul 05, 2023 at 10:15:37AM +0800, Jonathan Cameron wrote:
>>> On Tue, 4 Jul 2023 16:19:54 +0200
>>> Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
>>>
>>>> Hello,
>>>>
>>>> On Tue, Jul 04, 2023 at 05:06:12PM +0800, Yangtao Li wrote:
>>>>> On 2023/7/4 16:48, Krzysztof Kozlowski wrote:
>>>>>> [你通常不会收到来自 krzk@kernel.org 的电子邮件。请访问 https://aka.ms 
>>>>>> /LearnAboutSenderIdentification,以了解这一点为什么很重要]
>>>>>>
>>>>>> On 03/07/2023 19:43, Uwe Kleine-König wrote:
>>>>>>> Hello Krzysztof,
>>>>>>>
>>>>>>> On Mon, Jul 03, 2023 at 02:31:59PM +0200, Krzysztof Kozlowski wrote:
>>>>>>>> On 03/07/2023 11:04, Yangtao Li wrote:
>>>>>>>>> There are more than 700 calls to the devm_request_threaded_irq method.
>>>>>>>>> Most drivers only request one interrupt resource, and these error
>>>>>>>>> messages are basically the same. If error messages are printed
>>>>>>>>> everywhere, more than 1000 lines of code can be saved by removing the
>>>>>>>>> msg in the driver.
>>>>>>>> ...
>>>>>>>>> +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
>>>>>>>>> +                              irq_handler_t handler, irq_handler_t 
>>>>>>>>> thread_fn,
>>>>>>>>> +                              unsigned long irqflags, const char *devname,
>>>>>>>>> +                              void *dev_id, const char *emsg)
>>>>>>>>> +{
>>>>>>>>> +   int rc;
>>>>>>>>> +
>>>>>>>>> +   rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
>>>>>>>>> +                                  devname, dev_id);
>>>>>>>>> +   if (rc && rc != -EPROBE_DEFER) {
>>>>>>>>> +           dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
>>>>>>>>> +                   thread_fn ? "threaded " : "", irq, devname ? : 
>>>>>>>>> dev_name(dev),
>>>>>>>>> +                   emsg ? : "", ERR_PTR(rc));
>>>>>>>> It is open-coding dev_err_probe(). Just use dev_err_probe instead.
>>>>>>> dev_err_probe is supposed to be only called in probe functions, while
>>>>>>> devm_request_threaded_irq might be called in other contexts (e.g. when a
>>>>>>> device is opened). That's why I asked to not use dev_err_probe() in v2
>>>>>> True, but then all the callers of this function will forget to set
>>>>>> deferred probe reason.
>>>> That's another reason for letting the driver issue the error message and
>>>> not the request_irq function.
>>>>> So let's use dev_err_probe?
>>>>>
>>>>> BTW, any suggestions for names here, keep using
>>>>> devm_request_threaded_irq_emsg or change to a new name?
>>>> I would have called it devm_request_threaded_irq_verbose() which I
>>>> consider easier to understand. But maybe  is just my (green)
>>>> bikeshed.
>>> If going to use dev_err_probe() internally maybe can just use
>>> devm_request_threaded_irq_probe() thus reflecting that and making
>>> it different to the devm_request_threaded_irq()?
>> I like devm_request_threaded_irq_probe(), thanks for that suggestion
>> (even though it's red :-)
> 
> 
> devm_request_threaded_irq_probe() also sounds good to me, :-) If there is no 
> objection, I think it's time to start working on switching the api.
> 

+1 on devm_request_threaded_irq_probe() name, makes sense to me, as it'd be
using the same error logic as dev_err_probe() (no prints if -EPROBE_DEFER),
and also.. this is a function that's anyway used in .probe() callbacks at
least in the *vast* majority of the cases.

Cheers,
Angelo

> int devm_request_threaded_irq_probe(struct device *dev, unsigned int irq, 
> irq_handler_t handler, irq_handler_t thread_fn, unsigned long irqflags, const char 
> *devname, void *dev_id, const char *info) { int rc; rc = 
> devm_request_threaded_irq(dev, irq, handler, NULL, irqflags, devname, dev_id); if 
> (rc) return dev_err_probe(dev, rc, "Failed to request %sinterrupt %u %s %s\n", 
> thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev), info ? : ""); return 
> 0; } EXPORT_SYMBOL(devm_request_threaded_irq_probe); MBR, Yangtao
> 
> 
>>
>> Best regards
>> Uwe
>>


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

* Re: [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg()
@ 2023-07-05 10:14                     ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-07-05 10:14 UTC (permalink / raw)
  To: Yangtao Li, Uwe Kleine-König, Jonathan Cameron
  Cc: Krzysztof Kozlowski, miquel.raynal, rafael, daniel.lezcano,
	amitk, rui.zhang, mmayer, bcm-kernel-feedback-list,
	florian.fainelli, tglx, matthias.bgg, bchihi, wenst, linux-pm,
	linux-kernel, linux-arm-kernel, linux-mediatek

Il 05/07/23 09:43, Yangtao Li ha scritto:
> On 2023/7/5 15:30, Uwe Kleine-König wrote:
> 
>> Hello,
>>
>> On Wed, Jul 05, 2023 at 10:15:37AM +0800, Jonathan Cameron wrote:
>>> On Tue, 4 Jul 2023 16:19:54 +0200
>>> Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
>>>
>>>> Hello,
>>>>
>>>> On Tue, Jul 04, 2023 at 05:06:12PM +0800, Yangtao Li wrote:
>>>>> On 2023/7/4 16:48, Krzysztof Kozlowski wrote:
>>>>>> [你通常不会收到来自 krzk@kernel.org 的电子邮件。请访问 https://aka.ms 
>>>>>> /LearnAboutSenderIdentification,以了解这一点为什么很重要]
>>>>>>
>>>>>> On 03/07/2023 19:43, Uwe Kleine-König wrote:
>>>>>>> Hello Krzysztof,
>>>>>>>
>>>>>>> On Mon, Jul 03, 2023 at 02:31:59PM +0200, Krzysztof Kozlowski wrote:
>>>>>>>> On 03/07/2023 11:04, Yangtao Li wrote:
>>>>>>>>> There are more than 700 calls to the devm_request_threaded_irq method.
>>>>>>>>> Most drivers only request one interrupt resource, and these error
>>>>>>>>> messages are basically the same. If error messages are printed
>>>>>>>>> everywhere, more than 1000 lines of code can be saved by removing the
>>>>>>>>> msg in the driver.
>>>>>>>> ...
>>>>>>>>> +int devm_request_threaded_irq_emsg(struct device *dev, unsigned int irq,
>>>>>>>>> +                              irq_handler_t handler, irq_handler_t 
>>>>>>>>> thread_fn,
>>>>>>>>> +                              unsigned long irqflags, const char *devname,
>>>>>>>>> +                              void *dev_id, const char *emsg)
>>>>>>>>> +{
>>>>>>>>> +   int rc;
>>>>>>>>> +
>>>>>>>>> +   rc = devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
>>>>>>>>> +                                  devname, dev_id);
>>>>>>>>> +   if (rc && rc != -EPROBE_DEFER) {
>>>>>>>>> +           dev_err(dev, "Failed to request %sinterrupt %u %s %s: %pe\n",
>>>>>>>>> +                   thread_fn ? "threaded " : "", irq, devname ? : 
>>>>>>>>> dev_name(dev),
>>>>>>>>> +                   emsg ? : "", ERR_PTR(rc));
>>>>>>>> It is open-coding dev_err_probe(). Just use dev_err_probe instead.
>>>>>>> dev_err_probe is supposed to be only called in probe functions, while
>>>>>>> devm_request_threaded_irq might be called in other contexts (e.g. when a
>>>>>>> device is opened). That's why I asked to not use dev_err_probe() in v2
>>>>>> True, but then all the callers of this function will forget to set
>>>>>> deferred probe reason.
>>>> That's another reason for letting the driver issue the error message and
>>>> not the request_irq function.
>>>>> So let's use dev_err_probe?
>>>>>
>>>>> BTW, any suggestions for names here, keep using
>>>>> devm_request_threaded_irq_emsg or change to a new name?
>>>> I would have called it devm_request_threaded_irq_verbose() which I
>>>> consider easier to understand. But maybe  is just my (green)
>>>> bikeshed.
>>> If going to use dev_err_probe() internally maybe can just use
>>> devm_request_threaded_irq_probe() thus reflecting that and making
>>> it different to the devm_request_threaded_irq()?
>> I like devm_request_threaded_irq_probe(), thanks for that suggestion
>> (even though it's red :-)
> 
> 
> devm_request_threaded_irq_probe() also sounds good to me, :-) If there is no 
> objection, I think it's time to start working on switching the api.
> 

+1 on devm_request_threaded_irq_probe() name, makes sense to me, as it'd be
using the same error logic as dev_err_probe() (no prints if -EPROBE_DEFER),
and also.. this is a function that's anyway used in .probe() callbacks at
least in the *vast* majority of the cases.

Cheers,
Angelo

> int devm_request_threaded_irq_probe(struct device *dev, unsigned int irq, 
> irq_handler_t handler, irq_handler_t thread_fn, unsigned long irqflags, const char 
> *devname, void *dev_id, const char *info) { int rc; rc = 
> devm_request_threaded_irq(dev, irq, handler, NULL, irqflags, devname, dev_id); if 
> (rc) return dev_err_probe(dev, rc, "Failed to request %sinterrupt %u %s %s\n", 
> thread_fn ? "threaded " : "", irq, devname ? : dev_name(dev), info ? : ""); return 
> 0; } EXPORT_SYMBOL(devm_request_threaded_irq_probe); MBR, Yangtao
> 
> 
>>
>> Best regards
>> Uwe
>>


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2023-07-05 10:14 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-03  9:04 [PATCH v3 0/5] introduce devm_request_threaded_irq_emsg() Yangtao Li
2023-07-03  9:04 ` Yangtao Li
2023-07-03  9:04 ` [PATCH v3 1/5] genirq/devres: Add devm_request_threaded_irq_emsg() Yangtao Li
2023-07-03  9:04   ` Yangtao Li
2023-07-03 12:31   ` Krzysztof Kozlowski
2023-07-03 12:31     ` Krzysztof Kozlowski
2023-07-03 13:24     ` Yangtao Li
2023-07-03 13:24       ` Yangtao Li
2023-07-03 13:37       ` Krzysztof Kozlowski
2023-07-03 13:37         ` Krzysztof Kozlowski
2023-07-03 17:43     ` Uwe Kleine-König
2023-07-03 17:43       ` Uwe Kleine-König
2023-07-04  8:48       ` Krzysztof Kozlowski
2023-07-04  8:48         ` Krzysztof Kozlowski
2023-07-04  9:06         ` Yangtao Li
2023-07-04  9:06           ` Yangtao Li
2023-07-04 14:19           ` Uwe Kleine-König
2023-07-04 14:19             ` Uwe Kleine-König
2023-07-05  2:15             ` Jonathan Cameron
2023-07-05  2:15               ` Jonathan Cameron
2023-07-05  7:30               ` Uwe Kleine-König
2023-07-05  7:30                 ` Uwe Kleine-König
2023-07-05  7:43                 ` Yangtao Li
2023-07-05  7:43                   ` Yangtao Li
2023-07-05  7:49                   ` Yangtao Li
2023-07-05  7:49                     ` Yangtao Li
2023-07-05 10:14                   ` AngeloGioacchino Del Regno
2023-07-05 10:14                     ` AngeloGioacchino Del Regno
2023-07-03  9:04 ` [PATCH v3 2/5] thermal/drivers/armada: convert to use devm_request_threaded_irq_emsg() Yangtao Li
2023-07-03  9:04   ` Yangtao Li
2023-07-04  8:46   ` Miquel Raynal
2023-07-04  8:46     ` Miquel Raynal
2023-07-04 14:22     ` Uwe Kleine-König
2023-07-04 14:22       ` Uwe Kleine-König
2023-07-04 14:29       ` Miquel Raynal
2023-07-04 14:29         ` Miquel Raynal
2023-07-03  9:04 ` [PATCH v3 3/5] thermal/drivers/brcmstb_thermal: " Yangtao Li
2023-07-03  9:04   ` Yangtao Li
2023-07-03  9:04 ` [PATCH v3 4/5] thermal/drivers/db8500: " Yangtao Li
2023-07-03  9:04   ` Yangtao Li
2023-07-03  9:04 ` [PATCH v3 5/5] thermal/drivers/mediatek/lvts_thermal: " Yangtao Li
2023-07-03  9:04   ` Yangtao Li
2023-07-03 11:47 ` [PATCH v3 0/5] introduce devm_request_threaded_irq_emsg() Yangtao Li
2023-07-03 11:47   ` Yangtao Li

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.