From patchwork Fri Apr 4 04:18:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Anastasio X-Patchwork-Id: 14038127 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 643BB2E62B8; Fri, 4 Apr 2025 04:26:38 +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=1743740801; cv=none; b=P6R2naH1ecFRajWXZOaB/jGMJ7IjF1MVKqZIgnsOphY1mmCMZuaXKXQClY0UP0UUuKFE1lS1p6NE/PCg5kvPwoalnLLNlADhBjGUTBCym8s1TDIrINYlOrL+nUDNcpcTNGBXsr7KV+YkBOw+RFO12U0N917VkjN4HSE4U4P7Gmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743740801; c=relaxed/simple; bh=107+hfmFzFDDXOmCW6raL4he+f4ybLXUIsRpVGyruwg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WDdtEORD1Xry4cJgwQbeC9/vMMAUoJLUQLwab2MH368s3/HHJafflTtXvkXWUEpgaFyxc98vDrF5Tx47I6BHIyLnblMEg7GcPQK3KYdumPqOftX1hTfVvoIulxvX0Tk3KJQmWNntCQ8RKAnzEgUpd9iIDAa5MhrPJ77Cf0ZmGvA= 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=ZGJXyuPw; 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="ZGJXyuPw" Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 8BD958288948; Thu, 3 Apr 2025 23:18:15 -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 F3ugog3yIHEK; Thu, 3 Apr 2025 23:18:14 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id C832C8287DC7; Thu, 3 Apr 2025 23:18:14 -0500 (CDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com C832C8287DC7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1743740294; bh=R3TEJwuAJZ0klnHkNfJo7ybCDbPTaShTCK/BgFmdm60=; h=From:To:Date:Message-Id:MIME-Version; b=ZGJXyuPw/vyrls4htxAk3M/fQBla3YmcPvyqrIkmVqacNhP6uZOtU5anDmg+h2i2E 57mze6ubVXAd39dkvw0BwAcwssPd5yZZ+xTGd7Ye98O2wdxmSB+8FPkunVK0CbZ+s5 9hbXD6nrfuXMSKMwsN4u2FhbJXexWmbv+zbPXQAk= 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 7J193i_wQp1T; Thu, 3 Apr 2025 23:18:14 -0500 (CDT) Received: from raptor-ewks-026.lan (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id 393F38287182; Thu, 3 Apr 2025 23:18:14 -0500 (CDT) From: Shawn Anastasio To: linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, tpearson@raptorengineering.com, Madhavan Srinivasan , Michael Ellerman , Christophe Leroy , Naveen N Rao , Bjorn Helgaas , Shawn Anastasio Subject: [PATCH 2/3] pci/hotplug/pnv_php: Work around switches with broken presence detection Date: Thu, 3 Apr 2025 23:18:09 -0500 Message-Id: <20250404041810.245984-3-sanastasio@raptorengineering.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20250404041810.245984-1-sanastasio@raptorengineering.com> References: <20250404041810.245984-1-sanastasio@raptorengineering.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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 2c07544216fb..1a734adb5b10 100644 --- a/drivers/pci/hotplug/pnv_php.c +++ b/drivers/pci/hotplug/pnv_php.c @@ -390,6 +390,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); @@ -402,6 +416,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 {