Re: [PATCH v2 01/10] PCI/P2PDMA: Support peer to peer memory

From: Bjorn Helgaas
Date: Thu Mar 01 2018 - 18:45:32 EST


On Thu, Mar 01, 2018 at 11:14:46PM +0000, Stephen Bates wrote:
> > I'm pretty sure the spec disallows routing-to-self so doing a P2P
> > transaction in that sense isn't going to work unless the device
> > specifically supports it and intercepts the traffic before it gets to
> > the port.
>
> This is correct. Unless the device intercepts the TLP before it hits
> the root-port then this would be considered a "route to self"
> violation and an error event would occur. The same holds for the
> downstream port on a PCI switch (unless route-to-self violations are
> disabled which violates the spec but which I have seen done in
> certain applications).

I agree that a function doing DMA to a sibling within the same
multi-function device would probably not generate a TLP for it (I
would be curious to read about this in the spec if you have a
pointer).

More fundamentally, is there some multi-function-specific restriction
on peer-to-peer DMA? In conventional PCI, single-function devices on
the same bus can DMA to each other. The transactions will appear on
the bus, but the upstream bridge will ignore them because the address
is inside the bridge's memory window. As far as I know, the same
should happen on PCIe.

I don't know what happens with functions of a multi-function device,
either in conventional PCI or PCIe. I don't remember a restriction on
whether they can DMA to each other, but maybe there is.

Bjorn