svn commit: r262226 - stable/8/sys/dev/pci

John Baldwin jhb at FreeBSD.org
Wed Feb 19 18:35:23 UTC 2014


Author: jhb
Date: Wed Feb 19 18:35:22 2014
New Revision: 262226
URL: http://svnweb.freebsd.org/changeset/base/262226

Log:
  MFC 261524:
  Properly set the alignment flags when allocating the initial range for a
  BAR.  This only really matters when pci_do_realloc_bars is enabled and
  the initial allocation of a specific range fails.

Modified:
  stable/8/sys/dev/pci/pci.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/dev/   (props changed)
  stable/8/sys/dev/pci/   (props changed)

Modified: stable/8/sys/dev/pci/pci.c
==============================================================================
--- stable/8/sys/dev/pci/pci.c	Wed Feb 19 18:34:47 2014	(r262225)
+++ stable/8/sys/dev/pci/pci.c	Wed Feb 19 18:35:22 2014	(r262226)
@@ -2637,7 +2637,7 @@ pci_add_map(device_t bus, device_t dev, 
 	struct pci_map *pm;
 	pci_addr_t base, map, testval;
 	pci_addr_t start, end, count;
-	int barlen, basezero, maprange, mapsize, type;
+	int barlen, basezero, flags, maprange, mapsize, type;
 	uint16_t cmd;
 	struct resource *res;
 
@@ -2743,6 +2743,9 @@ pci_add_map(device_t bus, device_t dev, 
 	}
 
 	count = (pci_addr_t)1 << mapsize;
+	flags = RF_ALIGNMENT_LOG2(mapsize);
+	if (prefetch)
+		flags |= RF_PREFETCHABLE;
 	if (basezero || base == pci_mapbase(testval)) {
 		start = 0;	/* Let the parent decide. */
 		end = ~0ul;
@@ -2759,7 +2762,7 @@ pci_add_map(device_t bus, device_t dev, 
 	 * pci_alloc_resource().
 	 */
 	res = resource_list_alloc(rl, bus, dev, type, &reg, start, end, count,
-	    prefetch ? RF_PREFETCHABLE : 0);
+	    flags);
 	if (pci_do_realloc_bars && res == NULL && (start != 0 || end != ~0ul)) {
 		/*
 		 * If the allocation fails, try to allocate a resource for
@@ -2770,7 +2773,7 @@ pci_add_map(device_t bus, device_t dev, 
 		resource_list_delete(rl, type, reg);
 		resource_list_add(rl, type, reg, 0, ~0ul, count);
 		res = resource_list_alloc(rl, bus, dev, type, &reg, 0, ~0ul,
-		    count, prefetch ? RF_PREFETCHABLE : 0);
+		    count, flags);
 	}
 	if (res == NULL) {
 		/*


More information about the svn-src-stable-8 mailing list