Thread (11 messages) 11 messages, 4 authors, 2021-07-22
STALE1817d
Revisions (6)
  1. v1 [diff vs current]
  2. v2 [diff vs current]
  3. v4 [diff vs current]
  4. v5 current
  5. v6 [diff vs current]
  6. v7 [diff vs current]

[PATCH V5 1/3] driver core: add device_has_managed_msi_irq

From: Ming Lei <hidden>
Date: 2021-07-21 09:27:06
Subsystem: driver core, kobjects, debugfs and sysfs, the rest · Maintainers: Greg Kroah-Hartman, "Rafael J. Wysocki", Danilo Krummrich, Linus Torvalds

irq vector allocation with managed affinity may be used by driver, and
blk-mq needs this info for draining queue because genirq core will shutdown
managed irq when all CPUs in the affinity mask are offline.

The info of using managed irq is often produced by drivers, and it is
consumed by blk-mq, so different subsystems are involved in this info flow.

Address this issue by adding one helper of device_has_managed_msi_irq()
which is suggested by John Garry.

Suggested-by: John Garry <redacted>
Signed-off-by: Ming Lei <redacted>
---
 drivers/base/core.c    | 15 +++++++++++++++
 include/linux/device.h |  2 ++
 2 files changed, 17 insertions(+)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index cadcade65825..41daf9fabdfb 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -29,6 +29,7 @@
 #include <linux/sched/mm.h>
 #include <linux/sysfs.h>
 #include <linux/dma-map-ops.h> /* for dma_default_coherent */
+#include <linux/msi.h> /* for device_has_managed_irq */
 
 #include "base.h"
 #include "power/power.h"
@@ -4797,3 +4798,17 @@ int device_match_any(struct device *dev, const void *unused)
 	return 1;
 }
 EXPORT_SYMBOL_GPL(device_match_any);
+
+bool device_has_managed_msi_irq(struct device *dev)
+{
+	struct msi_desc *desc;
+
+	if (IS_ENABLED(CONFIG_GENERIC_MSI_IRQ)) {
+		for_each_msi_entry(desc, dev) {
+			if (desc->affinity && desc->affinity->is_managed)
+				return true;
+		}
+	}
+	return false;
+}
+EXPORT_SYMBOL_GPL(device_has_managed_msi_irq);
diff --git a/include/linux/device.h b/include/linux/device.h
index 59940f1744c1..b1255524ce8b 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -981,4 +981,6 @@ extern long sysfs_deprecated;
 #define sysfs_deprecated 0
 #endif
 
+bool device_has_managed_msi_irq(struct device *dev);
+
 #endif /* _DEVICE_H_ */
-- 
2.31.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help