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 AD4B7CD4857 for ; Wed, 4 Sep 2024 17:01:00 +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-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=aUspjdaZipuOhA4NRY0RJgeHGMKwRMzsWto8djn5vLI=; b=hfyn3oXrKj6HenzkdnYnznaGEX iKGTwGfcXg8zccGRRoJFrseJV2V0qjX13ba5nPqHdjhSFd/JENXoJWpOjmRG0DFfj4LYvlnHmZk9c ZQGjhbJie1jo/b1QS4uJnzaZaBCgqSQRk4C3hgp0FAhjR0f7GI3ds0HzDSKD/11BX60vJbqA5x2De OJvumf9qyPHl1utqFKZhOR1ICy8X2hs5Vo5AzM7X19pcutlTBqNesXfdbQ1KP9AQHhK4sRmW+uzCA sAewpJhz7OPKTJAuNtz6levAo/QrHr3sZBi7aHBdHwYNJcySr1OTXUucAgTfXJ7Jn6MCq6k/sBeTU PhsfHXkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sltND-00000005ML2-11uh; Wed, 04 Sep 2024 17:00:51 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1slsGb-0000000560P-4B51 for linux-arm-kernel@lists.infradead.org; Wed, 04 Sep 2024 15:50:12 +0000 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-2059112f0a7so27917975ad.3 for ; Wed, 04 Sep 2024 08:49:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725464996; x=1726069796; darn=lists.infradead.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=aUspjdaZipuOhA4NRY0RJgeHGMKwRMzsWto8djn5vLI=; b=ec1huN2RXlWU2Wq0Y2f8YBg3yylWWjI1wZP1gznl75a65k+OUZVU875F2VqlXU7BBQ 1wjVe7iWtE60Hi8WGurTSehnuIeuLmm5iBkfozGZT/VroBl8/JTUYOvoI57J19XyHtXt P8rYQbhVTlXNAuobt2mboPHzdkMKOzFbjPkLzotL3bHrpa5/m89pLcA5zy6CcMk8Ekuj L53PuHPaSIXtBYbAF8CjVIpU8iU5AjMU7HJ3co08XZ1FYYSMwdUyA4klYYKMAkg+Y4U/ WW0pvOk0pPfwxF/5maZDG4j3sj8b6s/FJqfR4Q4dHbbjif1glUkJvi0F/QytFomSY8X8 mCzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725464996; x=1726069796; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aUspjdaZipuOhA4NRY0RJgeHGMKwRMzsWto8djn5vLI=; b=D6pEcDAi1I2Ljfbo5jg0q6t6HT3gE2H9IRsaGFxo+l3n4I3dowprcZSbwA+LHBWLUB bYjTEWjIUwy9iGJlpa+eNCiNQueHHUsbLzWIgqg2NLqYbx7EJnqpe7rrMiJ+2EX2vA7B pxUqygP9A5b4TZ8TVGaz8Nz4yo5AnAyBmRZpXRzl1WfBGM9WeTaUo1B5CCj6Vi8OQP9l HYEZnsOG3yh/rRKVppDPP3FbgbGRVqFCeOXpE6Qx3ci3RlhTCJFkczbe9BohiQVFtCbl QnU6E5eUNmGlN4g4Hfk0bSdAnGpTDz/uFfGRnBUXHWs9fXmmlSBoRyjPz/bsPigGWr26 XldQ== X-Forwarded-Encrypted: i=1; AJvYcCWCv7W52nmI9GUO7+wSHzdtxPMHc2x3IHwZZFRaKnTfX1xhWgjJTduc3iCevKm0v3NgART41FHfdXs/SpOC+L5F@lists.infradead.org X-Gm-Message-State: AOJu0YxRP9aIVOQlcERBkx6SfaugbUvhbabcBW9hvDlEAPTghSiF0Sor G5PjRg+PPfOuJJ95QrfzK74OyxlJiNCt1ptSBuUpRbo8IF/k2SiEZ2n0+pIQuw== X-Google-Smtp-Source: AGHT+IGaIqW5Fd7iC7eWGx3Bkr4KIAhnl/c5JAG+0dmpw/6XA8lzo2zqW5pfYpjv80IFZFIFhT9/Sw== X-Received: by 2002:a17:902:cec6:b0:206:9caf:1e00 with SMTP id d9443c01a7336-2069caf211cmr72629265ad.25.1725464996370; Wed, 04 Sep 2024 08:49:56 -0700 (PDT) Received: from thinkpad ([120.60.128.165]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206ae950571sm15158925ad.82.2024.09.04.08.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 08:49:56 -0700 (PDT) Date: Wed, 4 Sep 2024 21:19:44 +0530 From: Manivannan Sadhasivam To: Johan Hovold 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: <20240904154944.w4bujfmhy5uhzkld@thinkpad> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240904_084958_078757_2C566FC2 X-CRM114-Status: GOOD ( 33.07 ) 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 11:30:08AM +0200, Johan Hovold wrote: > 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) { > Well I was trying to catch the error value here because if neither driver nor platform limits the max link speed, this would have -EINVAL (returned by of_pci_get_max_link_speed()). But logically it makes sense to use 'pci->max_link_speed < 1' since anything below value 1 is an invalid value. Will change it. - Mani > 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 -- மணிவண்ணன் சதாசிவம்