* [PATCH] PCI: rcar-gen4: Assure reset occurs before DBI access
@ 2025-09-24 0:55 Marek Vasut
2025-09-25 13:41 ` Geert Uytterhoeven
2025-09-25 16:36 ` Manivannan Sadhasivam
0 siblings, 2 replies; 4+ messages in thread
From: Marek Vasut @ 2025-09-24 0:55 UTC (permalink / raw)
To: linux-pci
Cc: Marek Vasut, Krzysztof Wilczyński, Bjorn Helgaas,
Geert Uytterhoeven, Lorenzo Pieralisi, Magnus Damm,
Manivannan Sadhasivam, Rob Herring, Yoshihiro Shimoda,
linux-renesas-soc
Assure the reset is latched and the core is ready for DBI access.
On R-Car V4H, the PCIe reset is asynchronized and does not take
effect immediately, but needs a short time to complete. In case
DBI access happens in that short time, that access generates an
SError. Make sure that condition can never happen, read back the
state of the reset which should turn the asynchronized reset into
synchronized one, and wait a little over 1ms to add additional
safety margin.
Fixes: 0d0c551011df ("PCI: rcar-gen4: Add R-Car Gen4 PCIe controller support for host mode")
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
Cc: "Krzysztof Wilczyński" <kwilczynski@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Manivannan Sadhasivam <mani@kernel.org>
Cc: Rob Herring <robh@kernel.org>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: linux-pci@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org
---
NOTE: This fix could be removed once the matching fix lands in linux-clk
https://patchwork.kernel.org/project/linux-clk/patch/20250922162113.113223-1-marek.vasut+renesas@mailbox.org/
This fix is implemented to assure PCIe is not broken in case the
fix sent to linux-clk is applied asynchronized.
---
drivers/pci/controller/dwc/pcie-rcar-gen4.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/pci/controller/dwc/pcie-rcar-gen4.c b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
index 365dff6fe7f8f..dd74e46f13933 100644
--- a/drivers/pci/controller/dwc/pcie-rcar-gen4.c
+++ b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
@@ -212,6 +212,19 @@ static int rcar_gen4_pcie_common_init(struct rcar_gen4_pcie *rcar)
if (ret)
goto err_unprepare;
+ /*
+ * Assure the reset is latched and the core is ready for DBI access.
+ * On R-Car V4H, the PCIe reset is asynchronized and does not take
+ * effect immediately, but needs a short time to complete. In case
+ * DBI access happens in that short time, that access generates an
+ * SError. Make sure that condition can never happen, read back the
+ * state of the reset which should turn the asynchronized reset into
+ * synchronized one, and wait a little over 1ms to add additional
+ * safety margin.
+ */
+ reset_control_status(dw->core_rsts[DW_PCIE_PWR_RST].rstc);
+ fsleep(1000);
+
if (rcar->drvdata->additional_common_init)
rcar->drvdata->additional_common_init(rcar);
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] PCI: rcar-gen4: Assure reset occurs before DBI access
2025-09-24 0:55 [PATCH] PCI: rcar-gen4: Assure reset occurs before DBI access Marek Vasut
@ 2025-09-25 13:41 ` Geert Uytterhoeven
2025-09-25 16:39 ` Manivannan Sadhasivam
2025-09-25 16:36 ` Manivannan Sadhasivam
1 sibling, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2025-09-25 13:41 UTC (permalink / raw)
To: Marek Vasut
Cc: linux-pci, Krzysztof Wilczyński, Bjorn Helgaas,
Lorenzo Pieralisi, Magnus Damm, Manivannan Sadhasivam,
Rob Herring, Yoshihiro Shimoda, linux-renesas-soc
Hi Marek,
On Wed, 24 Sept 2025 at 02:56, Marek Vasut
<marek.vasut+renesas@mailbox.org> wrote:
> Assure the reset is latched and the core is ready for DBI access.
> On R-Car V4H, the PCIe reset is asynchronized and does not take
> effect immediately, but needs a short time to complete. In case
> DBI access happens in that short time, that access generates an
> SError. Make sure that condition can never happen, read back the
> state of the reset which should turn the asynchronized reset into
> synchronized one, and wait a little over 1ms to add additional
> safety margin.
>
> Fixes: 0d0c551011df ("PCI: rcar-gen4: Add R-Car Gen4 PCIe controller support for host mode")
> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Thanks for your patch!
I have tested this on White Hawk, with (in any order) and without[1],
with and without CONFIG_DEBUG_LOCK_ALLOC.
> NOTE: This fix could be removed once the matching fix lands in linux-clk
> https://patchwork.kernel.org/project/linux-clk/patch/20250922162113.113223-1-marek.vasut+renesas@mailbox.org/
> This fix is implemented to assure PCIe is not broken in case the
> fix sent to linux-clk is applied asynchronized.
Indeed.
Note that to avoid regressions, this patch ("[PATCH] PCI: rcar-gen4:
Assure reset occurs before DBI access ") must be applied _before_ [1].
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
[1] "[PATCH] PCI: rcar-gen4: Fix inverted break condition in PHY initialization"
(https://lore.kernel.org/all/CAMuHMdXAK6EhxPoNoqwqWSjGtwM24gL4qjSf6_n+NMCcpDf1HA@mail.gmail.com/)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] PCI: rcar-gen4: Assure reset occurs before DBI access
2025-09-25 13:41 ` Geert Uytterhoeven
@ 2025-09-25 16:39 ` Manivannan Sadhasivam
0 siblings, 0 replies; 4+ messages in thread
From: Manivannan Sadhasivam @ 2025-09-25 16:39 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Marek Vasut, linux-pci, Krzysztof Wilczyński, Bjorn Helgaas,
Lorenzo Pieralisi, Magnus Damm, Rob Herring, Yoshihiro Shimoda,
linux-renesas-soc
On Thu, Sep 25, 2025 at 03:41:14PM +0200, Geert Uytterhoeven wrote:
> Hi Marek,
>
> On Wed, 24 Sept 2025 at 02:56, Marek Vasut
> <marek.vasut+renesas@mailbox.org> wrote:
> > Assure the reset is latched and the core is ready for DBI access.
> > On R-Car V4H, the PCIe reset is asynchronized and does not take
> > effect immediately, but needs a short time to complete. In case
> > DBI access happens in that short time, that access generates an
> > SError. Make sure that condition can never happen, read back the
> > state of the reset which should turn the asynchronized reset into
> > synchronized one, and wait a little over 1ms to add additional
> > safety margin.
> >
> > Fixes: 0d0c551011df ("PCI: rcar-gen4: Add R-Car Gen4 PCIe controller support for host mode")
> > Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
>
> Thanks for your patch!
>
> I have tested this on White Hawk, with (in any order) and without[1],
> with and without CONFIG_DEBUG_LOCK_ALLOC.
>
> > NOTE: This fix could be removed once the matching fix lands in linux-clk
> > https://patchwork.kernel.org/project/linux-clk/patch/20250922162113.113223-1-marek.vasut+renesas@mailbox.org/
> > This fix is implemented to assure PCIe is not broken in case the
> > fix sent to linux-clk is applied asynchronized.
>
> Indeed.
>
> Note that to avoid regressions, this patch ("[PATCH] PCI: rcar-gen4:
> Assure reset occurs before DBI access ") must be applied _before_ [1].
>
I've applied by this order:
https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/log/?h=controller/rcar-gen4
- Mani
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI: rcar-gen4: Assure reset occurs before DBI access
2025-09-24 0:55 [PATCH] PCI: rcar-gen4: Assure reset occurs before DBI access Marek Vasut
2025-09-25 13:41 ` Geert Uytterhoeven
@ 2025-09-25 16:36 ` Manivannan Sadhasivam
1 sibling, 0 replies; 4+ messages in thread
From: Manivannan Sadhasivam @ 2025-09-25 16:36 UTC (permalink / raw)
To: linux-pci, Marek Vasut
Cc: Krzysztof Wilczyński, Bjorn Helgaas, Geert Uytterhoeven,
Lorenzo Pieralisi, Magnus Damm, Rob Herring, Yoshihiro Shimoda,
linux-renesas-soc
On Wed, 24 Sep 2025 02:55:45 +0200, Marek Vasut wrote:
> Assure the reset is latched and the core is ready for DBI access.
> On R-Car V4H, the PCIe reset is asynchronized and does not take
> effect immediately, but needs a short time to complete. In case
> DBI access happens in that short time, that access generates an
> SError. Make sure that condition can never happen, read back the
> state of the reset which should turn the asynchronized reset into
> synchronized one, and wait a little over 1ms to add additional
> safety margin.
>
> [...]
Applied, thanks!
[1/1] PCI: rcar-gen4: Assure reset occurs before DBI access
commit: 1d45d0c80b9e8fd8167e0621146a32eecebd430f
Best regards,
--
Manivannan Sadhasivam <mani@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-09-25 16:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-24 0:55 [PATCH] PCI: rcar-gen4: Assure reset occurs before DBI access Marek Vasut
2025-09-25 13:41 ` Geert Uytterhoeven
2025-09-25 16:39 ` Manivannan Sadhasivam
2025-09-25 16:36 ` Manivannan Sadhasivam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox