[PATCH 2/4] PCI: Allow pci_msix_table_size() take MSIX cap struct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch introduces additional parameter to pci_msix_table_size()
to allow it take the address of MSI-X capability structure. If that's
zero, we need figure out the address from PCI config space.

Signed-off-by: Gavin Shan <shangw@xxxxxxxxxxxxxxxxxx>
---
 drivers/pci/msi.c               |    9 +++++----
 drivers/pci/pcie/portdrv_core.c |    2 +-
 include/linux/pci.h             |    4 ++--
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 05e9604..7ba9461 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -917,13 +917,14 @@ EXPORT_SYMBOL(pci_disable_msi);
 /**
  * pci_msix_table_size - return the number of device's MSI-X table entries
  * @dev: pointer to the pci_dev data structure of MSI-X device function
+ * @pos: address of MSI-X capability structure
  */
-int pci_msix_table_size(struct pci_dev *dev)
+int pci_msix_table_size(struct pci_dev *dev, int pos)
 {
-	int pos;
 	u16 control;
 
-	pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
+	if (!pos)
+		pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
 	if (!pos)
 		return 0;
 
@@ -958,7 +959,7 @@ int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec)
 	if (status)
 		return status;
 
-	nr_entries = pci_msix_table_size(dev);
+	nr_entries = pci_msix_table_size(dev, pos);
 	if (nvec > nr_entries)
 		return nr_entries;
 
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index 31063ac..d9600f3 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -79,7 +79,7 @@ static int pcie_port_enable_msix(struct pci_dev *dev, int *vectors, int mask)
 	u16 reg16;
 	u32 reg32;
 
-	nr_entries = pci_msix_table_size(dev);
+	nr_entries = pci_msix_table_size(dev, 0);
 	if (!nr_entries)
 		return -EINVAL;
 	if (nr_entries > PCIE_PORT_MAX_MSIX_ENTRIES)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 2461033a..1b7e7dc 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1116,7 +1116,7 @@ static inline void pci_msi_shutdown(struct pci_dev *dev)
 static inline void pci_disable_msi(struct pci_dev *dev)
 { }
 
-static inline int pci_msix_table_size(struct pci_dev *dev)
+static inline int pci_msix_table_size(struct pci_dev *dev, int pos)
 {
 	return 0;
 }
@@ -1145,7 +1145,7 @@ extern int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec);
 extern int pci_enable_msi_block_auto(struct pci_dev *dev, unsigned int *maxvec);
 extern void pci_msi_shutdown(struct pci_dev *dev);
 extern void pci_disable_msi(struct pci_dev *dev);
-extern int pci_msix_table_size(struct pci_dev *dev);
+extern int pci_msix_table_size(struct pci_dev *dev, int pos);
 extern int pci_enable_msix(struct pci_dev *dev,
 	struct msix_entry *entries, int nvec);
 extern void pci_msix_shutdown(struct pci_dev *dev);
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux