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 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 1D724CD3431 for ; Wed, 4 Sep 2024 10:08:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ly3kM2rRFEPXDrhGNjdHrtTMpcZmK92X2/x0uyaiggI=; b=sM0b3MnXyhrfqp9XB4lwXv8A6I zXYwc3uCyH3FVipuYnnUyznVmC2rXH2u860RPUSvCmDNrqHRR3QlA1j1UyZarqC6pjGwYC9fHlDcG ev7QITStVcDDPNcXgG6tFLsgeR0TZmdaj29b5mNaoO3gBG3BF0yqtAPJK+s7hpkmtkygK+ujDXyQq MdF1kBNM5DGAwrsUaNWUXfbJSgFl2qz0+TkScggPcbwqSbhXUT4ncUxYBiYNmjwtsPgtO45B99/7R TfZGlRlhSERa16tHL9eH/7OX6eVl3cjjg3zVIUKcPhXtwOTLAZPgmcpggeU9uVSBjsu3AMy0g1M1e MN58V4Cg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1slmvu-00000003pmW-121u; Wed, 04 Sep 2024 10:08:14 +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 1slmKm-00000003gQQ-2Oln for linux-arm-kernel@lists.infradead.org; Wed, 04 Sep 2024 09:29:54 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 3684F5C5596; Wed, 4 Sep 2024 09:29:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 661DEC4CEC9; Wed, 4 Sep 2024 09:29:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725442191; bh=54V5tRrYnwlqE+z9YtX9ph4B2JFbbRsCj+benJAsYwI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=b3P4OZcSIc7hjw+laxcYBj+S8AnEW9jJSxdE8ThEa6t1hCN6DSSGfvwYqDFZxKRD2 jjoK8Eho5TznssDQUROcxeeOPU/BYAK1KB9nsO5nWLdbE0zifFTZeDJbpvrSKkI7Ss yNzW+rC+VdhAGS0blclB2qCJ/ZNJdJs7QRmpl3QoyzYapQUzyBMcimMWH+3gVEs0mC tWq/GAFlNri3UTqQ1kUFD+YDplxEPSxKwe7vnzYS0q+0hfW8cDQtXg3NLIESmF8J0h vYuOzh4mgE4E7nAPCt0AlmaYz4oKSY0zR0HcQS4/Nq1F/wfzj9LdxdhaHg0hadtoA4 PIw5M+ypS+nxw== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1slmL2-000000001tc-18qO; Wed, 04 Sep 2024 11:30:08 +0200 Date: Wed, 4 Sep 2024 11:30:08 +0200 From: Johan Hovold To: manivannan.sadhasivam@linaro.org Cc: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Jingoo Han , Chuanhua Lei , Marek Vasut , Yoshihiro Shimoda , 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 Subject: Re: [PATCH v6 2/4] PCI: dwc: Always cache the maximum link speed value in dw_pcie::max_link_speed Message-ID: References: <20240904-pci-qcom-gen4-stability-v6-0-ec39f7ae3f62@linaro.org> <20240904-pci-qcom-gen4-stability-v6-2-ec39f7ae3f62@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240904-pci-qcom-gen4-stability-v6-2-ec39f7ae3f62@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240904_022952_776173_E909C837 X-CRM114-Status: GOOD ( 26.86 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Sep 04, 2024 at 12:41:58PM +0530, Manivannan Sadhasivam via B4 Relay wrote: > 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. > > 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..0704853daa85 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 < 0) { This should be if (pci->max_link_speed < 1) { but the patch works as-is because of the default case in the switch below which falls back to PCI_EXP_LNKCAP_SLS. > + 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); With the above fixed: Reviewed-by: Johan Hovold