* [PATCH v2 0/1] UefiScsiLib: Set FUA bit for synchronous SCSI Write operations @ 2020-03-26 7:34 Zurcher, Christopher J 2020-03-26 7:34 ` [PATCH v2 1/1] MdePkg/UefiScsiLib: " Zurcher, Christopher J 0 siblings, 1 reply; 6+ messages in thread From: Zurcher, Christopher J @ 2020-03-26 7:34 UTC (permalink / raw) To: devel; +Cc: Michael D Kinney, Jian J Wang, Liming Gao, Zhiguang Liu V2 changes: Add bit defines for cache control parameters from SBC-2. Some SCSI devices have very aggressive write caching implemented, causing data to be lost if the system is shut down or rebooted soon after receiving a successful write confirmation from the device. By setting the FUA bit in the synchronous versions of the Write10/Write16 commands, the write cache is skipped and data is forced directly to the disk. The Asynchronous (WriteEx) commands will not have this bit set, allowing performance-sensitive transactions to continue utilizing the write cache. An alternative, more complicated solution would be to implement the SYNCHRONIZE CACHE command and call it from ScsiDiskFlushBlocks, which currently returns EFI_SUCCESS without flushing anything. Since the SYNCHRONIZE CACHE command requires the caller to provide the specific blocks to flush, and the BlockIO FlushBlocks function does not accept any arguments, this would require keeping track of the write history inside the ScsiDiskDxe driver. I have not tested the asynchronous commands for this issue, so there is a chance that resetting the system even after a call to FlushBlocksEx might still result in lost data. Currently the ScsiDiskFlushBlocksEx command waits for the BlockIo2 requests queue to empty, but does not ask the device itself to flush anything. (EFI_SCSI_OP_SYNC_CACHE is defined in IndustryStandard/Scsi.h but is not implemented anywhere.) Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Zhiguang Liu <zhiguang.liu@intel.com> Christopher J Zurcher (1): MdePkg/UefiScsiLib: Set FUA bit for synchronous SCSI Write operations MdePkg/Include/IndustryStandard/Scsi.h | 8 +++++++- MdePkg/Library/UefiScsiLib/UefiScsiLib.c | 14 ++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) -- 2.16.2.windows.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/1] MdePkg/UefiScsiLib: Set FUA bit for synchronous SCSI Write operations 2020-03-26 7:34 [PATCH v2 0/1] UefiScsiLib: Set FUA bit for synchronous SCSI Write operations Zurcher, Christopher J @ 2020-03-26 7:34 ` Zurcher, Christopher J 2020-03-30 1:52 ` Zhiguang Liu 0 siblings, 1 reply; 6+ messages in thread From: Zurcher, Christopher J @ 2020-03-26 7:34 UTC (permalink / raw) To: devel; +Cc: Michael D Kinney, Jian J Wang, Liming Gao, Zhiguang Liu 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 <michael.d.kinney@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Zhiguang Liu <zhiguang.liu@intel.com> Signed-off-by: Christopher J Zurcher <christopher.j.zurcher@intel.com> --- MdePkg/Include/IndustryStandard/Scsi.h | 8 +++++++- MdePkg/Library/UefiScsiLib/UefiScsiLib.c | 14 ++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/MdePkg/Include/IndustryStandard/Scsi.h b/MdePkg/Include/IndustryStandard/Scsi.h index 3e966520a1..64b9918b82 100644 --- a/MdePkg/Include/IndustryStandard/Scsi.h +++ b/MdePkg/Include/IndustryStandard/Scsi.h @@ -1,7 +1,7 @@ /** @file Support for SCSI-2 standard - Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR> + Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -175,6 +175,12 @@ #define EFI_SCSI_DATA_IN 0 #define EFI_SCSI_DATA_OUT 1 +// +// SCSI Block Command Cache Control Parameters +// +#define EFI_SCSI_BLOCK_FUA BIT3 ///< Force Unit Access +#define EFI_SCSI_BLOCK_DPO BIT4 ///< Disable Page Out + // // Peripheral Device Type Definitions // diff --git a/MdePkg/Library/UefiScsiLib/UefiScsiLib.c b/MdePkg/Library/UefiScsiLib/UefiScsiLib.c index 13a2a1912c..512bec500c 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.<BR> + Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR> 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] = EFI_SCSI_BLOCK_FUA; 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] = EFI_SCSI_BLOCK_FUA; WriteUnaligned64 ((UINT64 *)&Cdb[2], SwapBytes64 (StartLba)); WriteUnaligned32 ((UINT32 *)&Cdb[10], SwapBytes32 (SectorSize)); -- 2.16.2.windows.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/1] MdePkg/UefiScsiLib: Set FUA bit for synchronous SCSI Write operations 2020-03-26 7:34 ` [PATCH v2 1/1] MdePkg/UefiScsiLib: " Zurcher, Christopher J @ 2020-03-30 1:52 ` Zhiguang Liu 2020-03-30 13:51 ` Liming Gao 0 siblings, 1 reply; 6+ messages in thread From: Zhiguang Liu @ 2020-03-30 1:52 UTC (permalink / raw) To: Zurcher, Christopher J, devel@edk2.groups.io Cc: Kinney, Michael D, Wang, Jian J, Gao, Liming Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com> > -----Original Message----- > From: Zurcher, Christopher J > Sent: Thursday, March 26, 2020 3:34 PM > To: devel@edk2.groups.io > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Wang, Jian J > <jian.j.wang@intel.com>; Gao, Liming <liming.gao@intel.com>; Liu, Zhiguang > <zhiguang.liu@intel.com> > Subject: [PATCH v2 1/1] MdePkg/UefiScsiLib: Set FUA bit for synchronous > SCSI Write operations > > 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 <michael.d.kinney@intel.com> > Cc: Jian J Wang <jian.j.wang@intel.com> > Cc: Liming Gao <liming.gao@intel.com> > Cc: Zhiguang Liu <zhiguang.liu@intel.com> > Signed-off-by: Christopher J Zurcher <christopher.j.zurcher@intel.com> > --- > MdePkg/Include/IndustryStandard/Scsi.h | 8 +++++++- > MdePkg/Library/UefiScsiLib/UefiScsiLib.c | 14 ++++++++------ > 2 files changed, 15 insertions(+), 7 deletions(-) > > diff --git a/MdePkg/Include/IndustryStandard/Scsi.h > b/MdePkg/Include/IndustryStandard/Scsi.h > index 3e966520a1..64b9918b82 100644 > --- a/MdePkg/Include/IndustryStandard/Scsi.h > +++ b/MdePkg/Include/IndustryStandard/Scsi.h > @@ -1,7 +1,7 @@ > /** @file > Support for SCSI-2 standard > > - Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR> > + Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR> > SPDX-License-Identifier: BSD-2-Clause-Patent > > **/ > @@ -175,6 +175,12 @@ > #define EFI_SCSI_DATA_IN 0 > #define EFI_SCSI_DATA_OUT 1 > > +// > +// SCSI Block Command Cache Control Parameters > +// > +#define EFI_SCSI_BLOCK_FUA BIT3 ///< Force Unit Access > +#define EFI_SCSI_BLOCK_DPO BIT4 ///< Disable Page Out > + > // > // Peripheral Device Type Definitions > // > diff --git a/MdePkg/Library/UefiScsiLib/UefiScsiLib.c > b/MdePkg/Library/UefiScsiLib/UefiScsiLib.c > index 13a2a1912c..512bec500c 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.<BR> > + Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR> > 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] = EFI_SCSI_BLOCK_FUA; > 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] = EFI_SCSI_BLOCK_FUA; > WriteUnaligned64 ((UINT64 *)&Cdb[2], SwapBytes64 (StartLba)); > WriteUnaligned32 ((UINT32 *)&Cdb[10], SwapBytes32 (SectorSize)); > > -- > 2.16.2.windows.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/1] MdePkg/UefiScsiLib: Set FUA bit for synchronous SCSI Write operations 2020-03-30 1:52 ` Zhiguang Liu @ 2020-03-30 13:51 ` Liming Gao 2020-03-30 20:34 ` Zurcher, Christopher J 0 siblings, 1 reply; 6+ messages in thread From: Liming Gao @ 2020-03-30 13:51 UTC (permalink / raw) To: Liu, Zhiguang, Zurcher, Christopher J, devel@edk2.groups.io Cc: Kinney, Michael D, Wang, Jian J Zurcher: What functionality test has been done for this test? Thanks Liming > -----Original Message----- > From: Liu, Zhiguang <zhiguang.liu@intel.com> > Sent: Monday, March 30, 2020 9:52 AM > To: Zurcher, Christopher J <christopher.j.zurcher@intel.com>; devel@edk2.groups.io > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Gao, Liming <liming.gao@intel.com> > Subject: RE: [PATCH v2 1/1] MdePkg/UefiScsiLib: Set FUA bit for synchronous SCSI Write operations > > Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com> > > > -----Original Message----- > > From: Zurcher, Christopher J > > Sent: Thursday, March 26, 2020 3:34 PM > > To: devel@edk2.groups.io > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Wang, Jian J > > <jian.j.wang@intel.com>; Gao, Liming <liming.gao@intel.com>; Liu, Zhiguang > > <zhiguang.liu@intel.com> > > Subject: [PATCH v2 1/1] MdePkg/UefiScsiLib: Set FUA bit for synchronous > > SCSI Write operations > > > > 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 <michael.d.kinney@intel.com> > > Cc: Jian J Wang <jian.j.wang@intel.com> > > Cc: Liming Gao <liming.gao@intel.com> > > Cc: Zhiguang Liu <zhiguang.liu@intel.com> > > Signed-off-by: Christopher J Zurcher <christopher.j.zurcher@intel.com> > > --- > > MdePkg/Include/IndustryStandard/Scsi.h | 8 +++++++- > > MdePkg/Library/UefiScsiLib/UefiScsiLib.c | 14 ++++++++------ > > 2 files changed, 15 insertions(+), 7 deletions(-) > > > > diff --git a/MdePkg/Include/IndustryStandard/Scsi.h > > b/MdePkg/Include/IndustryStandard/Scsi.h > > index 3e966520a1..64b9918b82 100644 > > --- a/MdePkg/Include/IndustryStandard/Scsi.h > > +++ b/MdePkg/Include/IndustryStandard/Scsi.h > > @@ -1,7 +1,7 @@ > > /** @file > > Support for SCSI-2 standard > > > > - Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR> > > + Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR> > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > **/ > > @@ -175,6 +175,12 @@ > > #define EFI_SCSI_DATA_IN 0 > > #define EFI_SCSI_DATA_OUT 1 > > > > +// > > +// SCSI Block Command Cache Control Parameters > > +// > > +#define EFI_SCSI_BLOCK_FUA BIT3 ///< Force Unit Access > > +#define EFI_SCSI_BLOCK_DPO BIT4 ///< Disable Page Out > > + > > // > > // Peripheral Device Type Definitions > > // > > diff --git a/MdePkg/Library/UefiScsiLib/UefiScsiLib.c > > b/MdePkg/Library/UefiScsiLib/UefiScsiLib.c > > index 13a2a1912c..512bec500c 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.<BR> > > + Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR> > > 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] = EFI_SCSI_BLOCK_FUA; > > 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] = EFI_SCSI_BLOCK_FUA; > > WriteUnaligned64 ((UINT64 *)&Cdb[2], SwapBytes64 (StartLba)); > > WriteUnaligned32 ((UINT32 *)&Cdb[10], SwapBytes32 (SectorSize)); > > > > -- > > 2.16.2.windows.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/1] MdePkg/UefiScsiLib: Set FUA bit for synchronous SCSI Write operations 2020-03-30 13:51 ` Liming Gao @ 2020-03-30 20:34 ` Zurcher, Christopher J 2020-04-14 15:53 ` Liming Gao 0 siblings, 1 reply; 6+ messages in thread From: Zurcher, Christopher J @ 2020-03-30 20:34 UTC (permalink / raw) To: Gao, Liming, Liu, Zhiguang, devel@edk2.groups.io Cc: Kinney, Michael D, Wang, Jian J This change has been validated on an internal development platform; I will share the details offline. Thanks, Christopher Zurcher > -----Original Message----- > From: Gao, Liming <liming.gao@intel.com> > Sent: Monday, March 30, 2020 06:51 > To: Liu, Zhiguang <zhiguang.liu@intel.com>; Zurcher, Christopher J > <christopher.j.zurcher@intel.com>; devel@edk2.groups.io > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Wang, Jian J > <jian.j.wang@intel.com> > Subject: RE: [PATCH v2 1/1] MdePkg/UefiScsiLib: Set FUA bit for synchronous > SCSI Write operations > > Zurcher: > What functionality test has been done for this test? > > Thanks > Liming > > -----Original Message----- > > From: Liu, Zhiguang <zhiguang.liu@intel.com> > > Sent: Monday, March 30, 2020 9:52 AM > > To: Zurcher, Christopher J <christopher.j.zurcher@intel.com>; > devel@edk2.groups.io > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Wang, Jian J > <jian.j.wang@intel.com>; Gao, Liming <liming.gao@intel.com> > > Subject: RE: [PATCH v2 1/1] MdePkg/UefiScsiLib: Set FUA bit for synchronous > SCSI Write operations > > > > Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com> > > > > > -----Original Message----- > > > From: Zurcher, Christopher J > > > Sent: Thursday, March 26, 2020 3:34 PM > > > To: devel@edk2.groups.io > > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Wang, Jian J > > > <jian.j.wang@intel.com>; Gao, Liming <liming.gao@intel.com>; Liu, > Zhiguang > > > <zhiguang.liu@intel.com> > > > Subject: [PATCH v2 1/1] MdePkg/UefiScsiLib: Set FUA bit for synchronous > > > SCSI Write operations > > > > > > 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 <michael.d.kinney@intel.com> > > > Cc: Jian J Wang <jian.j.wang@intel.com> > > > Cc: Liming Gao <liming.gao@intel.com> > > > Cc: Zhiguang Liu <zhiguang.liu@intel.com> > > > Signed-off-by: Christopher J Zurcher <christopher.j.zurcher@intel.com> > > > --- > > > MdePkg/Include/IndustryStandard/Scsi.h | 8 +++++++- > > > MdePkg/Library/UefiScsiLib/UefiScsiLib.c | 14 ++++++++------ > > > 2 files changed, 15 insertions(+), 7 deletions(-) > > > > > > diff --git a/MdePkg/Include/IndustryStandard/Scsi.h > > > b/MdePkg/Include/IndustryStandard/Scsi.h > > > index 3e966520a1..64b9918b82 100644 > > > --- a/MdePkg/Include/IndustryStandard/Scsi.h > > > +++ b/MdePkg/Include/IndustryStandard/Scsi.h > > > @@ -1,7 +1,7 @@ > > > /** @file > > > Support for SCSI-2 standard > > > > > > - Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR> > > > + Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR> > > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > **/ > > > @@ -175,6 +175,12 @@ > > > #define EFI_SCSI_DATA_IN 0 > > > #define EFI_SCSI_DATA_OUT 1 > > > > > > +// > > > +// SCSI Block Command Cache Control Parameters > > > +// > > > +#define EFI_SCSI_BLOCK_FUA BIT3 ///< Force Unit Access > > > +#define EFI_SCSI_BLOCK_DPO BIT4 ///< Disable Page Out > > > + > > > // > > > // Peripheral Device Type Definitions > > > // > > > diff --git a/MdePkg/Library/UefiScsiLib/UefiScsiLib.c > > > b/MdePkg/Library/UefiScsiLib/UefiScsiLib.c > > > index 13a2a1912c..512bec500c 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.<BR> > > > + Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR> > > > 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] = EFI_SCSI_BLOCK_FUA; > > > 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] = EFI_SCSI_BLOCK_FUA; > > > WriteUnaligned64 ((UINT64 *)&Cdb[2], SwapBytes64 (StartLba)); > > > WriteUnaligned32 ((UINT32 *)&Cdb[10], SwapBytes32 (SectorSize)); > > > > > > -- > > > 2.16.2.windows.1 > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/1] MdePkg/UefiScsiLib: Set FUA bit for synchronous SCSI Write operations 2020-03-30 20:34 ` Zurcher, Christopher J @ 2020-04-14 15:53 ` Liming Gao 0 siblings, 0 replies; 6+ messages in thread From: Liming Gao @ 2020-04-14 15:53 UTC (permalink / raw) To: Zurcher, Christopher J, Liu, Zhiguang, devel@edk2.groups.io Cc: Kinney, Michael D, Wang, Jian J Reviewed-by: Liming Gao <liming.gao@intel.com> > -----Original Message----- > From: Zurcher, Christopher J <christopher.j.zurcher@intel.com> > Sent: Tuesday, March 31, 2020 4:34 AM > To: Gao, Liming <liming.gao@intel.com>; Liu, Zhiguang <zhiguang.liu@intel.com>; devel@edk2.groups.io > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Wang, Jian J <jian.j.wang@intel.com> > Subject: RE: [PATCH v2 1/1] MdePkg/UefiScsiLib: Set FUA bit for synchronous SCSI Write operations > > This change has been validated on an internal development platform; I will share the details offline. > > Thanks, > Christopher Zurcher > > > -----Original Message----- > > From: Gao, Liming <liming.gao@intel.com> > > Sent: Monday, March 30, 2020 06:51 > > To: Liu, Zhiguang <zhiguang.liu@intel.com>; Zurcher, Christopher J > > <christopher.j.zurcher@intel.com>; devel@edk2.groups.io > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Wang, Jian J > > <jian.j.wang@intel.com> > > Subject: RE: [PATCH v2 1/1] MdePkg/UefiScsiLib: Set FUA bit for synchronous > > SCSI Write operations > > > > Zurcher: > > What functionality test has been done for this test? > > > > Thanks > > Liming > > > -----Original Message----- > > > From: Liu, Zhiguang <zhiguang.liu@intel.com> > > > Sent: Monday, March 30, 2020 9:52 AM > > > To: Zurcher, Christopher J <christopher.j.zurcher@intel.com>; > > devel@edk2.groups.io > > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Wang, Jian J > > <jian.j.wang@intel.com>; Gao, Liming <liming.gao@intel.com> > > > Subject: RE: [PATCH v2 1/1] MdePkg/UefiScsiLib: Set FUA bit for synchronous > > SCSI Write operations > > > > > > Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com> > > > > > > > -----Original Message----- > > > > From: Zurcher, Christopher J > > > > Sent: Thursday, March 26, 2020 3:34 PM > > > > To: devel@edk2.groups.io > > > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Wang, Jian J > > > > <jian.j.wang@intel.com>; Gao, Liming <liming.gao@intel.com>; Liu, > > Zhiguang > > > > <zhiguang.liu@intel.com> > > > > Subject: [PATCH v2 1/1] MdePkg/UefiScsiLib: Set FUA bit for synchronous > > > > SCSI Write operations > > > > > > > > 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 <michael.d.kinney@intel.com> > > > > Cc: Jian J Wang <jian.j.wang@intel.com> > > > > Cc: Liming Gao <liming.gao@intel.com> > > > > Cc: Zhiguang Liu <zhiguang.liu@intel.com> > > > > Signed-off-by: Christopher J Zurcher <christopher.j.zurcher@intel.com> > > > > --- > > > > MdePkg/Include/IndustryStandard/Scsi.h | 8 +++++++- > > > > MdePkg/Library/UefiScsiLib/UefiScsiLib.c | 14 ++++++++------ > > > > 2 files changed, 15 insertions(+), 7 deletions(-) > > > > > > > > diff --git a/MdePkg/Include/IndustryStandard/Scsi.h > > > > b/MdePkg/Include/IndustryStandard/Scsi.h > > > > index 3e966520a1..64b9918b82 100644 > > > > --- a/MdePkg/Include/IndustryStandard/Scsi.h > > > > +++ b/MdePkg/Include/IndustryStandard/Scsi.h > > > > @@ -1,7 +1,7 @@ > > > > /** @file > > > > Support for SCSI-2 standard > > > > > > > > - Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR> > > > > + Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR> > > > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > > > **/ > > > > @@ -175,6 +175,12 @@ > > > > #define EFI_SCSI_DATA_IN 0 > > > > #define EFI_SCSI_DATA_OUT 1 > > > > > > > > +// > > > > +// SCSI Block Command Cache Control Parameters > > > > +// > > > > +#define EFI_SCSI_BLOCK_FUA BIT3 ///< Force Unit Access > > > > +#define EFI_SCSI_BLOCK_DPO BIT4 ///< Disable Page Out > > > > + > > > > // > > > > // Peripheral Device Type Definitions > > > > // > > > > diff --git a/MdePkg/Library/UefiScsiLib/UefiScsiLib.c > > > > b/MdePkg/Library/UefiScsiLib/UefiScsiLib.c > > > > index 13a2a1912c..512bec500c 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.<BR> > > > > + Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR> > > > > 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] = EFI_SCSI_BLOCK_FUA; > > > > 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] = EFI_SCSI_BLOCK_FUA; > > > > WriteUnaligned64 ((UINT64 *)&Cdb[2], SwapBytes64 (StartLba)); > > > > WriteUnaligned32 ((UINT32 *)&Cdb[10], SwapBytes32 (SectorSize)); > > > > > > > > -- > > > > 2.16.2.windows.1 > > > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-04-14 15:53 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-03-26 7:34 [PATCH v2 0/1] UefiScsiLib: Set FUA bit for synchronous SCSI Write operations Zurcher, Christopher J 2020-03-26 7:34 ` [PATCH v2 1/1] MdePkg/UefiScsiLib: " Zurcher, Christopher J 2020-03-30 1:52 ` Zhiguang Liu 2020-03-30 13:51 ` Liming Gao 2020-03-30 20:34 ` Zurcher, Christopher J 2020-04-14 15:53 ` Liming Gao
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox