Skip to contentSkip to conversation

ntb: clean up unnecessary MSI/MSI-X capability find

PATCH Applied Yijing Wang 2 participants 2 messages Aug 8, 2013 NTB driver core

lore
Share & tools
lore
#0 lore raw

PATCH 10/16 ntb: clean up unnecessary MSI/MSI-X capability find

PCI core will initialize device MSI/MSI-X capability in pci_msi_init_pci_dev(). So device driver should use pci_dev->msi_cap/msix_cap to determine whether the device support MSI/MSI-X instead of using pci_find_capability(pci_dev, PCI_CAP_ID_MSI/MSIX). Access to PCIe device config space again will consume more time.

---
 drivers/ntb/ntb_hw.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
drivers/ntb/ntb_hw.c +3 -4
index 2dacd19..090d1b2 100644
@@ -758,16 +758,15 @@ static int ntb_setup_msix(struct ntb_device *ndev)
 	struct pci_dev *pdev = ndev->pdev;
 	struct msix_entry *msix;
 	int msix_entries;
-	int rc, i, pos;
+	int rc, i;
 	u16 val;
 
-	pos = pci_find_capability(pdev, PCI_CAP_ID_MSIX);
-	if (!pos) {
+	if (!pdev->msix_cap) {
 		rc = -EIO;
 		goto err;
 	}
 
-	rc = pci_read_config_word(pdev, pos + PCI_MSIX_FLAGS, &val);
+	rc = pci_read_config_word(pdev, pdev->msix_cap + PCI_MSIX_FLAGS, &val);
 	if (rc)
 		goto err;
 
Signature · 1 line
1.7.1
Acked-by on v1 10/16
#1 lore raw
Quoted 9 lines · Yijing Wang

PCI core will initialize device MSI/MSI-X capability in pci_msi_init_pci_dev(). So device driver should use pci_dev->msi_cap/msix_cap to determine whether the device support MSI/MSI-X instead of using pci_find_capability(pci_dev, PCI_CAP_ID_MSI/MSIX). Access to PCIe device config space again will consume more time.

Quoted 33 lines
---
 drivers/ntb/ntb_hw.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
drivers/ntb/ntb_hw.c +3 -4
index 2dacd19..090d1b2 100644
@@ -758,16 +758,15 @@ static int ntb_setup_msix(struct ntb_device *ndev)
 	struct pci_dev *pdev = ndev->pdev;
 	struct msix_entry *msix;
 	int msix_entries;
-	int rc, i, pos;
+	int rc, i;
 	u16 val;
 
-	pos = pci_find_capability(pdev, PCI_CAP_ID_MSIX);
-	if (!pos) {
+	if (!pdev->msix_cap) {
 		rc = -EIO;
 		goto err;
 	}
 
-	rc = pci_read_config_word(pdev, pos + PCI_MSIX_FLAGS, &val);
+	rc = pci_read_config_word(pdev, pdev->msix_cap + PCI_MSIX_FLAGS, &val);
 	if (rc)
 		goto err;
 
Signature · 1 line
1.7.1