Skip to contentSkip to conversation

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

PATCH Applied Yijing Wang 2 participants 3 messages Aug 8, 2013 – Aug 26, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 5/16 megaraid: 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.

Cc Neela Syam Kolli <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
---
 drivers/scsi/megaraid/megaraid_sas_base.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)
drivers/scsi/megaraid/megaraid_sas_base.c +4 -5
index 0177295..ad8fc44 100644
@@ -4072,21 +4072,20 @@ fail_set_dma_mask:
 static int megasas_probe_one(struct pci_dev *pdev,
 			     const struct pci_device_id *id)
 {
-	int rval, pos, i, j;
+	int rval, i, j;
 	struct Scsi_Host *host;
 	struct megasas_instance *instance;
 	u16 control = 0;
 
 	/* Reset MSI-X in the kdump kernel */
 	if (reset_devices) {
-		pos = pci_find_capability(pdev, PCI_CAP_ID_MSIX);
-		if (pos) {
-			pci_read_config_word(pdev, pos + PCI_MSIX_FLAGS,
+		if (pdev->msix_cap) {
+			pci_read_config_word(pdev, pdev->msix_cap + PCI_MSIX_FLAGS,
 					     &control);
 			if (control & PCI_MSIX_FLAGS_ENABLE) {
 				dev_info(&pdev->dev, "resetting MSI-X\n");
 				pci_write_config_word(pdev,
-						      pos + PCI_MSIX_FLAGS,
+						      pdev->msix_cap + PCI_MSIX_FLAGS,
 						      control &
 						      ~PCI_MSIX_FLAGS_ENABLE);
 			}
Signature · 1 line
1.7.1
Acked-by on v1 5/16
#1 lore raw
Quoted 57 lines

-----Original Message-----
From: Yijing Wang [mailto:[email protected]]
Sent: Thursday, August 08, 2013 6:38 PM
To: James E.J. Bottomley
Cc: Hanjun Guo; [email protected]; Yijing Wang; DL-MegaRAID Linux; [email protected]
Subject: [PATCH 05/16] megaraid: 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-

Quoted 1 line

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.

Cc Neela Syam Kolli <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>

---
drivers/scsi/megaraid/megaraid_sas_base.c | 9 ++++-----

1 files changed, 4 insertions(+), 5 deletions(-)
drivers/scsi/megaraid/megaraid_sas_base.c +4 -5
index 0177295..ad8fc44 100644
@@ -4072,21 +4072,20 @@ fail_set_dma_mask:
 static int megasas_probe_one(struct pci_dev *pdev,
 			     const struct pci_device_id *id)  {
-	int rval, pos, i, j;
+	int rval, i, j;
 	struct Scsi_Host *host;
 	struct megasas_instance *instance;
 	u16 control = 0;
 
 	/* Reset MSI-X in the kdump kernel */
 	if (reset_devices) {
-		pos = pci_find_capability(pdev, PCI_CAP_ID_MSIX);
-		if (pos) {
-			pci_read_config_word(pdev, pos + PCI_MSIX_FLAGS,
+		if (pdev->msix_cap) {
+			pci_read_config_word(pdev, pdev->msix_cap +
 PCI_MSIX_FLAGS,
 					     &control);
 			if (control & PCI_MSIX_FLAGS_ENABLE) {
 				dev_info(&pdev->dev, "resetting MSI-X\n");
 				pci_write_config_word(pdev,
-						      pos + PCI_MSIX_FLAGS,
+						      pdev->msix_cap +
 PCI_MSIX_FLAGS,
 						      control &
 						      ~PCI_MSIX_FLAGS_ENABLE);
			}
Quoted 4 lines

--
1.7.1

Sumit

#2 lore raw
Quoted 9 lines
Quoted 8 lines

PCI_MSIX_FLAGS,

						      control &
						      ~PCI_MSIX_FLAGS_ENABLE);
			}

--
1.7.1

Hi James,
Can you merge this patch?

Thanks!
Yijing.

Quoted 2 lines
Signature · 2 lines
Thanks!
Yijing