diff mbox series

[v4,1/2] genirq/msi: add wrapper msi allocation API and export msi functions

Message ID 20240305043040.224127-1-nipun.gupta@amd.com (mailing list archive)
State New, archived
Headers show
Series [v4,1/2] genirq/msi: add wrapper msi allocation API and export msi functions | expand

Commit Message

Nipun Gupta March 5, 2024, 4:30 a.m. UTC
MSI functions can be for allocation and free can be directly
used by the device drivers without any wrapper provided by
bus drivers. So export these MSI functions.

Also, add a wrapper API to allocate MSIs providing only the
number of IRQ's rather than range for simpler driver usage.

Signed-off-by: Nipun Gupta <nipun.gupta@amd.com>
---

Changes in v3->v4:
- No change

Changes in v3:
- New in this patch series. VFIO-CDX uses the new wrapper API
  msi_domain_alloc_irqs and exported APIs. (This patch is moved
  from CDX interrupt support to vfio-cdx patch, where these APIs
  are used).

 include/linux/msi.h | 6 ++++++
 kernel/irq/msi.c    | 2 ++
 2 files changed, 8 insertions(+)

Comments

Thomas Gleixner March 25, 2024, 3:06 p.m. UTC | #1
On Tue, Mar 05 2024 at 10:00, Nipun Gupta wrote:

  Subject: genirq/msi: Add MSI allocation helper and export MSI functions

> MSI functions can be for allocation and free can be directly
> used by the device drivers without any wrapper provided by
> bus drivers. So export these MSI functions.

s/can be for/for/ otherwise the sentence dos not make sense.

> Also, add a wrapper API to allocate MSIs providing only the
> number of IRQ's rather than range for simpler driver usage.

s/IRQ's/interrupts/ 

> Signed-off-by: Nipun Gupta <nipun.gupta@amd.com>

Other than that:

Reviewed-by: Thomas Gleixner <tglx@linutronix.de>

Alex, feel free to pick this up with the nitpicks resolved and route it
through your tree together with the VFIO driver.

Thanks,

        tglx
diff mbox series

Patch

diff --git a/include/linux/msi.h b/include/linux/msi.h
index ddace8c34dcf..a9f77cbc8847 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -658,6 +658,12 @@  void platform_msi_device_domain_free(struct irq_domain *domain, unsigned int vir
 void *platform_msi_get_host_data(struct irq_domain *domain);
 
 bool msi_device_has_isolated_msi(struct device *dev);
+
+static inline int msi_domain_alloc_irqs(struct device *dev, unsigned int domid, int nirqs)
+{
+	return msi_domain_alloc_irqs_range(dev, domid, 0, nirqs - 1);
+}
+
 #else /* CONFIG_GENERIC_MSI_IRQ */
 static inline bool msi_device_has_isolated_msi(struct device *dev)
 {
diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
index 79b4a58ba9c3..4a324f683858 100644
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -1404,6 +1404,7 @@  int msi_domain_alloc_irqs_range(struct device *dev, unsigned int domid,
 	msi_unlock_descs(dev);
 	return ret;
 }
+EXPORT_SYMBOL_GPL(msi_domain_alloc_irqs_range);
 
 /**
  * msi_domain_alloc_irqs_all_locked - Allocate all interrupts from a MSI interrupt domain
@@ -1596,6 +1597,7 @@  void msi_domain_free_irqs_range(struct device *dev, unsigned int domid,
 	msi_domain_free_irqs_range_locked(dev, domid, first, last);
 	msi_unlock_descs(dev);
 }
+EXPORT_SYMBOL_GPL(msi_domain_free_irqs_all);
 
 /**
  * msi_domain_free_irqs_all_locked - Free all interrupts from a MSI interrupt domain