From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6683C433EF for ; Wed, 29 Sep 2021 03:17:34 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED155613CF for ; Wed, 29 Sep 2021 03:17:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org ED155613CF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3680A8281E; Wed, 29 Sep 2021 05:17:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="iRkCQFAv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AFE4682E67; Wed, 29 Sep 2021 05:17:29 +0200 (CEST) Received: from mail-yb1-xb32.google.com (mail-yb1-xb32.google.com [IPv6:2607:f8b0:4864:20::b32]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 97C0182314 for ; Wed, 29 Sep 2021 05:17:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bmeng.cn@gmail.com Received: by mail-yb1-xb32.google.com with SMTP id v195so1769261ybb.0 for ; Tue, 28 Sep 2021 20:17:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NdAFnP1KVA9MNwFxrCm6ekCD6rVnRaIA3PHr0igL9Is=; b=iRkCQFAvgwocz6mG0ywURXHloxE6HI7abRqX2DZnhJaRSzWJS68z57qA6+M9UKHI0Y MXB3yJcazVjZL7Nt7mJi8g4rJBgRPxe6knzLFCN5pWWZ+ZTtCU1QRH3PogsLP3uW0lyL a9EO6Wz7q2WlOia0C4HKtelK9Rr2X4y6RF2FDkkbGe0D/vk2xRQb4W5zFoMOiM8Ikx/D 2zZmjG6HBfynjMM9CzyM3LZNpUBq2Axnx6x2fEEeD2fWmSXRI49STpbDJGUF5hfr06WW dbaOi4s7zGJMMUmTfWlvr3likz6UmpmZ9CGjipVeSLG7Cv6pUPR7Ez9FmLolyNvGh/M+ tGxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NdAFnP1KVA9MNwFxrCm6ekCD6rVnRaIA3PHr0igL9Is=; b=MjoDRTuV8z+H6pQe8/CV78x2eWKGzmYVhL41YJJ59JuDVeBGIyeUVB0eoURd7kIkdt EnsTx5zWN6MLuvYH8WTZ6SL+okUKCx1JfwWxbSfnc0SaghRKwpfO2jjnmVGIaija6c3s S0PSrjGlQ32gUqL+WxedIgzepw6yenCvd3vrx9goyIBQvfWo6PglkBLh1Az3Osis/j20 Z67wkuJGoRxdVvCwtcCP+9LfpfenOs/7wE0ExFRa7AxQOiUHrpUAnyubxa/Yl46n7ZIt vBagCM4UrNzItRGWZeB1XoupYxE5ZRaB1jZPHZSst0q5qgxwV4o9p63LXMmNxEucAN4F +faQ== X-Gm-Message-State: AOAM530DTt0NC+XW/7Q6Rjcgq1Ln4GKfGQsF2UKMjy8WxqpSnTC7Pnoj kf4z0Jt0uPZPoUVMzyFfqAQ42VGxkDQMAWDzjJ29nqcbocg= X-Google-Smtp-Source: ABdhPJxjrAOFqAKvAm++kHphgY+A5tINgwVo46ilKg9POtugqerXtKuWC0WZgnZLzjCHe087gBy8lS1eEKBm9fFcw3M= X-Received: by 2002:a25:6c1:: with SMTP id 184mr9968831ybg.453.1632885445270; Tue, 28 Sep 2021 20:17:25 -0700 (PDT) MIME-Version: 1.0 References: <20210927212225.v2.1.Ic581ec99f46b6dfa2e0b1922e670a333ac859e82@changeid> In-Reply-To: <20210927212225.v2.1.Ic581ec99f46b6dfa2e0b1922e670a333ac859e82@changeid> From: Bin Meng Date: Wed, 29 Sep 2021 11:17:17 +0800 Message-ID: Subject: Re: [PATCH v2 1/2] nvme: Enable FUA To: Jon Lin Cc: U-Boot Mailing List , zyf@rock-chips.com, Kever Yang , Lin Shawn , xxm@rock-chips.com Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On Mon, Sep 27, 2021 at 9:22 PM Jon Lin 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 > Reviewed-by: Stefan Agner > --- > > (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