pcib allocation failure

John Baldwin jhb at freebsd.org
Thu May 19 21:35:55 UTC 2011


On Thursday, May 19, 2011 12:28:46 pm deeptech71 at gmail.com wrote:
> On Thu, May 19, 2011 at 2:13 PM, John Baldwin <jhb at freebsd.org> wrote:
> > Yeah, your BIOS continues to behave very poorly.  Please try this hack to 
see
> > if it allows your video to still work with any AGP aperture size:
> >
> > Index: pci_pci.c
> > ===================================================================
> > --- pci_pci.c   (revision 222093)
> > +++ pci_pci.c   (working copy)
> > @@ -231,7 +231,9 @@ pcib_alloc_window(struct pcib_softc *sc, struct pc
> >                    w->name, (uintmax_t)w->base, (uintmax_t)w->limit);
> >                w->base = max_address;
> >                w->limit = 0;
> > +#if 0
> >                pcib_write_windows(sc, w->mask);
> > +#endif
> >                return;
> >        }
> >        pcib_activate_window(sc, type);
> 
> does not.

Hummm, that should leave the PCI-PCI bridge unchanged until we write the new 
values in place so it's never "turned off" (only updated to use a smaller 
range at some point).  You could try patching write_windows to disable IO and 
memory decoding in the PCI command register while the windows are frobbed.

Index: pci_pci.c
===================================================================
--- pci_pci.c	(revision 222093)
+++ pci_pci.c	(working copy)
@@ -162,8 +162,13 @@ pcib_write_windows(struct pcib_softc *sc, int mask
 {
 	device_t dev;
 	uint32_t val;
+	uint16_t cmd;
 
 	dev = sc->dev;
+	cmd = pci_read_config(dev, PCIR_COMMAND, 2);
+	if (cmd & (PCIM_CMD_PORTEN | PCIM_CMD_MEMEN))
+		pci_write_config(dev, PCIR_COMMAND,
+		    cmd & ~(PCIM_CMD_PORTEN | PCIM_CMD_MEMEN), 2);
 	if (sc->io.valid && mask & WIN_IO) {
 		val = pci_read_config(dev, PCIR_IOBASEL_1, 1);
 		if ((val & PCIM_BRIO_MASK) == PCIM_BRIO_32) {
@@ -192,6 +197,8 @@ pcib_write_windows(struct pcib_softc *sc, int mask
 		pci_write_config(dev, PCIR_PMBASEL_1, sc->pmem.base >> 16, 2);
 		pci_write_config(dev, PCIR_PMLIMITL_1, sc->pmem.limit >> 16, 2);
 	}
+	if (cmd & (PCIM_CMD_PORTEN | PCIM_CMD_MEMEN))
+		pci_write_config(dev, PCIR_COMMAND, cmd, 2);
 }
 
 static void
@@ -231,7 +238,9 @@ pcib_alloc_window(struct pcib_softc *sc, struct pc
 		    w->name, (uintmax_t)w->base, (uintmax_t)w->limit);
 		w->base = max_address;
 		w->limit = 0;
+#if 0
 		pcib_write_windows(sc, w->mask);
+#endif
 		return;
 	}
 	pcib_activate_window(sc, type);

-- 
John Baldwin


More information about the freebsd-current mailing list