Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5784748rwp; Mon, 17 Jul 2023 09:21:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlF9VXS2m4uSkSvADCKgjHQnsCBddHf+03w5vOR5nYDNNxnSlg668G/Ea3A0GdSzRrtQa5wI X-Received: by 2002:a05:6402:556:b0:51e:d3d:6498 with SMTP id i22-20020a056402055600b0051e0d3d6498mr11964725edx.10.1689610881295; Mon, 17 Jul 2023 09:21:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689610881; cv=none; d=google.com; s=arc-20160816; b=CaJ9iAg7+wY+XEwVn5tX4ZYZoFTGzWrf1etaZu18qDFYz0JViOQGP+qxRcrHABRodB /s49KAgU7ho5bIKMItzlPujB4r/09igQjxvjXp8nRI8va59kS7V1MXwt9pp2PzyXPIdB 8m7cIrgutbYrB164lyO6iWuokIqoWYgMnaXHJvwqmw46kNIo4hE6IlPL2KzCtRteqsnm y2xLlUuBv/UocG/D7YgOvWrXfIcobkzb3r8bVN6KL7k6vQirNcf4bb+xuTnyJcK2Ty8i 5YA5MsegOUP4WFuMgfv6zPnJ1B02HZlgz7acKwHPwlXyXpYprJ09CaS6NpKGU35zRkHm UPQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1QFIK8T+N7oZJ8L1lj9IrrrWfLU8P3cWJRuhRnwU54U=; fh=ER0hl+FgAL2GynTj5//s9R7pPcKKycXMN+GKoec8nyc=; b=KXjg6V981rPDJ7dlt+wXw3dt2cbcs3i8VwUsD6wNGGS33NXuw7dW5wZ+u4tZptkZ8L ZnDczOFabkpF0y1rPf4nt3Yh2sM21fP4nazpqhL+HBcQAU1pl7UWShHISObnF6vR4AtO nr5ZIEPGizS1HGNabetGahh221l3salK8OmaC7erSbd/46xxHpjEWo+L03KTzKXLOsXX +w2ycvBDPkCwC+PheeHDfyt/ecZndBJDac25MBrRnGvssXaLnub/H/RY3w2NK4Bi5ycm HwJbJQyxQHefXUFNv40mt0D+4bENMN5WVtiU6noYhDuVZ35MM5d+YoEiKbF70WAm9Ky1 BRxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bcN+QDhT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m17-20020aa7d351000000b0052061adfbb4si7145222edr.80.2023.07.17.09.20.55; Mon, 17 Jul 2023 09:21:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bcN+QDhT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231790AbjGQP7l (ORCPT + 99 others); Mon, 17 Jul 2023 11:59:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231938AbjGQP7h (ORCPT ); Mon, 17 Jul 2023 11:59:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 319AD10E3; Mon, 17 Jul 2023 08:59:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BB36461138; Mon, 17 Jul 2023 15:59:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8F28C433C8; Mon, 17 Jul 2023 15:59:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689609572; bh=mmNtx5DaCDSRpy/BMCSXBwbmRPuUIz4XFGeGgtAykCg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bcN+QDhTGO43S68G//SgxaH9wKR50gFXFbSk0rjCodtNU4hMLKoXmJhAycajkEXCU olADYw/g75sw6tM0wGiOQwUcMD5jsLdkNP+TAclWpDPQsAQfhUgzw7OcIVVm/odLfF uBYlGvZ6T9f9OhFVeCfhwwVpxC4ENk3506WGw66iy8eFCK8jY19gKzkAfZMieh2RWw GPSbuI9t7JyCC9dtdHulnvO4qqr8WmO9HhiFMCcp+qPuguiXw4fwEc4AOCtq/cQmHk yWSIiQiclE7hX4yLNzrEIOXfdkIK9olTBOp+fRxPA/kbsx3cHhA/c2ZXDy7fB7MDTA oaBYmzU9z2cpQ== Date: Mon, 17 Jul 2023 21:29:10 +0530 From: Manivannan Sadhasivam To: Frank Li Cc: Minghuan Lian , Mingkai Hu , Roy Zang , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , "open list:PCI DRIVER FOR FREESCALE LAYERSCAPE" , "open list:PCI DRIVER FOR FREESCALE LAYERSCAPE" , "moderated list:PCI DRIVER FOR FREESCALE LAYERSCAPE" , open list , imx@lists.linux.dev Subject: Re: [PATCH 2/2] PCI: layerscape: Add the workaround for lost link capablities during reset Message-ID: <20230717155910.GB35455@thinkpad> References: <20230615164113.2270698-1-Frank.Li@nxp.com> <20230615164113.2270698-2-Frank.Li@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230615164113.2270698-2-Frank.Li@nxp.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 15, 2023 at 12:41:12PM -0400, Frank Li wrote: > From: Xiaowei Bao > > A workaround for the issue where the PCI Express Endpoint (EP) controller > loses the values of the Maximum Link Width and Supported Link Speed from > the Link Capabilities Register, which initially configured by the Reset > Configuration Word (RCW) during a link-down or hot reset event. > If this fixes an issue, then there should be a Fixes tag. > Signed-off-by: Xiaowei Bao > Signed-off-by: Hou Zhiqiang > Signed-off-by: Frank Li > --- > drivers/pci/controller/dwc/pci-layerscape-ep.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c > index 4e4fdd1dfea7..2ef02d827eeb 100644 > --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c > +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c > @@ -45,6 +45,7 @@ struct ls_pcie_ep { > struct pci_epc_features *ls_epc; > const struct ls_pcie_ep_drvdata *drvdata; > int irq; > + u32 lnkcap; > bool big_endian; > }; > > @@ -73,6 +74,7 @@ static irqreturn_t ls_pcie_ep_event_handler(int irq, void *dev_id) > struct ls_pcie_ep *pcie = dev_id; > struct dw_pcie *pci = pcie->pci; > u32 val, cfg; > + u8 offset; > > val = ls_lut_readl(pcie, PEX_PF0_PME_MES_DR); > ls_lut_writel(pcie, PEX_PF0_PME_MES_DR, val); > @@ -81,6 +83,13 @@ static irqreturn_t ls_pcie_ep_event_handler(int irq, void *dev_id) > return IRQ_NONE; > > if (val & PEX_PF0_PME_MES_DR_LUD) { > + Please add a comment on why the LNKCAP is being restored here. > + offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); > + > + dw_pcie_dbi_ro_wr_en(pci); > + dw_pcie_writew_dbi(pci, offset + PCI_EXP_LNKCAP, pcie->lnkcap); lnkcap is a 32-bit variable, so you should use dw_pcie_writel_dbi(). - Mani > + dw_pcie_dbi_ro_wr_dis(pci); > + > cfg = ls_lut_readl(pcie, PEX_PF0_CONFIG); > cfg |= PEX_PF0_CFG_READY; > ls_lut_writel(pcie, PEX_PF0_CONFIG, cfg); > @@ -216,6 +225,7 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) > struct ls_pcie_ep *pcie; > struct pci_epc_features *ls_epc; > struct resource *dbi_base; > + u8 offset; > int ret; > > pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); > @@ -252,6 +262,9 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) > > platform_set_drvdata(pdev, pcie); > > + offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); > + pcie->lnkcap = dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCAP); > + > ret = dw_pcie_ep_init(&pci->ep); > if (ret) > return ret; > -- > 2.34.1 > -- மணிவண்ணன் சதாசிவம்