From owner-freebsd-current@FreeBSD.ORG Thu Jun 9 13:22:47 2011 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 968F3106566B for ; Thu, 9 Jun 2011 13:22:47 +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 567DE8FC13 for ; Thu, 9 Jun 2011 13:22:47 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id DF05546B03; Thu, 9 Jun 2011 09:22:46 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 155B48A027; Thu, 9 Jun 2011 09:22:46 -0400 (EDT) From: John Baldwin To: freebsd-current@freebsd.org Date: Thu, 9 Jun 2011 09:22:45 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <201106081356.39221.jhb@freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201106090922.45150.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Thu, 09 Jun 2011 09:22:46 -0400 (EDT) Cc: "deeptech71@gmail.com" Subject: Re: pcib allocation failure 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, 09 Jun 2011 13:22:47 -0000 On Wednesday, June 08, 2011 4:20:00 pm deeptech71@gmail.com wrote: > On Wed, Jun 8, 2011 at 7:56 PM, John Baldwin wrote: > > On Wednesday, June 08, 2011 11:20:17 am deeptech71@gmail.com wrote: > >> On Tue, Jun 7, 2011 at 4:35 PM, John Baldwin wrote: > >> found-> vendor=0x1002, dev=0x4170, revid=0x00 > >> domain=0, bus=1, slot=0, func=1 > >> class=03-80-00, hdrtype=0x00, mfdev=0 > >> cmdreg=0x0007, statreg=0x02b0, cachelnsz=4 (dwords) > >> lattimer=0x40 (1920 ns), mingnt=0x08 (2000 ns), maxlat=0x00 (0 ns) > >> powerspec 2 supports D0 D1 D2 D3 current D0 > >> map[10]: type Prefetchable Memory, range 32, base 0xe0000000, size 28, enabled > >> pcib1: attempting to grow prefetch window for (0xe0000000-0xefffffff,0x10000000) > >> pcib1: attempting to grow memory window for (0xe0000000-0xefffffff,0x10000000) > > > > Odd, I'm not sure why this failed. Hmm, it seems this was always failing for > > you though in the older dmesg's though. > > > > Hmmm, can you revert all your changes to pci_pci.c and try just this change: > > > > Index: pci_pci.c > > =================================================================== > > --- pci_pci.c (revision 222863) > > +++ pci_pci.c (working copy) > > @@ -953,7 +975,7 @@ pcib_grow_window(struct pcib_softc *sc, struct pci > > * ok, ensure it is properly aligned for this window. > > * Also check for overflow. > > */ > > - if (back <= end && start_free <= back) { > > + if (back <= end + 1 && start_free <= back) { > > if (bootverbose) > > printf("\tback candidate range: %#lx-%#lx\n", > > start_free, back); > > failure. Hmm, I would say 'progress' actually as it's getting better: > map[10]: type Prefetchable Memory, range 32, base 0xe0000000, size 28, enabled > pcib1: attempting to grow prefetch window for (0xe0000000-0xefffffff,0x10000000) > back candidate range: 0xe0000000-0xf0000000 It at least attempts to grow it now. This patch is a slightly more correct fix for the same bug as above but also adds extra debugging so I can see why bus_adjust_resource() is failing to grow the window. It won't fix it yet, but should output more debug info when it fails to grow the window: Index: pci_pci.c =================================================================== --- pci_pci.c (revision 222863) +++ pci_pci.c (working copy) @@ -916,7 +934,8 @@ pcib_grow_window(struct pcib_softc *sc, struct pci /* Move end_free down until it is properly aligned. */ end_free &= ~(align - 1); - front = end_free - count; + end_free--; + front = end_free - (count - 1); /* * The resource would now be allocated at (front, @@ -944,7 +963,7 @@ pcib_grow_window(struct pcib_softc *sc, struct pci /* Move start_free up until it is properly aligned. */ start_free = roundup2(start_free, align); - back = start_free + count; + back = start_free + count - 1; /* * The resource would now be allocated at (start_free, @@ -957,7 +976,7 @@ pcib_grow_window(struct pcib_softc *sc, struct pci if (bootverbose) printf("\tback candidate range: %#lx-%#lx\n", start_free, back); - back = roundup2(back, w->step) - 1; + back = roundup2(back + 1, w->step) - 1; back -= rman_get_end(w->res); } else back = 0; @@ -976,6 +995,11 @@ pcib_grow_window(struct pcib_softc *sc, struct pci rman_get_end(w->res)); if (error == 0) break; + if (bootverbose) + device_printf(sc->dev, + "failed to grow %s window to %#lx-%#lx: %d\n", + w->name, rman_get_start(w->res) - front, + rman_get_end(w->res), error); front = 0; } else { error = bus_adjust_resource(sc->dev, type, w->res, @@ -983,6 +1007,11 @@ pcib_grow_window(struct pcib_softc *sc, struct pci rman_get_end(w->res) + back); if (error == 0) break; + if (bootverbose) + device_printf(sc->dev, + "failed to grow %s window to %#lx-%#lx: %d\n", + w->name, rman_get_start(w->res), + rman_get_end(w->res) + back, error); back = 0; } } -- John Baldwin