From owner-p4-projects@FreeBSD.ORG Mon Jun 24 01:55:08 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id EB0E4BA0; Mon, 24 Jun 2013 01:55:07 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id AC742B9E for ; Mon, 24 Jun 2013 01:55:07 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id 8E4431737 for ; Mon, 24 Jun 2013 01:55:07 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r5O1t7Po047913 for ; Mon, 24 Jun 2013 01:55:07 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r5O1t707047910 for perforce@freebsd.org; Mon, 24 Jun 2013 01:55:07 GMT (envelope-from jhb@freebsd.org) Date: Mon, 24 Jun 2013 01:55:07 GMT Message-Id: <201306240155.r5O1t707047910@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 230088 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Jun 2013 01:55:08 -0000 http://p4web.freebsd.org/@@230088?ac=10 Change 230088 by jhb@jhb_pippin on 2013/06/24 01:54:55 Compile. Affected files ... .. //depot/projects/pci/sys/dev/pci/pci_pci.c#31 edit Differences ... ==== //depot/projects/pci/sys/dev/pci/pci_pci.c#31 (text+ko) ==== @@ -224,12 +224,12 @@ /* * If the start address is an alias, the range is an alias. * Otherwise, compute the start of the next alias range and - * check if it is beyond the end of the candidate range. + * check if it is before the end of the candidate range. */ if ((start & 0x300) != 0) goto alias; - next_start = (start & ~0xfful) | 0x100; - if (next_start <= end) + next_alias = (start & ~0xfful) | 0x100; + if (next_alias <= end) goto alias; return (0); @@ -264,7 +264,7 @@ } } -typedef void (*nonisa_callback)(u_long start, u_long end, void *arg); +typedef void (nonisa_callback)(u_long start, u_long end, void *arg); static void pcib_walk_nonisa_ranges(u_long start, u_long end, nonisa_callback *cb, @@ -300,7 +300,7 @@ int *countp; countp = arg; - *countp++; + (*countp)++; } struct alloc_state { @@ -354,7 +354,7 @@ as.sc = sc; as.count = 0; as.error = 0; - pcib_walk_nonisa_ranges(start, end, alloc_ranges &as); + pcib_walk_nonisa_ranges(start, end, alloc_ranges, &as); if (as.error != 0) { for (i = 0; i < as.count; i++) bus_release_resource(sc->dev, SYS_RES_IOPORT, @@ -362,7 +362,7 @@ free(as.res, M_DEVBUF); return (as.error); } - KASSERT(as.count == newcount, ("%s: count mismatch", __func__)); + KASSERT(as.count == new_count, ("%s: count mismatch", __func__)); /* Third, add the ranges to the window. */ pcib_add_window_resources(&sc->io, as.res, as.count); @@ -876,7 +876,7 @@ } if (sc->flags & PCIB_SUBTRACTIVE) printf("%ssubtractive", comma ? ", " : ""); - device_printf("\n"); + printf("\n"); } } @@ -1030,8 +1030,8 @@ u_long start, u_long end, u_long count, u_int flags) { struct resource *res; - u_long base, limit; - int error, rid; + u_long base, limit, wmask; + int rid; /* * If this is an I/O window on a bridge with ISA enable set @@ -1044,7 +1044,7 @@ */ if (type == SYS_RES_IOPORT && sc->bridgectl & PCIB_BCR_ISA_ENABLE && start < 65536) { - for (base = 0xf000; base >= 0; base -= 0x1000) { + for (base = 0xf000; (long)base >= 0; base -= 0x1000) { limit = base + 0xfff; /* @@ -1074,8 +1074,10 @@ return (0); } } + return (ENOSPC); } + wmask = (1ul << w->step) - 1; if (RF_ALIGNMENT(flags) < w->step) { flags &= ~RF_ALIGNMENT_MASK; flags |= RF_ALIGNMENT_LOG2(w->step); @@ -1086,17 +1088,8 @@ rid = w->reg; res = bus_alloc_resource(sc->dev, type, &rid, start, end, count, flags & ~RF_ACTIVE); - if (res == NULL) { - if (bootverbose) - device_printf(sc->dev, - "failed to allocate initial %s window (%#lx-%#lx,%#lx)\n", - w->name, start, end, count); - return (ENXIO); - } - if (bootverbose) - device_printf(sc->dev, - "allocated initial %s window of %#lx-%#lx\n", - w->name, rman_get_start(res), rman_get_end(res)); + if (res == NULL) + return (ENOSPC); pcib_add_window_resources(w, &res, 1); pcib_activate_window(sc, type); w->base = rman_get_start(res); @@ -1131,7 +1124,7 @@ * existing resource. */ if (type == SYS_RES_IOPORT && sc->bridgectl & PCIB_BCR_ISA_ENABLE && - limit <= 65535 || (base <= 65535 && base != w->base)) { + (limit <= 65535 || (base <= 65535 && base != w->base))) { KASSERT(limit == w->limit || limit <= 65535, ("attempting to grow both ends across 64k ISA alias")); @@ -1188,7 +1181,7 @@ w->base = base; } else { error = rman_manage_region(&w->rman, w->limit + 1, limit); - w->limit = rman_get_end(w->res); + w->limit = limit; } if (error) { if (bootverbose) @@ -1208,7 +1201,7 @@ u_long start, u_long end, u_long count, u_int flags) { u_long align, start_free, end_free, front, back, wmask; - int error, rid; + int error; /* * Clamp the desired resource range to the maximum address @@ -1235,8 +1228,17 @@ if (w->res == NULL) { error = pcib_alloc_new_window(sc, w, type, start, end, count, flags); - if (error) + if (error) { + if (bootverbose) + device_printf(sc->dev, + "failed to allocate initial %s window (%#lx-%#lx,%#lx)\n", + w->name, start, end, count); return (error); + } + if (bootverbose) + device_printf(sc->dev, + "allocated initial %s window of %#lx-%#lx\n", + w->name, w->base, w->limit); goto updatewin; } @@ -1250,6 +1252,11 @@ * edge of the window, grow from the inner edge of the free * region. Otherwise grow from the window boundary. * + * Growing an I/O window below 64k for a bridge with the ISA + * enable bit doesn't require any special magic as the step + * size of an I/O window (1k) always includes multiple + * non-alias ranges when it is grown in either direction. + * * XXX: Special case: if w->res is completely empty and the * request size is larger than w->res, we should find the * optimal aligned buffer containing w->res and allocate that.