From owner-p4-projects@FreeBSD.ORG Wed Apr 27 17:45:54 2011 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3B3811065670; Wed, 27 Apr 2011 17:45:54 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F224E106564A for ; Wed, 27 Apr 2011 17:45:53 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id C84DD8FC0A for ; Wed, 27 Apr 2011 17:45:53 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id p3RHjr8T029453 for ; Wed, 27 Apr 2011 17:45:53 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id p3RHjrfq029450 for perforce@freebsd.org; Wed, 27 Apr 2011 17:45:53 GMT (envelope-from jhb@freebsd.org) Date: Wed, 27 Apr 2011 17:45:53 GMT Message-Id: <201104271745.p3RHjrfq029450@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 192198 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Apr 2011 17:45:54 -0000 http://p4web.freebsd.org/@@192198?ac=10 Change 192198 by jhb@jhb_jhbbsd on 2011/04/27 17:45:29 - If we fail to allocate the initial window, disable the window. - Make sure we don't pass RF_ACTIVE up to the PCI bus when allocating the initial resource when growing a window. - Enable memory or I/O decoding when first activating a window. Affected files ... .. //depot/projects/pci/sys/dev/pci/pci_pci.c#15 edit Differences ... ==== //depot/projects/pci/sys/dev/pci/pci_pci.c#15 (text+ko) ==== @@ -60,6 +60,7 @@ static int pcib_resume(device_t dev); static int pcib_power_for_sleep(device_t pcib, device_t dev, int *pstate); +static void pcib_write_windows(struct pcib_softc *sc, int mask); static device_method_t pcib_methods[] = { /* Device interface */ @@ -146,7 +147,20 @@ return (pw->valid && pw->base < pw->limit); } +/* + * XXX: If RF_ACTIVE did not also imply allocating a bus space tag and + * handle for the resource, we could pass RF_ACTIVE up to the PCI bus + * when allocating the resource windows and rely on the PCI bus driver + * to do this for us. + */ static void +pcib_activate_window(struct pcib_softc *sc, int type) +{ + + PCI_ENABLE_IO(device_get_parent(sc->dev), sc->dev, type); +} + +static void pcib_alloc_window(struct pcib_softc *sc, struct pcib_window *w, int type, int flags, pci_addr_t max_address) { @@ -181,8 +195,12 @@ device_printf(sc->dev, "failed to allocate initial %s window: %#jx-%#jx\n", w->name, (uintmax_t)w->base, (uintmax_t)w->limit); + w->base = max_address; + w->limit = 0; + pcib_write_windows(sc, w->mask); return; } + pcib_activate_window(sc, type); error = rman_manage_region(&w->rman, rman_get_start(w->res), rman_get_end(w->res)); @@ -859,7 +877,7 @@ count = roundup2(count, 1ul << w->step); rid = w->reg; w->res = bus_alloc_resource(sc->dev, type, &rid, start, end, - count, flags); + count, flags & ~RF_ACTIVE); if (w->res == NULL) { if (bootverbose) device_printf(sc->dev, @@ -883,6 +901,7 @@ w->res = NULL; return (error); } + pcib_activate_window(sc, type); goto updatewin; }