Skip to contentSkip to conversation

PCI PM: clear IO and MEM when disabling a device

PATCH In review Adam Belay 3 participants 4 messages Jun 5, 2006 – Jun 7, 2006 PCI

lore
Share & tools
lore

Adam Belay

author
#0 lore raw

PATCH 8/9 PCI PM: clear IO and MEM when disabling a device

This patch modifies pci_disable_device() to clear IO and MEM from the COMMAND PCI config register. This is required before entering D3, but also probably a good general practice for system suspend.

---
 pci.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/pci/pci.c +6 -2
diff -urN a/drivers/pci/pci.c b/drivers/pci/pci.c
@@ -312,8 +312,12 @@
 	u16 pci_command;
 	
 	pci_read_config_word(dev, PCI_COMMAND, &pci_command);
-	if (pci_command & PCI_COMMAND_MASTER) {
-		pci_command &= ~PCI_COMMAND_MASTER;
+	if (pci_command & (PCI_COMMAND_MASTER |
+			   PCI_COMMAND_IO |
+			   PCI_COMMAND_MEMORY)) {
+		pci_command &= ~ (PCI_COMMAND_MASTER |
+				  PCI_COMMAND_IO |
+				  PCI_COMMAND_MEMORY);
 		pci_write_config_word(dev, PCI_COMMAND, pci_command);
 	}
 	dev->is_busmaster = 0;
#1 lore raw
Quoted 4 lines · Adam Belay

This patch modifies pci_disable_device() to clear IO and MEM from the COMMAND PCI config register. This is required before entering D3, but also probably a good general practice for system suspend.

I'd submitted a patch to do this about a month ago, see
http://marc.theaimsgroup.com/?l=linux-pci&m=114669552428309&w=2

That patch does the same thing, but in arch specific code (since that's where memory and IO decode get enabled today). This patch will cover the other arch's too, so I'm fine with this if this is the right thing to do. My original patch is already in Greg's tree and needs to be removed if this patch is accepted.

thanks,
Rajesh

#2 lore raw
In reply to Adam Belay
Quoted 3 lines · Adam Belay

This patch modifies pci_disable_device() to clear IO and MEM from the COMMAND PCI config register. This is required before entering D3, but also probably a good general practice for system suspend.

And will break a great deal of platforms. Don't do it :) The problem is, I think, mostly related to firmware issues.

Ben.

author
#3 lore raw
Quoted 9 lines · Benjamin Herrenschmidt
Quoted 3 lines · Adam Belay

This patch modifies pci_disable_device() to clear IO and MEM from the COMMAND PCI config register. This is required before entering D3, but also probably a good general practice for system suspend.

And will break a great deal of platforms. Don't do it :) The problem is, I think, mostly related to firmware issues.

Ben.

If the device must be enabled before passing control to firmware, then shouldn't its controlling driver never call pci_disable_device()? I'd like to have pci_disable_device() actually disable devices, as this is needed for D3.

Thanks,
Adam