From owner-svn-src-head@freebsd.org Wed May 30 02:41:48 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8AA31EF5D75; Wed, 30 May 2018 02:41:48 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 400FC6A7CC; Wed, 30 May 2018 02:41:48 +0000 (UTC) (envelope-from jhibbits@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2119324B1E; Wed, 30 May 2018 02:41:48 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4U2fmlt033943; Wed, 30 May 2018 02:41:48 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4U2fmvB033942; Wed, 30 May 2018 02:41:48 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201805300241.w4U2fmvB033942@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Wed, 30 May 2018 02:41:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334365 - head/sys/dev/pci X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/dev/pci X-SVN-Commit-Revision: 334365 X-SVN-Commit-Repository: base 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.26 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: Wed, 30 May 2018 02:41:48 -0000 Author: jhibbits Date: Wed May 30 02:41:47 2018 New Revision: 334365 URL: https://svnweb.freebsd.org/changeset/base/334365 Log: Restrict PCIe maxslots to 0, instead of PCI_SLOTMAX Summary: PCIe only permits 1 device on an endpoint, so some devices ignore the device part of B:D:F probing. Although ARI likely fixes this, not all platforms support ARI completely or correctly, so some devices end up showing up 32 times on the bus. This was found during bringup of POWER9/Talos, and has been tested on POWER9 and POWER8 hardware. Reviewed by: leitao Differential Revision: https://reviews.freebsd.org/D15461 Modified: head/sys/dev/pci/pci_pci.c Modified: head/sys/dev/pci/pci_pci.c ============================================================================== --- head/sys/dev/pci/pci_pci.c Wed May 30 02:26:36 2018 (r334364) +++ head/sys/dev/pci/pci_pci.c Wed May 30 02:41:47 2018 (r334365) @@ -2545,6 +2545,20 @@ pcib_enable_ari(struct pcib_softc *sc, uint32_t pcie_p int pcib_maxslots(device_t dev) { + uint32_t pcie_pos; + uint16_t val; + + /* + * If this is a PCIe rootport or downstream switch port, there's only + * one slot permitted. + */ + if (pci_find_cap(dev, PCIY_EXPRESS, &pcie_pos) == 0) { + val = pci_read_config(dev, pcie_pos + PCIER_FLAGS, 2); + val &= PCIEM_FLAGS_TYPE; + if (val == PCIEM_TYPE_ROOT_PORT || + val == PCIEM_TYPE_DOWNSTREAM_PORT) + return (0); + } return (PCI_SLOTMAX); } @@ -2558,7 +2572,7 @@ pcib_ari_maxslots(device_t dev) if (sc->flags & PCIB_ENABLE_ARI) return (PCIE_ARI_SLOTMAX); else - return (PCI_SLOTMAX); + return (pcib_maxslots(dev)); } static int