Page MenuHomeFreeBSD

nvmecontrol: Fix condition when print number of Firmware Slots and Firmware Slot1 Readonly.
ClosedPublic

Authored by wanpengqian_gmail.com on Mar 29 2022, 2:27 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Mar 22, 9:42 PM
Unknown Object (File)
Fri, Mar 22, 9:41 PM
Unknown Object (File)
Fri, Mar 22, 9:41 PM
Unknown Object (File)
Fri, Mar 22, 9:41 PM
Unknown Object (File)
Fri, Mar 22, 9:41 PM
Unknown Object (File)
Fri, Mar 8, 10:59 AM
Unknown Object (File)
Feb 26 2024, 11:30 PM
Unknown Object (File)
Jan 5 2024, 8:25 AM
Subscribers

Details

Summary

When print Number of Firmware Slots and Firmware Slot1 Readonly,
The condition is fw_num_slots != 0 instead of fw != 0 (the controller supports the Firmware Commit and Firmware
Image Download commands.)

ref: D32659

Signed-off-by: Wanpeng Qian <wanpengqian@gmail.com>

Test Plan

Within bhyve virtual machine, fire a nvmecontrol identify nvme0
to check the output.

before

Number of Firmware Slots:    N/A
Firmware Slot 1 Read-Only:   N/A

after

Number of Firmware Slots:    1
Firmware Slot 1 Read-Only:   Yes

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Since D32659 is committed. Can we give a go for this? @imp

This revision is now accepted and ready to land.Nov 10 2022, 7:16 AM

The existing code isn't quite right, but I'm not quite sure what to do here. The number of firmware slots should not ever be zero (i.e., "This field shall specify a value from one to seven"), and my guess is, for most drives, this condition will always be true. Perhaps removing the check and unconditionally printing the slot count and RO status makes more sense as the field description (e.g., "Number of Firmware Slots") are always present.

This revision now requires review to proceed.Nov 11 2022, 4:19 AM

I think Chuck is right. output fw_num_slots unconditionally, but for Firmware Slot 1 Read-Only, we have to make sure the fw_num_slots is bigger than zero. othersize it is meaningless. Although the NVMe controller should at least have one firmware slot.

I think Chuck is right. output fw_num_slots unconditionally, but for Firmware Slot 1 Read-Only, we have to make sure the fw_num_slots is bigger than zero. othersize it is meaningless. Although the NVMe controller should at least have one firmware slot.

I agree with chuck. fw_num_slots can't be zero. If it's zero, your controller will be broken and you can't rely on any of these values. So, I think it makes no sense to keep the if.

I agree with chuck. fw_num_slots can't be zero. If it's zero, your controller will be broken and you can't rely on any of these values. So, I think it makes no sense to keep the if.

alright, here it is.

This revision is now accepted and ready to land.Nov 11 2022, 7:31 PM