aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-30 20:17:14 -0400
committerIan Moffett <ian@osmora.org>2024-03-30 20:19:02 -0400
commit6f0129f366e723e27f53c514685b454db1a787c4 (patch)
tree355b671298c0b14c5250fb4a04fb6787cc92e8ad /sys/dev/ic
parentc5bb34325b55e63187379c19414ee43f01fd143b (diff)
kernel: nvme: Fix and rename nvme_create_adminq()
Rename nvme_create_adminq() to nvme_create_queue() and allow a queue ID to be passed as an argument Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/nvme.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/dev/ic/nvme.c b/sys/dev/ic/nvme.c
index d33c57a..24bf4e5 100644
--- a/sys/dev/ic/nvme.c
+++ b/sys/dev/ic/nvme.c
@@ -106,7 +106,7 @@ nvme_poll_ready(struct nvme_bar *bar, uint8_t val)
* Create an admin queue.
*/
static int
-nvme_create_adminq(struct nvme_state *s, struct nvme_queue *queue)
+nvme_create_queue(struct nvme_state *s, struct nvme_queue *queue, size_t id)
{
struct nvme_bar *bar = s->bar;
const size_t PAGESZ = vm_get_page_size();
@@ -130,8 +130,8 @@ nvme_create_adminq(struct nvme_state *s, struct nvme_queue *queue)
queue->sq_head = 0;
queue->sq_tail = 0;
queue->size = SLOTS;
- queue->sq_db = PHYS_TO_VIRT((uintptr_t)bar + PAGESZ);
- queue->cq_db = PHYS_TO_VIRT((uintptr_t)bar + PAGESZ + 1 * (4 << DBSTRIDE));
+ queue->sq_db = PHYS_TO_VIRT((uintptr_t)bar + PAGESZ + (2 * id * (4 << DBSTRIDE)));
+ queue->cq_db = PHYS_TO_VIRT((uintptr_t)bar + PAGESZ + ((2 * id + 1) * (4 << DBSTRIDE)));
queue->cq_phase = 1;
return 0;
}
@@ -325,7 +325,7 @@ nvme_init_controller(struct nvme_bar *bar)
pci_set_cmdreg(nvme_dev, cmdreg_bits);
nvme_disable_controller(&state);
- nvme_create_adminq(&state, adminq);
+ nvme_create_queue(&state, adminq, 0);
/* Setup admin submission and admin completion queues */
bar->aqa = (mqes | mqes << 16);