Skip to contentSkip to conversation

nvme: copy firmware_rev on each init

PATCH In review Keith Busch 4 participants 4 messages Sep 19, 2022 – Sep 21, 2022 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: copy firmware_rev on each init

From: Keith Busch <[email protected]>

The firmware revision can change on after a reset so copy the most recent info each time instead of just the first time, otherwise the sysfs firmware_rev entry may contain stale data.

---
 drivers/nvme/host/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +2 -1
index ea6694fd550f..e56ecc7fda2d 100644
@@ -2893,7 +2893,6 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
 	nvme_init_subnqn(subsys, ctrl, id);
 	memcpy(subsys->serial, id->sn, sizeof(subsys->serial));
 	memcpy(subsys->model, id->mn, sizeof(subsys->model));
-	memcpy(subsys->firmware_rev, id->fr, sizeof(subsys->firmware_rev));
 	subsys->vendor_id = le16_to_cpu(id->vid);
 	subsys->cmic = id->cmic;
 
@@ -3112,6 +3111,8 @@ static int nvme_init_identify(struct nvme_ctrl *ctrl)
 				ctrl->quirks |= core_quirks[i].quirks;
 		}
 	}
+	memcpy(ctrl->subsys->firmware_rev, id->fr,
+	       sizeof(ctrl->subsys->firmware_rev));
 
 	if (force_apst && (ctrl->quirks & NVME_QUIRK_NO_DEEPEST_PS)) {
 		dev_warn(ctrl->device, "forcibly allowing all power states due to nvme_core.force_apst -- use at your own risk\n");
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#3 lore raw
In reply to Keith Busch
Quoted 25 lines · Keith Busch

From: Keith Busch <[email protected]>

The firmware revision can change on after a reset so copy the most recent info each time instead of just the first time, otherwise the sysfs firmware_rev entry may contain stale data.

---
  drivers/nvme/host/core.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +0 -1
index ea6694fd550f..e56ecc7fda2d 100644
@@ -2893,7 +2893,6 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
  	nvme_init_subnqn(subsys, ctrl, id);
  	memcpy(subsys->serial, id->sn, sizeof(subsys->serial));
  	memcpy(subsys->model, id->mn, sizeof(subsys->model));
-	memcpy(subsys->firmware_rev, id->fr, sizeof(subsys->firmware_rev));
  	subsys->vendor_id = le16_to_cpu(id->vid);
  	subsys->cmic = id->cmic;
 

drivers/nvme/host/core.c static int nvme_init_identify(struct nvme_ctrl *ctrl) · line 3115

Quoted 5 lines
drivers/nvme/host/core.c +2 -0
@@ -3112,6 +3111,8 @@ static int nvme_init_identify(struct nvme_ctrl *ctrl)
  				ctrl->quirks |= core_quirks[i].quirks;
  		}
  	}
+	memcpy(ctrl->subsys->firmware_rev, id->fr,
+	       sizeof(ctrl->subsys->firmware_rev));

Perhaps it would be better to place it near the call to nvme_init_subsystem.

drivers/nvme/host/core.c static int nvme_init_identify(struct nvme_ctrl *ctrl)

Quoted 4 lines
drivers/nvme/host/core.c +0 -0
  	if (force_apst && (ctrl->quirks & NVME_QUIRK_NO_DEEPEST_PS)) {
  		dev_warn(ctrl->device, "forcibly allowing all power states due to nvme_core.force_apst -- use at your own risk\n");
 

Anyway, looks good to me.