From owner-svn-src-all@FreeBSD.ORG Thu Oct 21 17:46:24 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1B7621065695; Thu, 21 Oct 2010 17:46:24 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0B5B58FC12; Thu, 21 Oct 2010 17:46:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9LHkNxg098454; Thu, 21 Oct 2010 17:46:23 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9LHkN95098452; Thu, 21 Oct 2010 17:46:23 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201010211746.o9LHkN95098452@svn.freebsd.org> From: John Baldwin Date: Thu, 21 Oct 2010 17:46:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214146 - head/sys/dev/pci X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Oct 2010 17:46:24 -0000 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);