Skip to content

Conversation

@minwooim
Copy link
Collaborator

@minwooim minwooim commented Dec 1, 2025

introduce nvme_configure_sq_mem, nvme_configure_cq_mem and nvme_configure_adminq_mem in nvme/core.c to allow setting up a SQ/CQ with a pre-alloacted buffer passed via iommu_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).

introduce `nvme_configure_sq_mem`, `nvme_configure_cq_mem` and
`nvme_configure_adminq_mem` in nvme/core.c to allow setting up a SQ/CQ
with a pre-alloacted buffer passed via `iommu_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).

Signed-off-by: Haeun Kim <hanee.kim@samsung.com>
Signed-off-by: Minwoo Im <minwoo.im@samsung.com>
@minwooim minwooim requested a review from birkelund December 1, 2025 08:07
@birkelund birkelund added the approved Approved for device testing label Dec 1, 2025
@minwooim minwooim merged commit 0b0f4be into SamsungDS:main Dec 2, 2025
23 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Approved for device testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants