nvme: update firmware version after commit
PATCH 1/1 nvme: update firmware version after commit
The firmware version sysfs entry needs to be updated after a successfully firmware activation.
nvme-cli stopped issuing an Identify Controller command to list the current firmware information and relies on sysfs showing the current firmware version.
--- drivers/nvme/host/core.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/nvme/host/core.c +15 -0
@@ -4079,6 +4079,20 @@ static void nvme_get_fw_slot_info(struct nvme_ctrl *ctrl)kfree (log); } +static void nvme_update_firmware_rev (struct nvme_ctrl *ctrl) +{ +struct nvme_id_ctrl *id; +int ret; + + ret =nvme_identify_ctrl (ctrl, &id); +if (ret) { +dev_warn (ctrl->device,"Identify Controller failed (%d)\n" , ret); +return ; + } +memcpy (ctrl->subsys->firmware_rev, id->fr, +sizeof (ctrl->subsys->firmware_rev)); +} +static void nvme_fw_act_work (struct work_struct *work) { struct nvme_ctrl *ctrl = container_of(work,
@@ -4109,6 +4123,7 @@ static void nvme_fw_act_work(struct work_struct *work)nvme_unquiesce_io_queues (ctrl);/* read FW slot information to clear the AER */ nvme_get_fw_slot_info (ctrl); +nvme_update_firmware_rev (ctrl);queue_work (nvme_wq, &ctrl->async_event_work); }
Signature · 1 line
2.42.0
Quoted 17 lines · Daniel Wagner
The firmware version sysfs entry needs to be updated after a successfully firmware activation.
nvme-cli stopped issuing an Identify Controller command to list the current firmware information and relies on sysfs showing the current firmware version.
Signed-off-by Daniel Wagner <[email protected]>--- drivers/nvme/host/core.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)drivers/nvme/host/core.c +0
-0
drivers/nvme/host/core.c static void nvme_get_fw_slot_info(struct nvme_ctrl *ctrl) · line 4087
Quoted 9 lines
drivers/nvme/host/core.c +6
-0@@ -4079,6 +4079,20 @@ static void nvme_get_fw_slot_info(struct nvme_ctrl *ctrl)kfree (log); } +static void nvme_update_firmware_rev (struct nvme_ctrl *ctrl) +{ +struct nvme_id_ctrl *id; +int ret; + + ret =nvme_identify_ctrl (ctrl, &id);
Hello Daniel,
I understand that nvme_fw_act_work() is called when receiving a NVME_AER_NOTICE_FW_ACT_STARTING AEN.
This AEN is received when a Firmware Activate command was issued with value 0x3 "The image specified by the Firmware Slot field is requested to be activated immediately without reset."
However, when upgrading firmware (even without a reset), can't more things other than FW version change?
Sure, I understand that there is no need to do a reset (as in the cases there the firmware deems that a reset is needed to do the FW activation without reset, the Firmware Activate command with value 0x3 returns a failure), but it just seems like more fields than FW version needs to be re-read.
Theoretically, can't a FW upgrade go from NVMe 1.4 to NVMe 2.0, and that firmware can return success for the Firmware Activate command with value 0x3?
Kind regards,
Niklas
Keith Busch
maintainerQuoted 3 lines · Niklas Cassel
However, when upgrading firmware (even without a reset), can't more things other than FW version change?
New firmware can change all sorts of things, but I think firmware_rev is the only exported sysfs attribute we expect to change. Other attributes, like model, serial and unique id's, should be stable across these types of firmware upgrades. I don't think "activation without reset" can be used for firmware upgrades that change fundamental ways the device operates.
Keith Busch
maintainerQuoted 18 lines · Daniel Wagner
drivers/nvme/host/core.c +14
-0+static void nvme_update_firmware_rev (struct nvme_ctrl *ctrl) +{ +struct nvme_id_ctrl *id; +int ret; + + ret =nvme_identify_ctrl (ctrl, &id); +if (ret) { +dev_warn (ctrl->device,"Identify Controller failed (%d)\n" , ret); +return ; + } +memcpy (ctrl->subsys->firmware_rev, id->fr, +sizeof (ctrl->subsys->firmware_rev)); +} +static void nvme_fw_act_work (struct work_struct *work) { struct nvme_ctrl *ctrl = container_of(work,
drivers/nvme/host/core.c static void nvme_fw_act_work(struct work_struct *work) · line 4126
Quoted 4 lines
drivers/nvme/host/core.c +1
-0@@ -4109,6 +4123,7 @@ static void nvme_fw_act_work(struct work_struct *work)nvme_unquiesce_io_queues (ctrl);/* read FW slot information to clear the AER */ nvme_get_fw_slot_info (ctrl); +nvme_update_firmware_rev (ctrl);
The "fw_slot_info()" call also gets the firmware version, so no need to do it a different way. Just add the memcpy to that function instead of introducing a new one.