From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4F026634EB; Tue, 23 Jan 2024 01:57:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705975027; cv=none; b=WbblfqD5BFoelmLvVAwUK1C6K/0xHuTDgYG5zqPmWEUoOEyt7Wdpgk4cU4dTQch2Sw+l2KMDOJY4+iIfWBFvYwDcuzuM8vOXUITVF2S++MEZqihgFcdlmmfbUdeu7R3Zk4fCHMLebBjlO4f1SMceQ+iLRNNpi1UVHWnLzchAOv0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705975027; c=relaxed/simple; bh=VReD/P59Tgo42OXW2qPNepwMFPP9ONnYMx/zxlQWJeM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=McA/apC69+3eqMtqOU8OM9zuX/lbKFxOf0EQJ66GuAMIuJIHqN20ansBm0ZQFFRbcUHN41kMx+lYpb/RujwkroNq7BcVnMisJIjBdhSH68J4JDLfOXY9K349bhpIETfbqRA8kiv4oOw86msDq9tIBgqBhfy3Pi8ok5y0iasoz6w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=gHRAU+3A; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="gHRAU+3A" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1605AC433F1; Tue, 23 Jan 2024 01:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1705975027; bh=VReD/P59Tgo42OXW2qPNepwMFPP9ONnYMx/zxlQWJeM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gHRAU+3Ag1MKfdv57RKt2SUQ/9hTL4cOg0Vo3SJiJjWGwhAcEZv9eSjs1WNHUugz+ PPB2Ws8Dcz01kGsTn0cQ6wX3mHZEQoO5TF5sEFaXhpaPbMt9UGBfXm2vycSNYUtdLq rIiLHe75DtQ0Nx0fo47Riqx57dadYyayU8ABz3qw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Siddharth Vadapalli , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Ravi Gunasekaran , Sasha Levin Subject: [PATCH 5.15 330/374] PCI: keystone: Fix race condition when initializing PHYs Date: Mon, 22 Jan 2024 15:59:46 -0800 Message-ID: <20240122235756.373040498@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122235744.598274724@linuxfoundation.org> References: <20240122235744.598274724@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Siddharth Vadapalli [ Upstream commit c12ca110c613a81cb0f0099019c839d078cd0f38 ] The PCI driver invokes the PHY APIs using the ks_pcie_enable_phy() function. The PHY in this case is the Serdes. It is possible that the PCI instance is configured for two lane operation across two different Serdes instances, using one lane of each Serdes. In such a configuration, if the reference clock for one Serdes is provided by the other Serdes, it results in a race condition. After the Serdes providing the reference clock is initialized by the PCI driver by invoking its PHY APIs, it is not guaranteed that this Serdes remains powered on long enough for the PHY APIs based initialization of the dependent Serdes. In such cases, the PLL of the dependent Serdes fails to lock due to the absence of the reference clock from the former Serdes which has been powered off by the PM Core. Fix this by obtaining reference to the PHYs before invoking the PHY initialization APIs and releasing reference after the initialization is complete. Link: https://lore.kernel.org/linux-pci/20230927041845.1222080-1-s-vadapalli@ti.com Fixes: 49229238ab47 ("PCI: keystone: Cleanup PHY handling") Signed-off-by: Siddharth Vadapalli Signed-off-by: Krzysztof WilczyƄski Acked-by: Ravi Gunasekaran Signed-off-by: Sasha Levin --- drivers/pci/controller/dwc/pci-keystone.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c index eacdcb0a8771..09379e5f7724 100644 --- a/drivers/pci/controller/dwc/pci-keystone.c +++ b/drivers/pci/controller/dwc/pci-keystone.c @@ -1200,7 +1200,16 @@ static int ks_pcie_probe(struct platform_device *pdev) goto err_link; } + /* Obtain references to the PHYs */ + for (i = 0; i < num_lanes; i++) + phy_pm_runtime_get_sync(ks_pcie->phy[i]); + ret = ks_pcie_enable_phy(ks_pcie); + + /* Release references to the PHYs */ + for (i = 0; i < num_lanes; i++) + phy_pm_runtime_put_sync(ks_pcie->phy[i]); + if (ret) { dev_err(dev, "failed to enable phy\n"); goto err_link; -- 2.43.0