public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] nvme: do not update kato from a dsm io command
@ 2022-08-11 19:26 Keith Busch
  2022-08-11 20:01 ` Keith Busch
  0 siblings, 1 reply; 4+ messages in thread
From: Keith Busch @ 2022-08-11 19:26 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, sagi, Keith Busch

From: Keith Busch <kbusch@kernel.org>

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.

Signed-off-by: Keith Busch <kbusch@kernel.org>
---
 drivers/nvme/host/core.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index af367b22871b..7d49ca115cc5 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -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;
 }
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-12 14:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-11 19:26 [PATCH] nvme: do not update kato from a dsm io command Keith Busch
2022-08-11 20:01 ` Keith Busch
2022-08-12  5:33   ` Christoph Hellwig
2022-08-12 14:46     ` Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox