From owner-svn-src-all@freebsd.org Fri Aug 5 18:41:52 2016 Return-Path: Delivered-To: svn-src-all@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 D5AEBBB0759; Fri, 5 Aug 2016 18:41:52 +0000 (UTC) (envelope-from jhb@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 942961784; Fri, 5 Aug 2016 18:41:52 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u75Ifp69093874; Fri, 5 Aug 2016 18:41:51 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u75Ifp6M093873; Fri, 5 Aug 2016 18:41:51 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201608051841.u75Ifp6M093873@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 5 Aug 2016 18:41:51 +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: r303781 - stable/11/sys/dev/pci X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 05 Aug 2016 18:41:52 -0000 Author: jhb Date: Fri Aug 5 18:41:51 2016 New Revision: 303781 URL: https://svnweb.freebsd.org/changeset/base/303781 Log: MFC 303497,303559,303645: Disable PCI-e hotplug on bridges with power controllers. 303497: Add a loader tunable (hw.pci.enable_pcie_hp) to disable PCI-e HotPlug. Some systems and/or devices (such as riser cards) do not include a non-compliant implementation of PCI-e HotPlug that can result in devices not being attached (e.g. the HotPlug code might assume that a card is being unplugged and will power the slot off and detach it). This tunable can be set to 0 to disable support for PCI-e HotPlug ignoring the incorrect HotPlug state on these slots. 303559: Try to declare _hw_pci for all sysctl cases needed after r303497. 303645: Disable PCI hotplug support for slots with power controllers. After further review of the spec, I do not think the current HotPlug code handles slots with power controllers correctly. In particular, the power state of the slot is to be inferred from other events, not from examining the state of the power control bit in SLOT_CTL. For now, disable PCI hotplug support on such slots. PR: 211081 Approved by: re (gjb) Modified: stable/11/sys/dev/pci/pci_pci.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/pci/pci_pci.c ============================================================================== --- stable/11/sys/dev/pci/pci_pci.c Fri Aug 5 17:49:13 2016 (r303780) +++ stable/11/sys/dev/pci/pci_pci.c Fri Aug 5 18:41:51 2016 (r303781) @@ -128,9 +128,11 @@ static devclass_t pcib_devclass; DEFINE_CLASS_0(pcib, pcib_driver, pcib_methods, sizeof(struct pcib_softc)); DRIVER_MODULE(pcib, pci, pcib_driver, pcib_devclass, NULL, NULL); -#ifdef NEW_PCIB +#if defined(NEW_PCIB) || defined(PCI_HP) SYSCTL_DECL(_hw_pci); +#endif +#ifdef NEW_PCIB static int pci_clear_pcib; SYSCTL_INT(_hw_pci, OID_AUTO, clear_pcib, CTLFLAG_RDTUN, &pci_clear_pcib, 0, "Clear firmware-assigned resources for PCI-PCI bridge I/O windows."); @@ -907,11 +909,19 @@ pcib_set_mem_decode(struct pcib_softc *s /* * PCI-express HotPlug support. */ +static int pci_enable_pcie_hp = 1; +SYSCTL_INT(_hw_pci, OID_AUTO, enable_pcie_hp, CTLFLAG_RDTUN, + &pci_enable_pcie_hp, 0, + "Enable support for native PCI-express HotPlug."); + static void pcib_probe_hotplug(struct pcib_softc *sc) { device_t dev; + if (!pci_enable_pcie_hp) + return; + dev = sc->dev; if (pci_find_cap(dev, PCIY_EXPRESS, NULL) != 0) return; @@ -922,6 +932,13 @@ pcib_probe_hotplug(struct pcib_softc *sc sc->pcie_link_cap = pcie_read_config(dev, PCIER_LINK_CAP, 4); sc->pcie_slot_cap = pcie_read_config(dev, PCIER_SLOT_CAP, 4); + /* + * XXX: Handling of slots with a power controller needs to be + * reexamined. Ignore hotplug on such slots for now. + */ + if (sc->pcie_slot_cap & PCIEM_SLOT_CAP_PCP) + return; + if (sc->pcie_slot_cap & PCIEM_SLOT_CAP_HPC) sc->flags |= PCIB_HOTPLUG; }