nvme/core: configure sq/cq with pre-allocated buffer #46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
introduce
nvme_configure_sq_mem,nvme_configure_cq_memandnvme_configure_adminq_memin nvme/core.c to allow setting up a SQ/CQ with a pre-alloacted buffer passed viaiommu_dmabuf.Add NVME_Q_MEM_PREALLOCATED flag to nvme_sq and nvme_cq structs to indicate that the memory region was provided externally (not allocated by the driver). Set this flag in nvme_configure_sq_mem() and nvme_configure_cq_mem(). Update nvme_discard_sq() and nvme_discard_cq() to skip iommu_put_dmabuf() when NVME_Q_MEM_PREALLOCATED is set, preventing double-free or invalid free of externally managed memory.
This feature make it possible to construct SQs/CQs from memory that has been pre-mapped, such as IOMMU mapped memory area or CMB(Controller Memory Buffer).