From nobody Tue Oct 7 03:47:46 2025 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC94F1C4A24; Tue, 15 Jul 2025 21:36:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=23.155.224.40 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752615418; cv=none; b=lfoz/QGtJ7y8+03s2Bg9iBChDyd5RT2Urw6gdf7EJ3S0A4YaRztPO7KiauIlps+QA3tqD/86cvSTnuojYyRQeVa/q/in67IId72gA59fO9oscNfMPSjR0ZZvqG3c0Euf1L/7xWKsYPe0x6Mmt/zTUimTpK1f1N1/fwcdfOYVSQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752615418; c=relaxed/simple; bh=crhUl8K7NfSIhNH3G1cHvCpoEuha4kT7cS8OI37RL0s=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: MIME-Version:Content-Type; b=ju4qb7dZkoRZmYYdMn7INkdMG/FNIFG/Vrfz67S3byt+cAvfLoj6rOShYgPv7LbNbVo5W+Xs1DfBGKAYB1CtlxstpMC0swvmwxTvsv/IcjFqHmaIQ0kCzODB3o/kjgqYKqGzU+2a41H3sEpVd81IkMUXflXQbZeaJewgdrI4//E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raptorengineering.com; spf=pass smtp.mailfrom=raptorengineering.com; dkim=pass (1024-bit key) header.d=raptorengineering.com header.i=@raptorengineering.com header.b=Nep9x+2P; arc=none smtp.client-ip=23.155.224.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raptorengineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raptorengineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=raptorengineering.com header.i=@raptorengineering.com header.b="Nep9x+2P" Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 253FD8287698; Tue, 15 Jul 2025 16:36:56 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 6SdXHPDblhg1; Tue, 15 Jul 2025 16:36:55 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 641068287FFD; Tue, 15 Jul 2025 16:36:55 -0500 (CDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com 641068287FFD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1752615415; bh=LaLmDzHUyKChIzl5rHPnEoGKej3I2INTlfN2Cmf7iEc=; h=Date:From:To:Message-ID:MIME-Version; b=Nep9x+2PP5OT7QM2AGqVAkHugYtjVvmWYI1Qj333bXkUvyWlST5kZQsoX7dYAl+Gv FAOTzeAo76T3YqpyfkG/9WeA+byKHMQIAA/+8Mt3FqW7HR6NykU2CsAUQpfLGL8RJw N5Q7387kx7wnA7hBZRwqTYvMvFE0HAmZN5B9tkb8= X-Virus-Scanned: amavisd-new at rptsys.com Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id yxtRlKp8tukF; Tue, 15 Jul 2025 16:36:55 -0500 (CDT) Received: from vali.starlink.edu (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 328838287698; Tue, 15 Jul 2025 16:36:55 -0500 (CDT) Date: Tue, 15 Jul 2025 16:36:55 -0500 (CDT) From: Timothy Pearson To: Timothy Pearson Cc: linuxppc-dev , linux-kernel , linux-pci , Madhavan Srinivasan , Michael Ellerman , christophe leroy , Naveen N Rao , Bjorn Helgaas , Shawn Anastasio Message-ID: <505981576.1359853.1752615415117.JavaMail.zimbra@raptorengineeringinc.com> In-Reply-To: <1268570622.1359844.1752615109932.JavaMail.zimbra@raptorengineeringinc.com> References: <1268570622.1359844.1752615109932.JavaMail.zimbra@raptorengineeringinc.com> Subject: [PATCH v3 2/6] PCI: pnv_php: Work around switches with broken presence detection Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: Zimbra 8.5.0_GA_3042 (ZimbraWebClient - GC138 (Linux)/8.5.0_GA_3042) Thread-Topic: pnv_php: Work around switches with broken presence detection Thread-Index: XyF2OaMn/3q+H+nwsGaxXLVF4U4PF4ZEJFKH Content-Type: text/plain; charset="utf-8" The Microsemi Switchtec PM8533 PFX 48xG3 [11f8:8533] PCIe switch system was observed to incorrectly assert the Presence Detect Set bit in its capabilities when tested on a Raptor Computing Systems Blackbird system, resulting in the hot insert path never attempting a rescan of the bus and any downstream devices not being re-detected. Work around this by additionally checking whether the PCIe data link is active or not when performing presence detection on downstream switches' ports, similar to the pciehp_hpc.c driver. Signed-off-by: Shawn Anastasio Signed-off-by: Timothy Pearson --- drivers/pci/hotplug/pnv_php.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c index aec0a6d594ac..bac8af3df41a 100644 --- a/drivers/pci/hotplug/pnv_php.c +++ b/drivers/pci/hotplug/pnv_php.c @@ -391,6 +391,20 @@ static int pnv_php_get_power_state(struct hotplug_slot= *slot, u8 *state) return 0; } =20 +static int pcie_check_link_active(struct pci_dev *pdev) +{ + u16 lnk_status; + int ret; + + ret =3D pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status); + if (ret =3D=3D PCIBIOS_DEVICE_NOT_FOUND || PCI_POSSIBLE_ERROR(lnk_status)) + return -ENODEV; + + ret =3D !!(lnk_status & PCI_EXP_LNKSTA_DLLLA); + + return ret; +} + static int pnv_php_get_adapter_state(struct hotplug_slot *slot, u8 *state) { struct pnv_php_slot *php_slot =3D to_pnv_php_slot(slot); @@ -403,6 +417,19 @@ static int pnv_php_get_adapter_state(struct hotplug_sl= ot *slot, u8 *state) */ ret =3D pnv_pci_get_presence_state(php_slot->id, &presence); if (ret >=3D 0) { + if (pci_pcie_type(php_slot->pdev) =3D=3D PCI_EXP_TYPE_DOWNSTREAM && + presence =3D=3D OPAL_PCI_SLOT_EMPTY) { + /* + * Similar to pciehp_hpc, check whether the Link Active + * bit is set to account for broken downstream bridges + * that don't properly assert Presence Detect State, as + * was observed on the Microsemi Switchtec PM8533 PFX + * [11f8:8533]. + */ + if (pcie_check_link_active(php_slot->pdev) > 0) + presence =3D OPAL_PCI_SLOT_PRESENT; + } + *state =3D presence; ret =3D 0; } else { --=20 2.39.5