Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Jun 2013 01:55:07 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 230088 for review
Message-ID:  <201306240155.r5O1t707047910@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201306240155.r5O1t707047910>