enjoy-digital / litepcie

Small footprint and configurable PCIe core
Other
468 stars 116 forks source link

software/user: split DMA handling into an API #65

Closed sergachev closed 2 years ago

sergachev commented 2 years ago

The purpose of this changeset is to provide a clean and simple API to handle DMA reads and writes in user software and examples of it. I know the pull request looks huge, but code is 95% same as before, just reshuffled into different functions/files and deduplicated. It's worth starting looking at it from litepcie_dma_minimal_example.c which should be self-explanatory:

Zero-copy can now be used seamlessly anywhere by passing a flag to litepcie_dma_init().

Note I was still not able to test litepcie_test record and play properly yet even after setting pcie_dma0.writer.sink.valid.eq(1), pcie_dma0.reader.source.ready.eq(1) even before these changes - not sure why.

litepcie_util dma_test seems to work correctly though.

sjkelly commented 2 years ago

I tested this locally on the fairwaves xtrx and both litepcie_util and litepcie_dma_minimal_example are failing to make DMA transfers in both normal and zero-copy mode.

sergachev commented 2 years ago

Thanks for testing! Does it work before these changes? Do you get any errors in console and dmesg? I of course tested too (on acorn - https://github.com/sergachev/litepcie_acorn), but will be able to test again only in a week or so.

sjkelly commented 2 years ago

Does it work before these changes? Do you get any errors in console and dmesg?

Yes, the original userspace seems to work fine. I will keep investigating so I can give a better diagnostic.

maleadt commented 2 years ago

I'm not seeing any issues here with an XTRX and this PR, both modes work.

enjoy-digital commented 2 years ago

Thanks @sergachev, this indeed simplifies thing and avoid some duplication. I've been able to also test it on SQRL Acorn successfully. I'll also add an example for litepcie_test record/play. So this looks good, I'm merging to avoid stalling other PRs on top of this.