* [PATCH v4 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring
@ 2024-11-18 8:04 Lorenzo Bianconi
2024-11-18 8:04 ` [PATCH v4 1/6] PCI: mediatek-gen3: Add missing reset_control_deassert() for mac_rst in mtk_pcie_en7581_power_up() Lorenzo Bianconi
` (5 more replies)
0 siblings, 6 replies; 18+ messages in thread
From: Lorenzo Bianconi @ 2024-11-18 8:04 UTC (permalink / raw)
To: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd
Cc: linux-pci, linux-mediatek, linux-arm-kernel, linux-clk,
Lorenzo Bianconi
Minor fixes and code refactoring in mtk_pcie_en7581_power_up() routine
---
Changes in v4:
- fix comment in patch 4/6
- Link to v3: https://lore.kernel.org/r/20241116-pcie-en7581-fixes-v3-0-f7add3afc27e@kernel.org
Changes in v3:
- add trivial patches 5/6 and 6/6 to the series
- rename err_clk_init in err_clk_prepare_enable
- fix commit log for patches 2/6 and 3/6
- Link to v2: https://lore.kernel.org/r/20241109-pcie-en7581-fixes-v2-0-0ea3a4af994f@kernel.org
Changes in v2:
- added trivial patch 4/4
- improved commit logs and comments
- introduced PCIE_MTK_RESET_TIME_US macro
- Link to v1: https://lore.kernel.org/r/20241107-pcie-en7581-fixes-v1-0-af0c872323c7@kernel.org
---
Lorenzo Bianconi (6):
PCI: mediatek-gen3: Add missing reset_control_deassert() for mac_rst in mtk_pcie_en7581_power_up()
PCI: mediatek-gen3: rely on clk_bulk_prepare_enable() in mtk_pcie_en7581_power_up()
PCI: mediatek-gen3: Move reset/assert callbacks in .power_up()
PCI: mediatek-gen3: Add comment about initialization order in mtk_pcie_en7581_power_up()
PCI: mediatek-gen3: Add reset delay in mtk_pcie_en7581_power_up()
PCI: mediatek-gen3: rely on msleep() in mtk_pcie_en7581_power_up()
drivers/clk/clk-en7523.c | 1 -
drivers/pci/controller/pcie-mediatek-gen3.c | 60 +++++++++++++++++++----------
2 files changed, 39 insertions(+), 22 deletions(-)
---
base-commit: ac9626f643ea9cde795811d924388fa49f2c4c0c
change-id: 20241107-pcie-en7581-fixes-296505fd2353
Best regards,
--
Lorenzo Bianconi <lorenzo@kernel.org>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v4 1/6] PCI: mediatek-gen3: Add missing reset_control_deassert() for mac_rst in mtk_pcie_en7581_power_up()
2024-11-18 8:04 [PATCH v4 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Lorenzo Bianconi
@ 2024-11-18 8:04 ` Lorenzo Bianconi
2024-11-18 8:04 ` [PATCH v4 2/6] PCI: mediatek-gen3: rely on clk_bulk_prepare_enable() " Lorenzo Bianconi
` (4 subsequent siblings)
5 siblings, 0 replies; 18+ messages in thread
From: Lorenzo Bianconi @ 2024-11-18 8:04 UTC (permalink / raw)
To: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd
Cc: linux-pci, linux-mediatek, linux-arm-kernel, linux-clk,
Lorenzo Bianconi
Even if this is not a real issue since Airoha EN7581 SoC does not require
the mac reset line, add missing reset_control_deassert() for mac reset
line in mtk_pcie_en7581_power_up() callback.
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/pci/controller/pcie-mediatek-gen3.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
index 64ef8ff71b0357b9bf9ad8484095b7aa60c22271..4d1c797a32c236faf79428eb8a83708e9c4f21d8 100644
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
@@ -942,6 +942,9 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
*/
mdelay(PCIE_EN7581_RESET_TIME_MS);
+ /* MAC power on and enable transaction layer clocks */
+ reset_control_deassert(pcie->mac_reset);
+
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
@@ -976,6 +979,7 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
err_clk_prepare:
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);
+ reset_control_assert(pcie->mac_reset);
reset_control_bulk_assert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
err_phy_deassert:
phy_power_off(pcie->phy);
--
2.47.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v4 2/6] PCI: mediatek-gen3: rely on clk_bulk_prepare_enable() in mtk_pcie_en7581_power_up()
2024-11-18 8:04 [PATCH v4 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Lorenzo Bianconi
2024-11-18 8:04 ` [PATCH v4 1/6] PCI: mediatek-gen3: Add missing reset_control_deassert() for mac_rst in mtk_pcie_en7581_power_up() Lorenzo Bianconi
@ 2024-11-18 8:04 ` Lorenzo Bianconi
2024-11-23 9:05 ` Manivannan Sadhasivam
2024-11-18 8:04 ` [PATCH v4 3/6] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up() Lorenzo Bianconi
` (3 subsequent siblings)
5 siblings, 1 reply; 18+ messages in thread
From: Lorenzo Bianconi @ 2024-11-18 8:04 UTC (permalink / raw)
To: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd
Cc: linux-pci, linux-mediatek, linux-arm-kernel, linux-clk,
Lorenzo Bianconi
Replace clk_bulk_prepare() and clk_bulk_enable() with
clk_bulk_prepare_enable() in mtk_pcie_en7581_power_up() routine.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/pci/controller/pcie-mediatek-gen3.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
index 4d1c797a32c236faf79428eb8a83708e9c4f21d8..3cfcb45d31508142d28d338ff213f70de9b4e608 100644
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
@@ -948,12 +948,6 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
- err = clk_bulk_prepare(pcie->num_clks, pcie->clks);
- if (err) {
- dev_err(dev, "failed to prepare clock\n");
- goto err_clk_prepare;
- }
-
val = FIELD_PREP(PCIE_VAL_LN0_DOWNSTREAM, 0x47) |
FIELD_PREP(PCIE_VAL_LN1_DOWNSTREAM, 0x47) |
FIELD_PREP(PCIE_VAL_LN0_UPSTREAM, 0x41) |
@@ -966,17 +960,15 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
FIELD_PREP(PCIE_K_FINETUNE_MAX, 0xf);
writel_relaxed(val, pcie->base + PCIE_PIPE4_PIE8_REG);
- err = clk_bulk_enable(pcie->num_clks, pcie->clks);
+ err = clk_bulk_prepare_enable(pcie->num_clks, pcie->clks);
if (err) {
dev_err(dev, "failed to prepare clock\n");
- goto err_clk_enable;
+ goto err_clk_prepare_enable;
}
return 0;
-err_clk_enable:
- clk_bulk_unprepare(pcie->num_clks, pcie->clks);
-err_clk_prepare:
+err_clk_prepare_enable:
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);
reset_control_assert(pcie->mac_reset);
--
2.47.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v4 3/6] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up()
2024-11-18 8:04 [PATCH v4 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Lorenzo Bianconi
2024-11-18 8:04 ` [PATCH v4 1/6] PCI: mediatek-gen3: Add missing reset_control_deassert() for mac_rst in mtk_pcie_en7581_power_up() Lorenzo Bianconi
2024-11-18 8:04 ` [PATCH v4 2/6] PCI: mediatek-gen3: rely on clk_bulk_prepare_enable() " Lorenzo Bianconi
@ 2024-11-18 8:04 ` Lorenzo Bianconi
2024-11-18 8:49 ` Philipp Zabel
2024-11-23 9:06 ` Manivannan Sadhasivam
2024-11-18 8:04 ` [PATCH v4 4/6] PCI: mediatek-gen3: Add comment about initialization order in mtk_pcie_en7581_power_up() Lorenzo Bianconi
` (2 subsequent siblings)
5 siblings, 2 replies; 18+ messages in thread
From: Lorenzo Bianconi @ 2024-11-18 8:04 UTC (permalink / raw)
To: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd
Cc: linux-pci, linux-mediatek, linux-arm-kernel, linux-clk,
Lorenzo Bianconi
In order to make the code more readable, the reset_control_bulk_assert()
for PHY reset lines is moved to make it pair with
reset_control_bulk_deassert() in mtk_pcie_power_up() and
mtk_pcie_en7581_power_up(). The same change is done for
reset_control_assert() used to assert MAC reset line.
Introduce PCIE_MTK_RESET_TIME_US macro for the time needed to
complete PCIe reset on MediaTek controller.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/pci/controller/pcie-mediatek-gen3.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
index 3cfcb45d31508142d28d338ff213f70de9b4e608..2b80edd4462ad4e9f2a5d192db7f99307113eb8a 100644
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
@@ -125,6 +125,8 @@
#define MAX_NUM_PHY_RESETS 3
+#define PCIE_MTK_RESET_TIME_US 10
+
/* Time in ms needed to complete PCIe reset on EN7581 SoC */
#define PCIE_EN7581_RESET_TIME_MS 100
@@ -912,6 +914,14 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
int err;
u32 val;
+ /*
+ * The controller may have been left out of reset by the bootloader
+ * so make sure that we get a clean start by asserting resets here.
+ */
+ reset_control_bulk_assert(pcie->soc->phy_resets.num_resets,
+ pcie->phy_resets);
+ reset_control_assert(pcie->mac_reset);
+
/*
* Wait for the time needed to complete the bulk assert in
* mtk_pcie_setup for EN7581 SoC.
@@ -986,6 +996,15 @@ static int mtk_pcie_power_up(struct mtk_gen3_pcie *pcie)
struct device *dev = pcie->dev;
int err;
+ /*
+ * The controller may have been left out of reset by the bootloader
+ * so make sure that we get a clean start by asserting resets here.
+ */
+ reset_control_bulk_assert(pcie->soc->phy_resets.num_resets,
+ pcie->phy_resets);
+ reset_control_assert(pcie->mac_reset);
+ usleep_range(PCIE_MTK_RESET_TIME_US, 2 * PCIE_MTK_RESET_TIME_US);
+
/* PHY power on and enable pipe clock */
err = reset_control_bulk_deassert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
if (err) {
@@ -1070,14 +1089,6 @@ static int mtk_pcie_setup(struct mtk_gen3_pcie *pcie)
* counter since the bulk is shared.
*/
reset_control_bulk_deassert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
- /*
- * The controller may have been left out of reset by the bootloader
- * so make sure that we get a clean start by asserting resets here.
- */
- reset_control_bulk_assert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
-
- reset_control_assert(pcie->mac_reset);
- usleep_range(10, 20);
/* Don't touch the hardware registers before power up */
err = pcie->soc->power_up(pcie);
--
2.47.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v4 4/6] PCI: mediatek-gen3: Add comment about initialization order in mtk_pcie_en7581_power_up()
2024-11-18 8:04 [PATCH v4 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Lorenzo Bianconi
` (2 preceding siblings ...)
2024-11-18 8:04 ` [PATCH v4 3/6] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up() Lorenzo Bianconi
@ 2024-11-18 8:04 ` Lorenzo Bianconi
2024-11-18 8:04 ` [PATCH v4 5/6] PCI: mediatek-gen3: Add reset delay " Lorenzo Bianconi
2024-11-18 8:04 ` [PATCH v4 6/6] PCI: mediatek-gen3: rely on msleep() " Lorenzo Bianconi
5 siblings, 0 replies; 18+ messages in thread
From: Lorenzo Bianconi @ 2024-11-18 8:04 UTC (permalink / raw)
To: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd
Cc: linux-pci, linux-mediatek, linux-arm-kernel, linux-clk,
Lorenzo Bianconi
Add a comment in mtk_pcie_en7581_power_up() to clarify, unlike the other
MediaTek Gen3 controllers, the Airoha EN7581 requires PHY initialization
and power-on before PHY reset deassert.
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/pci/controller/pcie-mediatek-gen3.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
index 2b80edd4462ad4e9f2a5d192db7f99307113eb8a..e4f890a73cb8ada7423301fa7a9acc3e177d0cad 100644
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
@@ -928,6 +928,10 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
*/
mdelay(PCIE_EN7581_RESET_TIME_MS);
+ /*
+ * Unlike the other MediaTek Gen3 controllers, the Airoha EN7581
+ * requires PHY initialization and power-on before PHY reset deassert.
+ */
err = phy_init(pcie->phy);
if (err) {
dev_err(dev, "failed to initialize PHY\n");
--
2.47.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v4 5/6] PCI: mediatek-gen3: Add reset delay in mtk_pcie_en7581_power_up()
2024-11-18 8:04 [PATCH v4 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Lorenzo Bianconi
` (3 preceding siblings ...)
2024-11-18 8:04 ` [PATCH v4 4/6] PCI: mediatek-gen3: Add comment about initialization order in mtk_pcie_en7581_power_up() Lorenzo Bianconi
@ 2024-11-18 8:04 ` Lorenzo Bianconi
2024-11-19 22:32 ` Stephen Boyd
2024-11-23 9:10 ` Manivannan Sadhasivam
2024-11-18 8:04 ` [PATCH v4 6/6] PCI: mediatek-gen3: rely on msleep() " Lorenzo Bianconi
5 siblings, 2 replies; 18+ messages in thread
From: Lorenzo Bianconi @ 2024-11-18 8:04 UTC (permalink / raw)
To: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd
Cc: linux-pci, linux-mediatek, linux-arm-kernel, linux-clk,
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 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().
In order to make the code more readable, move the wait for the time
needed to complete the PCIe reset from en7581_pci_enable() to
mtk_pcie_en7581_power_up().
Reduce reset timeout from 250ms to PCIE_T_PVPERL_MS (100ms).
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/clk/clk-en7523.c | 1 -
drivers/pci/controller/pcie-mediatek-gen3.c | 7 +++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c
index 22fbea61c3dcc05e63f8fa37e203c62b2a6fe79e..bf9d9594bef8a54316e28e56a1642ecb0562377a 100644
--- a/drivers/clk/clk-en7523.c
+++ b/drivers/clk/clk-en7523.c
@@ -393,7 +393,6 @@ static int en7581_pci_enable(struct clk_hw *hw)
REG_PCI_CONTROL_PERSTOUT;
val = readl(np_base + REG_PCI_CONTROL);
writel(val | mask, np_base + REG_PCI_CONTROL);
- msleep(250);
return 0;
}
diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
index e4f890a73cb8ada7423301fa7a9acc3e177d0cad..f47c0f2995d94ea99bf41146657bd90b87781a7c 100644
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
@@ -980,6 +980,13 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
goto err_clk_prepare_enable;
}
+ /*
+ * Airoha EN7581 performs PCIe reset via clk callabacks since it has a
+ * hw issue with PCIE_PE_RSTB signal. Add wait for the time needed to
+ * complete the PCIe reset.
+ */
+ msleep(PCIE_T_PVPERL_MS);
+
return 0;
err_clk_prepare_enable:
--
2.47.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v4 6/6] PCI: mediatek-gen3: rely on msleep() in mtk_pcie_en7581_power_up()
2024-11-18 8:04 [PATCH v4 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Lorenzo Bianconi
` (4 preceding siblings ...)
2024-11-18 8:04 ` [PATCH v4 5/6] PCI: mediatek-gen3: Add reset delay " Lorenzo Bianconi
@ 2024-11-18 8:04 ` Lorenzo Bianconi
2024-11-23 9:11 ` Manivannan Sadhasivam
5 siblings, 1 reply; 18+ messages in thread
From: Lorenzo Bianconi @ 2024-11-18 8:04 UTC (permalink / raw)
To: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd
Cc: linux-pci, linux-mediatek, linux-arm-kernel, linux-clk,
Lorenzo Bianconi
Since mtk_pcie_en7581_power_up() runs in non-atomic context, rely on
msleep() routine instead of mdelay().
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/pci/controller/pcie-mediatek-gen3.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
index f47c0f2995d94ea99bf41146657bd90b87781a7c..69f3143783686e9ebcc7ce3dff1883fa6c80d0f4 100644
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
@@ -926,7 +926,7 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
* Wait for the time needed to complete the bulk assert in
* mtk_pcie_setup for EN7581 SoC.
*/
- mdelay(PCIE_EN7581_RESET_TIME_MS);
+ msleep(PCIE_EN7581_RESET_TIME_MS);
/*
* Unlike the other MediaTek Gen3 controllers, the Airoha EN7581
@@ -954,7 +954,7 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
* Wait for the time needed to complete the bulk de-assert above.
* This time is specific for EN7581 SoC.
*/
- mdelay(PCIE_EN7581_RESET_TIME_MS);
+ msleep(PCIE_EN7581_RESET_TIME_MS);
/* MAC power on and enable transaction layer clocks */
reset_control_deassert(pcie->mac_reset);
--
2.47.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v4 3/6] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up()
2024-11-18 8:04 ` [PATCH v4 3/6] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up() Lorenzo Bianconi
@ 2024-11-18 8:49 ` Philipp Zabel
2024-11-18 9:03 ` Lorenzo Bianconi
2024-11-23 9:06 ` Manivannan Sadhasivam
1 sibling, 1 reply; 18+ messages in thread
From: Philipp Zabel @ 2024-11-18 8:49 UTC (permalink / raw)
To: Lorenzo Bianconi, Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Matthias Brugger, AngeloGioacchino Del Regno,
Michael Turquette, Stephen Boyd
Cc: linux-pci, linux-mediatek, linux-arm-kernel, linux-clk
On Mo, 2024-11-18 at 09:04 +0100, Lorenzo Bianconi wrote:
> In order to make the code more readable, the reset_control_bulk_assert()
> for PHY reset lines is moved to make it pair with
> reset_control_bulk_deassert() in mtk_pcie_power_up() and
> mtk_pcie_en7581_power_up(). The same change is done for
> reset_control_assert() used to assert MAC reset line.
>
> Introduce PCIE_MTK_RESET_TIME_US macro for the time needed to
> complete PCIe reset on MediaTek controller.
>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/pci/controller/pcie-mediatek-gen3.c | 27 +++++++++++++++++++--------
> 1 file changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> index 3cfcb45d31508142d28d338ff213f70de9b4e608..2b80edd4462ad4e9f2a5d192db7f99307113eb8a 100644
> --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> @@ -125,6 +125,8 @@
>
> #define MAX_NUM_PHY_RESETS 3
>
> +#define PCIE_MTK_RESET_TIME_US 10
> +
> /* Time in ms needed to complete PCIe reset on EN7581 SoC */
> #define PCIE_EN7581_RESET_TIME_MS 100
>
> @@ -912,6 +914,14 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> int err;
> u32 val;
>
> + /*
> + * The controller may have been left out of reset by the bootloader
> + * so make sure that we get a clean start by asserting resets here.
> + */
> + reset_control_bulk_assert(pcie->soc->phy_resets.num_resets,
> + pcie->phy_resets);
> + reset_control_assert(pcie->mac_reset);
> +
> /*
> * Wait for the time needed to complete the bulk assert in
> * mtk_pcie_setup for EN7581 SoC.
This comment is not correct anymore.
regards
Philipp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 3/6] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up()
2024-11-18 8:49 ` Philipp Zabel
@ 2024-11-18 9:03 ` Lorenzo Bianconi
2024-11-18 11:01 ` Philipp Zabel
0 siblings, 1 reply; 18+ messages in thread
From: Lorenzo Bianconi @ 2024-11-18 9:03 UTC (permalink / raw)
To: Philipp Zabel
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Matthias Brugger, AngeloGioacchino Del Regno,
Michael Turquette, Stephen Boyd, linux-pci, linux-mediatek,
linux-arm-kernel, linux-clk
[-- Attachment #1: Type: text/plain, Size: 2231 bytes --]
On Nov 18, Philipp Zabel wrote:
> On Mo, 2024-11-18 at 09:04 +0100, Lorenzo Bianconi wrote:
> > In order to make the code more readable, the reset_control_bulk_assert()
> > for PHY reset lines is moved to make it pair with
> > reset_control_bulk_deassert() in mtk_pcie_power_up() and
> > mtk_pcie_en7581_power_up(). The same change is done for
> > reset_control_assert() used to assert MAC reset line.
> >
> > Introduce PCIE_MTK_RESET_TIME_US macro for the time needed to
> > complete PCIe reset on MediaTek controller.
> >
> > Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> > drivers/pci/controller/pcie-mediatek-gen3.c | 27 +++++++++++++++++++--------
> > 1 file changed, 19 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> > index 3cfcb45d31508142d28d338ff213f70de9b4e608..2b80edd4462ad4e9f2a5d192db7f99307113eb8a 100644
> > --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> > +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> > @@ -125,6 +125,8 @@
> >
> > #define MAX_NUM_PHY_RESETS 3
> >
> > +#define PCIE_MTK_RESET_TIME_US 10
> > +
> > /* Time in ms needed to complete PCIe reset on EN7581 SoC */
> > #define PCIE_EN7581_RESET_TIME_MS 100
> >
> > @@ -912,6 +914,14 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> > int err;
> > u32 val;
> >
> > + /*
> > + * The controller may have been left out of reset by the bootloader
> > + * so make sure that we get a clean start by asserting resets here.
> > + */
> > + reset_control_bulk_assert(pcie->soc->phy_resets.num_resets,
> > + pcie->phy_resets);
> > + reset_control_assert(pcie->mac_reset);
> > +
> > /*
> > * Wait for the time needed to complete the bulk assert in
> > * mtk_pcie_setup for EN7581 SoC.
>
> This comment is not correct anymore.
I agree naming is hard, but I guess we can assume with 'bulk' we refer to both
phy and mac reset (similar to what we have in mtk_pcie_power_up()),
what do you think?
Regards,
Lorenzo
>
>
> regards
> Philipp
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 3/6] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up()
2024-11-18 9:03 ` Lorenzo Bianconi
@ 2024-11-18 11:01 ` Philipp Zabel
2024-11-18 11:48 ` Lorenzo Bianconi
0 siblings, 1 reply; 18+ messages in thread
From: Philipp Zabel @ 2024-11-18 11:01 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Matthias Brugger, AngeloGioacchino Del Regno,
Michael Turquette, Stephen Boyd, linux-pci, linux-mediatek,
linux-arm-kernel, linux-clk
On Mo, 2024-11-18 at 10:03 +0100, Lorenzo Bianconi wrote:
> On Nov 18, Philipp Zabel wrote:
> > On Mo, 2024-11-18 at 09:04 +0100, Lorenzo Bianconi wrote:
> > > In order to make the code more readable, the reset_control_bulk_assert()
> > > for PHY reset lines is moved to make it pair with
> > > reset_control_bulk_deassert() in mtk_pcie_power_up() and
> > > mtk_pcie_en7581_power_up(). The same change is done for
> > > reset_control_assert() used to assert MAC reset line.
> > >
> > > Introduce PCIE_MTK_RESET_TIME_US macro for the time needed to
> > > complete PCIe reset on MediaTek controller.
> > >
> > > Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> > > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > > ---
> > > drivers/pci/controller/pcie-mediatek-gen3.c | 27 +++++++++++++++++++--------
> > > 1 file changed, 19 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> > > index 3cfcb45d31508142d28d338ff213f70de9b4e608..2b80edd4462ad4e9f2a5d192db7f99307113eb8a 100644
> > > --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> > > +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> > > @@ -125,6 +125,8 @@
> > >
> > > #define MAX_NUM_PHY_RESETS 3
> > >
> > > +#define PCIE_MTK_RESET_TIME_US 10
> > > +
> > > /* Time in ms needed to complete PCIe reset on EN7581 SoC */
> > > #define PCIE_EN7581_RESET_TIME_MS 100
> > >
> > > @@ -912,6 +914,14 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> > > int err;
> > > u32 val;
> > >
> > > + /*
> > > + * The controller may have been left out of reset by the bootloader
> > > + * so make sure that we get a clean start by asserting resets here.
> > > + */
> > > + reset_control_bulk_assert(pcie->soc->phy_resets.num_resets,
> > > + pcie->phy_resets);
> > > + reset_control_assert(pcie->mac_reset);
> > > +
> > > /*
> > > * Wait for the time needed to complete the bulk assert in
> > > * mtk_pcie_setup for EN7581 SoC.
> >
> > This comment is not correct anymore.
>
> I agree naming is hard, but I guess we can assume with 'bulk' we refer to both
> phy and mac reset (similar to what we have in mtk_pcie_power_up()),
> what do you think?
My point is that the referenced (bulk) assert isn't in mtk_pcie_setup()
anymore - it was just moved right above this comment.
I wonder why that delay is required at all, though. Does the reset
controller driver return from reset_control_ops::assert before the
reset line to the PCI controller is asserted?
regards
Philipp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 3/6] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up()
2024-11-18 11:01 ` Philipp Zabel
@ 2024-11-18 11:48 ` Lorenzo Bianconi
2024-11-18 12:07 ` Philipp Zabel
0 siblings, 1 reply; 18+ messages in thread
From: Lorenzo Bianconi @ 2024-11-18 11:48 UTC (permalink / raw)
To: Philipp Zabel
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Matthias Brugger, AngeloGioacchino Del Regno,
Michael Turquette, Stephen Boyd, linux-pci, linux-mediatek,
linux-arm-kernel, linux-clk
[-- Attachment #1: Type: text/plain, Size: 3229 bytes --]
> On Mo, 2024-11-18 at 10:03 +0100, Lorenzo Bianconi wrote:
> > On Nov 18, Philipp Zabel wrote:
> > > On Mo, 2024-11-18 at 09:04 +0100, Lorenzo Bianconi wrote:
> > > > In order to make the code more readable, the reset_control_bulk_assert()
> > > > for PHY reset lines is moved to make it pair with
> > > > reset_control_bulk_deassert() in mtk_pcie_power_up() and
> > > > mtk_pcie_en7581_power_up(). The same change is done for
> > > > reset_control_assert() used to assert MAC reset line.
> > > >
> > > > Introduce PCIE_MTK_RESET_TIME_US macro for the time needed to
> > > > complete PCIe reset on MediaTek controller.
> > > >
> > > > Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> > > > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > > > ---
> > > > drivers/pci/controller/pcie-mediatek-gen3.c | 27 +++++++++++++++++++--------
> > > > 1 file changed, 19 insertions(+), 8 deletions(-)
> > > >
> > > > diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> > > > index 3cfcb45d31508142d28d338ff213f70de9b4e608..2b80edd4462ad4e9f2a5d192db7f99307113eb8a 100644
> > > > --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> > > > +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> > > > @@ -125,6 +125,8 @@
> > > >
> > > > #define MAX_NUM_PHY_RESETS 3
> > > >
> > > > +#define PCIE_MTK_RESET_TIME_US 10
> > > > +
> > > > /* Time in ms needed to complete PCIe reset on EN7581 SoC */
> > > > #define PCIE_EN7581_RESET_TIME_MS 100
> > > >
> > > > @@ -912,6 +914,14 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> > > > int err;
> > > > u32 val;
> > > >
> > > > + /*
> > > > + * The controller may have been left out of reset by the bootloader
> > > > + * so make sure that we get a clean start by asserting resets here.
> > > > + */
> > > > + reset_control_bulk_assert(pcie->soc->phy_resets.num_resets,
> > > > + pcie->phy_resets);
> > > > + reset_control_assert(pcie->mac_reset);
> > > > +
> > > > /*
> > > > * Wait for the time needed to complete the bulk assert in
> > > > * mtk_pcie_setup for EN7581 SoC.
> > >
> > > This comment is not correct anymore.
> >
> > I agree naming is hard, but I guess we can assume with 'bulk' we refer to both
> > phy and mac reset (similar to what we have in mtk_pcie_power_up()),
> > what do you think?
>
> My point is that the referenced (bulk) assert isn't in mtk_pcie_setup()
> anymore - it was just moved right above this comment.
ok, thx. I got what you mean now, I will fix it.
>
> I wonder why that delay is required at all, though. Does the reset
> controller driver return from reset_control_ops::assert before the
> reset line to the PCI controller is asserted?
We discussed it in a previous revision and Bjorn requested to have the required delaies
in the PCIe driver.
https://patchwork.kernel.org/project/linux-pci/patch/aca00bd672ee576ad96d279414fc0835ff31f637.1720022580.git.lorenzo@kernel.org/#26110282
Btw this the same approach we had in mtk_pcie_setup() before this series (usleep_range(10, 20)).
Regards,
Lorenzo
>
> regards
> Philipp
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 3/6] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up()
2024-11-18 11:48 ` Lorenzo Bianconi
@ 2024-11-18 12:07 ` Philipp Zabel
0 siblings, 0 replies; 18+ messages in thread
From: Philipp Zabel @ 2024-11-18 12:07 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Matthias Brugger, AngeloGioacchino Del Regno,
Michael Turquette, Stephen Boyd, linux-pci, linux-mediatek,
linux-arm-kernel, linux-clk
On Mo, 2024-11-18 at 12:48 +0100, Lorenzo Bianconi wrote:
> > On Mo, 2024-11-18 at 10:03 +0100, Lorenzo Bianconi wrote:
> > > On Nov 18, Philipp Zabel wrote:
> > > > On Mo, 2024-11-18 at 09:04 +0100, Lorenzo Bianconi wrote:
> > > > > In order to make the code more readable, the
> > > > > reset_control_bulk_assert()
> > > > > for PHY reset lines is moved to make it pair with
> > > > > reset_control_bulk_deassert() in mtk_pcie_power_up() and
> > > > > mtk_pcie_en7581_power_up(). The same change is done for
> > > > > reset_control_assert() used to assert MAC reset line.
> > > > >
> > > > > Introduce PCIE_MTK_RESET_TIME_US macro for the time needed to
> > > > > complete PCIe reset on MediaTek controller.
> > > > >
> > > > > Reviewed-by: AngeloGioacchino Del Regno
> > > > > <angelogioacchino.delregno@collabora.com>
> > > > > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > > > > ---
> > > > > drivers/pci/controller/pcie-mediatek-gen3.c | 27
> > > > > +++++++++++++++++++--------
> > > > > 1 file changed, 19 insertions(+), 8 deletions(-)
> > > > >
> > > > > diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c
> > > > > b/drivers/pci/controller/pcie-mediatek-gen3.c
> > > > > index
> > > > > 3cfcb45d31508142d28d338ff213f70de9b4e608..2b80edd4462ad4e9f2a
> > > > > 5d192db7f99307113eb8a 100644
> > > > > --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> > > > > +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> > > > > @@ -125,6 +125,8 @@
> > > > >
> > > > > #define MAX_NUM_PHY_RESETS 3
> > > > >
> > > > > +#define PCIE_MTK_RESET_TIME_US 10
> > > > > +
> > > > > /* Time in ms needed to complete PCIe reset on EN7581 SoC */
> > > > > #define PCIE_EN7581_RESET_TIME_MS 100
> > > > >
> > > > > @@ -912,6 +914,14 @@ static int
> > > > > mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> > > > > int err;
> > > > > u32 val;
> > > > >
> > > > > + /*
> > > > > + * The controller may have been left out of reset by
> > > > > the bootloader
> > > > > + * so make sure that we get a clean start by
> > > > > asserting resets here.
> > > > > + */
> > > > > + reset_control_bulk_assert(pcie->soc-
> > > > > >phy_resets.num_resets,
> > > > > + pcie->phy_resets);
> > > > > + reset_control_assert(pcie->mac_reset);
> > > > > +
> > > > > /*
> > > > > * Wait for the time needed to complete the bulk
> > > > > assert in
> > > > > * mtk_pcie_setup for EN7581 SoC.
> > > >
> > > > This comment is not correct anymore.
> > >
> > > I agree naming is hard, but I guess we can assume with 'bulk' we
> > > refer to both
> > > phy and mac reset (similar to what we have in
> > > mtk_pcie_power_up()),
> > > what do you think?
> >
> > My point is that the referenced (bulk) assert isn't in
> > mtk_pcie_setup()
> > anymore - it was just moved right above this comment.
>
> ok, thx. I got what you mean now, I will fix it.
>
> >
> > I wonder why that delay is required at all, though. Does the reset
> > controller driver return from reset_control_ops::assert before the
> > reset line to the PCI controller is asserted?
>
> We discussed it in a previous revision and Bjorn requested to have
> the required delaies
> in the PCIe driver.
>
> https://patchwork.kernel.org/project/linux-pci/patch/aca00bd672ee576ad96d279414fc0835ff31f637.1720022580.git.lorenzo@kernel.org/#26110282
Ok, thank you.
regards
Philipp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 5/6] PCI: mediatek-gen3: Add reset delay in mtk_pcie_en7581_power_up()
2024-11-18 8:04 ` [PATCH v4 5/6] PCI: mediatek-gen3: Add reset delay " Lorenzo Bianconi
@ 2024-11-19 22:32 ` Stephen Boyd
2024-11-23 9:10 ` Manivannan Sadhasivam
1 sibling, 0 replies; 18+ messages in thread
From: Stephen Boyd @ 2024-11-19 22:32 UTC (permalink / raw)
To: AngeloGioacchino Del Regno, Bjorn Helgaas, Jianjun Wang,
Krzysztof Wilczyński, Lorenzo Bianconi, Lorenzo Pieralisi,
Manivannan Sadhasivam, Matthias Brugger, Michael Turquette,
Philipp Zabel, Rob Herring, Ryder Lee
Cc: linux-pci, linux-mediatek, linux-arm-kernel, linux-clk,
Lorenzo Bianconi
Quoting Lorenzo Bianconi (2024-11-18 00:04:57)
> 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 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().
> In order to make the code more readable, move the wait for the time
> needed to complete the PCIe reset from en7581_pci_enable() to
> mtk_pcie_en7581_power_up().
> Reduce reset timeout from 250ms to PCIE_T_PVPERL_MS (100ms).
>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
Acked-by: Stephen Boyd <sboyd@kernel.org>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 2/6] PCI: mediatek-gen3: rely on clk_bulk_prepare_enable() in mtk_pcie_en7581_power_up()
2024-11-18 8:04 ` [PATCH v4 2/6] PCI: mediatek-gen3: rely on clk_bulk_prepare_enable() " Lorenzo Bianconi
@ 2024-11-23 9:05 ` Manivannan Sadhasivam
0 siblings, 0 replies; 18+ messages in thread
From: Manivannan Sadhasivam @ 2024-11-23 9:05 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
Michael Turquette, Stephen Boyd, linux-pci, linux-mediatek,
linux-arm-kernel, linux-clk
On Mon, Nov 18, 2024 at 09:04:54AM +0100, Lorenzo Bianconi wrote:
> Replace clk_bulk_prepare() and clk_bulk_enable() with
> clk_bulk_prepare_enable() in mtk_pcie_en7581_power_up() routine.
>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
- Mani
> ---
> drivers/pci/controller/pcie-mediatek-gen3.c | 14 +++-----------
> 1 file changed, 3 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> index 4d1c797a32c236faf79428eb8a83708e9c4f21d8..3cfcb45d31508142d28d338ff213f70de9b4e608 100644
> --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> @@ -948,12 +948,6 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> pm_runtime_enable(dev);
> pm_runtime_get_sync(dev);
>
> - err = clk_bulk_prepare(pcie->num_clks, pcie->clks);
> - if (err) {
> - dev_err(dev, "failed to prepare clock\n");
> - goto err_clk_prepare;
> - }
> -
> val = FIELD_PREP(PCIE_VAL_LN0_DOWNSTREAM, 0x47) |
> FIELD_PREP(PCIE_VAL_LN1_DOWNSTREAM, 0x47) |
> FIELD_PREP(PCIE_VAL_LN0_UPSTREAM, 0x41) |
> @@ -966,17 +960,15 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> FIELD_PREP(PCIE_K_FINETUNE_MAX, 0xf);
> writel_relaxed(val, pcie->base + PCIE_PIPE4_PIE8_REG);
>
> - err = clk_bulk_enable(pcie->num_clks, pcie->clks);
> + err = clk_bulk_prepare_enable(pcie->num_clks, pcie->clks);
> if (err) {
> dev_err(dev, "failed to prepare clock\n");
> - goto err_clk_enable;
> + goto err_clk_prepare_enable;
> }
>
> return 0;
>
> -err_clk_enable:
> - clk_bulk_unprepare(pcie->num_clks, pcie->clks);
> -err_clk_prepare:
> +err_clk_prepare_enable:
> pm_runtime_put_sync(dev);
> pm_runtime_disable(dev);
> reset_control_assert(pcie->mac_reset);
>
> --
> 2.47.0
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 3/6] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up()
2024-11-18 8:04 ` [PATCH v4 3/6] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up() Lorenzo Bianconi
2024-11-18 8:49 ` Philipp Zabel
@ 2024-11-23 9:06 ` Manivannan Sadhasivam
1 sibling, 0 replies; 18+ messages in thread
From: Manivannan Sadhasivam @ 2024-11-23 9:06 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
Michael Turquette, Stephen Boyd, linux-pci, linux-mediatek,
linux-arm-kernel, linux-clk
On Mon, Nov 18, 2024 at 09:04:55AM +0100, Lorenzo Bianconi wrote:
> In order to make the code more readable, the reset_control_bulk_assert()
> for PHY reset lines is moved to make it pair with
> reset_control_bulk_deassert() in mtk_pcie_power_up() and
> mtk_pcie_en7581_power_up(). The same change is done for
> reset_control_assert() used to assert MAC reset line.
>
> Introduce PCIE_MTK_RESET_TIME_US macro for the time needed to
> complete PCIe reset on MediaTek controller.
>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
- Mani
> ---
> drivers/pci/controller/pcie-mediatek-gen3.c | 27 +++++++++++++++++++--------
> 1 file changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> index 3cfcb45d31508142d28d338ff213f70de9b4e608..2b80edd4462ad4e9f2a5d192db7f99307113eb8a 100644
> --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> @@ -125,6 +125,8 @@
>
> #define MAX_NUM_PHY_RESETS 3
>
> +#define PCIE_MTK_RESET_TIME_US 10
> +
> /* Time in ms needed to complete PCIe reset on EN7581 SoC */
> #define PCIE_EN7581_RESET_TIME_MS 100
>
> @@ -912,6 +914,14 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> int err;
> u32 val;
>
> + /*
> + * The controller may have been left out of reset by the bootloader
> + * so make sure that we get a clean start by asserting resets here.
> + */
> + reset_control_bulk_assert(pcie->soc->phy_resets.num_resets,
> + pcie->phy_resets);
> + reset_control_assert(pcie->mac_reset);
> +
> /*
> * Wait for the time needed to complete the bulk assert in
> * mtk_pcie_setup for EN7581 SoC.
> @@ -986,6 +996,15 @@ static int mtk_pcie_power_up(struct mtk_gen3_pcie *pcie)
> struct device *dev = pcie->dev;
> int err;
>
> + /*
> + * The controller may have been left out of reset by the bootloader
> + * so make sure that we get a clean start by asserting resets here.
> + */
> + reset_control_bulk_assert(pcie->soc->phy_resets.num_resets,
> + pcie->phy_resets);
> + reset_control_assert(pcie->mac_reset);
> + usleep_range(PCIE_MTK_RESET_TIME_US, 2 * PCIE_MTK_RESET_TIME_US);
> +
> /* PHY power on and enable pipe clock */
> err = reset_control_bulk_deassert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
> if (err) {
> @@ -1070,14 +1089,6 @@ static int mtk_pcie_setup(struct mtk_gen3_pcie *pcie)
> * counter since the bulk is shared.
> */
> reset_control_bulk_deassert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
> - /*
> - * The controller may have been left out of reset by the bootloader
> - * so make sure that we get a clean start by asserting resets here.
> - */
> - reset_control_bulk_assert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
> -
> - reset_control_assert(pcie->mac_reset);
> - usleep_range(10, 20);
>
> /* Don't touch the hardware registers before power up */
> err = pcie->soc->power_up(pcie);
>
> --
> 2.47.0
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 5/6] PCI: mediatek-gen3: Add reset delay in mtk_pcie_en7581_power_up()
2024-11-18 8:04 ` [PATCH v4 5/6] PCI: mediatek-gen3: Add reset delay " Lorenzo Bianconi
2024-11-19 22:32 ` Stephen Boyd
@ 2024-11-23 9:10 ` Manivannan Sadhasivam
2024-11-23 10:17 ` Lorenzo Bianconi
1 sibling, 1 reply; 18+ messages in thread
From: Manivannan Sadhasivam @ 2024-11-23 9:10 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
Michael Turquette, Stephen Boyd, linux-pci, linux-mediatek,
linux-arm-kernel, linux-clk
On Mon, Nov 18, 2024 at 09:04:57AM +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 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().
> In order to make the code more readable, move the wait for the time
> needed to complete the PCIe reset from en7581_pci_enable() to
> mtk_pcie_en7581_power_up().
> Reduce reset timeout from 250ms to PCIE_T_PVPERL_MS (100ms).
>
and this reduced timeout has no impact on the behavior? If so, it'd be good to
state it explicitly. But this information can be added while applying the patch,
so no need to resend just for this.
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
- Mani
> ---
> drivers/clk/clk-en7523.c | 1 -
> drivers/pci/controller/pcie-mediatek-gen3.c | 7 +++++++
> 2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c
> index 22fbea61c3dcc05e63f8fa37e203c62b2a6fe79e..bf9d9594bef8a54316e28e56a1642ecb0562377a 100644
> --- a/drivers/clk/clk-en7523.c
> +++ b/drivers/clk/clk-en7523.c
> @@ -393,7 +393,6 @@ static int en7581_pci_enable(struct clk_hw *hw)
> REG_PCI_CONTROL_PERSTOUT;
> val = readl(np_base + REG_PCI_CONTROL);
> writel(val | mask, np_base + REG_PCI_CONTROL);
> - msleep(250);
>
> return 0;
> }
> diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> index e4f890a73cb8ada7423301fa7a9acc3e177d0cad..f47c0f2995d94ea99bf41146657bd90b87781a7c 100644
> --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> @@ -980,6 +980,13 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> goto err_clk_prepare_enable;
> }
>
> + /*
> + * Airoha EN7581 performs PCIe reset via clk callabacks since it has a
> + * hw issue with PCIE_PE_RSTB signal. Add wait for the time needed to
> + * complete the PCIe reset.
> + */
> + msleep(PCIE_T_PVPERL_MS);
> +
> return 0;
>
> err_clk_prepare_enable:
>
> --
> 2.47.0
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 6/6] PCI: mediatek-gen3: rely on msleep() in mtk_pcie_en7581_power_up()
2024-11-18 8:04 ` [PATCH v4 6/6] PCI: mediatek-gen3: rely on msleep() " Lorenzo Bianconi
@ 2024-11-23 9:11 ` Manivannan Sadhasivam
0 siblings, 0 replies; 18+ messages in thread
From: Manivannan Sadhasivam @ 2024-11-23 9:11 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
Michael Turquette, Stephen Boyd, linux-pci, linux-mediatek,
linux-arm-kernel, linux-clk
On Mon, Nov 18, 2024 at 09:04:58AM +0100, Lorenzo Bianconi wrote:
> Since mtk_pcie_en7581_power_up() runs in non-atomic context, rely on
> msleep() routine instead of mdelay().
>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
- Mani
> ---
> drivers/pci/controller/pcie-mediatek-gen3.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> index f47c0f2995d94ea99bf41146657bd90b87781a7c..69f3143783686e9ebcc7ce3dff1883fa6c80d0f4 100644
> --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> @@ -926,7 +926,7 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> * Wait for the time needed to complete the bulk assert in
> * mtk_pcie_setup for EN7581 SoC.
> */
> - mdelay(PCIE_EN7581_RESET_TIME_MS);
> + msleep(PCIE_EN7581_RESET_TIME_MS);
>
> /*
> * Unlike the other MediaTek Gen3 controllers, the Airoha EN7581
> @@ -954,7 +954,7 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> * Wait for the time needed to complete the bulk de-assert above.
> * This time is specific for EN7581 SoC.
> */
> - mdelay(PCIE_EN7581_RESET_TIME_MS);
> + msleep(PCIE_EN7581_RESET_TIME_MS);
>
> /* MAC power on and enable transaction layer clocks */
> reset_control_deassert(pcie->mac_reset);
>
> --
> 2.47.0
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 5/6] PCI: mediatek-gen3: Add reset delay in mtk_pcie_en7581_power_up()
2024-11-23 9:10 ` Manivannan Sadhasivam
@ 2024-11-23 10:17 ` Lorenzo Bianconi
0 siblings, 0 replies; 18+ messages in thread
From: Lorenzo Bianconi @ 2024-11-23 10:17 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
Michael Turquette, Stephen Boyd, linux-pci, linux-mediatek,
linux-arm-kernel, linux-clk
[-- Attachment #1: Type: text/plain, Size: 2969 bytes --]
> On Mon, Nov 18, 2024 at 09:04:57AM +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 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().
> > In order to make the code more readable, move the wait for the time
> > needed to complete the PCIe reset from en7581_pci_enable() to
> > mtk_pcie_en7581_power_up().
> > Reduce reset timeout from 250ms to PCIE_T_PVPERL_MS (100ms).
> >
>
> and this reduced timeout has no impact on the behavior? If so, it'd be good to
> state it explicitly. But this information can be added while applying the patch,
> so no need to resend just for this.
nope, we discussed this here:
https://patchwork.kernel.org/project/linux-pci/patch/aca00bd672ee576ad96d279414fc0835ff31f637.1720022580.git.lorenzo@kernel.org/#26114968
no worries, I will fix it in v5 since I need to repost to address a
comment in patch 3/6.
Regards,
Lorenzo
>
> > Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
>
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
>
> - Mani
>
> > ---
> > drivers/clk/clk-en7523.c | 1 -
> > drivers/pci/controller/pcie-mediatek-gen3.c | 7 +++++++
> > 2 files changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c
> > index 22fbea61c3dcc05e63f8fa37e203c62b2a6fe79e..bf9d9594bef8a54316e28e56a1642ecb0562377a 100644
> > --- a/drivers/clk/clk-en7523.c
> > +++ b/drivers/clk/clk-en7523.c
> > @@ -393,7 +393,6 @@ static int en7581_pci_enable(struct clk_hw *hw)
> > REG_PCI_CONTROL_PERSTOUT;
> > val = readl(np_base + REG_PCI_CONTROL);
> > writel(val | mask, np_base + REG_PCI_CONTROL);
> > - msleep(250);
> >
> > return 0;
> > }
> > diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> > index e4f890a73cb8ada7423301fa7a9acc3e177d0cad..f47c0f2995d94ea99bf41146657bd90b87781a7c 100644
> > --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> > +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> > @@ -980,6 +980,13 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> > goto err_clk_prepare_enable;
> > }
> >
> > + /*
> > + * Airoha EN7581 performs PCIe reset via clk callabacks since it has a
> > + * hw issue with PCIE_PE_RSTB signal. Add wait for the time needed to
> > + * complete the PCIe reset.
> > + */
> > + msleep(PCIE_T_PVPERL_MS);
> > +
> > return 0;
> >
> > err_clk_prepare_enable:
> >
> > --
> > 2.47.0
> >
>
> --
> மணிவண்ணன் சதாசிவம்
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2024-11-23 10:19 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-18 8:04 [PATCH v4 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Lorenzo Bianconi
2024-11-18 8:04 ` [PATCH v4 1/6] PCI: mediatek-gen3: Add missing reset_control_deassert() for mac_rst in mtk_pcie_en7581_power_up() Lorenzo Bianconi
2024-11-18 8:04 ` [PATCH v4 2/6] PCI: mediatek-gen3: rely on clk_bulk_prepare_enable() " Lorenzo Bianconi
2024-11-23 9:05 ` Manivannan Sadhasivam
2024-11-18 8:04 ` [PATCH v4 3/6] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up() Lorenzo Bianconi
2024-11-18 8:49 ` Philipp Zabel
2024-11-18 9:03 ` Lorenzo Bianconi
2024-11-18 11:01 ` Philipp Zabel
2024-11-18 11:48 ` Lorenzo Bianconi
2024-11-18 12:07 ` Philipp Zabel
2024-11-23 9:06 ` Manivannan Sadhasivam
2024-11-18 8:04 ` [PATCH v4 4/6] PCI: mediatek-gen3: Add comment about initialization order in mtk_pcie_en7581_power_up() Lorenzo Bianconi
2024-11-18 8:04 ` [PATCH v4 5/6] PCI: mediatek-gen3: Add reset delay " Lorenzo Bianconi
2024-11-19 22:32 ` Stephen Boyd
2024-11-23 9:10 ` Manivannan Sadhasivam
2024-11-23 10:17 ` Lorenzo Bianconi
2024-11-18 8:04 ` [PATCH v4 6/6] PCI: mediatek-gen3: rely on msleep() " Lorenzo Bianconi
2024-11-23 9:11 ` Manivannan Sadhasivam
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).