Skip to contentSkip to conversation

mtip32xx: minor PCI cleanups

PATCH Applied Bjorn Helgaas 3 participants 7 messages Jan 26, 2021 – Jan 27, 2021 Block layer

lore
Share & tools
lore
#0 lore raw

cover mtip32xx: minor PCI cleanups

From: Bjorn Helgaas <[email protected]>

Use PCI #defines and the special accessors for the PCIe capability.

Bjorn Helgaas (2):
mtip32xx: use PCI #defines instead of numbers
mtip32xx: prefer pcie_capability_read_word()

 drivers/block/mtip32xx/mtip32xx.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 mtip32xx: use PCI #defines instead of numbers

From: Bjorn Helgaas <[email protected]>

Use PCI #defines for PCIe Device Control register values instead of hard-coding bit positions. No functional change intended.

---
 drivers/block/mtip32xx/mtip32xx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/mtip32xx/mtip32xx.c +2 -2
index 53ac59d19ae5..543eb30a3bc0 100644
@@ -3932,8 +3932,8 @@ static void mtip_disable_link_opts(struct driver_data *dd, struct pci_dev *pdev)
 		pci_read_config_word(pdev,
 			pos + PCI_EXP_DEVCTL,
 			&pcie_dev_ctrl);
-		if (pcie_dev_ctrl & (1 << 11) ||
-		    pcie_dev_ctrl & (1 << 4)) {
+		if (pcie_dev_ctrl & PCI_EXP_DEVCTL_NOSNOOP_EN ||
+		    pcie_dev_ctrl & PCI_EXP_DEVCTL_RELAX_EN) {
 			dev_info(&dd->pdev->dev,
 				"Disabling ERO/No-Snoop on bridge device %04x:%04x\n",
 					pdev->vendor, pdev->device);
Signature · 1 line
2.25.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] mtip32xx: use PCI #defines instead of numbers

Quoted 6 lines · Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

Use PCI #defines for PCIe Device Control register values instead of hard-coding bit positions. No functional change intended.

I've verified the values present in the include/uapi/linux/pci_regs.h matches open coded bit shift values. LGTM.

#3 lore raw

Re: [PATCH 1/2] mtip32xx: use PCI #defines instead of numbers

Quoted 10 lines · Chaitanya Kulkarni
Quoted 5 lines · Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

Use PCI #defines for PCIe Device Control register values instead of hard-coding bit positions. No functional change intended.

Quoted 7 lines
Quoted 1 line

I've verified the values present in the include/uapi/linux/pci_regs.h matches open coded bit shift values. LGTM.

Something is seriously wrong. I sent out this in the morning and it got delivered right now.

Quoted 1 line
#4 lore raw

Re: [PATCH 1/2] mtip32xx: use PCI #defines instead of numbers

Quoted 9 lines · Chaitanya Kulkarni
Quoted 9 lines · Chaitanya Kulkarni
Quoted 6 lines · Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

Use PCI #defines for PCIe Device Control register values instead of hard-coding bit positions. No functional change intended.

Quoted 7 lines
Quoted 5 lines

I've verified the values present in the include/uapi/linux/pci_regs.h matches open coded bit shift values. LGTM.

Something is seriously wrong. I sent out this in the morning and it got delivered right now.

I noticed that, too. Seems like the mailing list is really backed up. Thanks a lot for taking a look at this!

Bjorn

maintainer Applied
#5 lore raw
In reply to Bjorn Helgaas
Quoted 10 lines · Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

Use PCI #defines and the special accessors for the PCIe capability.

Bjorn Helgaas (2):
mtip32xx: use PCI #defines instead of numbers
mtip32xx: prefer pcie_capability_read_word()

 drivers/block/mtip32xx/mtip32xx.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

Applied, thanks.

Signature · 1 line
Jens Axboe
#6 lore raw

PATCH 2/2 mtip32xx: prefer pcie_capability_read_word()

In reply to Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

Replace pci_read_config_word() with pcie_capability_read_word().

pcie_capability_read_word() takes care of a few special cases when reading the PCIe capability. See 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability").

---
 drivers/block/mtip32xx/mtip32xx.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/block/mtip32xx/mtip32xx.c +3 -8
index 543eb30a3bc0..a0f9bf152ddc 100644
@@ -3924,14 +3924,10 @@ static DEFINE_HANDLER(7);
 
 static void mtip_disable_link_opts(struct driver_data *dd, struct pci_dev *pdev)
 {
-	int pos;
 	unsigned short pcie_dev_ctrl;
 
-	pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
-	if (pos) {
-		pci_read_config_word(pdev,
-			pos + PCI_EXP_DEVCTL,
-			&pcie_dev_ctrl);
+	if (pci_is_pcie(pdev)) {
+		pcie_capability_read_word(pdev, PCI_EXP_DEVCTL, &pcie_dev_ctrl);
 		if (pcie_dev_ctrl & PCI_EXP_DEVCTL_NOSNOOP_EN ||
 		    pcie_dev_ctrl & PCI_EXP_DEVCTL_RELAX_EN) {
 			dev_info(&dd->pdev->dev,
@@ -3939,8 +3935,7 @@ static void mtip_disable_link_opts(struct driver_data *dd, struct pci_dev *pdev)
 					pdev->vendor, pdev->device);
 			pcie_dev_ctrl &= ~(PCI_EXP_DEVCTL_NOSNOOP_EN |
 						PCI_EXP_DEVCTL_RELAX_EN);
-			pci_write_config_word(pdev,
-				pos + PCI_EXP_DEVCTL,
+			pcie_capability_write_word(pdev, PCI_EXP_DEVCTL,
 				pcie_dev_ctrl);
 		}
 	}
Signature · 1 line
2.25.1