Re: [PATCH v3] nvme: update firmware version after commit

From: Daniel Wagner
Date: Fri Nov 03 2023 - 08:09:31 EST


On Tue, Oct 31, 2023 at 10:08:53AM -0600, Keith Busch wrote:
> On Mon, Oct 30, 2023 at 05:00:44PM +0100, Daniel Wagner wrote:
> > 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.
> >
> > Reported-by: Kenji Tomonaga <tkenbo@xxxxxxxxx>
> > Signed-off-by: Daniel Wagner <dwagner@xxxxxxx>
>
> Thanks, applied for nvme-6.7.

I've got negative feedback from one of our customer. I've annotate the
code with

dev_info(ctrl->device, "afi: %#x\n", log->afi);
for (i = 0; i < 7; i++) {
dev_info(ctrl->device, "frs%d: %.*s\n", i + 1,
nvme_strlen((char *)&log->frs[i], sizeof(ctrl->subsys->firmware_rev)),
(char *)&log->frs[i]);
}


[ 124.824812] nvme nvme8: afi: 0x3
[ 124.824824] nvme nvme8: frs1: 0.4.0
[ 124.824828] nvme nvme8: frs2: 0.3.0
[ 124.824832] nvme nvme8: frs3: 0.4.0
[ 124.824835] nvme nvme8: frs4:
[ 124.824837] nvme nvme8: frs5:
[ 124.824840] nvme nvme8: frs6:
[ 124.824842] nvme nvme8: frs7:


This particular firmware seem to interpret afi one based, while
the this patch assumes it is zero based


memcpy(ctrl->subsys->firmware_rev, &log->frs[log->afi & 0x7],
sizeof(ctrl->subsys->firmware_rev));


The spec says


Active Firmware Info (AFI): Specifies information about the active
firmware revision.

Bit 7 is reserved.
Bits 6:4 indicates the firmware slot that is going to be activated
at the next Controller Level Reset. If this field is 0h,
then the controller does not indicate the firmware slot that
is going to be activated at the next Controller Level Reset.
Bit 3 is reserved.
Bits 2:0 indicates the firmware slot from which the actively running
firmware revision was loaded.


It's not clear to me if afi bits 2:0 is zero or one based. Bits 6:4
indicate to be 1 based.

Any ideas how to handle this?

Thanks,
Daniel