@@ -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;
@@ -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)
@@ -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);
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@linux.vnet.ibm.com> --- drivers/pci/msi.c | 9 +++++---- drivers/pci/pcie/portdrv_core.c | 2 +- include/linux/pci.h | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-)