From 26e17c070f845e4d93bff080eead9f5d22253319 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Wed, 10 Jul 2024 22:00:27 -0400 Subject: kernel: nvme: Improve nvme_identify() Require an NSID and CNS value to be passed to the nvme_identify() function. This enables the caller to control what type of data is returned by the NVMe controller. Signed-off-by: Ian Moffett --- sys/dev/ic/nvme.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/ic/nvme.c b/sys/dev/ic/nvme.c index 5f92d0e..9eb302b 100644 --- a/sys/dev/ic/nvme.c +++ b/sys/dev/ic/nvme.c @@ -244,19 +244,19 @@ nvme_poll_submit_cmd(struct nvme_queue *q, struct nvme_cmd cmd) } static int -nvme_identify(struct nvme_ctrl *ctrl, struct nvme_id *id) +nvme_identify(struct nvme_ctrl *ctrl, void *buf, uint32_t nsid, uint8_t cns) { struct nvme_cmd cmd = {0}; struct nvme_identify_cmd *idcmd = &cmd.identify; - if (!is_4k_aligned(id)) { + if (!is_4k_aligned(buf)) { return -1; } idcmd->opcode = NVME_OP_IDENTIFY; - idcmd->nsid = 0; - idcmd->cns = 1; /* Identify controller */ - idcmd->prp1 = VIRT_TO_PHYS(id); + idcmd->nsid = nsid; + idcmd->cns = cns; /* Identify controller */ + idcmd->prp1 = VIRT_TO_PHYS(buf); idcmd->prp2 = 0; return nvme_poll_submit_cmd(&ctrl->adminq, cmd); } @@ -338,8 +338,9 @@ nvme_init_ctrl(struct nvme_bar *bar) return -ENOMEM; } - nvme_identify(&ctrl, id); + nvme_identify(&ctrl, id, 0, ID_CNS_CTRL); nvme_log_ctrl_id(id); + dynfree(id); return 0; } -- cgit v1.2.3