From owner-freebsd-current@FreeBSD.ORG Thu Jan 15 22:47:16 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C99DC1065721 for ; Thu, 15 Jan 2009 22:47:15 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id CA0878FC34 for ; Thu, 15 Jan 2009 22:47:14 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (pool-98-109-39-197.nwrknj.fios.verizon.net [98.109.39.197]) by cyrus.watson.org (Postfix) with ESMTPSA id 4DA7D46B09; Thu, 15 Jan 2009 17:47:13 -0500 (EST) Received: from localhost (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id n0FMkttH004922; Thu, 15 Jan 2009 17:47:07 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: Tor Egge Date: Thu, 15 Jan 2009 16:42:35 -0500 User-Agent: KMail/1.9.7 References: <200812041421.53099.jhb@freebsd.org> <20081214.035113.104070918.Tor.Egge@cvsup.no.freebsd.org> <8D488E8F-BDEB-4384-9D64-48812E8DFC7B@baldwin.cx> In-Reply-To: <8D488E8F-BDEB-4384-9D64-48812E8DFC7B@baldwin.cx> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200901151642.35495.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Thu, 15 Jan 2009 17:47:07 -0500 (EST) X-Virus-Scanned: ClamAV 0.94.2/8870/Thu Jan 15 15:57:00 2009 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: "yr.retarded@gmail.com" , "freebsd-current@freebsd.org" Subject: Re: lockup booting 8.0-CURRENT-200811 snap image X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jan 2009 22:47:19 -0000 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