[PATCH v1 01/23] genirq/chip: Change irq_chip_pm_put() return type to void

Rafael J. Wysocki posted 1 patch 1 month, 2 weeks ago
include/linux/irq.h |    2 +-
kernel/irq/chip.c   |   22 +++++++++++-----------
2 files changed, 12 insertions(+), 12 deletions(-)
[PATCH v1 01/23] genirq/chip: Change irq_chip_pm_put() return type to void
Posted by Rafael J. Wysocki 1 month, 2 weeks ago
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

The irq_chip_pm_put() return value is only used in __irq_do_set_handler()
to trigger a WARN_ON() if it is negative, but doing so is not useful
because irq_chip_pm_put() simply passes the pm_runtime_put() return value
to its callers.

Returning an error code from pm_runtime_put() merely means that it has
not queued up a work item to check whether or not the device can be
suspended and there are many perfectly valid situations in which that
can happen, like after writing "on" to the devices' runtime PM "control"
attribute in sysfs for one example.

For this reason, modify irq_chip_pm_put() to discard the pm_runtime_put()
return value, change its return type to void, and drop the WARN_ON()
around the irq_chip_pm_put() invocation from __irq_do_set_handler().
Also update the irq_chip_pm_put() kerneldoc comment to be more accurate.

This will facilitate a planned change of the pm_runtime_put() return
type to void in the future.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---

This patch is part of a series, but it doesn't depend on anything else
in that series.  The last patch in the series depends on it.

It can be applied by itself and if you decide to do so, please let me
know.

Otherwise, an ACK or equivalent will be appreciated, but also the lack
of specific criticism will be eventually regarded as consent.

---
 include/linux/irq.h |    2 +-
 kernel/irq/chip.c   |   22 +++++++++++-----------
 2 files changed, 12 insertions(+), 12 deletions(-)

--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -659,7 +659,7 @@ extern void handle_percpu_devid_fasteoi_
 
 extern int irq_chip_compose_msi_msg(struct irq_data *data, struct msi_msg *msg);
 extern int irq_chip_pm_get(struct irq_data *data);
-extern int irq_chip_pm_put(struct irq_data *data);
+extern void irq_chip_pm_put(struct irq_data *data);
 #ifdef	CONFIG_IRQ_DOMAIN_HIERARCHY
 extern void handle_fasteoi_ack_irq(struct irq_desc *desc);
 extern void handle_fasteoi_mask_irq(struct irq_desc *desc);
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -995,7 +995,7 @@ __irq_do_set_handler(struct irq_desc *de
 		irq_state_set_disabled(desc);
 		if (is_chained) {
 			desc->action = NULL;
-			WARN_ON(irq_chip_pm_put(irq_desc_get_irq_data(desc)));
+			irq_chip_pm_put(irq_desc_get_irq_data(desc));
 		}
 		desc->depth = 1;
 	}
@@ -1551,20 +1551,20 @@ int irq_chip_pm_get(struct irq_data *dat
 }
 
 /**
- * irq_chip_pm_put - Disable power for an IRQ chip
+ * irq_chip_pm_put - Drop a PM reference on an IRQ chip
  * @data:	Pointer to interrupt specific data
  *
- * Disable the power to the IRQ chip referenced by the interrupt data
- * structure, belongs. Note that power will only be disabled, once this
- * function has been called for all IRQs that have called irq_chip_pm_get().
+ * Drop a power management reference, acquired via irq_chip_pm_get(), on the IRQ
+ * chip represented by the interrupt data structure.
+ *
+ * Note that this will not disable power to the IRQ chip until this function
+ * has been called for all IRQs that have called irq_chip_pm_get() and it may
+ * not disable power at all (which may be prefented by user space, for example).
  */
-int irq_chip_pm_put(struct irq_data *data)
+void irq_chip_pm_put(struct irq_data *data)
 {
 	struct device *dev = irq_get_pm_device(data);
-	int retval = 0;
-
-	if (IS_ENABLED(CONFIG_PM) && dev)
-		retval = pm_runtime_put(dev);
 
-	return (retval < 0) ? retval : 0;
+	if (dev)
+		pm_runtime_put(dev);
 }
Re: [PATCH v1 01/23] genirq/chip: Change irq_chip_pm_put() return type to void
Posted by Thomas Gleixner 4 weeks, 1 day ago
On Mon, Dec 22 2025 at 20:50, Rafael J. Wysocki wrote:

> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> The irq_chip_pm_put() return value is only used in __irq_do_set_handler()
> to trigger a WARN_ON() if it is negative, but doing so is not useful
> because irq_chip_pm_put() simply passes the pm_runtime_put() return value
> to its callers.
>
> Returning an error code from pm_runtime_put() merely means that it has
> not queued up a work item to check whether or not the device can be
> suspended and there are many perfectly valid situations in which that
> can happen, like after writing "on" to the devices' runtime PM "control"
> attribute in sysfs for one example.
>
> For this reason, modify irq_chip_pm_put() to discard the pm_runtime_put()
> return value, change its return type to void, and drop the WARN_ON()
> around the irq_chip_pm_put() invocation from __irq_do_set_handler().
> Also update the irq_chip_pm_put() kerneldoc comment to be more accurate.
>
> This will facilitate a planned change of the pm_runtime_put() return
> type to void in the future.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Reviewed-by: Thomas Gleixner <tglx@kernel.org>