From nobody Sat Nov 30 03:49:52 2024 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 CA4A21AB6F0; Wed, 11 Sep 2024 15:26:30 +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=1726068390; cv=none; b=dV/AJLTf+kYsmDvMvgMAV0qAfKn2wwaiOIPhcei0N7u2NWN1xFWggW1+VrLK5x/Fx37PXl6xMypnLbCoC9PLPyF809ID7aPmOHjkzRkbh/YBr7YIva3KwxuQkwFPZgHvBS0y8ke6Tem5g742wV+FqEiFIXPxw+GQYbio5PVs7yk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726068390; c=relaxed/simple; bh=kQrQIGlp9P0I9cADTEf4NhVSLqIlYDgAuwGdwynW+tU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LBl9pb/GLR63UPqXo7TnS14+31y27CQZw9NOYckVn8LIxSL0DVYJsMP54QkC8Fr0AgH7cV5AeYz+A/d3HDca0em3qH67BcGoBF0IwcBZNUrB3auoql1kmVmNB8xOxj5lcoo2BpRBRdDDBNaXHIL/w5NZn5LCSMfibzojJ/X8h0o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W7DCHzdG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="W7DCHzdG" Received: by smtp.kernel.org (Postfix) with ESMTPS id 5DD90C4CEC7; 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=kQrQIGlp9P0I9cADTEf4NhVSLqIlYDgAuwGdwynW+tU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=W7DCHzdG7kU7EZDw5UiLmbet6etFB/U1kPVxBvgnGJ4tOFui3HJCvrKgGdF6B46Mw Aqi/twoOu+p7cMR2VKyChIPKrrf6yEYR4xeJ8x/Q/CIzaSiqvxmAt03JJiWjBC5Efb YSNPFQZTxIxGSeXuByQs5vjIWP3hDzlaPjRLomlT86IAxzCCfXMBAoYOc8/NkKBCNI qZ45scSzvuv6Nb53rJUcHWINgdpqE438VqkFMFJSHXiugXnXg1kocN8Br6iTOyI/UZ Xyxg+cfACid22kAR7oRz2jbipI8KNmpRAGfTWDUWaSaliqh6PNYY1big/ZDlYgwZP6 Mrav+uvRcfVhg== 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 47A79EE49BC; Wed, 11 Sep 2024 15:26:30 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Wed, 11 Sep 2024 20:56:26 +0530 Subject: [PATCH v7 1/4] PCI: dwc: Rename 'dw_pcie::link_gen' to 'dw_pcie::max_link_speed' Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240911-pci-qcom-gen4-stability-v7-1-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=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=6424; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=pHiIcSf3kInKQ5/z8n45Gc3n1zKqo2wV2tSRaf1jaDo=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBm4baiO+pEdQnUJk8edfK/TGxqttK0GbgioFsFQ IwhN1LLdwaJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZuG2ogAKCRBVnxHm/pHO 9blYB/9dXlJhWHJu50VYK5uG88wQfLU+envnlEHfLs1Yo+ll2bhK+mpku56Derk/+N1PObNnxWB ZD0HlR+52Hezo+7Rtqr6Q8imFUZaC3YuOb+WE+Ho80rHwqMphYCUzQ9CkoL89cJ1gKJq+pYOswX lh0Ea0MyqZeHLCrpfqRSeDoCVzf73tpoV1Qi3u773iQzE0ctDHqYjQuszkH9hUqDHXfSSO+tVAI vXa2nQK6A2n5ZJDMH+/hXIvUrPlXr+pucRh8RI8p1mA0GRql8GNL4h3Hsh2lLD7/BWMbJzQJoxS kU6GTDVEEkCXQqMJRABPdb6qMs5jnDIDWwYiUDmf8nWsgr5l 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 Reply-To: manivannan.sadhasivam@linaro.org From: Manivannan Sadhasivam 'link_gen' field is now holding the maximum supported link speed set either by the controller driver or by DT through 'max-link-speed' property. But the name 'link_gen' sounds like the negotiated link speed of the PCIe link. So let's rename it to 'max_link_speed' to make it clear that it holds the maximum supported link speed of the controller. NOTE: For the sake of clarity, I've used 'max_link_speed' instead of 'max_link_gen'. Also the link speed and link generation values map 1:1. Reviewed-by: Frank Li Reviewed-by: Johan Hovold Tested-by: Johan Hovold Signed-off-by: Manivannan Sadhasivam --- drivers/pci/controller/dwc/pci-imx6.c | 8 ++++---- drivers/pci/controller/dwc/pcie-designware.c | 12 ++++++------ drivers/pci/controller/dwc/pcie-designware.h | 2 +- drivers/pci/controller/dwc/pcie-intel-gw.c | 4 ++-- drivers/pci/controller/dwc/pcie-rcar-gen4.c | 6 +++--- drivers/pci/controller/dwc/pcie-spear13xx.c | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller= /dwc/pci-imx6.c index 964d67756eb2..ef12a4f31740 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -847,12 +847,12 @@ static int imx6_pcie_start_link(struct dw_pcie *pci) if (ret) goto err_reset_phy; =20 - if (pci->link_gen > 1) { + if (pci->max_link_speed > 1) { /* Allow faster modes after the link is up */ dw_pcie_dbi_ro_wr_en(pci); tmp =3D dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCAP); tmp &=3D ~PCI_EXP_LNKCAP_SLS; - tmp |=3D pci->link_gen; + tmp |=3D pci->max_link_speed; dw_pcie_writel_dbi(pci, offset + PCI_EXP_LNKCAP, tmp); =20 /* @@ -1386,8 +1386,8 @@ static int imx6_pcie_probe(struct platform_device *pd= ev) imx6_pcie->tx_swing_low =3D 127; =20 /* Limit link speed */ - pci->link_gen =3D 1; - of_property_read_u32(node, "fsl,max-link-speed", &pci->link_gen); + pci->max_link_speed =3D 1; + of_property_read_u32(node, "fsl,max-link-speed", &pci->max_link_speed); =20 imx6_pcie->vpcie =3D devm_regulator_get_optional(&pdev->dev, "vpcie"); if (IS_ERR(imx6_pcie->vpcie)) { diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/con= troller/dwc/pcie-designware.c index 1b5aba1f0c92..86c49ba097c6 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c @@ -166,8 +166,8 @@ int dw_pcie_get_resources(struct dw_pcie *pci) return ret; } =20 - if (pci->link_gen < 1) - pci->link_gen =3D of_pci_get_max_link_speed(np); + if (pci->max_link_speed < 1) + pci->max_link_speed =3D of_pci_get_max_link_speed(np); =20 of_property_read_u32(np, "num-lanes", &pci->num_lanes); =20 @@ -687,7 +687,7 @@ void dw_pcie_upconfig_setup(struct dw_pcie *pci) } EXPORT_SYMBOL_GPL(dw_pcie_upconfig_setup); =20 -static void dw_pcie_link_set_max_speed(struct dw_pcie *pci, u32 link_gen) +static void dw_pcie_link_set_max_speed(struct dw_pcie *pci, u32 max_link_s= peed) { u32 cap, ctrl2, link_speed; u8 offset =3D dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); @@ -696,7 +696,7 @@ static void dw_pcie_link_set_max_speed(struct dw_pcie *= pci, u32 link_gen) ctrl2 =3D dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCTL2); ctrl2 &=3D ~PCI_EXP_LNKCTL2_TLS; =20 - switch (pcie_link_speed[link_gen]) { + switch (pcie_link_speed[max_link_speed]) { case PCIE_SPEED_2_5GT: link_speed =3D PCI_EXP_LNKCTL2_TLS_2_5GT; break; @@ -1058,8 +1058,8 @@ void dw_pcie_setup(struct dw_pcie *pci) { u32 val; =20 - if (pci->link_gen > 0) - dw_pcie_link_set_max_speed(pci, pci->link_gen); + if (pci->max_link_speed > 0) + dw_pcie_link_set_max_speed(pci, pci->max_link_speed); =20 /* Configure Gen1 N_FTS */ if (pci->n_fts[0]) { diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/con= troller/dwc/pcie-designware.h index 53c4c8f399c8..22765564f301 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -421,7 +421,7 @@ struct dw_pcie { u32 type; unsigned long caps; int num_lanes; - int link_gen; + int max_link_speed; u8 n_fts[2]; struct dw_edma_chip edma; struct clk_bulk_data app_clks[DW_PCIE_NUM_APP_CLKS]; diff --git a/drivers/pci/controller/dwc/pcie-intel-gw.c b/drivers/pci/contr= oller/dwc/pcie-intel-gw.c index acbe4f6d3291..676d2aba4fbd 100644 --- a/drivers/pci/controller/dwc/pcie-intel-gw.c +++ b/drivers/pci/controller/dwc/pcie-intel-gw.c @@ -132,7 +132,7 @@ static void intel_pcie_link_setup(struct intel_pcie *pc= ie) =20 static void intel_pcie_init_n_fts(struct dw_pcie *pci) { - switch (pci->link_gen) { + switch (pci->max_link_speed) { case 3: pci->n_fts[1] =3D PORT_AFR_N_FTS_GEN3; break; @@ -252,7 +252,7 @@ static int intel_pcie_wait_l2(struct intel_pcie *pcie) int ret; struct dw_pcie *pci =3D &pcie->pci; =20 - if (pci->link_gen < 3) + if (pci->max_link_speed < 3) return 0; =20 /* Send PME_TURN_OFF message */ diff --git a/drivers/pci/controller/dwc/pcie-rcar-gen4.c b/drivers/pci/cont= roller/dwc/pcie-rcar-gen4.c index f0f3ebd1a033..00ad4832f2cf 100644 --- a/drivers/pci/controller/dwc/pcie-rcar-gen4.c +++ b/drivers/pci/controller/dwc/pcie-rcar-gen4.c @@ -141,10 +141,10 @@ static int rcar_gen4_pcie_start_link(struct dw_pcie *= dw) } =20 /* - * Require direct speed change with retrying here if the link_gen is - * PCIe Gen2 or higher. + * Require direct speed change with retrying here if the max_link_speed + * is PCIe Gen2 or higher. */ - changes =3D min_not_zero(dw->link_gen, RCAR_MAX_LINK_SPEED) - 1; + changes =3D min_not_zero(dw->max_link_speed, RCAR_MAX_LINK_SPEED) - 1; =20 /* * Since dw_pcie_setup_rc() sets it once, PCIe Gen2 will be trained. diff --git a/drivers/pci/controller/dwc/pcie-spear13xx.c b/drivers/pci/cont= roller/dwc/pcie-spear13xx.c index 201dced209f0..ff986ced56b2 100644 --- a/drivers/pci/controller/dwc/pcie-spear13xx.c +++ b/drivers/pci/controller/dwc/pcie-spear13xx.c @@ -233,7 +233,7 @@ static int spear13xx_pcie_probe(struct platform_device = *pdev) } =20 if (of_property_read_bool(np, "st,pcie-is-gen1")) - pci->link_gen =3D 1; + pci->max_link_speed =3D 1; =20 platform_set_drvdata(pdev, spear13xx_pcie); =20 --=20 2.25.1 From nobody Sat Nov 30 03:49:52 2024 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 CA4F31AB6FE; Wed, 11 Sep 2024 15:26:30 +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=1726068390; cv=none; b=HfZ9EOWW/VH5Pu6Sg+JnRA9u2/QUAUR+HwOE+9yNgOQU5T0XNboYykXA+AMxVT140Yjwx/SE2hgvKPcGchI92PCfq2vdiQ4IBIYvujEOD63TvYyZSzBCyOJKc/A3b1RQ1KA4kMGh8WbzDb2KbBsnYXiiTW0KiQ47GCSdegcA6BM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726068390; c=relaxed/simple; bh=uReZcaZmhuTx7hytarOp5sjgfzxmW0949wLV45B1VrU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dQAY1QxtczLJPZHuOvCmWwqoJoo39eSN/xb+UwxIITJjkS3jdCC5FLyDTka6n5e5a7IP8hH+JvmNCsRsk/X9Cp74b0KUB0NBEwWCjlFFHGtsRZUraAOUK7ZEKOCxChlmHuxyXf4dBzFnRe09VVX/q/qNyAWI69CTUj7ht5Soh18= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GIYBAUeV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GIYBAUeV" 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=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 Reply-To: manivannan.sadhasivam@linaro.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/con= troller/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); =20 -static void dw_pcie_link_set_max_speed(struct dw_pcie *pci, u32 max_link_s= peed) +static void dw_pcie_link_set_max_speed(struct dw_pcie *pci) { u32 cap, ctrl2, link_speed; u8 offset =3D dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); =20 cap =3D 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 =3D FIELD_GET(PCI_EXP_LNKCAP_SLS, cap); + return; + } + ctrl2 =3D dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCTL2); ctrl2 &=3D ~PCI_EXP_LNKCTL2_TLS; =20 - switch (pcie_link_speed[max_link_speed]) { + switch (pcie_link_speed[pci->max_link_speed]) { case PCIE_SPEED_2_5GT: link_speed =3D PCI_EXP_LNKCTL2_TLS_2_5GT; break; @@ -1058,8 +1069,7 @@ void dw_pcie_setup(struct dw_pcie *pci) { u32 val; =20 - if (pci->max_link_speed > 0) - dw_pcie_link_set_max_speed(pci, pci->max_link_speed); + dw_pcie_link_set_max_speed(pci); =20 /* Configure Gen1 N_FTS */ if (pci->n_fts[0]) { --=20 2.25.1 From nobody Sat Nov 30 03:49:52 2024 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 E545A1AAE01; Wed, 11 Sep 2024 15:26:30 +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=1726068391; cv=none; b=mw57H1QIgs6gw1l+W9hIBppMJDblBOmfMa8ULisUuE1kVUc7IKXe6HvFlGPFhG5o96nyU73O3MO7pEXW3E1wamToonE7eitvsBK9nKQkp/o6mx0vrIMDlHqfzSJKn3ThQwGi94j3mYdPc4Q2TJ2+QB3kU3Kov1D7SzX6pa9ewCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726068391; c=relaxed/simple; bh=8g9CetueQMca5kqUY57tyDJLRYWCZlLEjXZ/ksj4xqk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gSm4h3amP/I3bOX/H3LOgVW/uCTfBDf3yLlkL0THVWpsVcYLM3+LjpfP9eeTeOqmMzdIdnTx12IC8N1rdVCdlVK8OtuSRJGEvxXnr2JiA7i/tGlKbcC9NNXfAwLI24tCovAJPahKYxO6scIMqKVTvvYkmw5+NapchIL4XkbNJEo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M0gl2vju; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M0gl2vju" Received: by smtp.kernel.org (Postfix) with ESMTPS id 7B9C5C4CECF; 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=8g9CetueQMca5kqUY57tyDJLRYWCZlLEjXZ/ksj4xqk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=M0gl2vjudZRKSDnAmOKdhEGXzqrNK0VhreYXIf3RlNDMmVP6+vsoFgQBf7hXK3Jh3 OGuZtEzrk0H5OkHN4PnWxWICNQNW2T8ER4OQDeSjQqiMcr2XbKYBUUFAdTbz15sfVW rbiFpE60IKr28/SVj7o/36jfFvoli6HCBHDz2eSbocWolwrA/ih03u1M4/sa0vPNZU RezdFrun4SqdfLHDNmxKVoGyq6igNct1xNPnA6zg+K+MKG8hvIfq2juB3MTz2O45Qy MW6/7A+H/Qodf+v+MKftyt5CYWioC54Kci80DBrEBxuVBkMhj/LZ4Jj0VAv5N4vacR q/dk98y9LvRfQ== 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 6D9E3EE57C2; Wed, 11 Sep 2024 15:26:30 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Wed, 11 Sep 2024 20:56:28 +0530 Subject: [PATCH v7 3/4] PCI: qcom: Add equalization settings for 16.0 GT/s Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240911-pci-qcom-gen4-stability-v7-3-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=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 X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=11360; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=oLENcLDkZ9Xxlyw7bSBn//6Zm5hvtwW9ikXnMa+bJ+w=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBm4baj8l761qQDkQGUsQzfial69zmXPxPs2BPO2 dabc+AlT16JATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZuG2owAKCRBVnxHm/pHO 9dwWB/94sV/tPUWS+NN1J78jOt2I2aSKWlmmhlkQCA9NBh+yHOpKqSBvMLn/3SD6/wpJ5NXo4Pw Nlt3NriovrhbGTzUZNJNb1Jn+sAzUW2G888VWBgpxShEpQ8dVFZcVqdCkTvE3ysXbrDZsbqXFsA B7f5m4bJ6JfMtfHH9HeSdQNESCRmFxBjbdpItGfSLPb0iK+pb2nG+uemjqMejd/J1hPLjzUGQb8 GTmO5IJBXoeefbcu2d/MDobERUkz6jOomJxLZq3cpviDjpZFfiLHs9Slk96IKdLGj8EtdDRl+TZ EzSf20r1/3dVESylkfhhRYflEoua5sXYYG0zZZ8+3nu1pFk1 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 Reply-To: manivannan.sadhasivam@linaro.org From: Shashank Babu Chinta Venkata During high data transmission rates such as 16.0 GT/s, there is an increased risk of signal loss due to poor channel quality and interference. This can impact receiver's ability to capture signals accurately. Hence, signal compensation is achieved through appropriate lane equalization settings at both transmitter and receiver. This will result in increased PCIe signal strength. While at it, let's also modify the pcie-tegra194 driver to make use of the common GEN3_EQ_CONTROL_OFF definitions in pcie-designware.h. Signed-off-by: Shashank Babu Chinta Venkata Reviewed-by: Manivannan Sadhasivam [mani: dropped the code refactoring and minor changes] Tested-by: Johan Hovold Signed-off-by: Manivannan Sadhasivam Reviewed-by: Johan Hovold --- MAINTAINERS | 4 ++- drivers/pci/controller/dwc/Kconfig | 5 +++ drivers/pci/controller/dwc/Makefile | 1 + drivers/pci/controller/dwc/pcie-designware.h | 13 ++++++++ drivers/pci/controller/dwc/pcie-qcom-common.c | 47 +++++++++++++++++++++++= ++++ drivers/pci/controller/dwc/pcie-qcom-common.h | 13 ++++++++ drivers/pci/controller/dwc/pcie-qcom-ep.c | 4 +++ drivers/pci/controller/dwc/pcie-qcom.c | 4 +++ drivers/pci/controller/dwc/pcie-tegra194.c | 19 ++++------- 9 files changed, 97 insertions(+), 13 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index f328373463b0..3cfb6068b9f0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2728,7 +2728,7 @@ F: drivers/iommu/msm* F: drivers/mfd/ssbi.c F: drivers/mmc/host/mmci_qcom* F: drivers/mmc/host/sdhci-msm.c -F: drivers/pci/controller/dwc/pcie-qcom.c +F: drivers/pci/controller/dwc/pcie-qcom* F: drivers/phy/qualcomm/ F: drivers/power/*/msm* F: drivers/reset/reset-qcom-* @@ -17757,6 +17757,7 @@ M: Manivannan Sadhasivam L: linux-pci@vger.kernel.org L: linux-arm-msm@vger.kernel.org S: Maintained +F: drivers/pci/controller/dwc/pcie-qcom-common.c F: drivers/pci/controller/dwc/pcie-qcom.c =20 PCIE DRIVER FOR ROCKCHIP @@ -17793,6 +17794,7 @@ L: linux-pci@vger.kernel.org L: linux-arm-msm@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/pci/qcom,pcie-ep.yaml +F: drivers/pci/controller/dwc/pcie-qcom-common.c F: drivers/pci/controller/dwc/pcie-qcom-ep.c =20 PCMCIA SUBSYSTEM diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dw= c/Kconfig index 4c38181acffa..b6d6778b0698 100644 --- a/drivers/pci/controller/dwc/Kconfig +++ b/drivers/pci/controller/dwc/Kconfig @@ -265,12 +265,16 @@ config PCIE_DW_PLAT_EP order to enable device-specific features PCI_DW_PLAT_EP must be selected. =20 +config PCIE_QCOM_COMMON + bool + config PCIE_QCOM bool "Qualcomm PCIe controller (host mode)" depends on OF && (ARCH_QCOM || COMPILE_TEST) depends on PCI_MSI select PCIE_DW_HOST select CRC8 + select PCIE_QCOM_COMMON help Say Y here to enable PCIe controller support on Qualcomm SoCs. The PCIe controller uses the DesignWare core plus Qualcomm-specific @@ -281,6 +285,7 @@ config PCIE_QCOM_EP depends on OF && (ARCH_QCOM || COMPILE_TEST) depends on PCI_ENDPOINT select PCIE_DW_EP + select PCIE_QCOM_COMMON help Say Y here to enable support for the PCIe controllers on Qualcomm SoCs to work in endpoint mode. The PCIe controller uses the DesignWare core diff --git a/drivers/pci/controller/dwc/Makefile b/drivers/pci/controller/d= wc/Makefile index ec215b3d6191..a8308d9ea986 100644 --- a/drivers/pci/controller/dwc/Makefile +++ b/drivers/pci/controller/dwc/Makefile @@ -12,6 +12,7 @@ obj-$(CONFIG_PCIE_SPEAR13XX) +=3D pcie-spear13xx.o obj-$(CONFIG_PCI_KEYSTONE) +=3D pci-keystone.o obj-$(CONFIG_PCI_LAYERSCAPE) +=3D pci-layerscape.o obj-$(CONFIG_PCI_LAYERSCAPE_EP) +=3D pci-layerscape-ep.o +obj-$(CONFIG_PCIE_QCOM_COMMON) +=3D pcie-qcom-common.o obj-$(CONFIG_PCIE_QCOM) +=3D pcie-qcom.o obj-$(CONFIG_PCIE_QCOM_EP) +=3D pcie-qcom-ep.o obj-$(CONFIG_PCIE_ARMADA_8K) +=3D pcie-armada8k.o diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/con= troller/dwc/pcie-designware.h index 22765564f301..7e3a9632fbe8 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -125,6 +125,19 @@ #define GEN3_RELATED_OFF_GEN3_EQ_DISABLE BIT(16) #define GEN3_RELATED_OFF_RATE_SHADOW_SEL_SHIFT 24 #define GEN3_RELATED_OFF_RATE_SHADOW_SEL_MASK GENMASK(25, 24) +#define GEN3_RELATED_OFF_RATE_SHADOW_SEL_16_0GT 0x1 + +#define GEN3_EQ_CONTROL_OFF 0x8A8 +#define GEN3_EQ_CONTROL_OFF_FB_MODE GENMASK(3, 0) +#define GEN3_EQ_CONTROL_OFF_PHASE23_EXIT_MODE BIT(4) +#define GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC GENMASK(23, 8) +#define GEN3_EQ_CONTROL_OFF_FOM_INC_INITIAL_EVAL BIT(24) + +#define GEN3_EQ_FB_MODE_DIR_CHANGE_OFF 0x8AC +#define GEN3_EQ_FMDC_T_MIN_PHASE23 GENMASK(4, 0) +#define GEN3_EQ_FMDC_N_EVALS GENMASK(9, 5) +#define GEN3_EQ_FMDC_MAX_PRE_CUSROR_DELTA GENMASK(13, 10) +#define GEN3_EQ_FMDC_MAX_POST_CUSROR_DELTA GENMASK(17, 14) =20 #define PCIE_PORT_MULTI_LANE_CTRL 0x8C0 #define PORT_MLTI_UPCFG_SUPPORT BIT(7) diff --git a/drivers/pci/controller/dwc/pcie-qcom-common.c b/drivers/pci/co= ntroller/dwc/pcie-qcom-common.c new file mode 100644 index 000000000000..596a35449de1 --- /dev/null +++ b/drivers/pci/controller/dwc/pcie-qcom-common.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#include + +#include "pcie-designware.h" +#include "pcie-qcom-common.h" + +void qcom_pcie_common_set_16gt_equalization(struct dw_pcie *pci) +{ + u32 reg; + + /* + * GEN3_RELATED_OFF register is repurposed to apply equalization + * settings at various data transmission rates through registers namely + * GEN3_EQ_*. The RATE_SHADOW_SEL bit field of GEN3_RELATED_OFF + * determines the data rate for which these equalization settings are + * applied. + */ + reg =3D dw_pcie_readl_dbi(pci, GEN3_RELATED_OFF); + reg &=3D ~GEN3_RELATED_OFF_GEN3_ZRXDC_NONCOMPL; + reg &=3D ~GEN3_RELATED_OFF_RATE_SHADOW_SEL_MASK; + reg |=3D FIELD_PREP(GEN3_RELATED_OFF_RATE_SHADOW_SEL_MASK, + GEN3_RELATED_OFF_RATE_SHADOW_SEL_16_0GT); + dw_pcie_writel_dbi(pci, GEN3_RELATED_OFF, reg); + + reg =3D dw_pcie_readl_dbi(pci, GEN3_EQ_FB_MODE_DIR_CHANGE_OFF); + reg &=3D ~(GEN3_EQ_FMDC_T_MIN_PHASE23 | + GEN3_EQ_FMDC_N_EVALS | + GEN3_EQ_FMDC_MAX_PRE_CUSROR_DELTA | + GEN3_EQ_FMDC_MAX_POST_CUSROR_DELTA); + reg |=3D FIELD_PREP(GEN3_EQ_FMDC_T_MIN_PHASE23, 0x1) | + FIELD_PREP(GEN3_EQ_FMDC_N_EVALS, 0xd) | + FIELD_PREP(GEN3_EQ_FMDC_MAX_PRE_CUSROR_DELTA, 0x5) | + FIELD_PREP(GEN3_EQ_FMDC_MAX_POST_CUSROR_DELTA, 0x5); + dw_pcie_writel_dbi(pci, GEN3_EQ_FB_MODE_DIR_CHANGE_OFF, reg); + + reg =3D dw_pcie_readl_dbi(pci, GEN3_EQ_CONTROL_OFF); + reg &=3D ~(GEN3_EQ_CONTROL_OFF_FB_MODE | + GEN3_EQ_CONTROL_OFF_PHASE23_EXIT_MODE | + GEN3_EQ_CONTROL_OFF_FOM_INC_INITIAL_EVAL | + GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC); + dw_pcie_writel_dbi(pci, GEN3_EQ_CONTROL_OFF, reg); +} +EXPORT_SYMBOL_GPL(qcom_pcie_common_set_16gt_equalization); diff --git a/drivers/pci/controller/dwc/pcie-qcom-common.h b/drivers/pci/co= ntroller/dwc/pcie-qcom-common.h new file mode 100644 index 000000000000..536387e02e29 --- /dev/null +++ b/drivers/pci/controller/dwc/pcie-qcom-common.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#ifndef _PCIE_QCOM_COMMON_H +#define _PCIE_QCOM_COMMON_H + +struct dw_pcie; + +void qcom_pcie_common_set_16gt_equalization(struct dw_pcie *pci); + +#endif diff --git a/drivers/pci/controller/dwc/pcie-qcom-ep.c b/drivers/pci/contro= ller/dwc/pcie-qcom-ep.c index 236229f66c80..b091432d9f90 100644 --- a/drivers/pci/controller/dwc/pcie-qcom-ep.c +++ b/drivers/pci/controller/dwc/pcie-qcom-ep.c @@ -25,6 +25,7 @@ =20 #include "../../pci.h" #include "pcie-designware.h" +#include "pcie-qcom-common.h" =20 /* PARF registers */ #define PARF_SYS_CTRL 0x00 @@ -486,6 +487,9 @@ static int qcom_pcie_perst_deassert(struct dw_pcie *pci) goto err_disable_resources; } =20 + if (pcie_link_speed[pci->max_link_speed] =3D=3D PCIE_SPEED_16_0GT) + qcom_pcie_common_set_16gt_equalization(pci); + /* * The physical address of the MMIO region which is exposed as the BAR * should be written to MHI BASE registers. diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controlle= r/dwc/pcie-qcom.c index 0180edf3310e..6f7957c4adcc 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -35,6 +35,7 @@ =20 #include "../../pci.h" #include "pcie-designware.h" +#include "pcie-qcom-common.h" =20 /* PARF registers */ #define PARF_SYS_CTRL 0x00 @@ -283,6 +284,9 @@ static int qcom_pcie_start_link(struct dw_pcie *pci) { struct qcom_pcie *pcie =3D to_qcom_pcie(pci); =20 + if (pcie_link_speed[pci->max_link_speed] =3D=3D PCIE_SPEED_16_0GT) + qcom_pcie_common_set_16gt_equalization(pci); + /* Enable Link Training state machine */ if (pcie->cfg->ops->ltssm_enable) pcie->cfg->ops->ltssm_enable(pcie); diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/contr= oller/dwc/pcie-tegra194.c index 4bf7b433417a..6e03e14151d6 100644 --- a/drivers/pci/controller/dwc/pcie-tegra194.c +++ b/drivers/pci/controller/dwc/pcie-tegra194.c @@ -177,11 +177,6 @@ #define N_FTS_VAL 52 #define FTS_VAL 52 =20 -#define GEN3_EQ_CONTROL_OFF 0x8a8 -#define GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC_SHIFT 8 -#define GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC_MASK GENMASK(23, 8) -#define GEN3_EQ_CONTROL_OFF_FB_MODE_MASK GENMASK(3, 0) - #define PORT_LOGIC_AMBA_ERROR_RESPONSE_DEFAULT 0x8D0 #define AMBA_ERROR_RESPONSE_CRS_SHIFT 3 #define AMBA_ERROR_RESPONSE_CRS_MASK GENMASK(1, 0) @@ -861,9 +856,9 @@ static void config_gen3_gen4_eq_presets(struct tegra_pc= ie_dw *pcie) dw_pcie_writel_dbi(pci, GEN3_RELATED_OFF, val); =20 val =3D dw_pcie_readl_dbi(pci, GEN3_EQ_CONTROL_OFF); - val &=3D ~GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC_MASK; - val |=3D (0x3ff << GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC_SHIFT); - val &=3D ~GEN3_EQ_CONTROL_OFF_FB_MODE_MASK; + val &=3D ~GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC; + val |=3D FIELD_PREP(GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC, 0x3ff); + val &=3D ~GEN3_EQ_CONTROL_OFF_FB_MODE; dw_pcie_writel_dbi(pci, GEN3_EQ_CONTROL_OFF, val); =20 val =3D dw_pcie_readl_dbi(pci, GEN3_RELATED_OFF); @@ -872,10 +867,10 @@ static void config_gen3_gen4_eq_presets(struct tegra_= pcie_dw *pcie) dw_pcie_writel_dbi(pci, GEN3_RELATED_OFF, val); =20 val =3D dw_pcie_readl_dbi(pci, GEN3_EQ_CONTROL_OFF); - val &=3D ~GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC_MASK; - val |=3D (pcie->of_data->gen4_preset_vec << - GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC_SHIFT); - val &=3D ~GEN3_EQ_CONTROL_OFF_FB_MODE_MASK; + val &=3D ~GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC; + val |=3D FIELD_PREP(GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC, + pcie->of_data->gen4_preset_vec); + val &=3D ~GEN3_EQ_CONTROL_OFF_FB_MODE; dw_pcie_writel_dbi(pci, GEN3_EQ_CONTROL_OFF, val); =20 val =3D dw_pcie_readl_dbi(pci, GEN3_RELATED_OFF); --=20 2.25.1 From nobody Sat Nov 30 03:49:52 2024 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 E54B41AB6FC; Wed, 11 Sep 2024 15:26:30 +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=1726068391; cv=none; b=Yrebt/BSfRiVkxXOghIzUpl5g0X5D/yjgQ8c5TvQFdFz6Q9shWwUrngEYLNoszT37+E5jwd5ofo3fjAPAOGxAow4DQG5haC5hE5sz0BroIolF2fQsjz69FR+wQZ6/dE6dIIQldmwJL5XDYztZ2GOpEK/UxfGzvWswz0Ho0o3Ucw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726068391; c=relaxed/simple; bh=Fs0tboqjW+PVHnmBXKKyJdbjGTmxaZZIL6+StRrdsRc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bI6AC3iDyxwaXdP8m4RJBPTXMS4n9MJLsOrBj86/hLrgUMAZWoHcLOcodr2D7LUuESLCNLayzrFQgOfTxUnJPnc48fpSmfdG2ABAl2bbE0n7vdEX4rHJI9URQaQnrjSoWGcAkKs9fMXYVIUAKlWFr2wUXiNrUxINaz/xdVYw2TI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f24PDyL+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="f24PDyL+" Received: by smtp.kernel.org (Postfix) with ESMTPS id 8FFBEC4CED4; 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=Fs0tboqjW+PVHnmBXKKyJdbjGTmxaZZIL6+StRrdsRc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=f24PDyL+zk9rQlLKThjjyQPvssGwnv3+9oCw/KlEAt8DauIOUh3l/CLTcfTnFZrw8 8Gn6VLX3Axial3Cw6vDRjq1mQpaNNdaz65X2Jkmkv//2ej/0P1yN4QlpngkL9F/NSe ijvVKnMA9J6AcJloeRufKf/my+5LuGQyk6O4DX7vD2Cpwq2pNsxjuZGiQhQtFM3i+2 apV4RXSTVQbHVDCTKJybIfFeq73o+9nteSwQq0qx7GXuf8xBKf0AwA4+DpX6UX5dB5 W0Cu0murF5Wy8JNVqEAqhlp0qwKyPcibMLvXfaJFWRmT97hiWXmcd9qVHMont9ML/1 g5BAiySUUr0tg== 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 82ABBEE57C1; Wed, 11 Sep 2024 15:26:30 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Wed, 11 Sep 2024 20:56:29 +0530 Subject: [PATCH v7 4/4] PCI: qcom: Add RX lane margining settings for 16.0 GT/s Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240911-pci-qcom-gen4-stability-v7-4-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=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 X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=5602; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=uwqmrdhg0JidfcFTkMSZUh/KB9Ztn0wyucNCKAvoYRU=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBm4bajR3CQi0dab9hbLx+zgTmNgaDe6uJXdKNhw IW7Gv+EqZuJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZuG2owAKCRBVnxHm/pHO 9S1GCACMX0WRpxGuWrzRU7hQrxgiBbElSht9W4cnKwkh5ro1yf2JvEfO4PtA5fsNsh8SMi/u/Os l4aiB40uUcMWsWpHegjSJKp+T05js5x6Nx5nkWhJNE4Gq6WmrDZxNVlIyQ89EVIJ3OVjX2Bc53z MdkKa9H5p7jMl2xK1fYbi2/QWsHpOfRJCaFq8fUjkRzrb/oDmG+N05W6nlTGJ1UKvjh0a5QWBjt juu/TcLAknZyivCnOGXXeZywT9Ix6lI6MsepCr5FjhjMsHZbzycGbH5+04dHLkVGzVWVqb0qyoa 0eWz5wg/cPsBy82ICOZzTDT+dY5Kc1ZAaOhSfx7ZPz1yMdRR 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 Reply-To: manivannan.sadhasivam@linaro.org From: Shashank Babu Chinta Venkata Add RX lane margining settings for 16.0 GT/s (GEN 4) data rate. These settings improve link stability while operating at high date rates and helps to improve signal quality. Signed-off-by: Shashank Babu Chinta Venkata Reviewed-by: Manivannan Sadhasivam [mani: dropped the code refactoring and minor changes] Tested-by: Johan Hovold Signed-off-by: Manivannan Sadhasivam Reviewed-by: Johan Hovold --- drivers/pci/controller/dwc/pcie-designware.h | 18 ++++++++++++++++ drivers/pci/controller/dwc/pcie-qcom-common.c | 31 +++++++++++++++++++++++= ++++ drivers/pci/controller/dwc/pcie-qcom-common.h | 1 + drivers/pci/controller/dwc/pcie-qcom-ep.c | 4 +++- drivers/pci/controller/dwc/pcie-qcom.c | 4 +++- 5 files changed, 56 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/con= troller/dwc/pcie-designware.h index 7e3a9632fbe8..da9b8f26636c 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -210,6 +210,24 @@ =20 #define PCIE_PL_CHK_REG_ERR_ADDR 0xB28 =20 +/* + * 16.0 GT/s (Gen 4) lane margining register definitions + */ +#define GEN4_LANE_MARGINING_1_OFF 0xB80 +#define MARGINING_MAX_VOLTAGE_OFFSET GENMASK(29, 24) +#define MARGINING_NUM_VOLTAGE_STEPS GENMASK(22, 16) +#define MARGINING_MAX_TIMING_OFFSET GENMASK(13, 8) +#define MARGINING_NUM_TIMING_STEPS GENMASK(5, 0) + +#define GEN4_LANE_MARGINING_2_OFF 0xB84 +#define MARGINING_IND_ERROR_SAMPLER BIT(28) +#define MARGINING_SAMPLE_REPORTING_METHOD BIT(27) +#define MARGINING_IND_LEFT_RIGHT_TIMING BIT(26) +#define MARGINING_IND_UP_DOWN_VOLTAGE BIT(25) +#define MARGINING_VOLTAGE_SUPPORTED BIT(24) +#define MARGINING_MAXLANES GENMASK(20, 16) +#define MARGINING_SAMPLE_RATE_TIMING GENMASK(13, 8) +#define MARGINING_SAMPLE_RATE_VOLTAGE GENMASK(5, 0) /* * iATU Unroll-specific register definitions * From 4.80 core version the address translation will be made by unroll diff --git a/drivers/pci/controller/dwc/pcie-qcom-common.c b/drivers/pci/co= ntroller/dwc/pcie-qcom-common.c index 596a35449de1..3aad19b56da8 100644 --- a/drivers/pci/controller/dwc/pcie-qcom-common.c +++ b/drivers/pci/controller/dwc/pcie-qcom-common.c @@ -45,3 +45,34 @@ void qcom_pcie_common_set_16gt_equalization(struct dw_pc= ie *pci) dw_pcie_writel_dbi(pci, GEN3_EQ_CONTROL_OFF, reg); } EXPORT_SYMBOL_GPL(qcom_pcie_common_set_16gt_equalization); + +void qcom_pcie_common_set_16gt_lane_margining(struct dw_pcie *pci) +{ + u32 reg; + + reg =3D dw_pcie_readl_dbi(pci, GEN4_LANE_MARGINING_1_OFF); + reg &=3D ~(MARGINING_MAX_VOLTAGE_OFFSET | + MARGINING_NUM_VOLTAGE_STEPS | + MARGINING_MAX_TIMING_OFFSET | + MARGINING_NUM_TIMING_STEPS); + reg |=3D FIELD_PREP(MARGINING_MAX_VOLTAGE_OFFSET, 0x24) | + FIELD_PREP(MARGINING_NUM_VOLTAGE_STEPS, 0x78) | + FIELD_PREP(MARGINING_MAX_TIMING_OFFSET, 0x32) | + FIELD_PREP(MARGINING_NUM_TIMING_STEPS, 0x10); + dw_pcie_writel_dbi(pci, GEN4_LANE_MARGINING_1_OFF, reg); + + reg =3D dw_pcie_readl_dbi(pci, GEN4_LANE_MARGINING_2_OFF); + reg |=3D MARGINING_IND_ERROR_SAMPLER | + MARGINING_SAMPLE_REPORTING_METHOD | + MARGINING_IND_LEFT_RIGHT_TIMING | + MARGINING_VOLTAGE_SUPPORTED; + reg &=3D ~(MARGINING_IND_UP_DOWN_VOLTAGE | + MARGINING_MAXLANES | + MARGINING_SAMPLE_RATE_TIMING | + MARGINING_SAMPLE_RATE_VOLTAGE); + reg |=3D FIELD_PREP(MARGINING_MAXLANES, pci->num_lanes) | + FIELD_PREP(MARGINING_SAMPLE_RATE_TIMING, 0x3f) | + FIELD_PREP(MARGINING_SAMPLE_RATE_VOLTAGE, 0x3f); + dw_pcie_writel_dbi(pci, GEN4_LANE_MARGINING_2_OFF, reg); +} +EXPORT_SYMBOL_GPL(qcom_pcie_common_set_16gt_lane_margining); diff --git a/drivers/pci/controller/dwc/pcie-qcom-common.h b/drivers/pci/co= ntroller/dwc/pcie-qcom-common.h index 536387e02e29..7d88d29e4766 100644 --- a/drivers/pci/controller/dwc/pcie-qcom-common.h +++ b/drivers/pci/controller/dwc/pcie-qcom-common.h @@ -9,5 +9,6 @@ struct dw_pcie; =20 void qcom_pcie_common_set_16gt_equalization(struct dw_pcie *pci); +void qcom_pcie_common_set_16gt_lane_margining(struct dw_pcie *pci); =20 #endif diff --git a/drivers/pci/controller/dwc/pcie-qcom-ep.c b/drivers/pci/contro= ller/dwc/pcie-qcom-ep.c index b091432d9f90..0df84e3e481c 100644 --- a/drivers/pci/controller/dwc/pcie-qcom-ep.c +++ b/drivers/pci/controller/dwc/pcie-qcom-ep.c @@ -487,8 +487,10 @@ static int qcom_pcie_perst_deassert(struct dw_pcie *pc= i) goto err_disable_resources; } =20 - if (pcie_link_speed[pci->max_link_speed] =3D=3D PCIE_SPEED_16_0GT) + if (pcie_link_speed[pci->max_link_speed] =3D=3D PCIE_SPEED_16_0GT) { qcom_pcie_common_set_16gt_equalization(pci); + qcom_pcie_common_set_16gt_lane_margining(pci); + } =20 /* * The physical address of the MMIO region which is exposed as the BAR diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controlle= r/dwc/pcie-qcom.c index 6f7957c4adcc..068aa559ebd8 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -284,8 +284,10 @@ static int qcom_pcie_start_link(struct dw_pcie *pci) { struct qcom_pcie *pcie =3D to_qcom_pcie(pci); =20 - if (pcie_link_speed[pci->max_link_speed] =3D=3D PCIE_SPEED_16_0GT) + if (pcie_link_speed[pci->max_link_speed] =3D=3D PCIE_SPEED_16_0GT) { qcom_pcie_common_set_16gt_equalization(pci); + qcom_pcie_common_set_16gt_lane_margining(pci); + } =20 /* Enable Link Training state machine */ if (pcie->cfg->ops->ltssm_enable) --=20 2.25.1