From: Koichiro Den <den@valinux.co.jp>
To: "Marek Vasut" <marek.vasut+renesas@mailbox.org>,
"Yoshihiro Shimoda" <yoshihiro.shimoda.uh@renesas.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Geert Uytterhoeven" <geert+renesas@glider.be>,
"Magnus Damm" <magnus.damm@gmail.com>,
"Jingoo Han" <jingoohan1@gmail.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>,
Frank Li <Frank.Li@nxp.com>, Niklas Cassel <cassel@kernel.org>,
Wilfred Mallawa <wilfred.mallawa@wdc.com>,
Serge Semin <fancer.lancer@gmail.com>,
linux-pci@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 00/11] PCI: rcar-gen4: Recover from link down and route Root Port interrupts
Date: Fri, 18 Sep 2026 12:20:27 +0900 [thread overview]
Message-ID: <20260918032038.2216471-1-den@valinux.co.jp> (raw)
Hi,
This series improves error handling on the R-Car Gen4 PCIe host
controller (tested on R-Car S4 Spider, r8a779f0). It fixes unexpected
link-down handling so the host doesn't hang, and wires up missing Root
Port interrupts (AER, PME, bandwidth notifications) so port services
actually work.
A few hardware quirks made this tricky:
1. PCIEINTSTS0 link-up bits don't track the actual link state. The
driver never noticed when the link dropped and kept trying config
accesses on the dead link. Patch 2 drops this broken callback in
favor of the DWC core check.
2. On link down, the controller's reset request shares the
intreq_pcim_sub line with the integrated MSI receiver. Accessing DBI
right after link down hangs the bus. Recovery has to hook into the
chained MSI handler before DBI is touched and reset the controller
via reset_root_port(). This works both with iMSI-RX and external MSI
controllers (GIC ITS).
3. Root Port interrupts only trigger APP status bits on platform IRQs.
The controller appears to lack SII2MSI, so Root Port MSIs never reach
the GIC ITS. With iMSI-RX, INTx gets routed to the chained MSI
handler where port services can't request it. This series works
around it by hiding Root Port MSI caps across the board and emulating
INTx using a virtual IRQ domain, fed by the "aer" IRQ and
intreq_pcim_sub.
Patch 1 is only loosely related: it adds Renesas to the RAS DES VSEC
list so the DWC debugfs error injection works on R-Car. I used it to
test the Root Port AER path (see below) and included it here for that
reason. Happy to send it separately if preferred.
Based on next-20260915. The driver patches build on f0a5c6bd797c ("PCI:
rcar-gen4: Limit Max_Read_Request_Size to 256 Bytes") in pci/next, and
the DTS patch is for renesas-devel, which already has b43aa6a6ebe8
("arm64: dts: renesas: r8a779f0: Add GICv3 ITS and update PCIe nodes");
configurations b and c below use that DT.
Note: backward compatibility with older DTs is kept. Without the "aer"
interrupt, only Root Port AER remains unavailable. See the Testing
section below.
Testing
-------
Setup: R-Car S4 Spider (RC) linked to another S4 Spider running the
pci-epf-test endpoint. pci_endpoint_test is bound on the RC side.
1. Link down / recovery. On the EP side, toggle the endpoint controller
off and on. The short pause keeps the endpoint away long enough for
the RC to notice, but brings it back within the reset window so
recovery can succeed. Adpoted the test approach from [1]:
# cd /sys/kernel/config/pci_ep
# echo 0 > controllers/e65d0000.pcie-ep/start
# sleep 0.1
# echo 1 > controllers/e65d0000.pcie-ep/start
Expected on the RC dmesg:
pcieport 0000:00:00.0: Recovering Root Port due to Link Down
pcieport 0000:00:00.0: Root Port has been reset
pcieport 0000:00:00.0: AER: device recovery successful
and the "msi" (intreq_pcim_sub) interrupt count going up in
/proc/interrupts. Without this series nothing shows up here: the
link comes back on its own once the endpoint returns, but the RC
never notices the outage and the endpoint is left unconfigured
(see 4). Config accesses issued while the link is down hang the
host.
[1] https://lore.kernel.org/r/abFMa6DCGGLUHddA@fedora/
2. Bandwidth notification. On the RC, retrain the link:
# setpci -s 00:00.0 CAP_EXP+0x10.w=0x0c23
Expected:
- the virtual Root Port IRQ (rcar-gen4-rp in /proc/interrupts,
shared by PCIe PME, aerdrv and PCIe bwctrl) fires once
- bwctrl clears LnkSta.LBMS
(setpci -s 00:00.0 CAP_EXP+0x12.w reads 0x2024 again).
Before the series LnkSta read 0xe024 afterwards, LBMS and LABS
stuck.
3. Root Port AER. On the RC, inject an LCRC error with the DWC debugfs
(patch 1) and issue one config read so a TLP actually goes out:
# cd /sys/kernel/debug/dwc_pcie_e65d0000.pcie/rasdes_err_inj
# echo 1 > rx_lcrc # error detected by the Root Port
# setpci -s 01:00.0 VENDOR_ID.w
# echo 1 > tx_lcrc # error detected by the endpoint,
# setpci -s 01:00.0 VENDOR_ID.w # reported back with ERR_COR
Expected on the RC dmesg, respectively:
pcieport 0000:00:00.0: PCIe Bus Error: severity=Correctable
pcieport 0000:00:00.0: [ 6] BadTLP | Receiver | Data Link Layer
pcieport 0000:00:00.0: AER: Correctable Error message received from 0000:01:00.0
pci-endpoint-test 0000:01:00.0: PCIe Bus Error: severity=Correctable
pci-endpoint-test 0000:01:00.0: [ 6] BadTLP | Receiver | Data Link Layer
plus the virtual Root Port IRQ count and aer_rootport_total_err_cor
going up by one each time. The link stays up throughout, the DLL
retry recovers the TLP. Before the series nothing is reported.
4. Regression check. Run pci_endpoint_test after step 1. PASS/FAIL/SKIP
counts match a run without step 1.
Configurations:
a. Without this series**
b. GIC ITS, DT with the new "aer" interrupt (this series)
c. GIC ITS, DT without "aer" (b43aa6a6ebe8 ("arm64: dts: renesas:
r8a779f0: Add GICv3 ITS and update PCIe nodes") or later)
d. iMSI-RX, DT before b43aa6a6ebe8 (no msi-parent, no "aer")
Result:
recovery bwctrl/PME RP AER pcitest
---------------------------------------------------------
a. none no no all FAIL
b. ok ok ok no change
c. ok ok n/a* no change
d. ok ok n/a* no change
* Root Port AER needs the "aer" interrupt; without it the behaviour is
unchanged from before the series.
** Only patch 1 applied on top of the base, so the same debugfs error
injection could be used for the comparison. pci_endpoint_test fails
across the board there because nothing restores the endpoint after
the toggle.
Best regards,
Koichiro
Koichiro Den (11):
PCI: dwc: Add Renesas to the RAS DES VSEC list
PCI: rcar-gen4: Drop the APP-based link_up check
dt-bindings: PCI: rcar-gen4: Add optional "aer" interrupt
PCI: dwc: Add a host op to run before iMSI-RX status is read
PCI: rcar-gen4: Split reusable hardware initialization
PCI: rcar-gen4: Add Root Port reset support
PCI: rcar-gen4: Recover the Root Port on link down
PCI: dwc: Let glue drivers hide the Root Port MSI capabilities
PCI: rcar-gen4: Route Root Port AER to a virtual Root Port IRQ
PCI: rcar-gen4: Route Root Port PME and bandwidth notifications
arm64: dts: renesas: r8a779f0: Describe the PCIe AER interrupts
.../bindings/pci/rcar-gen4-pci-host.yaml | 10 +-
arch/arm64/boot/dts/renesas/r8a779f0.dtsi | 10 +-
drivers/pci/controller/dwc/Kconfig | 1 +
.../pci/controller/dwc/pcie-designware-host.c | 9 +-
drivers/pci/controller/dwc/pcie-designware.h | 8 +
drivers/pci/controller/dwc/pcie-rcar-gen4.c | 673 ++++++++++++++++--
include/linux/pcie-dwc.h | 2 +
7 files changed, 652 insertions(+), 61 deletions(-)
base-commit: e6e35979777d646fe3c7c94dca7dd32fb25d45f4
--
2.51.0
next reply other threads:[~2026-09-18 3:20 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 3:20 Koichiro Den [this message]
2026-09-18 3:20 ` [PATCH 01/11] PCI: dwc: Add Renesas to the RAS DES VSEC list Koichiro Den
2026-09-18 3:24 ` sashiko-bot
2026-09-22 19:40 ` Marek Vasut
2026-09-18 3:20 ` [PATCH 02/11] PCI: rcar-gen4: Drop the APP-based link_up check Koichiro Den
2026-09-18 3:25 ` sashiko-bot
2026-09-22 20:56 ` Marek Vasut
2026-09-23 14:56 ` Koichiro Den
2026-09-27 19:59 ` Marek Vasut
2026-09-28 4:20 ` Koichiro Den
2026-09-28 15:07 ` Marek Vasut
2026-09-18 3:20 ` [PATCH 03/11] dt-bindings: PCI: rcar-gen4: Add optional "aer" interrupt Koichiro Den
2026-09-18 3:25 ` sashiko-bot
2026-09-22 20:59 ` Marek Vasut
2026-09-28 18:32 ` Rob Herring (Arm)
2026-09-18 3:20 ` [PATCH 04/11] PCI: dwc: Add a host op to run before iMSI-RX status is read Koichiro Den
2026-09-18 3:32 ` sashiko-bot
2026-09-18 3:20 ` [PATCH 05/11] PCI: rcar-gen4: Split reusable hardware initialization Koichiro Den
2026-09-18 3:27 ` sashiko-bot
2026-09-22 21:15 ` Marek Vasut
2026-09-23 15:24 ` Koichiro Den
2026-09-27 20:43 ` Marek Vasut
2026-09-18 3:20 ` [PATCH 06/11] PCI: rcar-gen4: Add Root Port reset support Koichiro Den
2026-09-18 3:29 ` sashiko-bot
2026-09-22 21:22 ` Marek Vasut
2026-09-23 16:12 ` Koichiro Den
2026-09-27 22:25 ` Marek Vasut
2026-09-28 3:50 ` Koichiro Den
2026-09-28 17:47 ` Marek Vasut
2026-09-18 3:20 ` [PATCH 07/11] PCI: rcar-gen4: Recover the Root Port on link down Koichiro Den
2026-09-18 3:33 ` sashiko-bot
2026-09-22 21:44 ` Marek Vasut
2026-09-24 16:15 ` Koichiro Den
2026-09-27 22:37 ` Marek Vasut
2026-09-28 4:06 ` Koichiro Den
2026-09-28 17:36 ` Marek Vasut
2026-09-18 3:20 ` [PATCH 08/11] PCI: dwc: Let glue drivers hide the Root Port MSI capabilities Koichiro Den
2026-09-18 3:24 ` sashiko-bot
2026-09-18 3:20 ` [PATCH 09/11] PCI: rcar-gen4: Route Root Port AER to a virtual Root Port IRQ Koichiro Den
2026-09-18 3:32 ` sashiko-bot
2026-09-18 3:20 ` [PATCH 10/11] PCI: rcar-gen4: Route Root Port PME and bandwidth notifications Koichiro Den
2026-09-18 3:30 ` sashiko-bot
2026-09-18 3:20 ` [PATCH 11/11] arm64: dts: renesas: r8a779f0: Describe the PCIe AER interrupts Koichiro Den
2026-09-18 3:27 ` sashiko-bot
2026-09-22 21:31 ` Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260918032038.2216471-1-den@valinux.co.jp \
--to=den@valinux.co.jp \
--cc=Frank.Li@nxp.com \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=fancer.lancer@gmail.com \
--cc=geert+renesas@glider.be \
--cc=jingoohan1@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=magnus.damm@gmail.com \
--cc=mani@kernel.org \
--cc=marek.vasut+renesas@mailbox.org \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=wilfred.mallawa@wdc.com \
--cc=yoshihiro.shimoda.uh@renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox