From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com []) by mx.groups.io with SMTP id smtpd.web11.1997.1582337513724814393 for ; Fri, 21 Feb 2020 18:11:54 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: christopher.j.zurcher@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Feb 2020 18:11:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,470,1574150400"; d="scan'208";a="270202773" Received: from cjzurch-desk.amr.corp.intel.com ([10.9.70.181]) by fmsmga002.fm.intel.com with ESMTP; 21 Feb 2020 18:11:53 -0800 From: "Zurcher, Christopher J" To: devel@edk2.groups.io Cc: Michael D Kinney , Jian J Wang , Liming Gao Subject: [PATCH 1/1] MdePkg/UefiScsiLib: Set FUA bit for synchronous SCSI Write operations Date: Fri, 21 Feb 2020 18:11:52 -0800 Message-Id: <20200222021152.23016-2-christopher.j.zurcher@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20200222021152.23016-1-christopher.j.zurcher@intel.com> References: <20200222021152.23016-1-christopher.j.zurcher@intel.com> The FUA (Force Unit Access) bit forces data to be written directly to disk instead of the write cache. This prevents data from being lost if a shutdown or reset is requested immediately after a SCSI write operation. Cc: Michael D Kinney Cc: Jian J Wang Cc: Liming Gao Signed-off-by: Christopher J Zurcher --- MdePkg/Library/UefiScsiLib/UefiScsiLib.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/MdePkg/Library/UefiScsiLib/UefiScsiLib.c b/MdePkg/Library/UefiScsiLib/UefiScsiLib.c index 13a2a1912c..cf78f131bd 100644 --- a/MdePkg/Library/UefiScsiLib/UefiScsiLib.c +++ b/MdePkg/Library/UefiScsiLib/UefiScsiLib.c @@ -1,7 +1,7 @@ /** @file UEFI SCSI Library implementation - Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -1055,15 +1055,16 @@ ScsiWrite10Command ( ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET)); ZeroMem (Cdb, EFI_SCSI_OP_LENGTH_TEN); - CommandPacket.Timeout = Timeout; - CommandPacket.OutDataBuffer = DataBuffer; - CommandPacket.SenseData = SenseData; - CommandPacket.OutTransferLength= *DataLength; - CommandPacket.Cdb = Cdb; + CommandPacket.Timeout = Timeout; + CommandPacket.OutDataBuffer = DataBuffer; + CommandPacket.SenseData = SenseData; + CommandPacket.OutTransferLength = *DataLength; + CommandPacket.Cdb = Cdb; // // Fill Cdb for Write (10) Command // Cdb[0] = EFI_SCSI_OP_WRITE10; + Cdb[1] = BIT3; //FUA bit (Force Unit Access) WriteUnaligned32 ((UINT32 *)&Cdb[2], SwapBytes32 (StartLba)); WriteUnaligned16 ((UINT16 *)&Cdb[7], SwapBytes16 ((UINT16) SectorSize)); @@ -1263,6 +1264,7 @@ ScsiWrite16Command ( // Fill Cdb for Write (16) Command // Cdb[0] = EFI_SCSI_OP_WRITE16; + Cdb[1] = BIT3; //FUA bit (Force Unit Access) WriteUnaligned64 ((UINT64 *)&Cdb[2], SwapBytes64 (StartLba)); WriteUnaligned32 ((UINT32 *)&Cdb[10], SwapBytes32 (SectorSize)); -- 2.16.2.windows.1