Skip to content

Commit 831ed60

Browse files
author
Christoph Hellwig
committed
nvme: also return I/O command effects from nvme_command_effects
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, the Commands Supported and Effects log is required to be present already. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Keith Busch <[email protected]> Reviewed-by: Kanchan Joshi <[email protected]>
1 parent 2a459f6 commit 831ed60

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

drivers/nvme/host/core.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,23 +1074,43 @@ static u32 nvme_known_admin_effects(u8 opcode)
10741074
return 0;
10751075
}
10761076

1077+
static u32 nvme_known_nvm_effects(u8 opcode)
1078+
{
1079+
switch (opcode) {
1080+
case nvme_cmd_write:
1081+
case nvme_cmd_write_zeroes:
1082+
case nvme_cmd_write_uncor:
1083+
return NVME_CMD_EFFECTS_LBCC;
1084+
default:
1085+
return 0;
1086+
}
1087+
}
1088+
10771089
u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u8 opcode)
10781090
{
10791091
u32 effects = 0;
10801092

10811093
if (ns) {
10821094
if (ns->head->effects)
10831095
effects = le32_to_cpu(ns->head->effects->iocs[opcode]);
1096+
if (ns->head->ids.csi == NVME_CAP_CSS_NVM)
1097+
effects |= nvme_known_nvm_effects(opcode);
10841098
if (effects & ~(NVME_CMD_EFFECTS_CSUPP | NVME_CMD_EFFECTS_LBCC))
10851099
dev_warn_once(ctrl->device,
1086-
"IO command:%02x has unhandled effects:%08x\n",
1100+
"IO command:%02x has unusual effects:%08x\n",
10871101
opcode, effects);
1088-
return 0;
1089-
}
10901102

1091-
if (ctrl->effects)
1092-
effects = le32_to_cpu(ctrl->effects->acs[opcode]);
1093-
effects |= nvme_known_admin_effects(opcode);
1103+
/*
1104+
* NVME_CMD_EFFECTS_CSE_MASK causes a freeze all I/O queues,
1105+
* which would deadlock when done on an I/O command. Note that
1106+
* We already warn about an unusual effect above.
1107+
*/
1108+
effects &= ~NVME_CMD_EFFECTS_CSE_MASK;
1109+
} else {
1110+
if (ctrl->effects)
1111+
effects = le32_to_cpu(ctrl->effects->acs[opcode]);
1112+
effects |= nvme_known_admin_effects(opcode);
1113+
}
10941114

10951115
return effects;
10961116
}

0 commit comments

Comments
 (0)