-
Notifications
You must be signed in to change notification settings - Fork 658
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
nvme: allocate aligned payloads for all nvme commands #2051
Conversation
The nvme_alloc has already a built in check which version of the allocation strategy should be used based on the len argument. There is no need for fw_download to do this as well. Signed-off-by: Daniel Wagner <dwagner@suse.de>
These two function are abstracting the libhugebtl API. Let's rename Rename these functions because we want to introduce a generic alloc function with alignment support. Signed-off-by: Daniel Wagner <dwagner@suse.de>
Introduce a cleanup helper function to free generic memory allocation from malloc, calloc, etc. Signed-off-by: Daniel Wagner <dwagner@suse.de>
The kernel supports since v5.2 direct mapped DMA buffers to userspace. Up to this point a bounce buffer was involved. Because the buffers are now directly accessed by the device, the rules of alignment also apply for the payloads. Introduce a helper to allocate all correctly buffers aligned. Furthermore, ensure that the buffer is a multiple of 4k, because there are devices on the market which will always transfer a multiple of 4k, even if we ask for less, e.g 512 bytes. This avoid stack smashes. Signed-off-by: Daniel Wagner <dwagner@suse.de>
11f3426
to
372cdf9
Compare
The kernel supports since v5.2 direct mapped DMA buffers to userspace. Up to this point a bounce buffer was involved. Because the buffers are now directly accessed by the device, the rules of alignment also apply for the payloads. Use the newly introduced nvme_alloc helper to allocate correctly aligned payloads for all nvme commands. Signed-off-by: Daniel Wagner <dwagner@suse.de>
Use the cleanup infra structure to free the nvme_dev resource. This allows us to use return directly and makes the code a bit more readable. While at it also do the same for trivial filedescriptor cases. The more complex cases such in submit_io() needs a bit more tinkering to get right. Signed-off-by: Daniel Wagner <dwagner@suse.de>
I've added a cleanup patch on top for the |
The kernel supports since v5.2 direct mapped DMA buffers to userspace.
Up to this point a bounce buffer was involved. Because the buffers are
now directly accessed by the device, the rules of alignment also apply
for the payloads.
Furthermore, ensure that the buffer is a multiple of 4k, because there
are devices on the market which will always transfer a multiple of 4k,
even if we ask for less, e.g 512 bytes. This avoid stack smashes.
Fixes: #linux-nvme/libnvme#684