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 617D1C71157 for ; Wed, 18 Jun 2025 16:56:59 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4bMqf20KR2z30VR; Thu, 19 Jun 2025 02:56: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=1750265818; cv=none; b=EemcexdVNvf5AXQJvXPyRSBpts4fpr0rnuyW2dO/bilkBn5L3sPX4OF+NrEB0M60pD0xTC8tWU6BjqywL5duWASUM61S7sN+rukGyWWGTZrXeatsg3rsc2MKIB2Dya+HWmV2kwVvBsi/etXAeQT0wnnvlRq3h0ePKTSl/dUCUx9exgkRqC3x78rIqML49ogyqNUG9whywz+GKKoFbMdahMv6nRCT+oj9IY7fcY224+O5C2j179Ahzyrv3p9QNI1bKiRFrNyGyoE/3x7Sly7jMJjHAT6s07TtIBXBakWP4nF31wwvBGlniVHQjOX7I2BzfPv+Ay5XWXw+vaVEc7B68Q== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1750265818; c=relaxed/relaxed; bh=sREPJsWJTR+II/tfen1J5UvqEzkTitKMBh+Xdyx4rAM=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: MIME-Version:Content-Type; b=IDzbwq6BtPApbRZloam7iGOl7xsViPHfZ0mWFZD8gGR+1fAKnJoq36TdsLdJX/NEVSrkRBZdA12SEZqqhCr2yaOzRpudFscntA0GYSRhwIe7Mq+MFWAgIHXJ9UOWND2HqzaBUL4tzdXMZnuS0aPYgaTOwanwd7NnaI+WZuzzl/g5p6yPpwVL1AcnhCcjkLculP4kcxZpT+epjzWD4Mrw5dFgiJZ6dxSSDu+vbWShS5wspsg0mhpeKq1u018Vht8qcdrFbEM7uXDbkMmgxDeUPdDcRCnV10VpytChF6EvhQ7hoPXszTin5u84g0/blaXmKrWCEYT0ZarbPO3fbOwYMw== 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=FPLMlgln; 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=FPLMlgln; 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 4bMqf11cKHz30VM for ; Thu, 19 Jun 2025 02:56:57 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 499608286FBD; Wed, 18 Jun 2025 11:56:55 -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 OzwSo1i5lY-5; Wed, 18 Jun 2025 11:56:54 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id A66358287179; Wed, 18 Jun 2025 11:56:54 -0500 (CDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com A66358287179 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1750265814; bh=sREPJsWJTR+II/tfen1J5UvqEzkTitKMBh+Xdyx4rAM=; h=Date:From:To:Message-ID:MIME-Version; b=FPLMlgln/Ncr+9I083bBPxQi6g4rRCiOdyqww8zDpkhfPuyneVgmqD2w9/pwRpEQm M3fFKnX2Os14BnzxrmV0UU58L8pJAKY3s7O9nO2yXk2lUbO99ufwZtrpcn/SZXjDOl 8o/6Ia84kDydEcBhqIdC2LGd+YvkTFgqtdT3OVTA= 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 LlwZ-2WCS83M; Wed, 18 Jun 2025 11:56:54 -0500 (CDT) Received: from vali.starlink.edu (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 7329E8286FBD; Wed, 18 Jun 2025 11:56:54 -0500 (CDT) Date: Wed, 18 Jun 2025 11:56:54 -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: <1741778252.1310636.1750265814430.JavaMail.zimbra@raptorengineeringinc.com> In-Reply-To: <581463409.1310624.1750265668004.JavaMail.zimbra@raptorengineeringinc.com> References: <581463409.1310624.1750265668004.JavaMail.zimbra@raptorengineeringinc.com> Subject: [PATCH v2 2/6] pci/hotplug/pnv_php: Work around switches with broken 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 - GC137 (Linux)/8.5.0_GA_3042) Thread-Topic: pci/hotplug/pnv_php: Work around switches with broken Thread-Index: 7ViWVrejj338yZQm64sXoMCfdWvE4IAxp3+8 presence detection 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