git: 4c8b9f40cda7 - main - pcib: Ignore power fault detected if a power controller is not present

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 22 Apr 2025 02:58:23 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=4c8b9f40cda7dd6b2de547b288d712c85998ce11

commit 4c8b9f40cda7dd6b2de547b288d712c85998ce11
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-04-22 02:08:01 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-04-22 02:08:01 +0000

    pcib: Ignore power fault detected if a power controller is not present
    
    At least some PCI-express bridges exposed by Intel Volume Management
    Devices report bogus power faults in their slot status register.  As a
    workaround, ignore the power fault detected flag if the slot
    capability register does not indicate support for a power controller.
    
    While the PCI-e spec does not explicitly state that the PFD flag
    should always be zero if a power controller is not present, parts of
    the spec do seem to assume this.  For example, the flag is included in
    the "Power Controller Registers" register group in 6.7.2.4, and the
    definition of the value for this flag seems to presume the presence of
    a power controller:
    
        If a Power Controller that supports power fault detection is
        implemented, this bit is Set when the Power Controller detects a
        power fault at this slot. Note that, depending on hardware
        capability, it is possible that a power fault can be detected at
        any time, independent of the Power Controller Control setting or
        the occupancy of the slot. If power fault detection is not
        supported, this bit must not be Set.
    
    PR:             285993
    Reported by:    Jim Long <freebsd-bugzilla@umpquanet.com>
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D49949
---
 sys/dev/pci/pci_pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c
index 5e71a376604b..cdd717266026 100644
--- a/sys/dev/pci/pci_pci.c
+++ b/sys/dev/pci/pci_pci.c
@@ -930,7 +930,8 @@ pcib_hotplug_inserted(struct pcib_softc *sc)
 		return (false);
 
 	/* A power fault implicitly turns off power to the slot. */
-	if (sc->pcie_slot_sta & PCIEM_SLOT_STA_PFD)
+	if (sc->pcie_slot_cap & PCIEM_SLOT_CAP_PCP &&
+	    sc->pcie_slot_sta & PCIEM_SLOT_STA_PFD)
 		return (false);
 
 	/* If the MRL is disengaged, the slot is powered off. */