-
Notifications
You must be signed in to change notification settings - Fork 204
Support unaligned DMA buffer address #2704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Split the base address into an aligned part and an offset. Add one cycle to the start of the DMA playback to skip ahead to the real start of the playback.
How so?
Why not just allocate an aligned buffer in the first place? |
Well, that was my question when I looked at the firmware code. I just figured that either no one care about that performance or that there's no easy way to do so in rust.
The direct answer to this question is that this solves one of the three requirements I've listed in #2697 . Since it reduce the number of missing pieces from 3 to 2 this change obviously made it easier. But I assume you are asking about comparing to other approaches. And here's a comparison for all the approaches/aspects I've considered. First of all, I'm assuming the alignment requirement can be removed without significant performance hit so I'm only considering the software/firmware side. With that out of the way, the usecases I've considered are,
The first three are mainly to make sure there's no regression and the latter two are usecases I'd like to support (though I personally only need 4 for now). Now comparing the approaches with or without the alignment requirements.
|
Obviously it can be done: allocate a buffer with extra size (alignment-1), then discard the beginning. For a dynamic buffer like I don't see any valid reason to deal with misalignment in gateware. It wastes FPGA resources and potentially makes timing closure more difficult. When receiving a host-compiled DMA buffer, the device could simply allocate an aligned buffer to store the data coming from the network. |
Sure. I did not write the code to do the extra realignment copy. I'm only commenting based on what you currently do and I'll take your word for what could be fixed.
So how much more resource would adding one more state to the FSM cost?
I'm certainly fine with supporting this. However, this must be done without bumping the alignment for all rpc dynamic allocation. Ideally it should also support kernel side allocation as well though I don't need it so I don't care about it very much. If you have something in mind that's easier than touching gateware and can be supported in both the current compiler version as well as all future version I'll probably be fine to implement that. |
ARTIQ Pull Request
Description of Changes
Split the base address into an aligned part and an offset. Add one cycle to the start of the DMA playback to skip ahead to the real start of the playback.
This makes it significantly easier to run DMA from a user provided buffer. (All the rest are easy compiler stuff).
Currently this is not tested at all, hence the draft status (I'm still figuring out how to setup the proper environment...) and I'm not even 100% sure if I'm using the correct syntax. However, I do want to post this to get some feedback (especially to see if I understands the handshake signals and the FSM correctly...). The main reasons I went for this rather than adding support to the compiler are that
Related Issue
Ref #2697.
Type of Changes
Steps (Choose relevant, delete irrelevant before submitting)
All Pull Requests
git commit --signoff
, see copyright).Code Changes
flake8
to check code style (follow PEP-8 style).flake8
has issues with parsing Migen/gateware code, ignore as necessary.Git Logistics
git rebase --interactive
). Merge/squash/fixup commits that just fix or amend previous commits. Remove unintended changes & cleanup. See tutorial.git show
). Format:Licensing
See copyright & licensing for more info.
ARTIQ files that do not contain a license header are copyrighted by M-Labs Limited and are licensed under LGPLv3+.