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. Tested-by: Wen Xiong <wenxiong@xxxxxxxxxx> Reviewed-by: Christoph Hellwig <hch@xxxxxx> Suggested-by: John Garry <john.garry@xxxxxxxxxx> Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> --- include/linux/msi.h | 5 +++++ kernel/irq/msi.c | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/linux/msi.h b/include/linux/msi.h index a20dc66b9946..b4511c606072 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -59,10 +59,15 @@ struct platform_msi_priv_data; void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg); #ifdef CONFIG_GENERIC_MSI_IRQ void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg); +bool device_has_managed_msi_irq(struct device *dev); #else static inline void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg) { } +static inline bool device_has_managed_msi_irq(struct device *dev) +{ + return false; +} #endif typedef void (*irq_write_msi_msg_t)(struct msi_desc *desc, diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index 00f89d5bd6f6..167bc1d8bf4a 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -71,6 +71,24 @@ void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg) } EXPORT_SYMBOL_GPL(get_cached_msi_msg); +/** + * device_has_managed_msi_irq - Query if device has managed irq entry + * @dev: Pointer to the device for which we want to query + * + * Return true if there is managed irq vector allocated on this device + */ +bool device_has_managed_msi_irq(struct device *dev) +{ + struct msi_desc *desc; + + 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); + #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN static inline void irq_chip_write_msi_msg(struct irq_data *data, struct msi_msg *msg) -- 2.31.1