Message ID | 20230707095119.447952-1-a-verma1@ti.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3146189vqx; Fri, 7 Jul 2023 02:56:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlGOm7QPccD42iNm1uFlNPRs1zPSyxM5+p2I6sncN5GfCV+somCRsHoKTXTh0rhd2vxjpDzq X-Received: by 2002:a17:90a:4414:b0:262:f8eb:ea5 with SMTP id s20-20020a17090a441400b00262f8eb0ea5mr3152770pjg.22.1688723780302; Fri, 07 Jul 2023 02:56:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688723780; cv=none; d=google.com; s=arc-20160816; b=0BwugUPAkAwC1A9lpGlauWYV7Bd4HzNiz+yMgGM+/6Mj+ME4jAg759WGsZqe0SGiiN u+D8uYCFyB0TTbdU39rpwJ41Iv3h3+AzqPOTMDT8G5hiEWXfcXsqUWLbAuRzok1qckNe B6y+2eTvq1tgfIDnAxUPHByLR5QxD0AEQOYfxM7DzRSBpm6ffV5jkVwPMV2QHBMCKMEj H73WbIT+mMyirbqCh0/MlBC/rfCQ4pKQ15fFd7WJvIAxK1/6lhByDpxdwim6lBs9SqRJ 5l/s70oHvm1DwfCN6ZdiZ6DcSooY6y0donoq0pdoi3rzqk0hHywnxauo/daNqDr3i98k CC1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=qDLhtas3u/8HJM6Jwdk+LzFdFPztFG/DMXDGaDAWII0=; fh=4+QNO2839kvtV879JoFcwEUSTfyGD2La5TgUGYYmoxA=; b=rKfqz+Z/fUiq6/z/qffK5II7iA3rqZhuxKXlS3LyDbTXKx5l34Wgd3L4fOheNGVv7I XtUraEQL23ox/8I7OYuD1t+J2vViOuKe+KvZ0zBPmD1P0I9sao+iG6JUPKmAv8M5bHBy QOzYjwmDw0eL8pj0u4CEmc5q4nSOU0veUtWDCSe9pS44uIA6r+XEvOKSPINace3MBkQy ZtJ14dgMqAXUacOpqRj9rX/NsyOnzO9WEW+S4gL4oEVKWERglmtr/unTOwpaQfdgX7i1 j+OZ3xn+vWjp4t6mLW+Vn24hTcQ+7kegjH6uB6IkJW5xKG1vdvXC+Xzs3llB88d0pVcx n2cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=MIP1BVgE; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w18-20020a631612000000b0055381e05244si3389736pgl.777.2023.07.07.02.56.06; Fri, 07 Jul 2023 02:56:20 -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=@ti.com header.s=ti-com-17Q1 header.b=MIP1BVgE; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232807AbjGGJvv (ORCPT <rfc822;hadasmailinglist@gmail.com> + 99 others); Fri, 7 Jul 2023 05:51:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232789AbjGGJvu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 7 Jul 2023 05:51:50 -0400 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD46F2125; Fri, 7 Jul 2023 02:51:43 -0700 (PDT) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3679pLQh006874; Fri, 7 Jul 2023 04:51:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1688723481; bh=qDLhtas3u/8HJM6Jwdk+LzFdFPztFG/DMXDGaDAWII0=; h=From:To:CC:Subject:Date; b=MIP1BVgEKJ3bX0GOsyL3+CLm/36bOVpOLMOlA+t2ueKoSH3kSoI6v4OT5iYIdTY+Z qSc+uq/OmHBJTrTmKdCu2DgUBv33JkgA2UzFyvEz75VJ4rbQtPt3Jv+iCvR5Q2LRZy 4VWCnwlR6FZv0uLO3dQId7Rp3/5NGB360RLzzDWA= Received: from DFLE110.ent.ti.com (dfle110.ent.ti.com [10.64.6.31]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3679pLSh122036 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 7 Jul 2023 04:51:21 -0500 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 7 Jul 2023 04:51:20 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 7 Jul 2023 04:51:20 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 3679pKTB065814; Fri, 7 Jul 2023 04:51:20 -0500 From: Achal Verma <a-verma1@ti.com> To: Vignesh Raghavendra <vigneshr@ti.com>, Lorenzo Pieralisi <lpieralisi@kernel.org>, Krzysztof Wilczy_ski <kw@linux.com>, Rob Herring <robh@kernel.org>, Bjorn Helgaas <bhelgaas@google.com> CC: <linux-omap@vger.kernel.org>, <linux-pci@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org>, Achal Verma <a-verma1@ti.com> Subject: [PATCH v3] PCI: j721e: Delay 100ms T_PVPERL from power stable to PERST# inactive Date: Fri, 7 Jul 2023 15:21:19 +0530 Message-ID: <20230707095119.447952-1-a-verma1@ti.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770755226454782364?= X-GMAIL-MSGID: =?utf-8?q?1770755226454782364?= |
Series |
[v3] PCI: j721e: Delay 100ms T_PVPERL from power stable to PERST# inactive
|
|
Commit Message
Achal Verma
July 7, 2023, 9:51 a.m. UTC
As per the PCIe Card Electromechanical specification REV. 5.0, PERST#
signal should be de-asserted after minimum 100ms from the time power-rails
become stable. So, to ensure 100ms delay to give sufficient time for
power-rails and refclk to become stable, change delay from 100us to 100ms.
From PCIe Card Electromechanical specification REV. 5.0 section 2.9.2:
TPVPERL: Power stable to PERST# inactive - 100ms
Fixes: f3e25911a430 ("PCI: j721e: Add TI J721E PCIe driver")
Signed-off-by: Achal Verma <a-verma1@ti.com>
---
Changes from v2:
* Fix commit message.
Change from v1:
* Add macro for delay value.
drivers/pci/controller/cadence/pci-j721e.c | 11 +++++------
drivers/pci/pci.h | 2 ++
2 files changed, 7 insertions(+), 6 deletions(-)
Comments
On 7/7/2023 3:21 PM, Achal Verma wrote: > As per the PCIe Card Electromechanical specification REV. 5.0, PERST# > signal should be de-asserted after minimum 100ms from the time power-rails > become stable. So, to ensure 100ms delay to give sufficient time for > power-rails and refclk to become stable, change delay from 100us to 100ms. > > From PCIe Card Electromechanical specification REV. 5.0 section 2.9.2: > TPVPERL: Power stable to PERST# inactive - 100ms > > Fixes: f3e25911a430 ("PCI: j721e: Add TI J721E PCIe driver") > Signed-off-by: Achal Verma <a-verma1@ti.com> Hello Bjorn, Could you please bless this with "Reviewed-by" tag. Thanks, Achal Verma > --- > > Changes from v2: > * Fix commit message. > > Change from v1: > * Add macro for delay value. > > drivers/pci/controller/cadence/pci-j721e.c | 11 +++++------ > drivers/pci/pci.h | 2 ++ > 2 files changed, 7 insertions(+), 6 deletions(-) > > diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c > index e70213c9060a..32b6a7dc3cff 100644 > --- a/drivers/pci/controller/cadence/pci-j721e.c > +++ b/drivers/pci/controller/cadence/pci-j721e.c > @@ -498,14 +498,13 @@ static int j721e_pcie_probe(struct platform_device *pdev) > > /* > * "Power Sequencing and Reset Signal Timings" table in > - * PCI EXPRESS CARD ELECTROMECHANICAL SPECIFICATION, REV. 3.0 > - * indicates PERST# should be deasserted after minimum of 100us > - * once REFCLK is stable. The REFCLK to the connector in RC > - * mode is selected while enabling the PHY. So deassert PERST# > - * after 100 us. > + * PCI EXPRESS CARD ELECTROMECHANICAL SPECIFICATION, REV. 5.0 > + * indicates PERST# should be deasserted after minimum of 100ms > + * after power rails achieve specified operating limits and > + * within this period reference clock should also become stable. > */ > if (gpiod) { > - usleep_range(100, 200); > + msleep(PCIE_TPVPERL_DELAY_MS); > gpiod_set_value_cansleep(gpiod, 1); > } > > diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h > index a4c397434057..6ab2367e5867 100644 > --- a/drivers/pci/pci.h > +++ b/drivers/pci/pci.h > @@ -13,6 +13,8 @@ > > #define PCIE_LINK_RETRAIN_TIMEOUT_MS 1000 > > +#define PCIE_TPVPERL_DELAY_MS 100 /* see PCIe CEM r5.0, sec 2.9.2 */ > + > extern const unsigned char pcie_link_speed[]; > extern bool pci_early_dump; >
On Fri, Jul 07, 2023 at 03:21:19PM +0530, Achal Verma wrote: > As per the PCIe Card Electromechanical specification REV. 5.0, PERST# > signal should be de-asserted after minimum 100ms from the time power-rails > become stable. So, to ensure 100ms delay to give sufficient time for > power-rails and refclk to become stable, change delay from 100us to 100ms. > > From PCIe Card Electromechanical specification REV. 5.0 section 2.9.2: > TPVPERL: Power stable to PERST# inactive - 100ms > > Fixes: f3e25911a430 ("PCI: j721e: Add TI J721E PCIe driver") > Signed-off-by: Achal Verma <a-verma1@ti.com> > --- > > Changes from v2: > * Fix commit message. > > Change from v1: > * Add macro for delay value. > > drivers/pci/controller/cadence/pci-j721e.c | 11 +++++------ > drivers/pci/pci.h | 2 ++ > 2 files changed, 7 insertions(+), 6 deletions(-) > > diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c > index e70213c9060a..32b6a7dc3cff 100644 > --- a/drivers/pci/controller/cadence/pci-j721e.c > +++ b/drivers/pci/controller/cadence/pci-j721e.c > @@ -498,14 +498,13 @@ static int j721e_pcie_probe(struct platform_device *pdev) > > /* > * "Power Sequencing and Reset Signal Timings" table in > - * PCI EXPRESS CARD ELECTROMECHANICAL SPECIFICATION, REV. 3.0 > - * indicates PERST# should be deasserted after minimum of 100us > - * once REFCLK is stable. The REFCLK to the connector in RC > - * mode is selected while enabling the PHY. So deassert PERST# > - * after 100 us. > + * PCI EXPRESS CARD ELECTROMECHANICAL SPECIFICATION, REV. 5.0 > + * indicates PERST# should be deasserted after minimum of 100ms > + * after power rails achieve specified operating limits and > + * within this period reference clock should also become stable. I think the problem is not that the current code is *wrong*, because we do need to observe T_PERST-CLK, but that it failed to *also* account for T_PVPERL. There are two delays before deasserting PERST#: T_PVPERL: delay after power becomes stable T_PERST-CLK: delay after REFCLK becomes stable I assume power is enabled by phy_power_on(), and REFCLK is enabled by clk_prepare_enable(): cdns_pcie_init_phy cdns_pcie_enable_phy phy_power_on <-- power becomes stable clk_prepare_enable <-- REFCLK becomes stable if (gpiod) usleep_range gpiod_set_value_cansleep(gpiod, 1) <-- deassert PERST# I don't actually know if phy_power_on() guarantees that power is stable before it returns. But I guess that's our assumption? Similarly for clk_prepare_enable(). In any case, we have to observe both delays. They overlap, and T_PVPERL is 1000 times longer than T_PERST-CLK, so there might be enough slop in an msleep(100) to cover both, but I think I would do the simple-minded: msleep(PCIE_TPVPERL_MS); usleep_range(PCIE_TPERST_CLK_US, 2 * PCIE_TPERST_CLK_US); This is slightly more conservative than necessary because they overlap, but at least it shows that we thought about both of them. > if (gpiod) { > - usleep_range(100, 200); > + msleep(PCIE_TPVPERL_DELAY_MS); > gpiod_set_value_cansleep(gpiod, 1); I wish this local variable were named something like "perst_gpiod" instead of "gpiod". We already know from its use in gpiod_set_value_cansleep() that it's a GPIO. What's NOT obvious from the context is that this is the PERST# signal. Tangent: it looks like the DT "reset" property that I'm assuming controls PERST# is optional. How do we enforce these delays if that property is missing? > diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h > index a4c397434057..6ab2367e5867 100644 > --- a/drivers/pci/pci.h > +++ b/drivers/pci/pci.h > @@ -13,6 +13,8 @@ > > #define PCIE_LINK_RETRAIN_TIMEOUT_MS 1000 > > +#define PCIE_TPVPERL_DELAY_MS 100 /* see PCIe CEM r5.0, sec 2.9.2 */ > + > extern const unsigned char pcie_link_speed[]; > extern bool pci_early_dump; > > -- > 2.25.1 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On 7/18/2023 9:25 PM, Bjorn Helgaas wrote: > On Fri, Jul 07, 2023 at 03:21:19PM +0530, Achal Verma wrote: >> As per the PCIe Card Electromechanical specification REV. 5.0, PERST# >> signal should be de-asserted after minimum 100ms from the time power-rails >> become stable. So, to ensure 100ms delay to give sufficient time for >> power-rails and refclk to become stable, change delay from 100us to 100ms. >> >> From PCIe Card Electromechanical specification REV. 5.0 section 2.9.2: >> TPVPERL: Power stable to PERST# inactive - 100ms >> >> Fixes: f3e25911a430 ("PCI: j721e: Add TI J721E PCIe driver") >> Signed-off-by: Achal Verma <a-verma1@ti.com> >> --- >> >> Changes from v2: >> * Fix commit message. >> >> Change from v1: >> * Add macro for delay value. >> >> drivers/pci/controller/cadence/pci-j721e.c | 11 +++++------ >> drivers/pci/pci.h | 2 ++ >> 2 files changed, 7 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c >> index e70213c9060a..32b6a7dc3cff 100644 >> --- a/drivers/pci/controller/cadence/pci-j721e.c >> +++ b/drivers/pci/controller/cadence/pci-j721e.c >> @@ -498,14 +498,13 @@ static int j721e_pcie_probe(struct platform_device *pdev) >> >> /* >> * "Power Sequencing and Reset Signal Timings" table in >> - * PCI EXPRESS CARD ELECTROMECHANICAL SPECIFICATION, REV. 3.0 >> - * indicates PERST# should be deasserted after minimum of 100us >> - * once REFCLK is stable. The REFCLK to the connector in RC >> - * mode is selected while enabling the PHY. So deassert PERST# >> - * after 100 us. >> + * PCI EXPRESS CARD ELECTROMECHANICAL SPECIFICATION, REV. 5.0 >> + * indicates PERST# should be deasserted after minimum of 100ms >> + * after power rails achieve specified operating limits and >> + * within this period reference clock should also become stable. > > I think the problem is not that the current code is *wrong*, because > we do need to observe T_PERST-CLK, but that it failed to *also* > account for T_PVPERL. > > There are two delays before deasserting PERST#: > > T_PVPERL: delay after power becomes stable > T_PERST-CLK: delay after REFCLK becomes stable > > I assume power is enabled by phy_power_on(), and REFCLK is enabled by > clk_prepare_enable(): > > cdns_pcie_init_phy > cdns_pcie_enable_phy > phy_power_on <-- power becomes stable > clk_prepare_enable <-- REFCLK becomes stable > if (gpiod) > usleep_range > gpiod_set_value_cansleep(gpiod, 1) <-- deassert PERST# > > I don't actually know if phy_power_on() guarantees that power is > stable before it returns. But I guess that's our assumption? > Similarly for clk_prepare_enable(). > > In any case, we have to observe both delays. They overlap, and > T_PVPERL is 1000 times longer than T_PERST-CLK, so there might be > enough slop in an msleep(100) to cover both, but I think I would do > the simple-minded: > > msleep(PCIE_TPVPERL_MS); > usleep_range(PCIE_TPERST_CLK_US, 2 * PCIE_TPERST_CLK_US); > I think adding 100us more is not required since as you said and as also mentioned in CEM spec, 100ms covers for both power rails and refclock to get stable and 2 consecutive sleep call looks different to me. But if still required (please let me know), will do the suggested change, along with other fixes you asked below. > This is slightly more conservative than necessary because they > overlap, but at least it shows that we thought about both of them. > >> if (gpiod) { >> - usleep_range(100, 200); >> + msleep(PCIE_TPVPERL_DELAY_MS); >> gpiod_set_value_cansleep(gpiod, 1); > > I wish this local variable were named something like "perst_gpiod" > instead of "gpiod". We already know from its use in > gpiod_set_value_cansleep() that it's a GPIO. What's NOT obvious from > the context is that this is the PERST# signal. sure will change variable name to perst_gpiod. > > Tangent: it looks like the DT "reset" property that I'm assuming > controls PERST# is optional. How do we enforce these delays if that > property is missing? > yes gpiod_get shouldn't be optional, will fix this too. >> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h >> index a4c397434057..6ab2367e5867 100644 >> --- a/drivers/pci/pci.h >> +++ b/drivers/pci/pci.h >> @@ -13,6 +13,8 @@ >> >> #define PCIE_LINK_RETRAIN_TIMEOUT_MS 1000 >> >> +#define PCIE_TPVPERL_DELAY_MS 100 /* see PCIe CEM r5.0, sec 2.9.2 */ >> + >> extern const unsigned char pcie_link_speed[]; >> extern bool pci_early_dump; >> >> -- >> 2.25.1 >> >> >> _______________________________________________ >> linux-arm-kernel mailing list >> linux-arm-kernel@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Wed, Aug 02, 2023 at 02:38:02PM +0530, Verma, Achal wrote: > On 7/18/2023 9:25 PM, Bjorn Helgaas wrote: > > On Fri, Jul 07, 2023 at 03:21:19PM +0530, Achal Verma wrote: > > > As per the PCIe Card Electromechanical specification REV. 5.0, PERST# > > > signal should be de-asserted after minimum 100ms from the time power-rails > > > become stable. So, to ensure 100ms delay to give sufficient time for > > > power-rails and refclk to become stable, change delay from 100us to 100ms. > > > > > > From PCIe Card Electromechanical specification REV. 5.0 section 2.9.2: > > > TPVPERL: Power stable to PERST# inactive - 100ms > > > > > > Fixes: f3e25911a430 ("PCI: j721e: Add TI J721E PCIe driver") > > > Signed-off-by: Achal Verma <a-verma1@ti.com> > > > --- > > > > > > Changes from v2: > > > * Fix commit message. > > > > > > Change from v1: > > > * Add macro for delay value. > > > > > > drivers/pci/controller/cadence/pci-j721e.c | 11 +++++------ > > > drivers/pci/pci.h | 2 ++ > > > 2 files changed, 7 insertions(+), 6 deletions(-) > > > > > > diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c > > > index e70213c9060a..32b6a7dc3cff 100644 > > > --- a/drivers/pci/controller/cadence/pci-j721e.c > > > +++ b/drivers/pci/controller/cadence/pci-j721e.c > > > @@ -498,14 +498,13 @@ static int j721e_pcie_probe(struct platform_device *pdev) > > > /* > > > * "Power Sequencing and Reset Signal Timings" table in > > > - * PCI EXPRESS CARD ELECTROMECHANICAL SPECIFICATION, REV. 3.0 > > > - * indicates PERST# should be deasserted after minimum of 100us > > > - * once REFCLK is stable. The REFCLK to the connector in RC > > > - * mode is selected while enabling the PHY. So deassert PERST# > > > - * after 100 us. > > > + * PCI EXPRESS CARD ELECTROMECHANICAL SPECIFICATION, REV. 5.0 > > > + * indicates PERST# should be deasserted after minimum of 100ms > > > + * after power rails achieve specified operating limits and > > > + * within this period reference clock should also become stable. > > > > I think the problem is not that the current code is *wrong*, because > > we do need to observe T_PERST-CLK, but that it failed to *also* > > account for T_PVPERL. > > > > There are two delays before deasserting PERST#: > > > > T_PVPERL: delay after power becomes stable > > T_PERST-CLK: delay after REFCLK becomes stable > > > > I assume power is enabled by phy_power_on(), and REFCLK is enabled by > > clk_prepare_enable(): > > > > cdns_pcie_init_phy > > cdns_pcie_enable_phy > > phy_power_on <-- power becomes stable > > clk_prepare_enable <-- REFCLK becomes stable > > if (gpiod) > > usleep_range > > gpiod_set_value_cansleep(gpiod, 1) <-- deassert PERST# > > > > I don't actually know if phy_power_on() guarantees that power is > > stable before it returns. But I guess that's our assumption? > > Similarly for clk_prepare_enable(). > > > > In any case, we have to observe both delays. They overlap, and > > T_PVPERL is 1000 times longer than T_PERST-CLK, so there might be > > enough slop in an msleep(100) to cover both, but I think I would do > > the simple-minded: > > > > msleep(PCIE_TPVPERL_MS); > > usleep_range(PCIE_TPERST_CLK_US, 2 * PCIE_TPERST_CLK_US); > > > I think adding 100us more is not required since as you said and as also > mentioned in CEM spec, 100ms covers for both power rails and refclock to > get stable and 2 consecutive sleep call looks different to me. > But if still required (please let me know), will do the suggested change, > along with other fixes you asked below. If REFCLK is stable when clk_prepare_enable() returns, and we don't start the msleep(PCIE_TPVPERL_MS) until then, it should be safe. Maybe mention T_PERST-CLK in a comment, e.g., PCIe CEM r5.0, sec 2.2.1, requires both T_PVPERL (100ms) between power stable and PERST# inactive and T_PERST_CLK (100us) between REFCLK stable and PERST# inactive. Starting the T_PVPERL delay after REFCLK is stable means that delay covers T_PERST_CLK as well. Bjorn
diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c index e70213c9060a..32b6a7dc3cff 100644 --- a/drivers/pci/controller/cadence/pci-j721e.c +++ b/drivers/pci/controller/cadence/pci-j721e.c @@ -498,14 +498,13 @@ static int j721e_pcie_probe(struct platform_device *pdev) /* * "Power Sequencing and Reset Signal Timings" table in - * PCI EXPRESS CARD ELECTROMECHANICAL SPECIFICATION, REV. 3.0 - * indicates PERST# should be deasserted after minimum of 100us - * once REFCLK is stable. The REFCLK to the connector in RC - * mode is selected while enabling the PHY. So deassert PERST# - * after 100 us. + * PCI EXPRESS CARD ELECTROMECHANICAL SPECIFICATION, REV. 5.0 + * indicates PERST# should be deasserted after minimum of 100ms + * after power rails achieve specified operating limits and + * within this period reference clock should also become stable. */ if (gpiod) { - usleep_range(100, 200); + msleep(PCIE_TPVPERL_DELAY_MS); gpiod_set_value_cansleep(gpiod, 1); } diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index a4c397434057..6ab2367e5867 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -13,6 +13,8 @@ #define PCIE_LINK_RETRAIN_TIMEOUT_MS 1000 +#define PCIE_TPVPERL_DELAY_MS 100 /* see PCIe CEM r5.0, sec 2.9.2 */ + extern const unsigned char pcie_link_speed[]; extern bool pci_early_dump;