diff options
author | Ian Moffett <ian@osmora.org> | 2024-03-30 20:14:38 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-03-30 20:14:38 -0400 |
commit | c5bb34325b55e63187379c19414ee43f01fd143b (patch) | |
tree | f834e3b80c9743cd18533f099ac3b20a2bd805de /sys/dev | |
parent | 02dd6681fa3887f1f33a815d414207d13bbbd23b (diff) |
kernel: nvme: Init CC.IOSQES and CC.IOCQES
This is required for I/O queues
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ic/nvme.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sys/dev/ic/nvme.c b/sys/dev/ic/nvme.c index b89545d..d33c57a 100644 --- a/sys/dev/ic/nvme.c +++ b/sys/dev/ic/nvme.c @@ -54,6 +54,8 @@ __KERNEL_META("$Hyra$: nvme.c, Ian Marco Moffett, " #define CONFIG_EN __BIT(0) #define CONFIG_CSS_SHIFT 4 +#define CONFIG_IOSQES_SHIFT 16 +#define CONFIG_IOCQES_SHIFT 20 static struct pci_device *nvme_dev; static struct timer driver_tmr; @@ -275,6 +277,8 @@ nvme_enable_controller(struct nvme_state *state) struct nvme_bar *bar = state->bar; struct nvme_id *id; + uint8_t max_sqes, max_cqes; + if (!__TEST(bar->config, CONFIG_EN)) { bar->config |= CONFIG_EN; } @@ -292,6 +296,17 @@ nvme_enable_controller(struct nvme_state *state) nvme_identify(state, id); nvme_log_ctrl_id(id); + + /* + * Before creating any I/O queues we need to set CC.IOCQES + * and CC.IOSQES... Bits 3:0 is the minimum and bits 7:4 + * is the maximum. We'll choose the maximum. + */ + max_sqes = id->sqes >> 4; + max_cqes = id->cqes >> 4; + bar->config |= (max_sqes << CONFIG_IOSQES_SHIFT); + bar->config |= (max_cqes << CONFIG_IOCQES_SHIFT); + dynfree(id); return 0; } |