From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1C936C83F17 for ; Tue, 15 Jul 2025 21:37:00 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4bhXZf5Bp8z2xlM; Wed, 16 Jul 2025 07:36:58 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=23.155.224.40 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1752615418; cv=none; b=E6mlIgj4BPX5kxxH1X3x6YNurneIPNkng23Z4GAd1yVgquthmZlSz+jO2t0nNaP7RaQtRz6Fp/Jc3WKImfBMmTMSwUX/lbOrtUhY4BFh1MadbLWtY/s+z4aTkNzwENLcLnO6u89PbRcpiUTF+bBxQQp/PnmKUpoTuF+9iet5pnYAd66PL1HoFJNcO2AjZtp135TSpUdANhh7JIAyVPaO731i1ffVt0YfdmNpfepI3MdxIq6iJn+6dOvr3I9MleCRQDu0qJqqQn5OdYNACQaZAreaOUW36E9oMoBEqG4P1smpiAnJDMxquMAUS/VeG/rBI7xQ8UWdPA26/BNQ34rR7Q== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1752615418; c=relaxed/relaxed; bh=LaLmDzHUyKChIzl5rHPnEoGKej3I2INTlfN2Cmf7iEc=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: MIME-Version:Content-Type; b=M2E5QhqWZugWkuEcz6iR6rXZ/3Tu1eAexgBvg5wk5MIb9nLJDBbxlhVJqxjXXoTggcregIOnmRamkuZL/niaQklrU1tZ8KQyjrMHsoA9YRUGl6ER3XpLxxrKBpp6YYknfgPdcwdc5MKYDWePO7OcR3FzZQWytv4NWvLWyJdZFTo3MnU6gtlotQfgoktoCBd93j6KPUt7qE9n+u6JYeqDNhg9gO+U+ZDSuJGiuCPkLLx4c4f9KMXNTg12bKBU23W3Xkc/jSRgMXMpUYV2o6tu8XpCxDBfO/t/DP5cGo6Hc2eqxJ4Ejs5iqaBr1J6tgaMlRj92/wvvZ+MWlrZS7FJ4SQ== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=raptorengineering.com; dkim=pass (1024-bit key; secure) header.d=raptorengineering.com header.i=@raptorengineering.com header.a=rsa-sha256 header.s=B8E824E6-0BE2-11E6-931D-288C65937AAD header.b=Nep9x+2P; dkim-atps=neutral; spf=pass (client-ip=23.155.224.40; helo=raptorengineering.com; envelope-from=tpearson@raptorengineering.com; receiver=lists.ozlabs.org) smtp.mailfrom=raptorengineering.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=raptorengineering.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=raptorengineering.com header.i=@raptorengineering.com header.a=rsa-sha256 header.s=B8E824E6-0BE2-11E6-931D-288C65937AAD header.b=Nep9x+2P; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=raptorengineering.com (client-ip=23.155.224.40; helo=raptorengineering.com; envelope-from=tpearson@raptorengineering.com; receiver=lists.ozlabs.org) 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 lists.ozlabs.org (Postfix) with ESMTPS id 4bhXZd6hNgz2xfR for ; Wed, 16 Jul 2025 07:36:57 +1000 (AEST) 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 X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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 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; } +static int pcie_check_link_active(struct pci_dev *pdev) +{ + u16 lnk_status; + int ret; + + ret = pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status); + if (ret == PCIBIOS_DEVICE_NOT_FOUND || PCI_POSSIBLE_ERROR(lnk_status)) + return -ENODEV; + + ret = !!(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 = to_pnv_php_slot(slot); @@ -403,6 +417,19 @@ static int pnv_php_get_adapter_state(struct hotplug_slot *slot, u8 *state) */ ret = pnv_pci_get_presence_state(php_slot->id, &presence); if (ret >= 0) { + if (pci_pcie_type(php_slot->pdev) == PCI_EXP_TYPE_DOWNSTREAM && + presence == 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 = OPAL_PCI_SLOT_PRESENT; + } + *state = presence; ret = 0; } else { -- 2.39.5