diff options
Diffstat (limited to 'src/hw/nvme.c')
-rw-r--r-- | src/hw/nvme.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/hw/nvme.c b/src/hw/nvme.c index 946487f4..e6d739d9 100644 --- a/src/hw/nvme.c +++ b/src/hw/nvme.c @@ -318,8 +318,11 @@ nvme_create_io_cq(struct nvme_ctrl *ctrl, struct nvme_cq *cq, u16 q_idx) { int rc; struct nvme_sqe *cmd_create_cq; + u16 length = 1 + (ctrl->reg->cap & 0xffff); + if (length > NVME_PAGE_SIZE / sizeof(struct nvme_cqe)) + length = NVME_PAGE_SIZE / sizeof(struct nvme_cqe); - rc = nvme_init_cq(ctrl, cq, q_idx, NVME_PAGE_SIZE / sizeof(struct nvme_cqe)); + rc = nvme_init_cq(ctrl, cq, q_idx, length); if (rc) { goto err; } @@ -359,8 +362,11 @@ nvme_create_io_sq(struct nvme_ctrl *ctrl, struct nvme_sq *sq, u16 q_idx, struct { int rc; struct nvme_sqe *cmd_create_sq; + u16 length = 1 + (ctrl->reg->cap & 0xffff); + if (length > NVME_PAGE_SIZE / sizeof(struct nvme_cqe)) + length = NVME_PAGE_SIZE / sizeof(struct nvme_cqe); - rc = nvme_init_sq(ctrl, sq, q_idx, NVME_PAGE_SIZE / sizeof(struct nvme_cqe), cq); + rc = nvme_init_sq(ctrl, sq, q_idx, length, cq); if (rc) { goto err; } |