Message ID | e9399426b08b16efbdf7224c0122f5bf80f6d0ea.1731130093.git.nicolinc@nvidia.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | vfio: Allow userspace to specify the address for each MSI vector | expand |
On Fri, Nov 08, 2024 at 09:48:51PM -0800, Nicolin Chen wrote: > Now, the common __pci_alloc_irq_vectors() accepts an array of msi_iovas, > which is a list of preset IOVAs for MSI doorbell addresses. > > Add a helper that would pass in a list. A following patch will call this > to forward msi_iovas from user space. ... > +/** > + * pci_alloc_irq_vectors_iovas() - Allocate multiple device interrupt > + * vectors with preset msi_iovas > + * @dev: the PCI device to operate on > + * @min_vecs: minimum required number of vectors (must be >= 1) > + * @max_vecs: maximum desired number of vectors > + * @flags: allocation flags, as in pci_alloc_irq_vectors() > + * @msi_iovas: list of IOVAs for MSI between [min_vecs, max_vecs] > + * > + * Same as pci_alloc_irq_vectors(), but with the extra @msi_iovas parameter. > + * Check that function docs, and &struct irq_affinity, for more details. > + */ Always validate your kernel-doc descriptions scripts/kernel-doc -Wall -none -v ... will give you a warning here.
On Mon, Nov 11, 2024 at 11:34:47AM +0200, Andy Shevchenko wrote: > On Fri, Nov 08, 2024 at 09:48:51PM -0800, Nicolin Chen wrote: > > Now, the common __pci_alloc_irq_vectors() accepts an array of msi_iovas, > > which is a list of preset IOVAs for MSI doorbell addresses. > > > > Add a helper that would pass in a list. A following patch will call this > > to forward msi_iovas from user space. > > ... > > > +/** > > + * pci_alloc_irq_vectors_iovas() - Allocate multiple device interrupt > > + * vectors with preset msi_iovas > > + * @dev: the PCI device to operate on > > + * @min_vecs: minimum required number of vectors (must be >= 1) > > + * @max_vecs: maximum desired number of vectors > > + * @flags: allocation flags, as in pci_alloc_irq_vectors() > > + * @msi_iovas: list of IOVAs for MSI between [min_vecs, max_vecs] > > + * > > + * Same as pci_alloc_irq_vectors(), but with the extra @msi_iovas parameter. > > + * Check that function docs, and &struct irq_affinity, for more details. > > + */ > > Always validate your kernel-doc descriptions > > scripts/kernel-doc -Wall -none -v ... > > will give you a warning here. Will do in next round. Thanks! Nicolin
diff --git a/include/linux/pci.h b/include/linux/pci.h index 68ebb9d42f7f..6423bee3b207 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1678,6 +1678,9 @@ int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, unsigned int max_vecs, unsigned int flags, struct irq_affinity *affd); +int pci_alloc_irq_vectors_iovas(struct pci_dev *dev, unsigned int min_vecs, + unsigned int max_vecs, unsigned int flags, + dma_addr_t *msi_iovas); bool pci_msix_can_alloc_dyn(struct pci_dev *dev); struct msi_map pci_msix_alloc_irq_at(struct pci_dev *dev, unsigned int index, @@ -1714,6 +1717,13 @@ pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, return -ENOSPC; } static inline int +pci_alloc_irq_vectors_iovas(struct pci_dev *dev, unsigned int min_vecs, + unsigned int max_vecs, unsigned int flags, + dma_addr_t *msi_iovas) + + return -ENOSPC; /* No support if !CONFIG_PCI_MSI */ +} +static inline int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, unsigned int max_vecs, unsigned int flags) { @@ -2068,6 +2078,13 @@ pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, return -ENOSPC; } static inline int +pci_alloc_irq_vectors_iovas(struct pci_dev *dev, unsigned int min_vecs, + unsigned int max_vecs, unsigned int flags, + dma_addr_t *msi_iovas) +{ + return -ENOSPC; +} +static inline int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, unsigned int max_vecs, unsigned int flags) { diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c index dff3d7350b38..4e90ef8f571c 100644 --- a/drivers/pci/msi/api.c +++ b/drivers/pci/msi/api.c @@ -327,6 +327,27 @@ int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, } EXPORT_SYMBOL(pci_alloc_irq_vectors_affinity); +/** + * pci_alloc_irq_vectors_iovas() - Allocate multiple device interrupt + * vectors with preset msi_iovas + * @dev: the PCI device to operate on + * @min_vecs: minimum required number of vectors (must be >= 1) + * @max_vecs: maximum desired number of vectors + * @flags: allocation flags, as in pci_alloc_irq_vectors() + * @msi_iovas: list of IOVAs for MSI between [min_vecs, max_vecs] + * + * Same as pci_alloc_irq_vectors(), but with the extra @msi_iovas parameter. + * Check that function docs, and &struct irq_affinity, for more details. + */ +int pci_alloc_irq_vectors_iovas(struct pci_dev *dev, unsigned int min_vecs, + unsigned int max_vecs, unsigned int flags, + dma_addr_t *msi_iovas) +{ + return __pci_alloc_irq_vectors(dev, min_vecs, max_vecs, + flags, NULL, msi_iovas); +} +EXPORT_SYMBOL(pci_alloc_irq_vectors_iovas); + /** * pci_irq_vector() - Get Linux IRQ number of a device interrupt vector * @dev: the PCI device to operate on
Now, the common __pci_alloc_irq_vectors() accepts an array of msi_iovas, which is a list of preset IOVAs for MSI doorbell addresses. Add a helper that would pass in a list. A following patch will call this to forward msi_iovas from user space. Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> --- include/linux/pci.h | 17 +++++++++++++++++ drivers/pci/msi/api.c | 21 +++++++++++++++++++++ 2 files changed, 38 insertions(+)