On 5/28/26 03:20, [email protected] wrote:
From: Denis Mukhin <[email protected]>

Introduce `nvme flush` to allow users to commit all dirty data explicitly
to the current NVMe device.

This adds flush for all blk devices, please rewrite
the commit subject, message and update all blk commands
and not only nvme.


Signed-off-by: Denis Mukhin <[email protected]>
---
  cmd/blk_common.c | 14 ++++++++++++++
  cmd/nvme.c       |  1 +
  2 files changed, 15 insertions(+)

diff --git a/cmd/blk_common.c b/cmd/blk_common.c
index 56529702a470..d3b00e10f17c 100644
--- a/cmd/blk_common.c
+++ b/cmd/blk_common.c
@@ -37,6 +37,20 @@ int blk_common_cmd(int argc, char *const argv[], enum 
uclass_id uclass_id,
                                printf("\nno %s partition table available\n",
                                       if_name);
                        return CMD_RET_SUCCESS;
+               } else if (strncmp(argv[1], "flush", 5) == 0) {
+                       struct blk_desc *desc;
+                       int ret;
+
+                       ret = blk_get_desc(uclass_id, *cur_devnump, &desc);
+                       if (ret)
+                               return CMD_RET_FAILURE;
+
+                       if (blk_dflush(desc)) {
+                               printf("\nfailed to flush device %s\n", 
if_name);
+                               return CMD_RET_FAILURE;
+                       }
+
+                       return CMD_RET_SUCCESS;
                }
                return CMD_RET_USAGE;
        case 3:
diff --git a/cmd/nvme.c b/cmd/nvme.c
index f2c9acba5c32..21ac9a6fac7a 100644
--- a/cmd/nvme.c
+++ b/cmd/nvme.c
@@ -46,6 +46,7 @@ U_BOOT_CMD(
        "NVM Express sub-system",
        "scan - scan NVMe devices\n"
        "nvme detail - show details of current NVMe device\n"
+       "nvme flush - commit all dirty data to the current NVMe device\n"
        "nvme info - show all available NVMe devices\n"
        "nvme device [dev] - show or set current NVMe device\n"
        "nvme part [dev] - print partition table of one or all NVMe devices\n"

Reply via email to