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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4FB1CCA47C for ; Mon, 13 Jun 2022 22:21:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234922AbiFMWVZ (ORCPT ); Mon, 13 Jun 2022 18:21:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230240AbiFMWVX (ORCPT ); Mon, 13 Jun 2022 18:21:23 -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 A11842DD58; Mon, 13 Jun 2022 15:21:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3B357614E1; Mon, 13 Jun 2022 22:21:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B347C34114; Mon, 13 Jun 2022 22:21:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655158881; bh=nlwQXs75cmtdhpBdJq2NMEj5gmKBm8iKQVRpWIQ9K8I=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=KruTBi4WgF++vsI5D55FT3ww4QRsubCGiagi2uhIqOTED9DxwCtIyIwLBP+6g6foZ x0/beM3ci/OJa2cB2BKMQCD6KpZZ6EyVdNJbztIzvYNoQ6f94ibgiGohlngzODMy89 WJDBoaViGjpqBOeRmSk+agruwWndko5q74DNpCG9jpOIJpkPf2c44Viy4ZF0RABh29 JeweSZGX/sOK3tMVO+NXte/+stMmirExcmWdo3OsoiaAR+5ZqafWLzsRp2+s+/6Tu4 HMj2maiy7ifbUZ+SOpVb/pMth7cKOYPfukqNj4DYOpexPtwNzO5+57hWdZk4tZUvwS WPYam8tCCJ5bw== Date: Mon, 13 Jun 2022 17:21:19 -0500 From: Bjorn Helgaas To: Richard Zhu Cc: l.stach@pengutronix.de, bhelgaas@google.com, robh+dt@kernel.org, broonie@kernel.org, lorenzo.pieralisi@arm.com, festevam@gmail.com, francesco.dolcini@toradex.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, linux-imx@nxp.com Subject: Re: [PATCH v10 6/7] PCI: imx6: Mark the link down as none fatal error Message-ID: <20220613222119.GA716475@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1655110538-10914-7-git-send-email-hongxing.zhu@nxp.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 13, 2022 at 04:55:37PM +0800, Richard Zhu wrote: > let the driver probe successfully, return zero in imx6_pcie_start_link() > when PCIe link is down. > > Because i.MX PCIe doesn't support hot-plug feature. > In this link down scenario, only start the PCIe link training in resume > when the link is up before system suspend to avoid the long latency in > the link training period. This looks like two changes that should be separate patches: 1) Make driver probe successful even if link is down. 2) Reduce resume time by only starting the link if it was up before suspend. > Signed-off-by: Richard Zhu > --- > drivers/pci/controller/dwc/pci-imx6.c | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c > index c02748393aac..ac6ec2d691a0 100644 > --- a/drivers/pci/controller/dwc/pci-imx6.c > +++ b/drivers/pci/controller/dwc/pci-imx6.c > @@ -67,6 +67,7 @@ struct imx6_pcie { > struct dw_pcie *pci; > int reset_gpio; > bool gpio_active_high; > + bool link_is_up; > struct clk *pcie_bus; > struct clk *pcie_phy; > struct clk *pcie_inbound_axi; > @@ -845,7 +846,9 @@ static int imx6_pcie_start_link(struct dw_pcie *pci) > /* Start LTSSM. */ > imx6_pcie_ltssm_enable(dev); > > - dw_pcie_wait_for_link(pci); > + ret = dw_pcie_wait_for_link(pci); > + if (ret) > + goto err_reset_phy; > > if (pci->link_gen == 2) { > /* Allow Gen2 mode after the link is up. */ > @@ -881,11 +884,14 @@ static int imx6_pcie_start_link(struct dw_pcie *pci) > } > > /* Make sure link training is finished as well! */ > - dw_pcie_wait_for_link(pci); > + ret = dw_pcie_wait_for_link(pci); > + if (ret) > + goto err_reset_phy; > } else { > dev_info(dev, "Link: Gen2 disabled\n"); > } > > + imx6_pcie->link_is_up = true; > tmp = dw_pcie_readw_dbi(pci, offset + PCI_EXP_LNKSTA); > dev_info(dev, "Link up, Gen%i\n", tmp & PCI_EXP_LNKSTA_CLS); > return 0; > @@ -895,7 +901,7 @@ static int imx6_pcie_start_link(struct dw_pcie *pci) > dw_pcie_readl_dbi(pci, PCIE_PORT_DEBUG0), > dw_pcie_readl_dbi(pci, PCIE_PORT_DEBUG1)); > imx6_pcie_reset_phy(imx6_pcie); > - return ret; > + return 0; > } > > static int imx6_pcie_host_init(struct pcie_port *pp) > @@ -1022,10 +1028,8 @@ static int imx6_pcie_resume_noirq(struct device *dev) > imx6_pcie_init_phy(imx6_pcie); > imx6_pcie_deassert_core_reset(imx6_pcie); > dw_pcie_setup_rc(pp); > - > - ret = imx6_pcie_start_link(imx6_pcie->pci); > - if (ret < 0) > - dev_info(dev, "pcie link is down after resume.\n"); > + if (imx6_pcie->link_is_up) > + imx6_pcie_start_link(imx6_pcie->pci); > > return 0; > } > -- > 2.25.1 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 281F6C433EF for ; Mon, 13 Jun 2022 22:22:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version: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:References: List-Owner; bh=q9pBAcLJWdT18IJzPdUcejiWAjVBZfejVL748QF5sn0=; b=PAtHbWCCWGZpwB Kpd7I9Txa+QvvsF3dFiuxS6CyUsYLvD0t3RaevatsPy2cE8rx/PEpufvLL956kKxto698T902Z2GZ 6sUGZORpoGTvrtTWk+q4Q1FJjPnNpH6A2U/hMvYX7zgMwxsFU9Ln2OG2cobIxLUy9zBj4/jAwyS/H H1LnZL7Mu6w5nuT1fqoImwChDst8gVHQoOLrKm23a1Y7BYSvsMDzZy+KDHNG7qVYg1lEDTbJEhaQp P0tHxJ5MVP07HJ+GD4VL5OmSaeoXEaRdZdMANMbyLxy8gHao7NjWQ1EV1g0BoX3lU0jnjk3ykAKDN a7/KSSCeEKFa1sRSA+CA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o0sR3-00656D-Sv; Mon, 13 Jun 2022 22:21:25 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o0sR1-00655W-1r for linux-arm-kernel@lists.infradead.org; Mon, 13 Jun 2022 22:21:24 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2C754614D3; Mon, 13 Jun 2022 22:21:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B347C34114; Mon, 13 Jun 2022 22:21:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655158881; bh=nlwQXs75cmtdhpBdJq2NMEj5gmKBm8iKQVRpWIQ9K8I=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=KruTBi4WgF++vsI5D55FT3ww4QRsubCGiagi2uhIqOTED9DxwCtIyIwLBP+6g6foZ x0/beM3ci/OJa2cB2BKMQCD6KpZZ6EyVdNJbztIzvYNoQ6f94ibgiGohlngzODMy89 WJDBoaViGjpqBOeRmSk+agruwWndko5q74DNpCG9jpOIJpkPf2c44Viy4ZF0RABh29 JeweSZGX/sOK3tMVO+NXte/+stMmirExcmWdo3OsoiaAR+5ZqafWLzsRp2+s+/6Tu4 HMj2maiy7ifbUZ+SOpVb/pMth7cKOYPfukqNj4DYOpexPtwNzO5+57hWdZk4tZUvwS WPYam8tCCJ5bw== Date: Mon, 13 Jun 2022 17:21:19 -0500 From: Bjorn Helgaas To: Richard Zhu Cc: l.stach@pengutronix.de, bhelgaas@google.com, robh+dt@kernel.org, broonie@kernel.org, lorenzo.pieralisi@arm.com, festevam@gmail.com, francesco.dolcini@toradex.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, linux-imx@nxp.com Subject: Re: [PATCH v10 6/7] PCI: imx6: Mark the link down as none fatal error Message-ID: <20220613222119.GA716475@bhelgaas> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1655110538-10914-7-git-send-email-hongxing.zhu@nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220613_152123_215212_5C953AC4 X-CRM114-Status: GOOD ( 25.96 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jun 13, 2022 at 04:55:37PM +0800, Richard Zhu wrote: > let the driver probe successfully, return zero in imx6_pcie_start_link() > when PCIe link is down. > > Because i.MX PCIe doesn't support hot-plug feature. > In this link down scenario, only start the PCIe link training in resume > when the link is up before system suspend to avoid the long latency in > the link training period. This looks like two changes that should be separate patches: 1) Make driver probe successful even if link is down. 2) Reduce resume time by only starting the link if it was up before suspend. > Signed-off-by: Richard Zhu > --- > drivers/pci/controller/dwc/pci-imx6.c | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c > index c02748393aac..ac6ec2d691a0 100644 > --- a/drivers/pci/controller/dwc/pci-imx6.c > +++ b/drivers/pci/controller/dwc/pci-imx6.c > @@ -67,6 +67,7 @@ struct imx6_pcie { > struct dw_pcie *pci; > int reset_gpio; > bool gpio_active_high; > + bool link_is_up; > struct clk *pcie_bus; > struct clk *pcie_phy; > struct clk *pcie_inbound_axi; > @@ -845,7 +846,9 @@ static int imx6_pcie_start_link(struct dw_pcie *pci) > /* Start LTSSM. */ > imx6_pcie_ltssm_enable(dev); > > - dw_pcie_wait_for_link(pci); > + ret = dw_pcie_wait_for_link(pci); > + if (ret) > + goto err_reset_phy; > > if (pci->link_gen == 2) { > /* Allow Gen2 mode after the link is up. */ > @@ -881,11 +884,14 @@ static int imx6_pcie_start_link(struct dw_pcie *pci) > } > > /* Make sure link training is finished as well! */ > - dw_pcie_wait_for_link(pci); > + ret = dw_pcie_wait_for_link(pci); > + if (ret) > + goto err_reset_phy; > } else { > dev_info(dev, "Link: Gen2 disabled\n"); > } > > + imx6_pcie->link_is_up = true; > tmp = dw_pcie_readw_dbi(pci, offset + PCI_EXP_LNKSTA); > dev_info(dev, "Link up, Gen%i\n", tmp & PCI_EXP_LNKSTA_CLS); > return 0; > @@ -895,7 +901,7 @@ static int imx6_pcie_start_link(struct dw_pcie *pci) > dw_pcie_readl_dbi(pci, PCIE_PORT_DEBUG0), > dw_pcie_readl_dbi(pci, PCIE_PORT_DEBUG1)); > imx6_pcie_reset_phy(imx6_pcie); > - return ret; > + return 0; > } > > static int imx6_pcie_host_init(struct pcie_port *pp) > @@ -1022,10 +1028,8 @@ static int imx6_pcie_resume_noirq(struct device *dev) > imx6_pcie_init_phy(imx6_pcie); > imx6_pcie_deassert_core_reset(imx6_pcie); > dw_pcie_setup_rc(pp); > - > - ret = imx6_pcie_start_link(imx6_pcie->pci); > - if (ret < 0) > - dev_info(dev, "pcie link is down after resume.\n"); > + if (imx6_pcie->link_is_up) > + imx6_pcie_start_link(imx6_pcie->pci); > > return 0; > } > -- > 2.25.1 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel