Message ID | ZR-7Nm2c5s4kuOp0@pidgin.makrotopia.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp152155vqo; Fri, 6 Oct 2023 00:48:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkQe90f+yDAE3TsBSVROD+zZ8+VxlYceGsw9TtAHMKbITtXC1WDeF3cRPPgl4SwVQQ69iu X-Received: by 2002:a05:6a20:4418:b0:14d:16c:2d20 with SMTP id ce24-20020a056a20441800b0014d016c2d20mr9491952pzb.44.1696578518420; Fri, 06 Oct 2023 00:48:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696578518; cv=none; d=google.com; s=arc-20160816; b=k1Tb8A1q8dFHLu64PJP5c15R3keJ2wq9AttM2XCDpLUDoTDwuJMgs4JyWcvZ6yup1e kQjflqTvK7KAIVH6yx2C/HyvHQMtqIiXJfIGRu+/kn+dMSXLYwxwzb8oOzIfRipDIdRl fqGWGYvlaaqxfpQGRtmy1EixRXf1OHKU0kSyG05i3D6fwbr2cmOUrZI5rRMiJkqS8u5g BnHNDr2XfIaexxeRLmODrGdKHeeS8M7OG3I9nNCD6ympY6XsFPDpx7p7OsmeAFjp2YfK snXSQ6NVuopUM4s5iN5aaMlltyZYQ4oBUUuk+AsMFlSaLPH5sWohIUlQKPzcQnNdQ0H9 yxaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date; bh=JfeQthEyRcO4HnjndpPZvj7t1sp9LUoj0/kmQtjW57Y=; fh=aPk37Nk8CNOmq5kqM2ebP7OTHA6W/Z2fH5L8vlDPn7s=; b=XmY+htLQTUNwIF+fSG5mi1KpgEpf2C8MXy4m57rhwBcV5ye2kWfgci294kicamET3e RUwkbE50+KJQTCul/e09yIqPJErd70CoZhP8bCQ1MzNPKf8/ajGonSZGFVpxqLIICbeY e/oP7WPQuMgmiy1WjXYjybErr6veQyk9trFpEITm7NA1VfXnTR4D2Rs92asX6pcifKo/ A4mch5/q77oYiLy2FK3SL1tBig1e/oYD6jlvX4ORWAmE6M9ZYz6JbYMDZ/2JQWgpGqQw mGRIyxnG4Cb9/KpaRXIc/pCNle4sFJVdn+pG/aPVxNvn/W5tpBPt+bcBHrFoJWH7c5v6 IcSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id eg7-20020a056a00800700b0068e41f07f33si996491pfb.94.2023.10.06.00.48.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 00:48:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D56C3804747D; Fri, 6 Oct 2023 00:48:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230355AbjJFHse (ORCPT <rfc822;ezelljr.billy@gmail.com> + 18 others); Fri, 6 Oct 2023 03:48:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230300AbjJFHsc (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 6 Oct 2023 03:48:32 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2998CE4; Fri, 6 Oct 2023 00:48:30 -0700 (PDT) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from <daniel@makrotopia.org>) id 1qofZT-0004lD-0L; Fri, 06 Oct 2023 07:48:27 +0000 Date: Fri, 6 Oct 2023 09:45:58 +0200 From: Daniel Golle <daniel@makrotopia.org> To: linux-pci@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, Matthias Brugger <matthias.bgg@gmail.com>, Bjorn Helgaas <bhelgaas@google.com>, Rob Herring <robh@kernel.org>, Krzysztof =?utf-8?q?Wilczy=C5=84ski?= <kw@linux.com>, Lorenzo Pieralisi <lpieralisi@kernel.org>, Jianjun Wang <jianjun.wang@mediatek.com>, Ryder Lee <ryder.lee@mediatek.com> Cc: Christian Marangi <ansuelsmth@gmail.com>, Frank Wunderlich <linux@fw-web.de>, John Crispin <john@phrozen.org> Subject: [PATCH] PCI: mediatek-gen3: fix PCIe #PERST being de-asserted too early Message-ID: <ZR-7Nm2c5s4kuOp0@pidgin.makrotopia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 06 Oct 2023 00:48:37 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778991516118566623 X-GMAIL-MSGID: 1778991516118566623 |
Series |
PCI: mediatek-gen3: fix PCIe #PERST being de-asserted too early
|
|
Commit Message
Daniel Golle
Oct. 6, 2023, 7:45 a.m. UTC
The driver for MediaTek gen3 PCIe hosts de-asserts all reset
signals at the same time using a single register write operation.
Delay the de-assertion of the #PERST signal by 100ms as required by
PCIe CEM clause 2.2, some PCIe devices fail to come up otherwise.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
drivers/pci/controller/pcie-mediatek-gen3.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
Comments
On Fri, Oct 06, 2023 at 09:45:58AM +0200, Daniel Golle wrote: > The driver for MediaTek gen3 PCIe hosts de-asserts all reset > signals at the same time using a single register write operation. > Delay the de-assertion of the #PERST signal by 100ms as required by > PCIe CEM clause 2.2, some PCIe devices fail to come up otherwise. > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > --- > drivers/pci/controller/pcie-mediatek-gen3.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c > index e0e27645fdf4..ba8cfce03aad 100644 > --- a/drivers/pci/controller/pcie-mediatek-gen3.c > +++ b/drivers/pci/controller/pcie-mediatek-gen3.c > @@ -350,7 +350,13 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie) I feel like I'm missing something because this patch seems to be adding a delay for T_PVPERL, but the comment before the existing msleep() claims *it* is the T_PVPERL delay: * Described in PCIe CEM specification sections 2.2 (PERST# Signal) * and 2.2.1 (Initial Power-Up (G3 to S0)). * The deassertion of PERST# should be delayed 100ms (TPVPERL) * for the power and clock to become stable. > msleep(100); > > /* De-assert reset signals */ > - val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB); > + val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB); > + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); > + > + msleep(100); So I'm confused about these two sleeps. Are they for different parameters? T_PVPERL is defined from "Power stable to PERST# inactive". Do we have any actual indication of when to start that delay, i.e., do we have a clue about when power became stable? > + /* De-assert PERST# signals */ > + val &= ~(PCIE_PE_RSTB); > writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); > > /* Check if the link is up or not */ > -- > 2.42.0 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Tue, Oct 10, 2023 at 06:42:07PM +0200, Frank Wunderlich wrote: > Am 10. Oktober 2023 18:04:23 MESZ schrieb Bjorn Helgaas <helgaas@kernel.org>: > >On Fri, Oct 06, 2023 at 09:45:58AM +0200, Daniel Golle wrote: > >> The driver for MediaTek gen3 PCIe hosts de-asserts all reset > >> signals at the same time using a single register write operation. > >> Delay the de-assertion of the #PERST signal by 100ms as required by > >> PCIe CEM clause 2.2, some PCIe devices fail to come up otherwise. > >> > >> Signed-off-by: Daniel Golle <daniel@makrotopia.org> > >> --- > >> drivers/pci/controller/pcie-mediatek-gen3.c | 8 +++++++- > >> 1 file changed, 7 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c > >> index e0e27645fdf4..ba8cfce03aad 100644 > >> --- a/drivers/pci/controller/pcie-mediatek-gen3.c > >> +++ b/drivers/pci/controller/pcie-mediatek-gen3.c > >> @@ -350,7 +350,13 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie) > > > >I feel like I'm missing something because this patch seems to be > >adding a delay for T_PVPERL, but the comment before the existing > >msleep() claims *it* is the T_PVPERL delay: > > > > * Described in PCIe CEM specification sections 2.2 (PERST# Signal) > > * and 2.2.1 (Initial Power-Up (G3 to S0)). > > * The deassertion of PERST# should be delayed 100ms (TPVPERL) > > * for the power and clock to become stable. > > > >> msleep(100); > >> > >> /* De-assert reset signals */ > >> - val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB); > >> + val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB); > >> + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); > >> + > >> + msleep(100); > > > >So I'm confused about these two sleeps. Are they for different > >parameters? > > > >T_PVPERL is defined from "Power stable to PERST# inactive". Do we > >have any actual indication of when to start that delay, i.e., do we > >have a clue about when power became stable? > > > >> + /* De-assert PERST# signals */ > >> + val &= ~(PCIE_PE_RSTB); > >> writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); > >> > >> /* Check if the link is up or not */ > >> -- > >> 2.42.0 > >> > >> > >> _______________________________________________ > >> linux-arm-kernel mailing list > >> linux-arm-kernel@lists.infradead.org > >> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel > > Hi > > Seems it is same as the patch i've sent some time ago and which was rejected because of the additional delay... > > https://patchwork.kernel.org/project/linux-mediatek/patch/20230402131347.99268-1-linux@fw-web.de/ > > Or am i wrong? > regards Frank Reading the other series, I smell this can only be handled by a quirk... This might be a defect or the board not following PCIE hw specs. Thing is that the bug/limitation is there and we have enough info to find way to fix this and lots of tester. Eventually even a fixup based on a specific compatible.
On Tue, 2023-10-10 at 18:42 +0200, Frank Wunderlich wrote: > > External email : Please do not click links or open attachments until > you have verified the sender or the content. > Am 10. Oktober 2023 18:04:23 MESZ schrieb Bjorn Helgaas < > helgaas@kernel.org>: > > On Fri, Oct 06, 2023 at 09:45:58AM +0200, Daniel Golle wrote: > > > The driver for MediaTek gen3 PCIe hosts de-asserts all reset > > > signals at the same time using a single register write operation. > > > Delay the de-assertion of the #PERST signal by 100ms as required > > > by > > > PCIe CEM clause 2.2, some PCIe devices fail to come up otherwise. > > > > > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > > > drivers/pci/controller/pcie-mediatek-gen3.c | 8 +++++++- > > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c > > > b/drivers/pci/controller/pcie-mediatek-gen3.c > > > index e0e27645fdf4..ba8cfce03aad 100644 > > > --- a/drivers/pci/controller/pcie-mediatek-gen3.c > > > +++ b/drivers/pci/controller/pcie-mediatek-gen3.c > > > @@ -350,7 +350,13 @@ static int mtk_pcie_startup_port(struct > > > mtk_gen3_pcie *pcie) > > > > > > > I feel like I'm missing something because this patch seems to be > > adding a delay for T_PVPERL, but the comment before the existing > > msleep() claims *it* is the T_PVPERL delay: > > > > * Described in PCIe CEM specification sections 2.2 (PERST# > > Signal) > > * and 2.2.1 (Initial Power-Up (G3 to S0)). > > * The deassertion of PERST# should be delayed 100ms > > (TPVPERL) > > * for the power and clock to become stable. > > > > > msleep(100); > > > > > > /* De-assert reset signals */ > > > - val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | > > > PCIE_PE_RSTB); > > > + val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB); > > > + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); > > > + > > > + msleep(100); > > > > > > > So I'm confused about these two sleeps. Are they for different > > parameters? > > > > T_PVPERL is defined from "Power stable to PERST# inactive". Do we > > have any actual indication of when to start that delay, i.e., do we > > have a clue about when power became stable? > > > > > + /* De-assert PERST# signals */ > > > + val &= ~(PCIE_PE_RSTB); > > > writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); > > > > > > /* Check if the link is up or not */ > > > -- > > > 2.42.0 > > > linux-arm-kernel mailing list > > > linux-arm-kernel@lists.infradead.org > > > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel > > Hi > > Seems it is same as the patch i've sent some time ago and which was > rejected because of the additional delay... > > https://patchwork.kernel.org/project/linux-mediatek/patch/20230402131347.99268-1-linux@fw-web.de/ > > Or am i wrong? > regards Frank Hi Daniel, Did you found this issue on MT7986(BPI-R3) or other platforms? Can you share the PCIe device model that failed to link up? Thanks.
diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c index e0e27645fdf4..ba8cfce03aad 100644 --- a/drivers/pci/controller/pcie-mediatek-gen3.c +++ b/drivers/pci/controller/pcie-mediatek-gen3.c @@ -350,7 +350,13 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie) msleep(100); /* De-assert reset signals */ - val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB); + val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB); + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); + + msleep(100); + + /* De-assert PERST# signals */ + val &= ~(PCIE_PE_RSTB); writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); /* Check if the link is up or not */