Skip to contentSkip to conversation

nvme: do not update kato from a dsm io command

PATCH In review Keith Busch 3 participants 4 messages Aug 11, 2022 – Aug 12, 2022 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: do not update kato from a dsm io command

From: Keith Busch <[email protected]>

The Set Features Admin command shares the same opcode as the DSM IO command (0x9). If the DSM's 'nr' field happens to match the KATO feature ID (0xf), the driver will use a bogus keep-alive frequency.

---
 drivers/nvme/host/core.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +5 -2
index af367b22871b..7d49ca115cc5 100644
@@ -1111,7 +1111,7 @@ static u32 nvme_passthru_start(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
 	return effects;
 }
 
-static void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects,
+static void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects, bool admin,
 			      struct nvme_command *cmd, int status)
 {
 	if (effects & NVME_CMD_EFFECTS_CSE_MASK) {
@@ -1128,6 +1128,9 @@ static void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects,
 		flush_work(&ctrl->scan_work);
 	}
 
+	if (!admin)
+		return;
+
 	switch (cmd->common.opcode) {
 	case nvme_admin_set_features:
 		switch (le32_to_cpu(cmd->common.cdw10) & 0xFF) {
@@ -1160,7 +1163,7 @@ int nvme_execute_passthru_rq(struct request *rq)
 	effects = nvme_passthru_start(ctrl, ns, cmd->common.opcode);
 	ret = nvme_execute_rq(rq, false);
 	if (effects) /* nothing to be done for zero cmd effects */
-		nvme_passthru_end(ctrl, effects, cmd, ret);
+		nvme_passthru_end(ctrl, effects, ns == NULL, cmd, ret);
 
 	return ret;
 }
Signature · 1 line
2.30.2
maintainer
#1 lore raw

Actually please disregard this. We don't reach the effects_end on io commands as it is already.

#2 lore raw
Quoted 2 lines · Keith Busch

Actually please disregard this. We don't reach the effects_end on io commands as it is already.

I thought we do, what prevents them from ending up there?

And we really should be more careful on admin vs I/O commands here anyway.

maintainer
#3 lore raw
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · Keith Busch

Actually please disregard this. We don't reach the effects_end on io commands as it is already.

I thought we do, what prevents them from ending up there?

It's pretty subtle: the driver always returns '0' for IO commands, and the passthrough end handling isn't called in that case. We're not expecting IO commands to have effects that need special handling.