* [PATCH 0/2] PCI: {qcom-ep/tegra194}: Move endpoint cleanups to PERST# deassert handler
@ 2024-08-17 5:39 Manivannan Sadhasivam via B4 Relay
2024-08-17 5:39 ` [PATCH 1/2] PCI: qcom-ep: Move controller cleanups to qcom_pcie_perst_deassert() Manivannan Sadhasivam via B4 Relay
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Manivannan Sadhasivam via B4 Relay @ 2024-08-17 5:39 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas, Thierry Reding, Jonathan Hunter, Vidya Sagar
Cc: linux-pci, linux-arm-msm, linux-kernel, Thierry Reding,
linux-tegra, Manivannan Sadhasivam
Hi,
This series moves the call to endpoint cleanup functions (dw_pcie_ep_cleanup()
pci_epc_deinit_notify()) to PERST# deassert handler in qcom-ep and tegra194
drivers. It aims to fix a crash that is seen with Qcom endpoint SoCs when host
asserts PERST# and the cleanup functions are called without refclk.
During the review of v1 [1], Bjorn suggested fixing up tegra194 driver as well
as both drivers share the same design and require refclk from host for
operation.
Testing
=======
The Qcom patch is tested on SM8450 development board. For tegra194, I'm
expecting someone in the Cc list or the community will do the testing.
[1] https://lore.kernel.org/linux-pci/20240815224717.GA53536@bhelgaas/
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
Manivannan Sadhasivam (2):
PCI: qcom-ep: Move controller cleanups to qcom_pcie_perst_deassert()
PCI: tegra194: Move controller cleanups to pex_ep_event_pex_rst_deassert()
drivers/pci/controller/dwc/pcie-qcom-ep.c | 6 ++++--
drivers/pci/controller/dwc/pcie-tegra194.c | 7 ++++---
2 files changed, 8 insertions(+), 5 deletions(-)
---
base-commit: 8400291e289ee6b2bf9779ff1c83a291501f017b
change-id: 20240817-pci-qcom-ep-cleanup-740745e21d87
Best regards,
--
Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] PCI: qcom-ep: Move controller cleanups to qcom_pcie_perst_deassert()
2024-08-17 5:39 [PATCH 0/2] PCI: {qcom-ep/tegra194}: Move endpoint cleanups to PERST# deassert handler Manivannan Sadhasivam via B4 Relay
@ 2024-08-17 5:39 ` Manivannan Sadhasivam via B4 Relay
2024-11-03 20:53 ` Krzysztof Wilczyński
2024-08-17 5:39 ` [PATCH 2/2] PCI: tegra194: Move controller cleanups to pex_ep_event_pex_rst_deassert() Manivannan Sadhasivam via B4 Relay
2024-11-02 17:11 ` [PATCH 0/2] PCI: {qcom-ep/tegra194}: Move endpoint cleanups to PERST# deassert handler Manivannan Sadhasivam
2 siblings, 1 reply; 6+ messages in thread
From: Manivannan Sadhasivam via B4 Relay @ 2024-08-17 5:39 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas, Thierry Reding, Jonathan Hunter, Vidya Sagar
Cc: linux-pci, linux-arm-msm, linux-kernel, Thierry Reding,
linux-tegra, Manivannan Sadhasivam
From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Currently, the endpoint cleanup function dw_pcie_ep_cleanup() and EPF
deinit notify function pci_epc_deinit_notify() are called during the
execution of qcom_pcie_perst_assert() i.e., when the host has asserted
PERST#. But quickly after this step, refclk will also be disabled by the
host.
All of the Qcom endpoint SoCs supported as of now depend on the refclk from
the host for keeping the controller operational. Due to this limitation,
any access to the hardware registers in the absence of refclk will result
in a whole endpoint crash. Unfortunately, most of the controller cleanups
require accessing the hardware registers (like eDMA cleanup performed in
dw_pcie_ep_cleanup(), powering down MHI EPF etc...). So these cleanup
functions are currently causing the crash in the endpoint SoC once host
asserts PERST#.
One way to address this issue is by generating the refclk in the endpoint
itself and not depending on the host. But that is not always possible as
some of the endpoint designs do require the endpoint to consume refclk from
the host (as I was told by the Qcom engineers).
So let's fix this crash by moving the controller cleanups to the start of
the qcom_pcie_perst_deassert() function. qcom_pcie_perst_deassert() is
called whenever the host has deasserted PERST# and it is guaranteed that
the refclk would be active at this point. So at the start of this function
(after enabling resources), the controller cleanup can be performed. Once
finished, rest of the code execution for PERST# deassert can continue as
usual.
Fixes: 473b2cf9c4d1 ("PCI: endpoint: Introduce 'epc_deinit' event and notify the EPF drivers")
Fixes: 570d7715eed8 ("PCI: dwc: ep: Introduce dw_pcie_ep_cleanup() API for drivers supporting PERST#")
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
drivers/pci/controller/dwc/pcie-qcom-ep.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-qcom-ep.c b/drivers/pci/controller/dwc/pcie-qcom-ep.c
index 236229f66c80..5d31285685b6 100644
--- a/drivers/pci/controller/dwc/pcie-qcom-ep.c
+++ b/drivers/pci/controller/dwc/pcie-qcom-ep.c
@@ -389,6 +389,10 @@ static int qcom_pcie_perst_deassert(struct dw_pcie *pci)
return ret;
}
+ /* Perform cleanup that requires refclk */
+ pci_epc_deinit_notify(pci->ep.epc);
+ dw_pcie_ep_cleanup(&pci->ep);
+
/* Assert WAKE# to RC to indicate device is ready */
gpiod_set_value_cansleep(pcie_ep->wake, 1);
usleep_range(WAKE_DELAY_US, WAKE_DELAY_US + 500);
@@ -522,8 +526,6 @@ static void qcom_pcie_perst_assert(struct dw_pcie *pci)
{
struct qcom_pcie_ep *pcie_ep = to_pcie_ep(pci);
- pci_epc_deinit_notify(pci->ep.epc);
- dw_pcie_ep_cleanup(&pci->ep);
qcom_pcie_disable_resources(pcie_ep);
pcie_ep->link_status = QCOM_PCIE_EP_LINK_DISABLED;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] PCI: tegra194: Move controller cleanups to pex_ep_event_pex_rst_deassert()
2024-08-17 5:39 [PATCH 0/2] PCI: {qcom-ep/tegra194}: Move endpoint cleanups to PERST# deassert handler Manivannan Sadhasivam via B4 Relay
2024-08-17 5:39 ` [PATCH 1/2] PCI: qcom-ep: Move controller cleanups to qcom_pcie_perst_deassert() Manivannan Sadhasivam via B4 Relay
@ 2024-08-17 5:39 ` Manivannan Sadhasivam via B4 Relay
2024-11-03 20:55 ` Krzysztof Wilczyński
2024-11-02 17:11 ` [PATCH 0/2] PCI: {qcom-ep/tegra194}: Move endpoint cleanups to PERST# deassert handler Manivannan Sadhasivam
2 siblings, 1 reply; 6+ messages in thread
From: Manivannan Sadhasivam via B4 Relay @ 2024-08-17 5:39 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas, Thierry Reding, Jonathan Hunter, Vidya Sagar
Cc: linux-pci, linux-arm-msm, linux-kernel, Thierry Reding,
linux-tegra, Manivannan Sadhasivam
From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Currently, the endpoint cleanup function dw_pcie_ep_cleanup() and EPF
deinit notify function pci_epc_deinit_notify() are called during the
execution of pex_ep_event_pex_rst_assert() i.e., when the host has asserted
PERST#. But quickly after this step, refclk will also be disabled by the
host.
All of the tegra194 endpoint SoCs supported as of now depend on the refclk
from the host for keeping the controller operational. Due to this
limitation, any access to the hardware registers in the absence of refclk
will result in a whole endpoint crash. Unfortunately, most of the
controller cleanups require accessing the hardware registers (like eDMA
cleanup performed in dw_pcie_ep_cleanup(), etc...). So these cleanup
functions can cause the crash in the endpoint SoC once host asserts PERST#.
One way to address this issue is by generating the refclk in the endpoint
itself and not depending on the host. But that is not always possible as
some of the endpoint designs do require the endpoint to consume refclk from
the host.
So let's fix this crash by moving the controller cleanups to the start of
the pex_ep_event_pex_rst_deassert() function. This function is called
whenever the host has deasserted PERST# and it is guaranteed that the
refclk would be active at this point. So at the start of this function
(after enabling resources) the controller cleanup can be performed. Once
finished, rest of the code execution for PERST# deassert can continue as
usual.
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Vidya Sagar <vidyas@nvidia.com>
Cc: linux-tegra@vger.kernel.org
Fixes: 473b2cf9c4d1 ("PCI: endpoint: Introduce 'epc_deinit' event and notify the EPF drivers")
Fixes: 570d7715eed8 ("PCI: dwc: ep: Introduce dw_pcie_ep_cleanup() API for drivers supporting PERST#")
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
drivers/pci/controller/dwc/pcie-tegra194.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c
index 4bf7b433417a..d68dd18ed43c 100644
--- a/drivers/pci/controller/dwc/pcie-tegra194.c
+++ b/drivers/pci/controller/dwc/pcie-tegra194.c
@@ -1709,9 +1709,6 @@ static void pex_ep_event_pex_rst_assert(struct tegra_pcie_dw *pcie)
if (ret)
dev_err(pcie->dev, "Failed to go Detect state: %d\n", ret);
- pci_epc_deinit_notify(pcie->pci.ep.epc);
- dw_pcie_ep_cleanup(&pcie->pci.ep);
-
reset_control_assert(pcie->core_rst);
tegra_pcie_disable_phy(pcie);
@@ -1790,6 +1787,10 @@ static void pex_ep_event_pex_rst_deassert(struct tegra_pcie_dw *pcie)
goto fail_phy;
}
+ /* Perform cleanup that requires refclk */
+ pci_epc_deinit_notify(pcie->pci.ep.epc);
+ dw_pcie_ep_cleanup(&pcie->pci.ep);
+
/* Clear any stale interrupt statuses */
appl_writel(pcie, 0xFFFFFFFF, APPL_INTR_STATUS_L0);
appl_writel(pcie, 0xFFFFFFFF, APPL_INTR_STATUS_L1_0_0);
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] PCI: {qcom-ep/tegra194}: Move endpoint cleanups to PERST# deassert handler
2024-08-17 5:39 [PATCH 0/2] PCI: {qcom-ep/tegra194}: Move endpoint cleanups to PERST# deassert handler Manivannan Sadhasivam via B4 Relay
2024-08-17 5:39 ` [PATCH 1/2] PCI: qcom-ep: Move controller cleanups to qcom_pcie_perst_deassert() Manivannan Sadhasivam via B4 Relay
2024-08-17 5:39 ` [PATCH 2/2] PCI: tegra194: Move controller cleanups to pex_ep_event_pex_rst_deassert() Manivannan Sadhasivam via B4 Relay
@ 2024-11-02 17:11 ` Manivannan Sadhasivam
2 siblings, 0 replies; 6+ messages in thread
From: Manivannan Sadhasivam @ 2024-11-02 17:11 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas, Thierry Reding, Jonathan Hunter, Vidya Sagar,
linux-pci, linux-arm-msm, linux-kernel, Thierry Reding,
linux-tegra
On Sat, Aug 17, 2024 at 11:09:02AM +0530, Manivannan Sadhasivam via B4 Relay wrote:
> Hi,
>
> This series moves the call to endpoint cleanup functions (dw_pcie_ep_cleanup()
> pci_epc_deinit_notify()) to PERST# deassert handler in qcom-ep and tegra194
> drivers. It aims to fix a crash that is seen with Qcom endpoint SoCs when host
> asserts PERST# and the cleanup functions are called without refclk.
>
> During the review of v1 [1], Bjorn suggested fixing up tegra194 driver as well
> as both drivers share the same design and require refclk from host for
> operation.
>
> Testing
> =======
>
> The Qcom patch is tested on SM8450 development board. For tegra194, I'm
> expecting someone in the Cc list or the community will do the testing.
>
> [1] https://lore.kernel.org/linux-pci/20240815224717.GA53536@bhelgaas/
>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Can this series be merged for 6.13?
- Mani
> ---
> Manivannan Sadhasivam (2):
> PCI: qcom-ep: Move controller cleanups to qcom_pcie_perst_deassert()
> PCI: tegra194: Move controller cleanups to pex_ep_event_pex_rst_deassert()
>
> drivers/pci/controller/dwc/pcie-qcom-ep.c | 6 ++++--
> drivers/pci/controller/dwc/pcie-tegra194.c | 7 ++++---
> 2 files changed, 8 insertions(+), 5 deletions(-)
> ---
> base-commit: 8400291e289ee6b2bf9779ff1c83a291501f017b
> change-id: 20240817-pci-qcom-ep-cleanup-740745e21d87
>
> Best regards,
> --
> Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
>
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] PCI: qcom-ep: Move controller cleanups to qcom_pcie_perst_deassert()
2024-08-17 5:39 ` [PATCH 1/2] PCI: qcom-ep: Move controller cleanups to qcom_pcie_perst_deassert() Manivannan Sadhasivam via B4 Relay
@ 2024-11-03 20:53 ` Krzysztof Wilczyński
0 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Wilczyński @ 2024-11-03 20:53 UTC (permalink / raw)
To: manivannan.sadhasivam
Cc: Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas, Thierry Reding,
Jonathan Hunter, Vidya Sagar, linux-pci, linux-arm-msm,
linux-kernel, Thierry Reding, linux-tegra
Hello,
> Currently, the endpoint cleanup function dw_pcie_ep_cleanup() and EPF
> deinit notify function pci_epc_deinit_notify() are called during the
> execution of qcom_pcie_perst_assert() i.e., when the host has asserted
> PERST#. But quickly after this step, refclk will also be disabled by the
> host.
>
> All of the Qcom endpoint SoCs supported as of now depend on the refclk from
> the host for keeping the controller operational. Due to this limitation,
> any access to the hardware registers in the absence of refclk will result
> in a whole endpoint crash. Unfortunately, most of the controller cleanups
> require accessing the hardware registers (like eDMA cleanup performed in
> dw_pcie_ep_cleanup(), powering down MHI EPF etc...). So these cleanup
> functions are currently causing the crash in the endpoint SoC once host
> asserts PERST#.
>
> One way to address this issue is by generating the refclk in the endpoint
> itself and not depending on the host. But that is not always possible as
> some of the endpoint designs do require the endpoint to consume refclk from
> the host (as I was told by the Qcom engineers).
>
> So let's fix this crash by moving the controller cleanups to the start of
> the qcom_pcie_perst_deassert() function. qcom_pcie_perst_deassert() is
> called whenever the host has deasserted PERST# and it is guaranteed that
> the refclk would be active at this point. So at the start of this function
> (after enabling resources), the controller cleanup can be performed. Once
> finished, rest of the code execution for PERST# deassert can continue as
> usual.
Applied to controller/qcom, thank you!
[01/01] PCI: qcom-ep: Move controller cleanups to qcom_pcie_perst_deassert()
https://git.kernel.org/pci/pci/c/7d7cf89b119a
Krzysztof
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] PCI: tegra194: Move controller cleanups to pex_ep_event_pex_rst_deassert()
2024-08-17 5:39 ` [PATCH 2/2] PCI: tegra194: Move controller cleanups to pex_ep_event_pex_rst_deassert() Manivannan Sadhasivam via B4 Relay
@ 2024-11-03 20:55 ` Krzysztof Wilczyński
0 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Wilczyński @ 2024-11-03 20:55 UTC (permalink / raw)
To: manivannan.sadhasivam
Cc: Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas, Thierry Reding,
Jonathan Hunter, Vidya Sagar, linux-pci, linux-arm-msm,
linux-kernel, Thierry Reding, linux-tegra
Hello,
> Currently, the endpoint cleanup function dw_pcie_ep_cleanup() and EPF
> deinit notify function pci_epc_deinit_notify() are called during the
> execution of pex_ep_event_pex_rst_assert() i.e., when the host has asserted
> PERST#. But quickly after this step, refclk will also be disabled by the
> host.
>
> All of the tegra194 endpoint SoCs supported as of now depend on the refclk
> from the host for keeping the controller operational. Due to this
> limitation, any access to the hardware registers in the absence of refclk
> will result in a whole endpoint crash. Unfortunately, most of the
> controller cleanups require accessing the hardware registers (like eDMA
> cleanup performed in dw_pcie_ep_cleanup(), etc...). So these cleanup
> functions can cause the crash in the endpoint SoC once host asserts PERST#.
>
> One way to address this issue is by generating the refclk in the endpoint
> itself and not depending on the host. But that is not always possible as
> some of the endpoint designs do require the endpoint to consume refclk from
> the host.
>
> So let's fix this crash by moving the controller cleanups to the start of
> the pex_ep_event_pex_rst_deassert() function. This function is called
> whenever the host has deasserted PERST# and it is guaranteed that the
> refclk would be active at this point. So at the start of this function
> (after enabling resources) the controller cleanup can be performed. Once
> finished, rest of the code execution for PERST# deassert can continue as
> usual.
Applied to controller/tegra194, thank you!
[01/01] PCI: tegra194: Move controller cleanups to pex_ep_event_pex_rst_deassert()
https://git.kernel.org/pci/pci/c/40e2125381dc
Krzysztof
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-03 20:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-17 5:39 [PATCH 0/2] PCI: {qcom-ep/tegra194}: Move endpoint cleanups to PERST# deassert handler Manivannan Sadhasivam via B4 Relay
2024-08-17 5:39 ` [PATCH 1/2] PCI: qcom-ep: Move controller cleanups to qcom_pcie_perst_deassert() Manivannan Sadhasivam via B4 Relay
2024-11-03 20:53 ` Krzysztof Wilczyński
2024-08-17 5:39 ` [PATCH 2/2] PCI: tegra194: Move controller cleanups to pex_ep_event_pex_rst_deassert() Manivannan Sadhasivam via B4 Relay
2024-11-03 20:55 ` Krzysztof Wilczyński
2024-11-02 17:11 ` [PATCH 0/2] PCI: {qcom-ep/tegra194}: Move endpoint cleanups to PERST# deassert handler Manivannan Sadhasivam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox