[PATCH v2 1/2] nvme: Enable FUA

Bin Meng bmeng.cn at gmail.com
Wed Sep 29 05:17:17 CEST 2021


On Mon, Sep 27, 2021 at 9:22 PM Jon Lin <jon.lin at rock-chips.com> wrote:
>
> Most NVME devcies maintain data in internal cache for an uncertain

typo: devices

> times, and u-boot has no method to force NVME to flush cache.
> So this patch adds FUA to avoid data loss caused by power off after data
> programming.
>
> Signed-off-by: Jon Lin <jon.lin at rock-chips.com>
> Reviewed-by: Stefan Agner <stefan at agner.ch>
> ---
>
> (no changes since v1)
>
>  drivers/nvme/nvme.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
> index f6465ea7f4..5d05cb6e9e 100644
> --- a/drivers/nvme/nvme.c
> +++ b/drivers/nvme/nvme.c
> @@ -761,6 +761,9 @@ static ulong nvme_blk_rw(struct udevice *udev, lbaint_t blknr,
>         c.rw.appmask = 0;
>         c.rw.metadata = 0;
>
> +       /* Always enable FUA for data integrity */
> +       c.rw.control |= NVME_RW_FUA;

I don't think we should blindly enable FUA, instead we should check
whether the Volatile Write Cache is enabled or not, and if enabled,
set FUA, or just completely disable Volatile Write Cache.

> +
>         while (total_lbas) {
>                 if (total_lbas < lbas) {
>                         lbas = (u16)total_lbas;
> --

Regards,
Bin


More information about the U-Boot mailing list