Skip to contentSkip to conversation

PCI: make pci_set_mwi a dummy for PCIe devices

PATCH In review Heiner Kallweit 2 participants 2 messages Oct 21, 2018 – Jan 30, 2019 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: make pci_set_mwi a dummy for PCIe devices

Memory-Write-Invalidate isn't applicable for PCIe devices, therefore make the MWI functions a dummy and don't even write to the (dummy) PCI config space registers.

---
 drivers/pci/pci.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/pci/pci.c +6 -0
index d068f11d0..fb63b3d89 100644
@@ -4137,6 +4137,9 @@ int pci_set_mwi(struct pci_dev *dev)
 	int rc;
 	u16 cmd;
 
+	if (pci_is_pcie(dev))
+		return 0;
+
 	rc = pci_set_cacheline_size(dev);
 	if (rc)
 		return rc;
@@ -4203,6 +4206,9 @@ void pci_clear_mwi(struct pci_dev *dev)
 #ifndef PCI_DISABLE_MWI
 	u16 cmd;
 
+	if (pci_is_pcie(dev))
+		return;
+
 	pci_read_config_word(dev, PCI_COMMAND, &cmd);
 	if (cmd & PCI_COMMAND_INVALIDATE) {
 		cmd &= ~PCI_COMMAND_INVALIDATE;
Signature · 1 line
2.19.1
#1 lore raw
Quoted 14 lines · Heiner Kallweit

Memory-Write-Invalidate isn't applicable for PCIe devices, therefore make the MWI functions a dummy and don't even write to the (dummy) PCI config space registers.

---
 drivers/pci/pci.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/pci/pci.c +0 -0
index d068f11d0..fb63b3d89 100644

drivers/pci/pci.c int pci_set_mwi(struct pci_dev *dev) · line 4141

Quoted 5 lines
drivers/pci/pci.c +2 -0
@@ -4137,6 +4137,9 @@ int pci_set_mwi(struct pci_dev *dev)
 	int rc;
 	u16 cmd;
 
+	if (pci_is_pcie(dev))
+		return 0;

I don't think this works quite right for the case of a PCIe-to-PCI/PCI-X bridge. That is a PCIe device (it has a PCIe Capability, and pci_is_pcie() should return true), but the MWI bit is writable and meaningful (it controls whether the bridge can convert a PCIe Memory Write into a PCI Memory Write and Invalidate), so I don't think it would be correct to just skip this.

I'm looking at the "PCI EXPRESS TO PCI/PCI-X BRIDGE" spec, r1.0, sec 5.1.1.1.

Quoted 16 lines
drivers/pci/pci.c +3 -0
 	rc = pci_set_cacheline_size(dev);
 	if (rc)
 		return rc;
@@ -4203,6 +4206,9 @@ void pci_clear_mwi(struct pci_dev *dev)
 #ifndef PCI_DISABLE_MWI
 	u16 cmd;
 
+	if (pci_is_pcie(dev))
+		return;
+
 	pci_read_config_word(dev, PCI_COMMAND, &cmd);
 	if (cmd & PCI_COMMAND_INVALIDATE) {
 		cmd &= ~PCI_COMMAND_INVALIDATE;
Signature · 1 line
2.19.1