aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilippo Sironi <sironi@amazon.de>2017-10-12 00:42:34 +0200
committerKevin O'Connor <kevin@koconnor.net>2017-10-14 11:10:08 -0400
commitcd47172a673762a05a0c7bd27df6e3cc8febe8d6 (patch)
tree8636f93dfb9280251ed3bf21813471a124dce477
parent5c1a2c75951c4a59f1bf2d3c82ca7447244513ad (diff)
downloadseabios-cd47172a673762a05a0c7bd27df6e3cc8febe8d6.tar.gz
nvme: Use the Maximum Queue Entries Supported (MQES) to initialize I/O queues
Use the Maximum Queue Entries Supported (MQES) to initialize I/O queues depth rather than picking a fixed number (256) which might not be supported by some NVMe controllers (the NVMe specification says that an NVMe controller may support any number between 2 to 4096). Still cap the I/O queues depth to 256 since, during my testing, SeaBIOS was running out of memory when using something higher than 256 (4096 on the NVMe controller that I've had a chance to try). Signed-off-by: Filippo Sironi <sironi@amazon.de>
-rw-r--r--src/hw/nvme.c10
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;
}