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);
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to