Skip to content

Commit

Permalink
genirq/msi: Add MSI allocation helper and export MSI functions
Browse files Browse the repository at this point in the history
MSI functions 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 interrupts rather than range for simpler driver usage.

Signed-off-by: Nipun Gupta <nipun.gupta@amd.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20240423111021.1686144-1-nipun.gupta@amd.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
  • Loading branch information
nipung87 authored and awilliam committed Apr 23, 2024
1 parent 82b951e commit 06fe8fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/linux/msi.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,12 @@ int platform_device_msi_init_and_alloc_irqs(struct device *dev, unsigned int nve
void platform_device_msi_free_irqs_all(struct device *dev);

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)
{
Expand Down
2 changes: 2 additions & 0 deletions kernel/irq/msi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,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
Expand Down Expand Up @@ -1680,6 +1681,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
Expand Down

0 comments on commit 06fe8fd

Please sign in to comment.