[PATCH] Fix boot-time hang on G31/G33 PC

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-pci@...>, <linux-kernel@...>
Cc: Robert Hancock <hancockr@...>, Jesse Barnes <jesse.barnes@...>, Greg KH <greg@...>
Date: Saturday, August 25, 2007 - 9:55 pm

This patch, loosely based on a patch from Robert Hancock, which was in
turn based on a patch from Jesse Barnes, fixes a boot-time hang on my
shiny new PC.  The 'conflict' mentioned in the patch in my case happens
to be between mmconfig and the graphics card, but it could easily be
between any pair of devices if they are left enabled by the BIOS and
mappen in the wrong place.

Signed-off-by: Matthew Wilcox <matthew@wil.cx>

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 34b8dae..51ef450 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -180,11 +180,26 @@ static inline int is_64bit_memory(u32 mask)
 	return 0;
 }
 
+/*
+ * Sizing PCI BARs requires us to disable decoding, otherwise we may run
+ * into conflicts with other devices while trying to size the BAR.  Normally
+ * this isn't a problem, but it happens on some machines normally, and can
+ * happen on others during PCI device hotplug.  Don't disable BARs for host
+ * bridges, though.  Some of them do silly things like disable accesses to
+ * RAM from the CPU
+ */
 static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
 {
 	unsigned int pos, reg, next;
 	u32 l, sz;
 	struct resource *res;
+	u16 orig_cmd;
+
+	if ((dev->class >> 8) != PCI_CLASS_BRIDGE_HOST) {
+		pci_read_config_word(dev, PCI_COMMAND, &orig_cmd);
+		pci_write_config_word(dev, PCI_COMMAND,
+			orig_cmd & ~(PCI_COMMAND_MEMORY | PCI_COMMAND_IO));
+	}
 
 	for(pos=0; pos<howmany; pos = next) {
 		u64 l64;
@@ -283,6 +298,9 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
 			}
 		}
 	}
+
+	if ((dev->class >> 8) != PCI_CLASS_BRIDGE_HOST)
+		pci_write_config_word(dev, PCI_COMMAND, orig_cmd);
 }
 
 void __devinit pci_read_bridge_bases(struct pci_bus *child)

-- 
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Fix boot-time hang on G31/G33 PC, Matthew Wilcox, (Sat Aug 25, 9:55 pm)
Re: PCI: Fix boot-time hang on G31/G33 PC, Greg KH, (Wed Sep 26, 5:18 pm)
Re: PCI: Fix boot-time hang on G31/G33 PC, Jesse Barnes, (Wed Sep 26, 5:55 pm)
Re: PCI: Fix boot-time hang on G31/G33 PC, Greg KH, (Wed Sep 26, 5:56 pm)
Re: PCI: Fix boot-time hang on G31/G33 PC, Jesse Barnes, (Wed Sep 26, 6:20 pm)
Re: PCI: Fix boot-time hang on G31/G33 PC, Ivan Kokshaysky, (Thu Sep 27, 10:31 am)
Re: PCI: Fix boot-time hang on G31/G33 PC, Kok, Auke, (Thu Sep 27, 2:36 pm)
Re: PCI: Fix boot-time hang on G31/G33 PC, Greg KH, (Thu Sep 27, 7:13 pm)
Re: PCI: Fix boot-time hang on G31/G33 PC, Vitaliy Gusev, (Fri Oct 12, 10:26 am)
Re: PCI: Fix boot-time hang on G31/G33 PC, Kok, Auke, (Fri Oct 12, 1:07 pm)
Re: PCI: Fix boot-time hang on G31/G33 PC, Robert Hancock, (Wed Sep 26, 7:04 pm)
Re: [PATCH] Fix boot-time hang on G31/G33 PC, Grant Grundler, (Tue Aug 28, 1:59 pm)
Re: [PATCH] Fix boot-time hang on G31/G33 PC, Grant Grundler, (Tue Aug 28, 2:28 pm)
Re: [PATCH] Fix boot-time hang on G31/G33 PC, Robert Hancock, (Sun Aug 26, 12:24 am)
Re: [PATCH] Fix boot-time hang on G31/G33 PC, Matthew Wilcox, (Sun Aug 26, 8:55 am)
Re: [PATCH] Fix boot-time hang on G31/G33 PC, Matthew Wilcox, (Sun Aug 26, 10:07 am)
Re: [PATCH] Fix boot-time hang on G31/G33 PC, Robert Hancock, (Sun Aug 26, 1:59 pm)
Re: [PATCH] Fix boot-time hang on G31/G33 PC, Jesse Barnes, (Tue Aug 28, 1:22 pm)