From owner-svn-src-head@FreeBSD.ORG Fri Jun 12 12:27:11 2015 Return-Path: Delivered-To: svn-src-head@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 08FA74BC; Fri, 12 Jun 2015 12:27:11 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EB568167E; Fri, 12 Jun 2015 12:27:10 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5CCRAwr063793; Fri, 12 Jun 2015 12:27:10 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t5CCRAGI063792; Fri, 12 Jun 2015 12:27:10 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201506121227.t5CCRAGI063792@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Fri, 12 Jun 2015 12:27:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r284315 - head/sys/dev/proto X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jun 2015 12:27:11 -0000 Author: marcel Date: Fri Jun 12 12:27:10 2015 New Revision: 284315 URL: https://svnweb.freebsd.org/changeset/base/284315 Log: We need to handle 64-bit BARs ourselves to avoid that the PCI infrastructure instantiates a non-existent resource. This has BARs suddenly show up with pciconf(8) under VMware as well. Now that we read the BAR ourselves, ask for the correct resource type. Modified: head/sys/dev/proto/proto_bus_pci.c Modified: head/sys/dev/proto/proto_bus_pci.c ============================================================================== --- head/sys/dev/proto/proto_bus_pci.c Fri Jun 12 11:52:32 2015 (r284314) +++ head/sys/dev/proto/proto_bus_pci.c Fri Jun 12 12:27:10 2015 (r284315) @@ -82,6 +82,7 @@ proto_pci_attach(device_t dev) { struct proto_softc *sc; struct resource *res; + uint32_t val; int bar, rid, type; sc = device_get_softc(dev); @@ -91,15 +92,17 @@ proto_pci_attach(device_t dev) for (bar = 0; bar < PCIR_MAX_BAR_0; bar++) { rid = PCIR_BAR(bar); - type = SYS_RES_MEMORY; + val = pci_read_config(dev, rid, 4); + type = (PCI_BAR_IO(val)) ? SYS_RES_IOPORT : SYS_RES_MEMORY; res = bus_alloc_resource_any(dev, type, &rid, RF_ACTIVE); - if (res == NULL) { - type = SYS_RES_IOPORT; - res = bus_alloc_resource_any(dev, type, &rid, - RF_ACTIVE); - } - if (res != NULL) - proto_add_resource(sc, type, rid, res); + if (res == NULL) + continue; + proto_add_resource(sc, type, rid, res); + if (type == SYS_RES_IOPORT) + continue; + /* Skip over adjacent BAR for 64-bit memory BARs. */ + if ((val & PCIM_BAR_MEM_TYPE) == PCIM_BAR_MEM_64) + bar++; } rid = 0;