Skip to content

Commit 69f4bda

Browse files
Christoph Hellwiggregkh
authored andcommitted
nvme: also return I/O command effects from nvme_command_effects
[ Upstream commit 831ed60 ] 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 <hch@lst.de> Reviewed-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Kanchan Joshi <joshi.k@samsung.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a6a4b05 commit 69f4bda

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
@@ -1113,23 +1113,43 @@ static u32 nvme_known_admin_effects(u8 opcode)
11131113
return 0;
11141114
}
11151115

1116+
static u32 nvme_known_nvm_effects(u8 opcode)
1117+
{
1118+
switch (opcode) {
1119+
case nvme_cmd_write:
1120+
case nvme_cmd_write_zeroes:
1121+
case nvme_cmd_write_uncor:
1122+
return NVME_CMD_EFFECTS_LBCC;
1123+
default:
1124+
return 0;
1125+
}
1126+
}
1127+
11161128
u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u8 opcode)
11171129
{
11181130
u32 effects = 0;
11191131

11201132
if (ns) {
11211133
if (ns->head->effects)
11221134
effects = le32_to_cpu(ns->head->effects->iocs[opcode]);
1135+
if (ns->head->ids.csi == NVME_CAP_CSS_NVM)
1136+
effects |= nvme_known_nvm_effects(opcode);
11231137
if (effects & ~(NVME_CMD_EFFECTS_CSUPP | NVME_CMD_EFFECTS_LBCC))
11241138
dev_warn_once(ctrl->device,
1125-
"IO command:%02x has unhandled effects:%08x\n",
1139+
"IO command:%02x has unusual effects:%08x\n",
11261140
opcode, effects);
1127-
return 0;
1128-
}
11291141

1130-
if (ctrl->effects)
1131-
effects = le32_to_cpu(ctrl->effects->acs[opcode]);
1132-
effects |= nvme_known_admin_effects(opcode);
1142+
/*
1143+
* NVME_CMD_EFFECTS_CSE_MASK causes a freeze all I/O queues,
1144+
* which would deadlock when done on an I/O command. Note that
1145+
* We already warn about an unusual effect above.
1146+
*/
1147+
effects &= ~NVME_CMD_EFFECTS_CSE_MASK;
1148+
} else {
1149+
if (ctrl->effects)
1150+
effects = le32_to_cpu(ctrl->effects->acs[opcode]);
1151+
effects |= nvme_known_admin_effects(opcode);
1152+
}
11331153

11341154
return effects;
11351155
}

0 commit comments

Comments
 (0)