Skip to contentSkip to conversation

PCI: Don't try to disable Bus Master on disconnected PCI devices

PATCH Applied Konstantin Khlebnikov 2 participants 3 messages Mar 14, 2013 – Apr 3, 2013

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

PATCH 1/1 PCI: Don't try to disable Bus Master on disconnected PCI devices

This is fix for commit 7897e6022761ace7377f0f784fca059da55f5d71 from v3.9-rc1 ("PCI: Disable Bus Master unconditionally in pci_device_shutdown()") in turn that was fix for b566a22c23327f18ce941ffad0ca907e50a53d41 from v3.5-rc1 ("PCI: disable Bus Master on PCI device shutdown")

Unfortunately fixing one bug uncovers another:
->shutdown() callback might switch device to deep sleep state. PCI config space no longer available after that.

---
 drivers/pci/pci-driver.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pci/pci-driver.c +3 -2
index 1fa1e48..79277fb 100644
@@ -390,9 +390,10 @@ static void pci_device_shutdown(struct device *dev)
 
 	/*
 	 * Turn off Bus Master bit on the device to tell it to not
-	 * continue to do DMA
+	 * continue to do DMA. Don't touch devices in D3cold or unknown states.
 	 */
-	pci_clear_master(pci_dev);
+	if (pci_dev->current_state <= PCI_D3hot)
+		pci_clear_master(pci_dev);
 }
 
 #ifdef CONFIG_PM
#1 lore raw

BUMP. This is degradation from 3.8, so this patch must be in 3.9.

I still don't like this forced clearing bus-master bit. But this hack definitely fixes problems in kexec, so there is reason to keep it here.

Quoted 36 lines · Konstantin Khlebnikov

This is fix for commit 7897e6022761ace7377f0f784fca059da55f5d71 from v3.9-rc1 ("PCI: Disable Bus Master unconditionally in pci_device_shutdown()") in turn that was fix for b566a22c23327f18ce941ffad0ca907e50a53d41 from v3.5-rc1 ("PCI: disable Bus Master on PCI device shutdown")

Unfortunately fixing one bug uncovers another:
->shutdown() callback might switch device to deep sleep state. PCI config space no longer available after that.

---
  drivers/pci/pci-driver.c |    5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pci/pci-driver.c +3 -2
index 1fa1e48..79277fb 100644
@@ -390,9 +390,10 @@ static void pci_device_shutdown(struct device *dev)
 
  	/*
  	 * Turn off Bus Master bit on the device to tell it to not
-	 * continue to do DMA
+	 * continue to do DMA. Don't touch devices in D3cold or unknown states.
  	 */
-	pci_clear_master(pci_dev);
+	if (pci_dev->current_state <= PCI_D3hot)
+		pci_clear_master(pci_dev);
  }
 
  #ifdef CONFIG_PM
maintainer Applied
#2 lore raw

[+cc linux-pci]

Quoted 4 lines · Konstantin Khlebnikov

BUMP. This is degradation from 3.8, so this patch must be in 3.9.

I still don't like this forced clearing bus-master bit. But this hack definitely fixes problems in kexec, so there is reason to keep it here.

Applied to for-linus for v3.9, thanks!

Quoted 42 lines
Quoted 40 lines · Konstantin Khlebnikov

This is fix for commit 7897e6022761ace7377f0f784fca059da55f5d71 from v3.9-rc1
("PCI: Disable Bus Master unconditionally in pci_device_shutdown()") in turn that was fix for b566a22c23327f18ce941ffad0ca907e50a53d41 from v3.5-rc1
("PCI: disable Bus Master on PCI device shutdown")

Unfortunately fixing one bug uncovers another:
->shutdown() callback might switch device to deep sleep state. PCI config space no longer available after that.

---
  drivers/pci/pci-driver.c |    5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pci/pci-driver.c +1 -1
index 1fa1e48..79277fb 100644
@@ -390,9 +390,10 @@ static void pci_device_shutdown(struct device *dev)
 
        /*
         * Turn off Bus Master bit on the device to tell it to not
-        * continue to do DMA
+        * continue to do DMA. Don't touch devices in D3cold or unknown

states.

         */
drivers/pci/pci-driver.c +2 -1
-       pci_clear_master(pci_dev);
+       if (pci_dev->current_state <= PCI_D3hot)
+               pci_clear_master(pci_dev);
  }
 
  #ifdef CONFIG_PM