From: Matt Thompson via B4 Relay <devnull+matt.boondocker.io@kernel.org>
To: "Shawn Lin" <shawn.lin@rock-chips.com>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Heiko Stuebner" <heiko@sntech.de>,
"Catalin Marinas" <catalin.marinas@arm.com>,
"Will Deacon" <will@kernel.org>
Cc: Rob Herring <robh@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
linux-pci@vger.kernel.org, linux-rockchip@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Igor Velkov <iav@iav.lv>
Subject: [PATCH RFC v3 3/6] PCI: rockchip-host: Recover downstream configuration access
Date: Mon, 16 Nov 2026 02:35:45 -0700 [thread overview]
Message-ID: <20261116-rfc-b4-v3-3-0bf052b68f2a@boondocker.io> (raw)
In-Reply-To: <20261116-rfc-b4-v3-0-0bf052b68f2a@boondocker.io>
From: Matt Thompson <matt@boondocker.io>
The link status can change between the readiness check and a downstream
PCI configuration read. A link that reports up can also fail to return
a usable completion.
On arm64, annotate downstream loads for all three access widths so a
synchronous external abort returns PCIBIOS_DEVICE_NOT_FOUND with all-ones
data. Keep little-endian conversion and I/O read ordering on success.
After retraining, the controller can continue to block configuration
traffic until its AXI link-down latch is cleared. Clear the latch before
downstream config reads and writes once the link readiness checks pass.
Link: https://lore.kernel.org/linux-pci/20261024-rockchip-pcie-resume-v1-2-58e54a5cf5f1@iav.lv/
Signed-off-by: Matt Thompson <matt@boondocker.io>
---
drivers/pci/controller/pcie-rockchip-host.c | 62 +++++++++++++++++++++++++++--
drivers/pci/controller/pcie-rockchip.h | 1 +
2 files changed, 59 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/controller/pcie-rockchip-host.c b/drivers/pci/controller/pcie-rockchip-host.c
index 35105c1..64ac6f4 100644
--- a/drivers/pci/controller/pcie-rockchip-host.c
+++ b/drivers/pci/controller/pcie-rockchip-host.c
@@ -29,6 +29,10 @@
#include "../pci.h"
#include "pcie-rockchip.h"
+#ifdef CONFIG_ARM64
+#include <asm/asm-extable.h>
+#endif
+
static void rockchip_pcie_enable_bw_int(struct rockchip_pcie *rockchip)
{
u32 status;
@@ -149,16 +153,36 @@ static bool rockchip_pcie_downstream_ready(struct rockchip_pcie *rockchip)
PCIE_LINK_TRAINING_DONE(rockchip_pcie_read(rockchip, PCIE_CORE_CTRL));
}
+#ifdef CONFIG_ARM64
+/*
+ * An absent completion can raise a synchronous external abort even when
+ * the link status indicated up immediately before the config transaction.
+ */
+#define rockchip_pcie_cfg_load(insn, addr, val) \
+ ({ \
+ int err = 0; \
+ asm volatile("1: " #insn " %w0, [%2]\n" \
+ "2:\n" \
+ _ASM_EXTABLE_MMIO_READ_ERR_ZERO(1b, 2b, \
+ %w1, %w0) \
+ : "=&r" (val), "+r" (err) \
+ : "r" (addr) : "memory"); \
+ err; \
+ })
+#endif
+
static int rockchip_pcie_rd_other_conf(struct rockchip_pcie *rockchip,
struct pci_bus *bus, u32 devfn,
int where, int size, u32 *val)
{
void __iomem *addr;
+#ifdef CONFIG_ARM64
+ u32 data;
+ int err;
+#endif
- if (!rockchip_pcie_downstream_ready(rockchip)) {
- *val = ~0U;
- return PCIBIOS_DEVICE_NOT_FOUND;
- }
+ if (!rockchip_pcie_downstream_ready(rockchip))
+ goto absent;
addr = rockchip->reg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where);
@@ -174,6 +198,28 @@ static int rockchip_pcie_rd_other_conf(struct rockchip_pcie *rockchip,
rockchip_pcie_cfg_configuration_accesses(rockchip,
AXI_WRAPPER_TYPE1_CFG);
+ /* Clear the AXI link-down latch before downstream config traffic. */
+ rockchip_pcie_write(rockchip, 0, PCIE_CORE_AXI_LINK_DOWN);
+
+#ifdef CONFIG_ARM64
+ if (size == 4) {
+ err = rockchip_pcie_cfg_load(ldr, addr, data);
+ *val = le32_to_cpu((__force __le32)data);
+ } else if (size == 2) {
+ err = rockchip_pcie_cfg_load(ldrh, addr, data);
+ *val = le16_to_cpu((__force __le16)data);
+ } else if (size == 1) {
+ err = rockchip_pcie_cfg_load(ldrb, addr, data);
+ *val = data;
+ } else {
+ *val = 0;
+ return PCIBIOS_BAD_REGISTER_NUMBER;
+ }
+ if (err)
+ goto absent;
+ /* Preserve the I/O read ordering of readl/readw/readb. */
+ __io_ar(*val);
+#else
if (size == 4) {
*val = readl(addr);
} else if (size == 2) {
@@ -184,7 +230,12 @@ static int rockchip_pcie_rd_other_conf(struct rockchip_pcie *rockchip,
*val = 0;
return PCIBIOS_BAD_REGISTER_NUMBER;
}
+#endif
return PCIBIOS_SUCCESSFUL;
+
+absent:
+ *val = ~0U;
+ return PCIBIOS_DEVICE_NOT_FOUND;
}
static int rockchip_pcie_wr_other_conf(struct rockchip_pcie *rockchip,
@@ -208,6 +259,9 @@ static int rockchip_pcie_wr_other_conf(struct rockchip_pcie *rockchip,
rockchip_pcie_cfg_configuration_accesses(rockchip,
AXI_WRAPPER_TYPE1_CFG);
+ /* Clear the AXI link-down latch before downstream config traffic. */
+ rockchip_pcie_write(rockchip, 0, PCIE_CORE_AXI_LINK_DOWN);
+
if (size == 4)
writel(val, addr);
else if (size == 2)
diff --git a/drivers/pci/controller/pcie-rockchip.h b/drivers/pci/controller/pcie-rockchip.h
index b5da156..1cc3621 100644
--- a/drivers/pci/controller/pcie-rockchip.h
+++ b/drivers/pci/controller/pcie-rockchip.h
@@ -164,6 +164,7 @@
#define MIN_AXI_ADDR_BITS_PASSED 8
#define PCIE_ADDR_MASK GENMASK_ULL(63, MIN_AXI_ADDR_BITS_PASSED)
#define PCIE_CORE_AXI_CONF_BASE 0xc00000
+#define PCIE_CORE_AXI_LINK_DOWN (PCIE_CORE_AXI_CONF_BASE + 0x824)
#define PCIE_CORE_OB_REGION_ADDR0 (PCIE_CORE_AXI_CONF_BASE + 0x0)
#define PCIE_CORE_OB_REGION_ADDR0_NUM_BITS 0x3f
#define PCIE_CORE_OB_REGION_ADDR0_LO_ADDR PCIE_ADDR_MASK
--
Git-155)
next prev parent reply other threads:[~2026-11-16 9:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 9:35 [PATCH RFC v3 0/6] PCI: rockchip-host: Handle unavailable downstream config space Matt Thompson via B4 Relay
2026-11-16 9:35 ` [PATCH RFC v3 1/6] PCI: rockchip-host: Skip downstream config access while link is down Matt Thompson via B4 Relay
2026-11-16 9:35 ` [PATCH RFC v3 2/6] arm64: Allow synchronous abort fixups for guarded MMIO reads Matt Thompson via B4 Relay
2026-11-16 9:35 ` Matt Thompson via B4 Relay [this message]
2026-11-16 9:35 ` [PATCH RFC v3 4/6] PCI: Resume downstream ports before sysfs Link Control writes Matt Thompson via B4 Relay
2026-11-16 9:35 ` [PATCH RFC v3 5/6] PCI: rockchip-host: Defer retraining during initial link training Matt Thompson via B4 Relay
2026-11-16 9:35 ` [PATCH RFC v3 6/6] PCI: rockchip-host: Mask the client correctable error interrupt Matt Thompson via B4 Relay
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=20261116-rfc-b4-v3-3-0bf052b68f2a@boondocker.io \
--to=devnull+matt.boondocker.io@kernel.org \
--cc=bhelgaas@google.com \
--cc=catalin.marinas@arm.com \
--cc=heiko@sntech.de \
--cc=iav@iav.lv \
--cc=kwilczynski@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=mark.rutland@arm.com \
--cc=matt@boondocker.io \
--cc=robh@kernel.org \
--cc=shawn.lin@rock-chips.com \
--cc=will@kernel.org \
/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
all inboxes | Powered by JetHome®