[b]Does it work like this:
- I take tegra-pcie-ep-mem.c, compile it in X86 host.
- get pcie-tegra-dw-ep.c to work on Xavier
- hook it up via some kinds of pcie cable.
- then I will be able to read/write xavier from X86 side?
[/b]
Yes. It would work. Please make sure that the cable you are using would route Tx from one end to Rx of another end. Also, since Xavier is self powered, there is no need to supply power from x86 to Xavier(EP)
If Xavier can work in endpoint mode, does that mean I can wire PC PCIE directly to Xavier PCIE ? Maybe through own carrier board design or through Molex cable/PCIE card?
Yes
BTW, which controller of three is used as RC to link to GPU? If I configure this controller to EP mode, what will happen? GPU can’t work properly?
As far as I know, GPU is not supplied by default. So, whichever controller you have planning to connect GPU to cannot be operated in endpoint mode. Dual mode controller can work either in root port mode or endpoint mode but only one at a time (mutually exclusive)
Once a controller is configured to operate in endpoint mode, you can reserve memory to be exposed through EP’s BAR to host and thereby letting host (in this case x86) be able to directly write to Xavier’s system memory. (OR) Xavier-EP’s internal DMA engine can be used to push/pull data to/from x86’s system memory (this is like how a typical PCIe endpoint works). You can go through Xavier TRM to learn more about it and also device tree documentation on how EP can be configured through device-tree entries.