From e262ca7391fc34e0d36791a333492e4ef509ba27 Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Sun, 1 Feb 2026 17:58:25 +0900 Subject: [PATCH 1/4] util: fix argconfig_match_val() to check option value length Currently get/set-feature feature-id "fdp" option value is not parsed. Handled as ambiguous by the multiple matches with the "fdp-events" option. Fixes: 1b3ba5de38ef ("util: reduce complexity of argconfig_parse_val()") Signed-off-by: Tokunori Ikegami --- util/argconfig.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/argconfig.c b/util/argconfig.c index 34607202ae..1fabfed4b9 100644 --- a/util/argconfig.c +++ b/util/argconfig.c @@ -263,6 +263,9 @@ argconfig_match_val(struct argconfig_opt_val *v, const char *str) if (strncasecmp(str, v->str, len)) continue; + if (len == strlen(v->str)) + return v; + if (match) return NULL; /* multiple matches; input is ambiguous */ From 86be4e05c320ff5bbeb992e456060b8a8eef10f9 Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Sun, 1 Feb 2026 20:17:50 +0900 Subject: [PATCH 2/4] nvme: add fw-commit command ca option values Allow to set the ca definition names instead of the values. Signed-off-by: Tokunori Ikegami --- completions/_nvme | 10 ++++++++++ completions/bash-nvme-completion.sh | 7 +++++++ nvme.c | 16 +++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/completions/_nvme b/completions/_nvme index a0ddbfc71b..9ee30d421d 100644 --- a/completions/_nvme +++ b/completions/_nvme @@ -732,6 +732,16 @@ _nvme () { ;; esac ;; + (fw-commit) + case ${words[CURRENT-1]} in + (--action=|-a) + _values '' 'replace' 'replace-and-activate' 'set-active' 'replace-and-activate-immediate' 'replace-boot-partition' 'activate-boot-partition' + ;; + (*) + _files + ;; + esac + ;; (*) _files ;; diff --git a/completions/bash-nvme-completion.sh b/completions/bash-nvme-completion.sh index 043fe47df4..b96b4c0e88 100644 --- a/completions/bash-nvme-completion.sh +++ b/completions/bash-nvme-completion.sh @@ -231,6 +231,13 @@ nvme_list_opts () { ;; "fw-commit") opts+=" --slot= -s --action= -a --bpid= -b --timeout= -t" + case $opt in + --action|-a) + vals+=" replace replace-and-activate set-active \ + replace-and-activate-immediate + replace-boot-partition activate-boot-partition" + ;; + esac ;; "fw-download") opts+=" --fw= -f --xfer= -x --offset= -O --timeout= -t" diff --git a/nvme.c b/nvme.c index 4331db36a1..65a7e5ad83 100644 --- a/nvme.c +++ b/nvme.c @@ -5290,9 +5290,23 @@ static int fw_commit(int argc, char **argv, struct command *acmd, struct plugin .bpid = 0, }; + OPT_VALS(ca) = { + VAL_BYTE("replace", NVME_FW_COMMIT_CA_REPLACE), + VAL_BYTE("replace-and-activate", + NVME_FW_COMMIT_CA_REPLACE_AND_ACTIVATE), + VAL_BYTE("set-active", NVME_FW_COMMIT_CA_SET_ACTIVE), + VAL_BYTE("replace-and-activate-immediate", + NVME_FW_COMMIT_CA_REPLACE_AND_ACTIVATE_IMMEDIATE), + VAL_BYTE("replace-boot-partition", + NVME_FW_COMMIT_CA_REPLACE_BOOT_PARTITION), + VAL_BYTE("activate-boot-partition", + NVME_FW_COMMIT_CA_ACTIVATE_BOOT_PARTITION), + VAL_END() + }; + NVME_ARGS(opts, OPT_BYTE("slot", 's', &cfg.slot, slot), - OPT_BYTE("action", 'a', &cfg.action, action), + OPT_BYTE("action", 'a', &cfg.action, action, ca), OPT_BYTE("bpid", 'b', &cfg.bpid, bpid)); err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); From 0632a18b7be7e75b743a5af59f652792073ac1fb Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Sun, 1 Feb 2026 20:24:40 +0900 Subject: [PATCH 3/4] nvme: check fw-commit command ca value with definition Use the definition values instead of the hard coded values. Signed-off-by: Tokunori Ikegami --- nvme.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nvme.c b/nvme.c index 65a7e5ad83..bc82359e91 100644 --- a/nvme.c +++ b/nvme.c @@ -5323,10 +5323,19 @@ static int fw_commit(int argc, char **argv, struct command *acmd, struct plugin nvme_show_error("invalid slot:%d", cfg.slot); return -EINVAL; } - if (cfg.action > 7 || cfg.action == 4 || cfg.action == 5) { + + switch (cfg.action) { + case NVME_FW_COMMIT_CA_REPLACE: + case NVME_FW_COMMIT_CA_REPLACE_AND_ACTIVATE: + case NVME_FW_COMMIT_CA_SET_ACTIVE: + case NVME_FW_COMMIT_CA_REPLACE_BOOT_PARTITION: + case NVME_FW_COMMIT_CA_ACTIVATE_BOOT_PARTITION: + break; + default: nvme_show_error("invalid action:%d", cfg.action); return -EINVAL; } + if (cfg.bpid > 1) { nvme_show_error("invalid boot partition id:%d", cfg.bpid); return -EINVAL; From d91e40a4a2c6c4fa7cfc74147836143a04e4f0d1 Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Wed, 11 Feb 2026 01:30:14 +0900 Subject: [PATCH 4/4] nvme, doc: update fw-commit action help message and documentation Add the ca definition names description for the values. Signed-off-by: Tokunori Ikegami --- Documentation/nvme-fw-commit.txt | 24 +++++++++++++----------- nvme.c | 6 +++++- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Documentation/nvme-fw-commit.txt b/Documentation/nvme-fw-commit.txt index 89f551d740..3dc35419a4 100644 --- a/Documentation/nvme-fw-commit.txt +++ b/Documentation/nvme-fw-commit.txt @@ -51,18 +51,20 @@ OPTIONS [] |================= |Value|Definition -|0|Downloaded image replaces the image indicated by the Firmware Slot -field. This image is not activated. -|1|Downloaded image replaces the image indicated by the Firmware Slot -field. This image is activated at the next reset. -|2|The image indicated by the Firmware Slot field is activated at the +|0 \| 'replace'| Downloaded image replaces the image indicated by the +Firmware Slot field. This image is not activated. +|1 \| 'replace-and-activate'| Downloaded image replaces the image +indicated by the Firmware Slot field. This image is activated at the next reset. -|3|The image specified by the Firmware Slot field is requested to be -activated immediately without reset. -|6|Downloaded image replaces the Boot Partition specified by the Boot Partition -ID field. -|7|Mark the Boot Partition specified in the BPID field as active and update -BPINFO.ABPID. +|2 \| 'set-active'| The image indicated by the Firmware Slot field is +activated at the next reset. +|3 \| 'replace-and-activate-immediate'| The image specified by the +Firmware Slot field is requested to be activated immediately without +reset. +|6 \| 'replace-boot-partition'| Downloaded image replaces the Boot +Partition specified by the Boot Partition ID field. +|7 \| 'activate-boot-partition'| Mark the Boot Partition specified in +the BPID field as active and update BPINFO.ABPID. |================= -s :: diff --git a/nvme.c b/nvme.c index bc82359e91..d40d97f9a3 100644 --- a/nvme.c +++ b/nvme.c @@ -5269,7 +5269,11 @@ static int fw_commit(int argc, char **argv, struct command *acmd, struct plugin "with an 'echo 1 > /sys/class/nvme/nvmeX/reset_controller'. " "Ensure nvmeX is the device you just activated before reset."; const char *slot = "[0-7]: firmware slot for commit action"; - const char *action = "[0-7]: commit action"; + const char *action = "[0-7]: commit action: 0 = replace, " + "1 = replace and activate, 2 = set active, " + "3 = replace and activate immediate, " + "6 = replace boot partition, " + "7 = activate boot partition"; const char *bpid = "[0,1]: boot partition identifier, if applicable (default: 0)"; _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;