* [PATCH v3] PCI: mediatek-gen3: Avoid PCIe resetting via PCIE_RSTB for Airoha EN7581 SoC
@ 2024-11-13 13:58 Lorenzo Bianconi
2024-11-19 8:15 ` Lorenzo Bianconi
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Lorenzo Bianconi @ 2024-11-13 13:58 UTC (permalink / raw)
To: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
Matthias Brugger, AngeloGioacchino Del Regno,
Manivannan Sadhasivam
Cc: Christian Marangi, linux-pci, linux-mediatek, linux-arm-kernel,
upstream, Hui Ma, Lorenzo Bianconi
Airoha EN7581 has a hw bug asserting/releasing PCIE_PE_RSTB signal
causing occasional PCIe link down issues. In order to overcome the
problem, PCIE_RSTB signals are not asserted/released during device probe or
suspend/resume phase and the PCIe block is reset using REG_PCI_CONTROL
(0x88) and REG_RESET_CONTROL (0x834) registers available in the clock
module running clk_bulk_prepare_enable in mtk_pcie_en7581_power_up().
Introduce flags field in the mtk_gen3_pcie_pdata struct in order to
specify per-SoC capabilities.
Tested-by: Hui Ma <hui.ma@airoha.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
Changes in v3:
- cosmetics
- Link to v2: https://lore.kernel.org/r/20241104-pcie-en7581-rst-fix-v2-1-ffe5839c76d8@kernel.org
Changes in v2:
- introduce flags field in mtk_gen3_pcie_flags struct instead of adding
reset callback
- fix the leftover case in mtk_pcie_suspend_noirq routine
- add more comments
- Link to v1: https://lore.kernel.org/r/20240920-pcie-en7581-rst-fix-v1-1-1043fb63ffc9@kernel.org
---
drivers/pci/controller/pcie-mediatek-gen3.c | 60 ++++++++++++++++++++---------
1 file changed, 42 insertions(+), 18 deletions(-)
diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
index 16a55711a7f3bdc8d6620029e3d2cfdd40b537b7..443072adb9b52a6934a5d1e38eb6fca5f86a1e13 100644
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
@@ -128,10 +128,18 @@
struct mtk_gen3_pcie;
+enum mtk_gen3_pcie_flags {
+ SKIP_PCIE_RSTB = BIT(0), /* skip PCIE_RSTB signals configuration
+ * during device probing or suspend/resume
+ * phase in order to avoid hw bugs/issues.
+ */
+};
+
/**
* struct mtk_gen3_pcie_pdata - differentiate between host generations
* @power_up: pcie power_up callback
* @phy_resets: phy reset lines SoC data.
+ * @flags: pcie device flags.
*/
struct mtk_gen3_pcie_pdata {
int (*power_up)(struct mtk_gen3_pcie *pcie);
@@ -139,6 +147,7 @@ struct mtk_gen3_pcie_pdata {
const char *id[MAX_NUM_PHY_RESETS];
int num_resets;
} phy_resets;
+ u32 flags;
};
/**
@@ -405,22 +414,34 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie)
val |= PCIE_DISABLE_DVFSRC_VLT_REQ;
writel_relaxed(val, pcie->base + PCIE_MISC_CTRL_REG);
- /* Assert all reset signals */
- val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
- val |= PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB;
- writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
-
/*
- * 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.
+ * Airoha EN7581 has a hw bug asserting/releasing PCIE_PE_RSTB signal
+ * causing occasional PCIe link down. In order to overcome the issue,
+ * PCIE_RSTB signals are not asserted/released at this stage and the
+ * PCIe block is reset configuting REG_PCI_CONTROL (0x88) and
+ * REG_RESET_CONTROL (0x834) registers available in the clock module
+ * running clk_bulk_prepare_enable in mtk_pcie_en7581_power_up().
*/
- msleep(100);
-
- /* De-assert reset signals */
- val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB);
- writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
+ if (!(pcie->soc->flags & SKIP_PCIE_RSTB)) {
+ /* Assert all reset signals */
+ val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
+ val |= PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB |
+ PCIE_PE_RSTB;
+ writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
+
+ /*
+ * 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(PCIE_T_PVPERL_MS);
+
+ /* De-assert reset signals */
+ val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB |
+ PCIE_PE_RSTB);
+ writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
+ }
/* Check if the link is up or not */
err = readl_poll_timeout(pcie->base + PCIE_LINK_STATUS_REG, val,
@@ -1179,10 +1200,12 @@ static int mtk_pcie_suspend_noirq(struct device *dev)
return err;
}
- /* Pull down the PERST# pin */
- val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
- val |= PCIE_PE_RSTB;
- writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
+ if (!(pcie->soc->flags & SKIP_PCIE_RSTB)) {
+ /* Pull down the PERST# pin */
+ val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
+ val |= PCIE_PE_RSTB;
+ writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
+ }
dev_dbg(pcie->dev, "entered L2 states successfully");
@@ -1233,6 +1256,7 @@ static const struct mtk_gen3_pcie_pdata mtk_pcie_soc_en7581 = {
.id[2] = "phy-lane2",
.num_resets = 3,
},
+ .flags = SKIP_PCIE_RSTB,
};
static const struct of_device_id mtk_pcie_of_match[] = {
---
base-commit: ff80d707f3cb5e8d9ec0739e0e5ed42dea179125
change-id: 20240920-pcie-en7581-rst-fix-8161658c13c4
Best regards,
--
Lorenzo Bianconi <lorenzo@kernel.org>
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3] PCI: mediatek-gen3: Avoid PCIe resetting via PCIE_RSTB for Airoha EN7581 SoC
2024-11-13 13:58 [PATCH v3] PCI: mediatek-gen3: Avoid PCIe resetting via PCIE_RSTB for Airoha EN7581 SoC Lorenzo Bianconi
@ 2024-11-19 8:15 ` Lorenzo Bianconi
2024-11-19 17:43 ` Bjorn Helgaas
2024-12-22 21:17 ` Krzysztof Wilczyński
2024-12-30 18:58 ` Bjorn Helgaas
2 siblings, 1 reply; 7+ messages in thread
From: Lorenzo Bianconi @ 2024-11-19 8:15 UTC (permalink / raw)
To: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
Matthias Brugger, AngeloGioacchino Del Regno,
Manivannan Sadhasivam
Cc: Christian Marangi, linux-pci, linux-mediatek, linux-arm-kernel,
upstream, Hui Ma
[-- Attachment #1: Type: text/plain, Size: 5661 bytes --]
> Airoha EN7581 has a hw bug asserting/releasing PCIE_PE_RSTB signal
> causing occasional PCIe link down issues. In order to overcome the
> problem, PCIE_RSTB signals are not asserted/released during device probe or
> suspend/resume phase and the PCIe block is reset using REG_PCI_CONTROL
> (0x88) and REG_RESET_CONTROL (0x834) registers available in the clock
> module running clk_bulk_prepare_enable in mtk_pcie_en7581_power_up().
>
> Introduce flags field in the mtk_gen3_pcie_pdata struct in order to
> specify per-SoC capabilities.
>
> Tested-by: Hui Ma <hui.ma@airoha.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Hi Jianjun and Bjorn,
any news about this patch? Thanks in advance.
Regards,
Lorenzo
> ---
> Changes in v3:
> - cosmetics
> - Link to v2: https://lore.kernel.org/r/20241104-pcie-en7581-rst-fix-v2-1-ffe5839c76d8@kernel.org
>
> Changes in v2:
> - introduce flags field in mtk_gen3_pcie_flags struct instead of adding
> reset callback
> - fix the leftover case in mtk_pcie_suspend_noirq routine
> - add more comments
> - Link to v1: https://lore.kernel.org/r/20240920-pcie-en7581-rst-fix-v1-1-1043fb63ffc9@kernel.org
> ---
> drivers/pci/controller/pcie-mediatek-gen3.c | 60 ++++++++++++++++++++---------
> 1 file changed, 42 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> index 16a55711a7f3bdc8d6620029e3d2cfdd40b537b7..443072adb9b52a6934a5d1e38eb6fca5f86a1e13 100644
> --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> @@ -128,10 +128,18 @@
>
> struct mtk_gen3_pcie;
>
> +enum mtk_gen3_pcie_flags {
> + SKIP_PCIE_RSTB = BIT(0), /* skip PCIE_RSTB signals configuration
> + * during device probing or suspend/resume
> + * phase in order to avoid hw bugs/issues.
> + */
> +};
> +
> /**
> * struct mtk_gen3_pcie_pdata - differentiate between host generations
> * @power_up: pcie power_up callback
> * @phy_resets: phy reset lines SoC data.
> + * @flags: pcie device flags.
> */
> struct mtk_gen3_pcie_pdata {
> int (*power_up)(struct mtk_gen3_pcie *pcie);
> @@ -139,6 +147,7 @@ struct mtk_gen3_pcie_pdata {
> const char *id[MAX_NUM_PHY_RESETS];
> int num_resets;
> } phy_resets;
> + u32 flags;
> };
>
> /**
> @@ -405,22 +414,34 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie)
> val |= PCIE_DISABLE_DVFSRC_VLT_REQ;
> writel_relaxed(val, pcie->base + PCIE_MISC_CTRL_REG);
>
> - /* Assert all reset signals */
> - val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
> - val |= PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB;
> - writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> -
> /*
> - * 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.
> + * Airoha EN7581 has a hw bug asserting/releasing PCIE_PE_RSTB signal
> + * causing occasional PCIe link down. In order to overcome the issue,
> + * PCIE_RSTB signals are not asserted/released at this stage and the
> + * PCIe block is reset configuting REG_PCI_CONTROL (0x88) and
> + * REG_RESET_CONTROL (0x834) registers available in the clock module
> + * running clk_bulk_prepare_enable in mtk_pcie_en7581_power_up().
> */
> - msleep(100);
> -
> - /* De-assert reset signals */
> - val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB);
> - writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> + if (!(pcie->soc->flags & SKIP_PCIE_RSTB)) {
> + /* Assert all reset signals */
> + val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
> + val |= PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB |
> + PCIE_PE_RSTB;
> + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> +
> + /*
> + * 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(PCIE_T_PVPERL_MS);
> +
> + /* De-assert reset signals */
> + val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB |
> + PCIE_PE_RSTB);
> + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> + }
>
> /* Check if the link is up or not */
> err = readl_poll_timeout(pcie->base + PCIE_LINK_STATUS_REG, val,
> @@ -1179,10 +1200,12 @@ static int mtk_pcie_suspend_noirq(struct device *dev)
> return err;
> }
>
> - /* Pull down the PERST# pin */
> - val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
> - val |= PCIE_PE_RSTB;
> - writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> + if (!(pcie->soc->flags & SKIP_PCIE_RSTB)) {
> + /* Pull down the PERST# pin */
> + val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
> + val |= PCIE_PE_RSTB;
> + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> + }
>
> dev_dbg(pcie->dev, "entered L2 states successfully");
>
> @@ -1233,6 +1256,7 @@ static const struct mtk_gen3_pcie_pdata mtk_pcie_soc_en7581 = {
> .id[2] = "phy-lane2",
> .num_resets = 3,
> },
> + .flags = SKIP_PCIE_RSTB,
> };
>
> static const struct of_device_id mtk_pcie_of_match[] = {
>
> ---
> base-commit: ff80d707f3cb5e8d9ec0739e0e5ed42dea179125
> change-id: 20240920-pcie-en7581-rst-fix-8161658c13c4
>
> Best regards,
> --
> Lorenzo Bianconi <lorenzo@kernel.org>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] PCI: mediatek-gen3: Avoid PCIe resetting via PCIE_RSTB for Airoha EN7581 SoC
2024-11-19 8:15 ` Lorenzo Bianconi
@ 2024-11-19 17:43 ` Bjorn Helgaas
0 siblings, 0 replies; 7+ messages in thread
From: Bjorn Helgaas @ 2024-11-19 17:43 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
Matthias Brugger, AngeloGioacchino Del Regno,
Manivannan Sadhasivam, Christian Marangi, linux-pci,
linux-mediatek, linux-arm-kernel, upstream, Hui Ma
On Tue, Nov 19, 2024 at 09:15:45AM +0100, Lorenzo Bianconi wrote:
> > Airoha EN7581 has a hw bug asserting/releasing PCIE_PE_RSTB signal
> > causing occasional PCIe link down issues. In order to overcome the
> > problem, PCIE_RSTB signals are not asserted/released during device probe or
> > suspend/resume phase and the PCIe block is reset using REG_PCI_CONTROL
> > (0x88) and REG_RESET_CONTROL (0x834) registers available in the clock
> > module running clk_bulk_prepare_enable in mtk_pcie_en7581_power_up().
> >
> > Introduce flags field in the mtk_gen3_pcie_pdata struct in order to
> > specify per-SoC capabilities.
> >
> > Tested-by: Hui Ma <hui.ma@airoha.com>
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
>
> Hi Jianjun and Bjorn,
>
> any news about this patch? Thanks in advance.
The v6.13 merge window is open now, so we will merge new content for
v6.14 soon after v6.13-rc1 is tagged, which will probably be Dec 1.
> > ---
> > Changes in v3:
> > - cosmetics
> > - Link to v2: https://lore.kernel.org/r/20241104-pcie-en7581-rst-fix-v2-1-ffe5839c76d8@kernel.org
> >
> > Changes in v2:
> > - introduce flags field in mtk_gen3_pcie_flags struct instead of adding
> > reset callback
> > - fix the leftover case in mtk_pcie_suspend_noirq routine
> > - add more comments
> > - Link to v1: https://lore.kernel.org/r/20240920-pcie-en7581-rst-fix-v1-1-1043fb63ffc9@kernel.org
> > ---
> > drivers/pci/controller/pcie-mediatek-gen3.c | 60 ++++++++++++++++++++---------
> > 1 file changed, 42 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> > index 16a55711a7f3bdc8d6620029e3d2cfdd40b537b7..443072adb9b52a6934a5d1e38eb6fca5f86a1e13 100644
> > --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> > +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> > @@ -128,10 +128,18 @@
> >
> > struct mtk_gen3_pcie;
> >
> > +enum mtk_gen3_pcie_flags {
> > + SKIP_PCIE_RSTB = BIT(0), /* skip PCIE_RSTB signals configuration
> > + * during device probing or suspend/resume
> > + * phase in order to avoid hw bugs/issues.
> > + */
> > +};
> > +
> > /**
> > * struct mtk_gen3_pcie_pdata - differentiate between host generations
> > * @power_up: pcie power_up callback
> > * @phy_resets: phy reset lines SoC data.
> > + * @flags: pcie device flags.
> > */
> > struct mtk_gen3_pcie_pdata {
> > int (*power_up)(struct mtk_gen3_pcie *pcie);
> > @@ -139,6 +147,7 @@ struct mtk_gen3_pcie_pdata {
> > const char *id[MAX_NUM_PHY_RESETS];
> > int num_resets;
> > } phy_resets;
> > + u32 flags;
> > };
> >
> > /**
> > @@ -405,22 +414,34 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie)
> > val |= PCIE_DISABLE_DVFSRC_VLT_REQ;
> > writel_relaxed(val, pcie->base + PCIE_MISC_CTRL_REG);
> >
> > - /* Assert all reset signals */
> > - val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
> > - val |= PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB;
> > - writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> > -
> > /*
> > - * 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.
> > + * Airoha EN7581 has a hw bug asserting/releasing PCIE_PE_RSTB signal
> > + * causing occasional PCIe link down. In order to overcome the issue,
> > + * PCIE_RSTB signals are not asserted/released at this stage and the
> > + * PCIe block is reset configuting REG_PCI_CONTROL (0x88) and
> > + * REG_RESET_CONTROL (0x834) registers available in the clock module
> > + * running clk_bulk_prepare_enable in mtk_pcie_en7581_power_up().
> > */
> > - msleep(100);
> > -
> > - /* De-assert reset signals */
> > - val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB);
> > - writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> > + if (!(pcie->soc->flags & SKIP_PCIE_RSTB)) {
> > + /* Assert all reset signals */
> > + val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
> > + val |= PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB |
> > + PCIE_PE_RSTB;
> > + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> > +
> > + /*
> > + * 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(PCIE_T_PVPERL_MS);
> > +
> > + /* De-assert reset signals */
> > + val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB |
> > + PCIE_PE_RSTB);
> > + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> > + }
> >
> > /* Check if the link is up or not */
> > err = readl_poll_timeout(pcie->base + PCIE_LINK_STATUS_REG, val,
> > @@ -1179,10 +1200,12 @@ static int mtk_pcie_suspend_noirq(struct device *dev)
> > return err;
> > }
> >
> > - /* Pull down the PERST# pin */
> > - val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
> > - val |= PCIE_PE_RSTB;
> > - writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> > + if (!(pcie->soc->flags & SKIP_PCIE_RSTB)) {
> > + /* Pull down the PERST# pin */
> > + val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
> > + val |= PCIE_PE_RSTB;
> > + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> > + }
> >
> > dev_dbg(pcie->dev, "entered L2 states successfully");
> >
> > @@ -1233,6 +1256,7 @@ static const struct mtk_gen3_pcie_pdata mtk_pcie_soc_en7581 = {
> > .id[2] = "phy-lane2",
> > .num_resets = 3,
> > },
> > + .flags = SKIP_PCIE_RSTB,
> > };
> >
> > static const struct of_device_id mtk_pcie_of_match[] = {
> >
> > ---
> > base-commit: ff80d707f3cb5e8d9ec0739e0e5ed42dea179125
> > change-id: 20240920-pcie-en7581-rst-fix-8161658c13c4
> >
> > Best regards,
> > --
> > Lorenzo Bianconi <lorenzo@kernel.org>
> >
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] PCI: mediatek-gen3: Avoid PCIe resetting via PCIE_RSTB for Airoha EN7581 SoC
2024-11-13 13:58 [PATCH v3] PCI: mediatek-gen3: Avoid PCIe resetting via PCIE_RSTB for Airoha EN7581 SoC Lorenzo Bianconi
2024-11-19 8:15 ` Lorenzo Bianconi
@ 2024-12-22 21:17 ` Krzysztof Wilczyński
2024-12-30 18:58 ` Bjorn Helgaas
2 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Wilczyński @ 2024-12-22 21:17 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi, Rob Herring,
Bjorn Helgaas, Matthias Brugger, AngeloGioacchino Del Regno,
Manivannan Sadhasivam, Christian Marangi, linux-pci,
linux-mediatek, linux-arm-kernel, upstream, Hui Ma
Hello,
> Airoha EN7581 has a hw bug asserting/releasing PCIE_PE_RSTB signal
> causing occasional PCIe link down issues. In order to overcome the
> problem, PCIE_RSTB signals are not asserted/released during device probe or
> suspend/resume phase and the PCIe block is reset using REG_PCI_CONTROL
> (0x88) and REG_RESET_CONTROL (0x834) registers available in the clock
> module running clk_bulk_prepare_enable in mtk_pcie_en7581_power_up().
>
> Introduce flags field in the mtk_gen3_pcie_pdata struct in order to
> specify per-SoC capabilities.
Applied to controller/mediatek, thank you!
[01/01] PCI: mediatek-gen3: Avoid PCIe resetting via PCIE_RSTB for Airoha EN7581 SoC
https://git.kernel.org/pci/pci/c/0d0a2b74dc08
Krzysztof
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] PCI: mediatek-gen3: Avoid PCIe resetting via PCIE_RSTB for Airoha EN7581 SoC
2024-11-13 13:58 [PATCH v3] PCI: mediatek-gen3: Avoid PCIe resetting via PCIE_RSTB for Airoha EN7581 SoC Lorenzo Bianconi
2024-11-19 8:15 ` Lorenzo Bianconi
2024-12-22 21:17 ` Krzysztof Wilczyński
@ 2024-12-30 18:58 ` Bjorn Helgaas
2025-01-02 11:29 ` Lorenzo Bianconi
2 siblings, 1 reply; 7+ messages in thread
From: Bjorn Helgaas @ 2024-12-30 18:58 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
Matthias Brugger, AngeloGioacchino Del Regno,
Manivannan Sadhasivam, Christian Marangi, linux-pci,
linux-mediatek, linux-arm-kernel, upstream, Hui Ma
On Wed, Nov 13, 2024 at 02:58:08PM +0100, Lorenzo Bianconi wrote:
> Airoha EN7581 has a hw bug asserting/releasing PCIE_PE_RSTB signal
> causing occasional PCIe link down issues. In order to overcome the
> problem, PCIE_RSTB signals are not asserted/released during device probe or
> suspend/resume phase and the PCIe block is reset using REG_PCI_CONTROL
> (0x88) and REG_RESET_CONTROL (0x834) registers available in the clock
> module running clk_bulk_prepare_enable in mtk_pcie_en7581_power_up().
>
> Introduce flags field in the mtk_gen3_pcie_pdata struct in order to
> specify per-SoC capabilities.
Is there a URL or some other way to cite erratum documentation for
this?
> Tested-by: Hui Ma <hui.ma@airoha.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> Changes in v3:
> - cosmetics
> - Link to v2: https://lore.kernel.org/r/20241104-pcie-en7581-rst-fix-v2-1-ffe5839c76d8@kernel.org
>
> Changes in v2:
> - introduce flags field in mtk_gen3_pcie_flags struct instead of adding
> reset callback
> - fix the leftover case in mtk_pcie_suspend_noirq routine
> - add more comments
> - Link to v1: https://lore.kernel.org/r/20240920-pcie-en7581-rst-fix-v1-1-1043fb63ffc9@kernel.org
> ---
> drivers/pci/controller/pcie-mediatek-gen3.c | 60 ++++++++++++++++++++---------
> 1 file changed, 42 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> index 16a55711a7f3bdc8d6620029e3d2cfdd40b537b7..443072adb9b52a6934a5d1e38eb6fca5f86a1e13 100644
> --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> @@ -128,10 +128,18 @@
>
> struct mtk_gen3_pcie;
>
> +enum mtk_gen3_pcie_flags {
> + SKIP_PCIE_RSTB = BIT(0), /* skip PCIE_RSTB signals configuration
> + * during device probing or suspend/resume
> + * phase in order to avoid hw bugs/issues.
Maybe "Skip PERST# assertion"?
s/in order to/to/
> + */
> +};
> +
> /**
> * struct mtk_gen3_pcie_pdata - differentiate between host generations
> * @power_up: pcie power_up callback
> * @phy_resets: phy reset lines SoC data.
> + * @flags: pcie device flags.
> */
> struct mtk_gen3_pcie_pdata {
> int (*power_up)(struct mtk_gen3_pcie *pcie);
> @@ -139,6 +147,7 @@ struct mtk_gen3_pcie_pdata {
> const char *id[MAX_NUM_PHY_RESETS];
> int num_resets;
> } phy_resets;
> + u32 flags;
> };
>
> /**
> @@ -405,22 +414,34 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie)
> val |= PCIE_DISABLE_DVFSRC_VLT_REQ;
> writel_relaxed(val, pcie->base + PCIE_MISC_CTRL_REG);
>
> - /* Assert all reset signals */
> - val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
> - val |= PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB;
> - writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> -
> /*
> - * 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.
> + * Airoha EN7581 has a hw bug asserting/releasing PCIE_PE_RSTB signal
> + * causing occasional PCIe link down. In order to overcome the issue,
> + * PCIE_RSTB signals are not asserted/released at this stage and the
> + * PCIe block is reset configuting REG_PCI_CONTROL (0x88) and
s/configuting/configuring/
"... is reset configuring ..." doesn't read smoothly. Maybe "reset
*using*" or similar? (I guess "reset using" is what you wrote in the
commit log.)
I think if you mention the name of the en7581 clk function, that would
be enough, and we wouldn't need the register names, offsets, and
"available in the clock module".
> + * REG_RESET_CONTROL (0x834) registers available in the clock module
> + * running clk_bulk_prepare_enable in mtk_pcie_en7581_power_up().
Mention the en7581 clk function, not the generic
clk_bulk_prepare_enable(). It's hard to get from generic to specific.
> - msleep(100);
> -
> - /* De-assert reset signals */
> - val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB);
> - writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> + if (!(pcie->soc->flags & SKIP_PCIE_RSTB)) {
> + /* Assert all reset signals */
> + val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
> + val |= PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB |
> + PCIE_PE_RSTB;
> + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> +
> + /*
> + * 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.
Add PCIe CEM spec revision, since section numbers may change between
revisions. I know you're just moving it, but this is a good chance to
fix this.
Add blank lines between paragraphs.
> + msleep(PCIE_T_PVPERL_MS);
> +
> + /* De-assert reset signals */
> + val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB |
> + PCIE_PE_RSTB);
> + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> + }
>
> /* Check if the link is up or not */
> err = readl_poll_timeout(pcie->base + PCIE_LINK_STATUS_REG, val,
> @@ -1179,10 +1200,12 @@ static int mtk_pcie_suspend_noirq(struct device *dev)
> return err;
> }
>
> - /* Pull down the PERST# pin */
> - val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
> - val |= PCIE_PE_RSTB;
> - writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> + if (!(pcie->soc->flags & SKIP_PCIE_RSTB)) {
> + /* Pull down the PERST# pin */
s/Pull down .../Assert PERST#/ to match other comments above
> + val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
> + val |= PCIE_PE_RSTB;
> + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> + }
>
> dev_dbg(pcie->dev, "entered L2 states successfully");
>
> @@ -1233,6 +1256,7 @@ static const struct mtk_gen3_pcie_pdata mtk_pcie_soc_en7581 = {
> .id[2] = "phy-lane2",
> .num_resets = 3,
> },
> + .flags = SKIP_PCIE_RSTB,
> };
>
> static const struct of_device_id mtk_pcie_of_match[] = {
>
> ---
> base-commit: ff80d707f3cb5e8d9ec0739e0e5ed42dea179125
> change-id: 20240920-pcie-en7581-rst-fix-8161658c13c4
>
> Best regards,
> --
> Lorenzo Bianconi <lorenzo@kernel.org>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] PCI: mediatek-gen3: Avoid PCIe resetting via PCIE_RSTB for Airoha EN7581 SoC
2024-12-30 18:58 ` Bjorn Helgaas
@ 2025-01-02 11:29 ` Lorenzo Bianconi
2025-01-02 23:28 ` Bjorn Helgaas
0 siblings, 1 reply; 7+ messages in thread
From: Lorenzo Bianconi @ 2025-01-02 11:29 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
Matthias Brugger, AngeloGioacchino Del Regno,
Manivannan Sadhasivam, Christian Marangi, linux-pci,
linux-mediatek, linux-arm-kernel, upstream, Hui Ma
[-- Attachment #1: Type: text/plain, Size: 7156 bytes --]
> On Wed, Nov 13, 2024 at 02:58:08PM +0100, Lorenzo Bianconi wrote:
> > Airoha EN7581 has a hw bug asserting/releasing PCIE_PE_RSTB signal
> > causing occasional PCIe link down issues. In order to overcome the
> > problem, PCIE_RSTB signals are not asserted/released during device probe or
> > suspend/resume phase and the PCIe block is reset using REG_PCI_CONTROL
> > (0x88) and REG_RESET_CONTROL (0x834) registers available in the clock
> > module running clk_bulk_prepare_enable in mtk_pcie_en7581_power_up().
> >
> > Introduce flags field in the mtk_gen3_pcie_pdata struct in order to
> > specify per-SoC capabilities.
Hi Bjorn,
similar to the other series, this patch is already in Krzysztof's branch.
Do you prefer to resend it or just incremental changes?
>
> Is there a URL or some other way to cite erratum documentation for
> this?
>
> > Tested-by: Hui Ma <hui.ma@airoha.com>
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> > Changes in v3:
> > - cosmetics
> > - Link to v2: https://lore.kernel.org/r/20241104-pcie-en7581-rst-fix-v2-1-ffe5839c76d8@kernel.org
> >
> > Changes in v2:
> > - introduce flags field in mtk_gen3_pcie_flags struct instead of adding
> > reset callback
> > - fix the leftover case in mtk_pcie_suspend_noirq routine
> > - add more comments
> > - Link to v1: https://lore.kernel.org/r/20240920-pcie-en7581-rst-fix-v1-1-1043fb63ffc9@kernel.org
> > ---
> > drivers/pci/controller/pcie-mediatek-gen3.c | 60 ++++++++++++++++++++---------
> > 1 file changed, 42 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> > index 16a55711a7f3bdc8d6620029e3d2cfdd40b537b7..443072adb9b52a6934a5d1e38eb6fca5f86a1e13 100644
> > --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> > +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> > @@ -128,10 +128,18 @@
> >
> > struct mtk_gen3_pcie;
> >
> > +enum mtk_gen3_pcie_flags {
> > + SKIP_PCIE_RSTB = BIT(0), /* skip PCIE_RSTB signals configuration
> > + * during device probing or suspend/resume
> > + * phase in order to avoid hw bugs/issues.
>
> Maybe "Skip PERST# assertion"?
>
> s/in order to/to/
ack, I will fix it.
>
> > + */
> > +};
> > +
> > /**
> > * struct mtk_gen3_pcie_pdata - differentiate between host generations
> > * @power_up: pcie power_up callback
> > * @phy_resets: phy reset lines SoC data.
> > + * @flags: pcie device flags.
> > */
> > struct mtk_gen3_pcie_pdata {
> > int (*power_up)(struct mtk_gen3_pcie *pcie);
> > @@ -139,6 +147,7 @@ struct mtk_gen3_pcie_pdata {
> > const char *id[MAX_NUM_PHY_RESETS];
> > int num_resets;
> > } phy_resets;
> > + u32 flags;
> > };
> >
> > /**
> > @@ -405,22 +414,34 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie)
> > val |= PCIE_DISABLE_DVFSRC_VLT_REQ;
> > writel_relaxed(val, pcie->base + PCIE_MISC_CTRL_REG);
> >
> > - /* Assert all reset signals */
> > - val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
> > - val |= PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB;
> > - writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> > -
> > /*
> > - * 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.
> > + * Airoha EN7581 has a hw bug asserting/releasing PCIE_PE_RSTB signal
> > + * causing occasional PCIe link down. In order to overcome the issue,
> > + * PCIE_RSTB signals are not asserted/released at this stage and the
> > + * PCIe block is reset configuting REG_PCI_CONTROL (0x88) and
>
> s/configuting/configuring/
>
> "... is reset configuring ..." doesn't read smoothly. Maybe "reset
> *using*" or similar? (I guess "reset using" is what you wrote in the
> commit log.)
>
> I think if you mention the name of the en7581 clk function, that would
> be enough, and we wouldn't need the register names, offsets, and
> "available in the clock module".
ack, I will fix it.
>
> > + * REG_RESET_CONTROL (0x834) registers available in the clock module
> > + * running clk_bulk_prepare_enable in mtk_pcie_en7581_power_up().
>
> Mention the en7581 clk function, not the generic
> clk_bulk_prepare_enable(). It's hard to get from generic to specific.
ack, I will fix it.
>
> > - msleep(100);
> > -
> > - /* De-assert reset signals */
> > - val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB);
> > - writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> > + if (!(pcie->soc->flags & SKIP_PCIE_RSTB)) {
> > + /* Assert all reset signals */
> > + val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
> > + val |= PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB |
> > + PCIE_PE_RSTB;
> > + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> > +
> > + /*
> > + * 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.
>
> Add PCIe CEM spec revision, since section numbers may change between
> revisions. I know you're just moving it, but this is a good chance to
> fix this.
ack, I will fix it.
>
> Add blank lines between paragraphs.
ack, I will fix it.
>
> > + msleep(PCIE_T_PVPERL_MS);
> > +
> > + /* De-assert reset signals */
> > + val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB |
> > + PCIE_PE_RSTB);
> > + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> > + }
> >
> > /* Check if the link is up or not */
> > err = readl_poll_timeout(pcie->base + PCIE_LINK_STATUS_REG, val,
> > @@ -1179,10 +1200,12 @@ static int mtk_pcie_suspend_noirq(struct device *dev)
> > return err;
> > }
> >
> > - /* Pull down the PERST# pin */
> > - val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
> > - val |= PCIE_PE_RSTB;
> > - writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> > + if (!(pcie->soc->flags & SKIP_PCIE_RSTB)) {
> > + /* Pull down the PERST# pin */
>
> s/Pull down .../Assert PERST#/ to match other comments above
ack, I will fix it.
Regards,
Lorenzo
>
> > + val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
> > + val |= PCIE_PE_RSTB;
> > + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> > + }
> >
> > dev_dbg(pcie->dev, "entered L2 states successfully");
> >
> > @@ -1233,6 +1256,7 @@ static const struct mtk_gen3_pcie_pdata mtk_pcie_soc_en7581 = {
> > .id[2] = "phy-lane2",
> > .num_resets = 3,
> > },
> > + .flags = SKIP_PCIE_RSTB,
> > };
> >
> > static const struct of_device_id mtk_pcie_of_match[] = {
> >
> > ---
> > base-commit: ff80d707f3cb5e8d9ec0739e0e5ed42dea179125
> > change-id: 20240920-pcie-en7581-rst-fix-8161658c13c4
> >
> > Best regards,
> > --
> > Lorenzo Bianconi <lorenzo@kernel.org>
> >
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] PCI: mediatek-gen3: Avoid PCIe resetting via PCIE_RSTB for Airoha EN7581 SoC
2025-01-02 11:29 ` Lorenzo Bianconi
@ 2025-01-02 23:28 ` Bjorn Helgaas
0 siblings, 0 replies; 7+ messages in thread
From: Bjorn Helgaas @ 2025-01-02 23:28 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
Matthias Brugger, AngeloGioacchino Del Regno,
Manivannan Sadhasivam, Christian Marangi, linux-pci,
linux-mediatek, linux-arm-kernel, upstream, Hui Ma
On Thu, Jan 02, 2025 at 12:29:17PM +0100, Lorenzo Bianconi wrote:
> > On Wed, Nov 13, 2024 at 02:58:08PM +0100, Lorenzo Bianconi wrote:
> > > Airoha EN7581 has a hw bug asserting/releasing PCIE_PE_RSTB signal
> > > causing occasional PCIe link down issues. In order to overcome the
> > > problem, PCIE_RSTB signals are not asserted/released during device probe or
> > > suspend/resume phase and the PCIe block is reset using REG_PCI_CONTROL
> > > (0x88) and REG_RESET_CONTROL (0x834) registers available in the clock
> > > module running clk_bulk_prepare_enable in mtk_pcie_en7581_power_up().
> > >
> > > Introduce flags field in the mtk_gen3_pcie_pdata struct in order to
> > > specify per-SoC capabilities.
>
> Hi Bjorn,
>
> similar to the other series, this patch is already in Krzysztof's branch.
> Do you prefer to resend it or just incremental changes?
If it's not too much trouble, I think a new v4 would be simplest so
the Link: in the lore archives is more correct.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-01-02 23:29 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-13 13:58 [PATCH v3] PCI: mediatek-gen3: Avoid PCIe resetting via PCIE_RSTB for Airoha EN7581 SoC Lorenzo Bianconi
2024-11-19 8:15 ` Lorenzo Bianconi
2024-11-19 17:43 ` Bjorn Helgaas
2024-12-22 21:17 ` Krzysztof Wilczyński
2024-12-30 18:58 ` Bjorn Helgaas
2025-01-02 11:29 ` Lorenzo Bianconi
2025-01-02 23:28 ` Bjorn Helgaas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).