Date: Thu, 15 Jan 2009 16:42:35 -0500 From: John Baldwin <jhb@freebsd.org> To: Tor Egge <Tor.Egge@cvsup.no.freebsd.org> Cc: "yr.retarded@gmail.com" <yr.retarded@gmail.com>, "freebsd-current@freebsd.org" <freebsd-current@freebsd.org> Subject: Re: lockup booting 8.0-CURRENT-200811 snap image Message-ID: <200901151642.35495.jhb@freebsd.org> In-Reply-To: <8D488E8F-BDEB-4384-9D64-48812E8DFC7B@baldwin.cx> References: <200812041421.53099.jhb@freebsd.org> <20081214.035113.104070918.Tor.Egge@cvsup.no.freebsd.org> <8D488E8F-BDEB-4384-9D64-48812E8DFC7B@baldwin.cx>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday 16 December 2008 10:18:16 am John Baldwin wrote: > So the real fix is that we need to disable memory and I/O decoding int > the PCI command register when messing with the BARs. One thing to be > careful with is we can't do any console I/O (i.e. printfs) while the > BAR is disabled. I will come up with a proper patch when I get back to > a real computer. Please try this instead (compiled, but not run-tested): --- //depot/vendor/freebsd/src/sys/dev/pci/pci.c 2008/11/13 20:00:29 +++ //depot/user/jhb/acpipci/dev/pci/pci.c 2009/01/15 21:40:48 @@ -2291,9 +2291,27 @@ struct resource *res; map = PCIB_READ_CONFIG(pcib, b, s, f, reg, 4); + + /* + * Disable decoding via the command register before + * determining the BAR's length since we will be placing them + * in a weird state. + */ + cmd = PCIB_READ_CONFIG(pcib, b, s, f, PCIR_COMMAND, 2); + PCIB_WRITE_CONFIG(pcib, b, s, f, PCIR_COMMAND, + cmd & ~(PCI_BAR_MEM(map) ? PCIM_CMD_MEMEN : PCIM_CMD_PORTEN), 2); + + /* + * Determine the BAR's length by writing all 1's. The bottom + * log_2(size) bits of the BAR will stick as 0 when we read + * the value back. + */ PCIB_WRITE_CONFIG(pcib, b, s, f, reg, 0xffffffff, 4); testval = PCIB_READ_CONFIG(pcib, b, s, f, reg, 4); + + /* Restore the BAR and command register. */ PCIB_WRITE_CONFIG(pcib, b, s, f, reg, map, 4); + PCIB_WRITE_CONFIG(pcib, b, s, f, PCIR_COMMAND, cmd, 2); if (PCI_BAR_MEM(map)) type = SYS_RES_MEMORY; -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901151642.35495.jhb>