Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Apr 2025 03:18:58 GMT
From:      Colin Percival <cperciva@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 217fce137713 - stable/14 - pci: Make PCIe Eject timeout configurable
Message-ID:  <202504160318.53G3Iw0F009130@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=217fce137713ab7f44783c28681ebd4cfcd1465d

commit 217fce137713ab7f44783c28681ebd4cfcd1465d
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2025-03-31 04:08:44 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2025-04-16 03:15:00 +0000

    pci: Make PCIe Eject timeout configurable
    
    PCIe mandates a 5 second delay between when the "Attention Button" is
    pressed and when the associated device is detached; this is to allow
    for the button to be pressed a second time to cancel the ejection.  On
    some systems this 5 second delay may not be desireable; so introduce a
    hw.pci.pcie_hp_detach_timeout sysctl (which can also be set as a loader
    tunable) which specifies the timeout in milliseconds (default 5000).
    If set to zero, the device is detached immediately.
    
    Reviewed by:    jhb
    MFC after:      2 weeks
    Sponsored by:   Amazon
    Differential Revision:  https://reviews.freebsd.org/D49585
    
    (cherry picked from commit 9be42ee6c9c741052bdc49f13bc953bf88a24423)
---
 sys/dev/pci/pci_pci.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c
index 06e8c2bc8433..a9567b3e2c4c 100644
--- a/sys/dev/pci/pci_pci.c
+++ b/sys/dev/pci/pci_pci.c
@@ -951,6 +951,11 @@ SYSCTL_INT(_hw_pci, OID_AUTO, enable_pcie_hp, CTLFLAG_RDTUN,
     &pci_enable_pcie_hp, 0,
     "Enable support for native PCI-express HotPlug.");
 
+static sbintime_t pcie_hp_detach_timeout = 5 * SBT_1S;
+SYSCTL_SBINTIME_MSEC(_hw_pci, OID_AUTO, pcie_hp_detach_timeout, CTLFLAG_RWTUN,
+    &pcie_hp_detach_timeout,
+    "Attention Button delay for PCI-express Eject.");
+
 TASKQUEUE_DEFINE_THREAD(pci_hp);
 
 static void
@@ -1221,11 +1226,17 @@ pcib_pcie_intr_hotplug(void *arg)
 			    &sc->pcie_ab_task, NULL);
 		} else if (old_slot_sta & PCIEM_SLOT_STA_PDS) {
 			/* Only initiate detach sequence if device present. */
-			device_printf(dev,
-		    "Attention Button Pressed: Detaching in 5 seconds\n");
-			sc->flags |= PCIB_DETACH_PENDING;
-			taskqueue_enqueue_timeout(taskqueue_pci_hp,
-			    &sc->pcie_ab_task, 5 * hz);
+			if (pcie_hp_detach_timeout != 0) {
+				device_printf(dev,
+			    "Attention Button Pressed: Detaching in %ld ms\n",
+			    (long)(pcie_hp_detach_timeout / SBT_1MS));
+				sc->flags |= PCIB_DETACH_PENDING;
+				taskqueue_enqueue_timeout_sbt(taskqueue_pci_hp,
+				    &sc->pcie_ab_task, pcie_hp_detach_timeout,
+				    SBT_1S, 0);
+			} else {
+				sc->flags |= PCIB_DETACHING;
+			}
 		}
 	}
 	if (sc->pcie_slot_sta & PCIEM_SLOT_STA_PFD)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202504160318.53G3Iw0F009130>