On Thu, Nov 21, 2024 at 02:43:19PM -0500, Frank Li wrote: > On Thu, Nov 21, 2024 at 04:23:21PM +0100, Niklas Cassel wrote: > > The test BAR is on the EP side is allocated using pci_epf_alloc_space(), > > which allocates the backing memory using dma_alloc_coherent(), which will > > return zeroed memory regardless of __GFP_ZERO was set or not. > > > > This means that running a new version of pci-endpoint-test.c (host side) > > with an old version of pci-epf-test.c (EP side) will not see any > > capabilities being set (as intended), so this is backwards compatible. > > > > Additionally, the EP side always allocates at least 128 bytes for the test > > BAR (excluding the MSI-X table), this means that adding another register at > > offset 0x30 is still within the 128 available bytes. > > > > For now, we only add the CAP_UNALIGNED_ACCESS capability. > > > > If CAP_UNALIGNED_ACCESS is set, that means that the EP side supports > > reading/writing to an address without any alignment requirements. > > > > Thus, if CAP_UNALIGNED_ACCESS is set, make sure that the host side does > > not add any extra padding to the buffers that we allocate (which was only > > done in order to get the buffers to satisfy certain alignment requirements > > by the endpoint controller). > > > > Signed-off-by: Niklas Cassel <cassel@xxxxxxxxxx> > > I think 4byte align for readl/writel still required? I've been running this series on rk3588 (which has CAP_UNALIGNED_ACCESS set), so alignment will be set to 0 in pci_endpoint_test_{copy,read,write}(). When running: pcitest -r -s 1 pcitest -r -s 2 pcitest -r -s 3 pcitest -r -s 4 many, many times, and dma_alloc_coherent() always returned an address that was 4 byte aligned, regardless of input size. Additionally, when setting alignment to 0, the code in pci_endpoint_test_{copy,read,write}() will behave exactly as it did before the "alignment support" was added in commit: https://github.com/torvalds/linux/commit/13107c60681f19fec25af93de86442ac9373e43f So I think this patch is good as is. Kind regards, Niklas > > Reviewed-by: Frank Li <Frank.Li@xxxxxxx> > > > --- > > drivers/misc/pci_endpoint_test.c | 21 +++++++++++++++++++++ > > 1 file changed, 21 insertions(+) > >