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 4D642C87FDA for ; Fri, 8 Aug 2025 15:31:18 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4bz7Kc6lh0z2xQ3; Sat, 9 Aug 2025 01:31:16 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2604:1380:45d1:ec00::3" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1754667076; cv=none; b=Odz3QxJ4Qh3nw4HFjwOVGTyXO1h59X62E6biX3D4PQCxVCM5hYLy55vWUMZ+ELY2SBpPGQKDY5+5uiWrd3qMoFNbptU3rDOTMkd86o0TYfCndIQimMGPGskvU+aIb3H56uQ4LK/xo2ChlpIZaP8MUKufHMHWxriOEg/uLenoZFT9RtW2cE+1klIZdDuwZotfD+nvMKvhjBENTjKHVDEG85Uwp4Gzz1S4sWOZMPqly2F3ix4J3xyuczM4ybCUhCK+tbTJAa5a0SHuECfPZM4OwgjU9Ph+JcMeyLHTdY2phJylwv2YrvgX7MxJTs55iEbOYxmY765DIrIi/l+dxa7UUg== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1754667076; c=relaxed/relaxed; bh=ZUNGwp6iq0sapqsSAPIpsl4ub/yz8ycLB/2lqK2ufQo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bSR05Eqk1wFbbIl+Ymw8BMPaPHD9OKQZM9JXLZIVdH9wYU6be7OgmWt6rGhkhPro1BCij37xqoHFa3ID1Hkb36a9PR1pxMqiyLcRbXpV5uBHagGfODg0it71CkXHQ34ipUgLEeLGdsDB0CUlA+4Hp7nvuUPXR0wj+dn+dshqUf2JxIsdeUaVs/rx14klqx0oWxlpdHRvP+p+tetr9lwgY+4YyOcHbU+vRc7FEItSs9mYu7R7Lh/7+CoWysIBsH+dm5JtYVQGXci/MD9LEgIBFAmBsOOHxPDOLQss8PiJNq4eOr466/Hex5Z083+I6r5M3vd1k0UbYm1fPMx2qR1BSA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=dkYO3Pjr; dkim-atps=neutral; spf=pass (client-ip=2604:1380:45d1:ec00::3; helo=nyc.source.kernel.org; envelope-from=sashal@kernel.org; receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=dkYO3Pjr; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=2604:1380:45d1:ec00::3; helo=nyc.source.kernel.org; envelope-from=sashal@kernel.org; receiver=lists.ozlabs.org) Received: from nyc.source.kernel.org (nyc.source.kernel.org [IPv6:2604:1380:45d1:ec00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4bz7Kb3j3Sz2xHY for ; Sat, 9 Aug 2025 01:31:15 +1000 (AEST) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 862E7A55744; Fri, 8 Aug 2025 15:31:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFBDDC4CEF8; Fri, 8 Aug 2025 15:31:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1754667072; bh=iALWdkXx5wrJBTQPkCiENWIVUEgZyasgDgnGqe0+EYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dkYO3PjrGLBdMlbT+EBO4QTZjRQtKDU7vC8CLsg1+Scy6wBy319QGWW1DNZjO69zh J8FkXyalAjSBxFGAHSzAHCx7Gce5MvF0Lt8v/FhikCB0b2coLEjjE/T3r/xsu+Srdp dFGnP4jn5ZZCvDpLTHJ09OfCUf+0iX+CBznuneoKd/w2P+mb3gfdVOLZFdUnCBqpWS lc0OOheSiMv0Uc+yZXRtSJlbfa66SVsZfSVT/9VKYGop6baWVIhgPLFth/UNdxIhmI MSBpaUn97v1v+5mLYOX+DGLHasPRBx1UEKN4UA63fQ3Mz3to32dOoetk4FYLnBM34/ ubsf9j8yrYJMQ== From: Sasha Levin To: patches@lists.linux.dev, stable@vger.kernel.org Cc: Timothy Pearson , Shawn Anastasio , Bjorn Helgaas , Madhavan Srinivasan , Sasha Levin , mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 6.16-5.4] PCI: pnv_php: Work around switches with broken presence detection Date: Fri, 8 Aug 2025 11:30:48 -0400 Message-Id: <20250808153054.1250675-8-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250808153054.1250675-1-sashal@kernel.org> References: <20250808153054.1250675-1-sashal@kernel.org> 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 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.16 Content-Transfer-Encoding: 8bit From: Timothy Pearson [ Upstream commit 80f9fc2362797538ebd4fd70a1dfa838cc2c2cdb ] 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 Signed-off-by: Bjorn Helgaas Signed-off-by: Madhavan Srinivasan Link: https://patch.msgid.link/505981576.1359853.1752615415117.JavaMail.zimbra@raptorengineeringinc.com Signed-off-by: Sasha Levin --- LLM Generated explanations, may be completely bogus: **Backport Status: YES** This commit is suitable for backporting to stable kernel trees based on the following analysis: ## Commit Analysis ### 1. Bug Fix Nature The commit fixes a real hardware bug where the Microsemi Switchtec PM8533 PFX 48xG3 PCIe switch incorrectly reports presence detection. This causes downstream devices to not be re-detected after hot insertion, which is a significant functional issue affecting users. ### 2. Small and Contained Fix The patch adds only 33 lines of code: - Adds a new helper function `pcie_check_link_active()` (11 lines) - Modifies `pnv_php_get_adapter_state()` with a targeted workaround (13 lines) - The changes are confined to a single file: `drivers/pci/hotplug/pnv_php.c` ### 3. Clear and Minimal Side Effects The workaround is: - Only activated for specific hardware (downstream PCIe ports) - Only when presence detection returns EMPTY - Uses an additional check (link active status) as a fallback - Similar approach already proven in pciehp_hpc.c driver ### 4. Hardware Quirk Fix This is explicitly a hardware quirk workaround for broken hardware (Microsemi Switchtec PM8533), which is one of the accepted categories for stable backports according to stable kernel rules. ### 5. No Architectural Changes The commit: - Does not introduce new features - Does not change any APIs or interfaces - Does not modify core kernel infrastructure - Simply adds a fallback detection mechanism ### 6. Tested Solution The commit message indicates this was "observed" and tested on a Raptor Computing Systems Blackbird system, suggesting real-world validation. ## Stable Tree Compliance According to Documentation/process/stable-kernel-rules.rst, this patch meets the criteria: - Fixes a real bug that bothers people (hotplug detection failure) - Is a hardware quirk fix (explicitly allowed) - Is under 100 lines with context - Is obviously correct (uses established pattern from pciehp_hpc.c) - Has clear user impact (devices not being detected after hot insertion) The workaround pattern of checking link active status when presence detection fails is a well-established approach in PCIe hotplug drivers, making this a low-risk backport candidate. 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 573a41869c15..aaa8e0a2a893 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