From: Alex Williamson <alex.williamson@redhat.com>
To: bhelgaas@google.com
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
x86@kernel.org, tglx@linutronix.de, mingo@redhat.com,
hpa@zytor.com, joro@8bytes.org, iommu@lists.linux-foundation.org
Subject: [PATCH 3/3] PCI: Extend and export pci_msi_supported() for multivector MSI
Date: Fri, 21 Nov 2014 15:08:46 -0700 [thread overview]
Message-ID: <20141121220845.31095.19173.stgit@gimli.home> (raw)
In-Reply-To: <20141121213752.31095.30735.stgit@gimli.home>
Embrace and extend this existing function as an interface to test
for multivector MSI support. Drivers can now call this function
with nvec >1 and type PCI_CAP_ID_MSI to verify whether the platform
is capable of supporting multiple MSI vectors.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
drivers/pci/msi.c | 15 ++++++++++++---
include/linux/pci.h | 3 +++
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 36b503a..da3c709 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -793,12 +793,13 @@ out_free:
* pci_msi_supported - check whether MSI may be enabled on a device
* @dev: pointer to the pci_dev data structure of MSI device function
* @nvec: how many MSIs have been requested ?
+ * @type: PCI_CAP_ID_MSI or PCI_CAP_ID_MSIX
*
* Look at global flags, the device itself, and its parent buses
* to determine if MSI/-X are supported for the device. If MSI/-X is
* supported return 1, else return 0.
**/
-static int pci_msi_supported(struct pci_dev *dev, int nvec)
+int pci_msi_supported(struct pci_dev *dev, int nvec, int type)
{
struct pci_bus *bus;
@@ -809,6 +810,9 @@ static int pci_msi_supported(struct pci_dev *dev, int nvec)
if (!dev || dev->no_msi || dev->current_state != PCI_D0)
return 0;
+ if (type != PCI_CAP_ID_MSI && type != PCI_CAP_ID_MSIX)
+ return 0;
+
/*
* You can't ask to have 0 or less MSIs configured.
* a) it's stupid ..
@@ -828,8 +832,13 @@ static int pci_msi_supported(struct pci_dev *dev, int nvec)
if (bus->bus_flags & PCI_BUS_FLAGS_NO_MSI)
return 0;
+ if (type == PCI_CAP_ID_MSI && nvec > 1 &&
+ !arch_supports_multivector_msi(dev))
+ return 0;
+
return 1;
}
+EXPORT_SYMBOL(pci_msi_supported);
/**
* pci_msi_vec_count - Return the number of MSI vectors a device can send
@@ -930,7 +939,7 @@ int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec)
int nr_entries;
int i, j;
- if (!pci_msi_supported(dev, nvec))
+ if (!pci_msi_supported(dev, nvec, PCI_CAP_ID_MSIX))
return -EINVAL;
if (!entries)
@@ -1041,7 +1050,7 @@ int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec)
int nvec;
int rc;
- if (!pci_msi_supported(dev, minvec))
+ if (!pci_msi_supported(dev, minvec, PCI_CAP_ID_MSI))
return -EINVAL;
WARN_ON(!!dev->msi_enabled);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index c9a8904..f20605e 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1197,6 +1197,7 @@ struct msix_entry {
#ifdef CONFIG_PCI_MSI
+int pci_msi_supported(struct pci_dev *dev, int nvec, int type);
int pci_msi_vec_count(struct pci_dev *dev);
void pci_msi_shutdown(struct pci_dev *dev);
void pci_disable_msi(struct pci_dev *dev);
@@ -1225,6 +1226,8 @@ static inline int pci_enable_msix_exact(struct pci_dev *dev,
return 0;
}
#else
+static inline int pci_msi_supported(struct pci_dev *dev, int nvec, int type)
+{ return 0; }
static inline int pci_msi_vec_count(struct pci_dev *dev) { return -ENOSYS; }
static inline void pci_msi_shutdown(struct pci_dev *dev) { }
static inline void pci_disable_msi(struct pci_dev *dev) { }
next prev parent reply other threads:[~2014-11-21 22:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-21 22:08 [PATCH 0/3] PCI/x86: Interface for testing multivector MSI support Alex Williamson
2014-11-21 22:08 ` [PATCH 1/3] PCI/MSI: Initial hook for archs to declare " Alex Williamson
2014-11-23 20:20 ` Thomas Gleixner
2014-11-24 21:45 ` Alex Williamson
2014-11-25 3:22 ` Jiang Liu
2014-11-21 22:08 ` [PATCH 2/3] PCI/x86: Add arch_supports_multivector_msi() hook Alex Williamson
2014-11-21 22:08 ` Alex Williamson [this message]
2015-01-08 16:15 ` [PATCH 0/3] PCI/x86: Interface for testing multivector MSI support Bjorn Helgaas
2015-01-12 15:42 ` Alex Williamson
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=20141121220845.31095.19173.stgit@gimli.home \
--to=alex.williamson@redhat.com \
--cc=bhelgaas@google.com \
--cc=hpa@zytor.com \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@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).