From: Alexander Gordeev <agordeev@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH 5/5] pci: spread interrupt vectors in pci_alloc_irq_vectors
Date: Mon, 11 Jul 2016 22:51:11 +0200 [thread overview]
Message-ID: <20160711205110.GA23915@dhcp-27-118.brq.redhat.com> (raw)
In-Reply-To: <1468151866-7776-6-git-send-email-hch@lst.de>
On Sun, Jul 10, 2016 at 08:57:46PM +0900, Christoph Hellwig wrote:
> @@ -1028,19 +1038,8 @@ int pci_msi_enabled(void)
> }
> EXPORT_SYMBOL(pci_msi_enabled);
>
> -/**
> - * pci_enable_msi_range - configure device's MSI capability structure
> - * @dev: device to configure
> - * @minvec: minimal number of interrupts to configure
> - * @maxvec: maximum number of interrupts to configure
> - *
> - * This function tries to allocate a maximum possible number of interrupts in a
> - * range between @minvec and @maxvec. It returns a negative errno if an error
> - * occurs. If it succeeds, it returns the actual number of interrupts allocated
> - * and updates the @dev's irq member to the lowest new interrupt number;
> - * the other interrupt numbers allocated to this device are consecutive.
> - **/
> -int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec)
> +static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec,
> + unsigned int flags)
> {
> int nvec;
> int rc;
> @@ -1068,21 +1067,78 @@ int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec)
> else if (nvec > maxvec)
> nvec = maxvec;
>
> - do {
> + for (;;) {
> + if (!(flags & PCI_IRQ_NOAFFINITY)) {
> + dev->irq_affinity = irq_create_affinity_mask(&nvec);
> + if (nvec < minvec)
> + return -ERANGE;
return -ENOSPC;
> + }
> +
> rc = msi_capability_init(dev, nvec);
> - if (rc < 0) {
> + if (rc == 0)
> + return nvec;
> +
> + kfree(dev->irq_affinity);
> + dev->irq_affinity = NULL;
> +
> + if (rc < 0)
> return rc;
> - } else if (rc > 0) {
> - if (rc < minvec)
> - return -ENOSPC;
> - nvec = rc;
> - }
> - } while (rc);
> + if (rc < minvec)
else if (rc < minvec)
> + return -ENOSPC;
> + nvec = rc;
> + }
> +}
>
> - return nvec;
> +/**
> + * pci_enable_msi_range - configure device's MSI capability structure
> + * @dev: device to configure
> + * @minvec: minimal number of interrupts to configure
> + * @maxvec: maximum number of interrupts to configure
> + *
> + * This function tries to allocate a maximum possible number of interrupts in a
> + * range between @minvec and @maxvec. It returns a negative errno if an error
> + * occurs. If it succeeds, it returns the actual number of interrupts allocated
> + * and updates the @dev's irq member to the lowest new interrupt number;
> + * the other interrupt numbers allocated to this device are consecutive.
> + **/
> +int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec)
> +{
> + return __pci_enable_msi_range(dev, minvec, maxvec, PCI_IRQ_NOAFFINITY);
> }
> EXPORT_SYMBOL(pci_enable_msi_range);
As a one-liner pci_enable_msi_range() appears rather as a static inline
in linux/pci.h, but we do not want __pci_enable_msi*_range() to show up
in a public header, right?
> +static int __pci_enable_msix_range(struct pci_dev *dev,
> + struct msix_entry *entries, int minvec, int maxvec,
> + unsigned int flags)
> +{
> + int nvec = maxvec;
> + int rc;
> +
> + if (maxvec < minvec)
> + return -ERANGE;
> +
> + for (;;) {
> + if (!(flags & PCI_IRQ_NOAFFINITY)) {
> + dev->irq_affinity = irq_create_affinity_mask(&nvec);
> + if (nvec < minvec)
> + return -ERANGE;
return -ENOSPC;
> + }
> +
> + rc = pci_enable_msix(dev, entries, nvec);
> + if (rc == 0)
> + return nvec;
> +
> + kfree(dev->irq_affinity);
> + dev->irq_affinity = NULL;
> +
> + if (rc < 0)
> + return rc;
> + if (rc < minvec)
else if (rc < minvec)
> + return -ENOSPC;
> + nvec = rc;
> + }
> +}
> +
> /**
> * pci_enable_msix_range - configure device's MSI-X capability structure
> * @dev: pointer to the pci_dev data structure of MSI-X device function
next prev parent reply other threads:[~2016-07-11 20:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-10 11:57 pci: automatic interrupt affinity for MSI/MSI-X capable devices Christoph Hellwig
2016-07-10 11:57 ` [PATCH 1/5] pci: add a pci_msix_desc_addr helper Christoph Hellwig
2016-07-10 11:57 ` [PATCH 2/5] pci: switch msix_program_entries to use pci_msix_desc_addr Christoph Hellwig
2016-07-10 11:57 ` [PATCH 3/5] pci: make the entries argument to pci_enable_msix optional Christoph Hellwig
2016-07-11 11:33 ` Alexander Gordeev
2016-07-10 11:57 ` [PATCH 4/5] pci: Provide sensible irq vector alloc/free routines Christoph Hellwig
2016-07-11 11:47 ` Alexander Gordeev
2016-07-12 9:13 ` Christoph Hellwig
2016-07-10 11:57 ` [PATCH 5/5] pci: spread interrupt vectors in pci_alloc_irq_vectors Christoph Hellwig
2016-07-11 20:51 ` Alexander Gordeev [this message]
2016-07-12 9:17 ` Christoph Hellwig
2016-07-12 12:15 ` Alexander Gordeev
-- strict thread matches above, loose matches on Subject: below --
2016-07-12 9:20 pci: automatic interrupt affinity for MSI/MSI-X capable devices V2 Christoph Hellwig
2016-07-12 9:20 ` [PATCH 5/5] pci: spread interrupt vectors in pci_alloc_irq_vectors Christoph Hellwig
2016-07-12 12:57 ` Alexander Gordeev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160711205110.GA23915@dhcp-27-118.brq.redhat.com \
--to=agordeev@redhat.com \
--cc=hch@lst.de \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).