Re: [PATCH] PCI: dwc: rcar-gen4: Use 4K EPC BAR alignment
From: Niklas Cassel
Date: Thu Mar 05 2026 - 10:47:12 EST
On Thu, Mar 05, 2026 at 11:13:14PM +0900, Koichiro Den wrote:
> On Thu, Mar 05, 2026 at 08:37:35AM +0100, Niklas Cassel wrote:
> > On Thu, Mar 05, 2026 at 10:54:39AM +0900, Koichiro Den wrote:
> > > 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.
> > >
> > > Update the advertised alignment to 4K, as described in
> > > commit 2a9a801620ef ("PCI: endpoint: Add support to specify alignment
> > > for buffers allocated to BARs").
> > >
> > > With the previous 1MB alignment requirement, iATU programming for BAR4
> > > on this platform often cannot be performed, since a 1MB-aligned target
> > > address may fall outside the tiny 256B BAR4 window.
> >
> > You could also mention that CX_ATU_MIN_REGION_SIZE can configured to
> > a value in range 4 kB to 64 kB, so 1 MB is clearly bogus.
> >
> > Reviewed-by: Niklas Cassel <cassel@xxxxxxxxxx>
>
> Thanks for the review and follow-up, Niklas.
>
> (I initially wondered whether the 1MB alignment had some historical reason
> behind it, i.e. an intentional or unavoidable hack, which is why I hesitated to
> add a Fixes tag. But I agree that it is bogus today.)
My best guess:
Since rcar-gen4 previously incorrectly marked the Resizable BARs as
Programmable, and we know that the minumum size for a Resizable BAR is 1 MB...
pci_epf_alloc_space() and pci_epf_align_inbound_addr() would have done the
"right thing" for these incorrectly configured BARs, when putting an incorrect
alignment of 1 MB. (Even if this would result in excessive alignment for the
non-Resizable BARs, e.g. BAR4.)
Now when rcar-gen4 have marked the resizable BARs as resizable,
pci_epf_alloc_space() and pci_epf_align_inbound_addr() will still do the right
thing (ensure 1 MB alignment for the resizable BARs), but will not result in
excessive alignment for the non-Resizable BARs, e.g. BAR4.
Kind regards,
Niklas