Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Oct 2010 17:46:23 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r214146 - head/sys/dev/pci
Message-ID:  <201010211746.o9LHkN95098452@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Thu Oct 21 17:46:23 2010
New Revision: 214146
URL: http://svn.freebsd.org/changeset/base/214146

Log:
  Clarify a misleading comment.  The test in pci_reserve_map() was meant to
  ignore BARs that are invalid due to having a size of zero, not to ignore
  BARs with an existing base of zero.  While here, reorganize the code
  slightly to make the intent clearer.
  
  Reported by:	avg
  MFC after:	1 week

Modified:
  head/sys/dev/pci/pci.c

Modified: head/sys/dev/pci/pci.c
==============================================================================
--- head/sys/dev/pci/pci.c	Thu Oct 21 17:35:08 2010	(r214145)
+++ head/sys/dev/pci/pci.c	Thu Oct 21 17:46:23 2010	(r214146)
@@ -3664,9 +3664,15 @@ pci_reserve_map(device_t dev, device_t c
 	res = NULL;
 	pci_read_bar(child, *rid, &map, &testval);
 
-	/* Ignore a BAR with a base of 0. */
-	if ((*rid == PCIR_BIOS && pci_rombase(testval) == 0) ||
-	    pci_mapbase(testval) == 0)
+	/*
+	 * Determine the size of the BAR and ignore BARs with a size
+	 * of 0.  Device ROM BARs use a different mask value.
+	 */
+	if (*rid == PCIR_BIOS)
+		mapsize = pci_romsize(testval);
+	else
+		mapsize = pci_mapsize(testval);
+	if (mapsize == 0)
 		goto out;
 
 	if (PCI_BAR_MEM(testval) || *rid == PCIR_BIOS) {
@@ -3695,13 +3701,7 @@ pci_reserve_map(device_t dev, device_t c
 	 * actually uses and we would otherwise have a
 	 * situation where we might allocate the excess to
 	 * another driver, which won't work.
-	 *
-	 * Device ROM BARs use a different mask value.
 	 */
-	if (*rid == PCIR_BIOS)
-		mapsize = pci_romsize(testval);
-	else
-		mapsize = pci_mapsize(testval);
 	count = 1UL << mapsize;
 	if (RF_ALIGNMENT(flags) < mapsize)
 		flags = (flags & ~RF_ALIGNMENT_MASK) | RF_ALIGNMENT_LOG2(mapsize);



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