[PATCH 8/9] nvme: also return I/O command effects from nvme_command_effects
Christoph Hellwig
hch at lst.de
Wed Dec 14 08:13:46 PST 2022
To be able to use the Commands Supported and Effects Log for allowing
unprivileged passtrough, it needs to be corretly reported for I/O
commands as well. Return the I/O command effects from
nvme_command_effects, and also add a default list of effects for the
NVM command set. For other command sets we do require the log page
to be present already.
Signed-off-by: Christoph Hellwig <hch at lst.de>
---
drivers/nvme/host/core.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 9529abe22c9cdb..c50678390def38 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1069,13 +1069,12 @@ u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u8 opcode)
effects = le32_to_cpu(ns->head->effects->iocs[opcode]);
if (effects & ~(NVME_CMD_EFFECTS_CSUPP | NVME_CMD_EFFECTS_LBCC))
dev_warn_once(ctrl->device,
- "IO command:%02x has unhandled effects:%08x\n",
+ "IO command:%02x has unusual effects:%08x\n",
opcode, effects);
- return 0;
+ } else {
+ effects = le32_to_cpu(ctrl->effects->acs[opcode]);
}
- effects = le32_to_cpu(ctrl->effects->acs[opcode]);
-
/* only return actual command effects and not misc information */
return effects & (NVME_CMD_EFFECTS_CSUPP | NVME_CMD_EFFECTS_LBCC |
NVME_CMD_EFFECTS_NCC | NVME_CMD_EFFECTS_NIC |
@@ -3064,8 +3063,8 @@ static int nvme_init_effects(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
}
/*
- * Initialize known admin command set effects for controllers don't
- * provide the log or are buggy enough to not correctly mark the
+ * Initialize known admin and NVM command set effects for controllers
+ * don't provide the log or are buggy enough to not correctly mark the
* usual effects.
*/
ctrl->effects->acs[nvme_admin_format_nvm] |=
@@ -3073,6 +3072,13 @@ static int nvme_init_effects(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
NVME_CMD_EFFECTS_CSE_MASK);
ctrl->effects->acs[nvme_admin_sanitize_nvm] |=
cpu_to_le32(NVME_CMD_EFFECTS_LBCC | NVME_CMD_EFFECTS_CSE_MASK);
+
+ ctrl->effects->iocs[nvme_cmd_write] |=
+ cpu_to_le32(NVME_CMD_EFFECTS_LBCC);
+ ctrl->effects->iocs[nvme_cmd_write_zeroes] |=
+ cpu_to_le32(NVME_CMD_EFFECTS_LBCC);
+ ctrl->effects->iocs[nvme_cmd_write_uncor] |=
+ cpu_to_le32(NVME_CMD_EFFECTS_LBCC);
return 0;
}
--
2.35.1
More information about the Linux-nvme
mailing list