From patchwork Wed Sep 11 15:26:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam via B4 Relay X-Patchwork-Id: 13800856 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 EE435EE49BC for ; Wed, 11 Sep 2024 15:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To: References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version: Subject:Date:From:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7ZyAcRUQaqtAChkw9m5mQ9+4no/Wq6dxOtSVUSV21eE=; b=fp36qdAJn5GHjvyKsBabb0/xma GPTE9boxVgZ2uNjRxRtKHeZZ0GfySkn3dD/OnpExrbgbHTJZVS5OKryEYBpkavFKXfNFfHwh73ceN csR9gHjzQW1/6ESRUQ5PelZLvTjEvPqo3ja1YSPdwA6jkY7w66z9mUEVoVFEOKEij9ObQL+HAoYxw lf8ge71MOcBomgA4dlGysw4zmCKIPNq1MF6FQXmX3LKG1whl+Km3VCcsZHTzJYEtAsCK8ie4Ohr6p qJzkmIb0FarMmwaRymgLJdtT6MYYrzoMQRZCv243vWZkm779/b24hi2LI7Nu9T3COq3lVumHAQ9do GbJ0KiWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1soPUI-0000000ADDO-1buB; Wed, 11 Sep 2024 15:42:34 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1soPEn-0000000A98d-0CUu for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2024 15:26:37 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 64BF45C0708; Wed, 11 Sep 2024 15:26:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 64E70C4CECE; Wed, 11 Sep 2024 15:26:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726068390; bh=uReZcaZmhuTx7hytarOp5sjgfzxmW0949wLV45B1VrU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=GIYBAUeVoEX1hw6zjgqoahdTiEfNFUKIyiun5/iQp5ZPS+5Tbsso0tc6LPz8b5BKN L8ERI7vtpdAezTT4zGgmepXPvY0+ouX7mfNNIS8iaPZfazm/lQ/ZUqJjtXBFpJkxSu JIr/Rrs2hVmxZJ9Md6KLUDRbi43jia7OKbIb2lg2u8YJhfwBOFaeEqDXWVZfXdIL8m gxNNyc+bM/5J2ERTKivtrBtorxIEYkfUjbIeiIg/MdrTPoK5uxzIzMSq+kRwFG9YOO 3wsbnxhcn56syKmdhxpxs7pfYMBASFBiKTO7rbpyI8w468HfnqgO9NGDTQvDLYMsF7 Rv1adgLj/IaQg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C03FEE57C0; Wed, 11 Sep 2024 15:26:30 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Wed, 11 Sep 2024 20:56:27 +0530 Subject: [PATCH v7 2/4] PCI: dwc: Always cache the maximum link speed value in dw_pcie::max_link_speed MIME-Version: 1.0 Message-Id: <20240911-pci-qcom-gen4-stability-v7-2-743f5c1fd027@linaro.org> References: <20240911-pci-qcom-gen4-stability-v7-0-743f5c1fd027@linaro.org> In-Reply-To: <20240911-pci-qcom-gen4-stability-v7-0-743f5c1fd027@linaro.org> To: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Jingoo Han , Chuanhua Lei , Marek Vasut , Yoshihiro Shimoda , Pratyush Anand , Thierry Reding , Jonathan Hunter Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, abel.vesa@linaro.org, johan+linaro@kernel.org, Shashank Babu Chinta Venkata , linux-tegra@vger.kernel.org, Manivannan Sadhasivam , Frank Li X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2572; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=/m0D3VhQoRtBu+iAIP7ukQZibxzd0TZMHoHNWuugw4g=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBm4bajwE+7XsT98PbZu6z/xKeE6l7lneaPs9NDW rVKZjBfGwqJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZuG2owAKCRBVnxHm/pHO 9eTjB/48I+vJMP8fVdR5OJwBQB3TnmPP51CESri1oOcsInJjuPdK6gxd4iKS6FgxvO6cjF/HM8U SfwE3I1N3dSBGcSWG4HpCxZ9h1AsJ4dDp7mrCshz8irKiLWFD0lj6NK7+FCkzbHH3Un7NvffRQ3 PloYijxoskNDj8JBowMS7yqoz8R+SkBUAC3hEC6wnT3zNEkx0hPh0b9eEzxmlT09fUui6QqEGdX tEXcqf2zc1svKgOnNtpriF1X6XWzW4soohgU0D2M4xo0lXwQ9AnMt6ZcA5+TFMoBC+iqJdWlsFX 4bdOTCcomHA7okIUxUAHP03ZGBO+ZlIcmi7gUVPbcGDbU5Lh X-Developer-Key: i=manivannan.sadhasivam@linaro.org; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@linaro.org/default with auth_id=185 X-Original-From: Manivannan Sadhasivam X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240911_082633_313520_87EB6F0F X-CRM114-Status: GOOD ( 16.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: manivannan.sadhasivam@linaro.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Manivannan Sadhasivam Currently, dw_pcie::max_link_speed has a valid value only if the controller driver restricts the maximum link speed in the driver or if the platform does so in the devicetree using the 'max-link-speed' property. But having the maximum supported link speed of the platform would be helpful for the vendor drivers to configure any link specific settings. So in the case of non-valid value in dw_pcie::max_link_speed, just cache the hardware default value from Link Capability register. While at it, let's also remove the 'max_link_speed' argument to the dw_pcie_link_set_max_speed() function since the value can be retrieved within the function. Reviewed-by: Johan Hovold Reviewed-by: Frank Li Tested-by: Johan Hovold Signed-off-by: Manivannan Sadhasivam --- drivers/pci/controller/dwc/pcie-designware.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c index 86c49ba097c6..7c4e316eb749 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c @@ -687,16 +687,27 @@ void dw_pcie_upconfig_setup(struct dw_pcie *pci) } EXPORT_SYMBOL_GPL(dw_pcie_upconfig_setup); -static void dw_pcie_link_set_max_speed(struct dw_pcie *pci, u32 max_link_speed) +static void dw_pcie_link_set_max_speed(struct dw_pcie *pci) { u32 cap, ctrl2, link_speed; u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); cap = dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCAP); + + /* + * Even if the platform doesn't want to limit the maximum link speed, + * just cache the hardware default value so that the vendor drivers can + * use it to do any link specific configuration. + */ + if (pci->max_link_speed < 1) { + pci->max_link_speed = FIELD_GET(PCI_EXP_LNKCAP_SLS, cap); + return; + } + ctrl2 = dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCTL2); ctrl2 &= ~PCI_EXP_LNKCTL2_TLS; - switch (pcie_link_speed[max_link_speed]) { + switch (pcie_link_speed[pci->max_link_speed]) { case PCIE_SPEED_2_5GT: link_speed = PCI_EXP_LNKCTL2_TLS_2_5GT; break; @@ -1058,8 +1069,7 @@ void dw_pcie_setup(struct dw_pcie *pci) { u32 val; - if (pci->max_link_speed > 0) - dw_pcie_link_set_max_speed(pci, pci->max_link_speed); + dw_pcie_link_set_max_speed(pci); /* Configure Gen1 N_FTS */ if (pci->n_fts[0]) {