[PATCH v2] PCI: dwc: rcar-gen4: Use 4K EPC BAR alignment

From: Koichiro Den

Date: Thu Mar 05 2026 - 10:15:22 EST


R-Car S4 Series (R8A779F[4-7]*) uses a 4K minimum iATU region size
(CX_ATU_MIN_REGION_SIZE = 4K) as per R19UH0161EJ0130 Rev.1.30. The
DesignWare parameter itself can only be configured in the range 4 kB to
64 kB, so the current 1 MB alignment requirement is incorrect.

Update the advertised EPC BAR alignment to 4K, as described in
commit 2a9a801620ef ("PCI: endpoint: Add support to specify alignment
for buffers allocated to BARs").

This also fixes needless unusability of BAR4 on this platform when the
target address is fixed, such as for doorbell targets.

pci_epf_assign_bar_space() aligns the target address down to the
advertised alignment before programming the mapping. BAR4 is fixed at
256 bytes, so aligning the target address to 1 MB is highly likely to
move the mapping base far enough that the resulting offset no longer
fits within the BAR4 window. In that case the mapping cannot be
programmed. With this patch, it becomes more likely that BAR4 can be
used for such cases. If the 4K-aligned offset still exceeds 256B, the
mapping cannot be programmed and this should be treated as a hardware
limitation.

Fixes: e311b3834dfa ("PCI: rcar-gen4: Add endpoint mode support")
Reviewed-by: Niklas Cassel <cassel@xxxxxxxxxx>
Signed-off-by: Koichiro Den <den@xxxxxxxxxxxxx>
---
v1->v2 changes:
- Updated commit message for clarity
- Added Fixes and Reviewed-by tags

drivers/pci/controller/dwc/pcie-rcar-gen4.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/controller/dwc/pcie-rcar-gen4.c b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
index 3d4a889e38cc..396ef9432299 100644
--- a/drivers/pci/controller/dwc/pcie-rcar-gen4.c
+++ b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
@@ -428,7 +428,7 @@ static const struct pci_epc_features rcar_gen4_pcie_epc_features = {
.bar[BAR_3] = { .type = BAR_RESERVED, },
.bar[BAR_4] = { .type = BAR_FIXED, .fixed_size = 256 },
.bar[BAR_5] = { .type = BAR_RESERVED, },
- .align = SZ_1M,
+ .align = SZ_4K,
};

static const struct pci_epc_features*
--
2.51.0