From owner-svn-src-stable-11@freebsd.org Fri Sep 15 09:03:03 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0B084E08934; Fri, 15 Sep 2017 09:03:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 DA959831DA; Fri, 15 Sep 2017 09:03:02 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v8F932e8074186; Fri, 15 Sep 2017 09:03:02 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v8F932Ai074185; Fri, 15 Sep 2017 09:03:02 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201709150903.v8F932Ai074185@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 15 Sep 2017 09:03:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r323609 - stable/11/sys/x86/pci X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/x86/pci X-SVN-Commit-Revision: 323609 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Sep 2017 09:03:03 -0000 Author: kib Date: Fri Sep 15 09:03:01 2017 New Revision: 323609 URL: https://svnweb.freebsd.org/changeset/base/323609 Log: MFC r323327: Enhance qpi.c to make it usable on all Core-microarchitecture Xeons. Modified: stable/11/sys/x86/pci/qpi.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/x86/pci/qpi.c ============================================================================== --- stable/11/sys/x86/pci/qpi.c Fri Sep 15 09:00:45 2017 (r323608) +++ stable/11/sys/x86/pci/qpi.c Fri Sep 15 09:03:01 2017 (r323609) @@ -63,13 +63,19 @@ static MALLOC_DEFINE(M_QPI, "qpidrv", "qpi system devi static void qpi_identify(driver_t *driver, device_t parent) { + int do_qpi; /* Check CPUID to ensure this is an i7 CPU of some sort. */ - if (!(cpu_vendor_id == CPU_VENDOR_INTEL && - CPUID_TO_FAMILY(cpu_id) == 0x6 && - (CPUID_TO_MODEL(cpu_id) == 0x1a || CPUID_TO_MODEL(cpu_id) == 0x2c))) + if (cpu_vendor_id != CPU_VENDOR_INTEL || + CPUID_TO_FAMILY(cpu_id) != 0x6) return; + /* Only discover buses with configuration devices if allowed by user */ + do_qpi = 0; + TUNABLE_INT_FETCH("hw.attach_intel_csr_pci", &do_qpi); + if (!do_qpi) + return; + /* PCI config register access is required. */ if (pci_cfgregopen() == 0) return; @@ -97,6 +103,7 @@ qpi_probe_pcib(device_t dev, int bus) struct qpi_device *qdev; device_t child; uint32_t devid; + int s; /* * If a PCI bus already exists for this bus number, then @@ -106,18 +113,23 @@ qpi_probe_pcib(device_t dev, int bus) return (EEXIST); /* - * Attempt to read the device id for device 0, function 0 on - * the bus. A value of 0xffffffff means that the bus is not - * present. + * Attempt to read the device id for every slot, function 0 on + * the bus. If all read values are 0xffffffff this means that + * the bus is not present. */ - devid = pci_cfgregread(bus, 0, 0, PCIR_DEVVENDOR, 4); + for (s = 0; s <= PCI_SLOTMAX; s++) { + devid = pci_cfgregread(bus, s, 0, PCIR_DEVVENDOR, 4); + if (devid != 0xffffffff) + break; + } if (devid == 0xffffffff) return (ENOENT); if ((devid & 0xffff) != 0x8086) { - device_printf(dev, - "Device at pci%d.0.0 has non-Intel vendor 0x%x\n", bus, - devid & 0xffff); + if (bootverbose) + device_printf(dev, + "Device at pci%d.%d.0 has non-Intel vendor 0x%x\n", + bus, s, devid & 0xffff); return (ENXIO); } @@ -137,12 +149,12 @@ qpi_attach(device_t dev) int bus; /* - * Each processor socket has a dedicated PCI bus counting down from - * 255. We keep probing buses until one fails. + * Each processor socket has a dedicated PCI bus, sometimes + * not enumerated by ACPI. Probe all unattached buses from 0 + * to 255. */ - for (bus = 255;; bus--) - if (qpi_probe_pcib(dev, bus) != 0) - break; + for (bus = PCI_BUSMAX; bus >= 0; bus--) + qpi_probe_pcib(dev, bus); return (bus_generic_attach(dev)); }