diff mbox

[1/4] PCI: Cache MSI/MSIX structure in pci_msi_check_device()

Message ID 1364374564-19096-2-git-send-email-shangw@linux.vnet.ibm.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Gavin Shan March 27, 2013, 8:56 a.m. UTC
The patch introduces additional parameter to pci_msi_check_device()
to trace the address of MSI or MSI-X capability structure so that
we needn't retrieve that again while enabling MSI or MSI-X based
interrupts for specific PCI device.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
---
 drivers/pci/msi.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 00cc78c..05e9604 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -758,12 +758,14 @@  error:
  * @dev: pointer to the pci_dev data structure of MSI device function
  * @nvec: how many MSIs have been requested ?
  * @type: are we checking for MSI or MSI-X ?
+ * @pos: address of MSI or MSI-X capability structure
  *
  * Look at global flags, the device itself, and its parent busses
  * to determine if MSI/-X are supported for the device. If MSI/-X is
  * supported return 0, else return an error code.
  **/
-static int pci_msi_check_device(struct pci_dev *dev, int nvec, int type)
+static int pci_msi_check_device(struct pci_dev *dev,
+				int nvec, int type, int *pos)
 {
 	struct pci_bus *bus;
 	int ret;
@@ -795,7 +797,8 @@  static int pci_msi_check_device(struct pci_dev *dev, int nvec, int type)
 	if (ret)
 		return ret;
 
-	if (!pci_find_capability(dev, type))
+	*pos = pci_find_capability(dev, type);
+	if (!*pos)
 		return -EINVAL;
 
 	return 0;
@@ -816,7 +819,7 @@  static int pci_msi_check_device(struct pci_dev *dev, int nvec, int type)
  */
 int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec)
 {
-	int status, pos, maxvec;
+	int pos, status, maxvec;
 	u16 msgctl;
 
 	pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
@@ -827,7 +830,7 @@  int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec)
 	if (nvec > maxvec)
 		return maxvec;
 
-	status = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSI);
+	status = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSI, &pos);
 	if (status)
 		return status;
 
@@ -945,13 +948,13 @@  int pci_msix_table_size(struct pci_dev *dev)
  **/
 int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec)
 {
-	int status, nr_entries;
+	int pos, status, nr_entries;
 	int i, j;
 
 	if (!entries)
 		return -EINVAL;
 
-	status = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSIX);
+	status = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSIX, &pos);
 	if (status)
 		return status;