If it's to copy from hw to sw memory, why do we need volatile?

Thanks,
Ray

> -----Original Message-----
> From: [email protected] <[email protected]> On Behalf Of Oliver
> Smith-Denny
> Sent: Thursday, April 20, 2023 7:41 AM
> To: [email protected]
> Cc: Wu, Hao A <[email protected]>; Ni, Ray <[email protected]>; Wang,
> Jian J <[email protected]>; Gao, Liming <[email protected]>;
> Michael Kubacki <[email protected]>; Sean Brogan
> <[email protected]>
> Subject: [edk2-devel][PATCH v1 1/2] Add the volatile keyword to
> NvmExpressDxe's Passthru CQs and SQs.
> 
> This updates the relevant functions that expect a non-volatile
> 
> structure to be passed to them to take casts of the CQ and SQ,
> 
> now that they are volatile.
> 
> 
> 
> Cc: Hao A Wu <[email protected]>
> 
> Cc: Ray Ni <[email protected]>
> 
> Cc: Jian J Wang <[email protected]>
> 
> Cc: Liming Gao <[email protected]>
> 
> Cc: Michael Kubacki <[email protected]>
> 
> Cc: Sean Brogan <[email protected]>
> 
> Signed-off-by: Oliver Smith-Denny <[email protected]>
> 
> ---
> 
>  MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c | 10
> +++++-----
> 
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> 
> 
> diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
> b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
> 
> index f37baa626a16..1a7e39500ac0 100644
> 
> --- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
> 
> +++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
> 
> @@ -459,8 +459,8 @@ NvmExpressPassThru (
> 
>    EFI_STATUS                     Status;
> 
>    EFI_STATUS                     PreviousStatus;
> 
>    EFI_PCI_IO_PROTOCOL            *PciIo;
> 
> -  NVME_SQ                        *Sq;
> 
> -  NVME_CQ                        *Cq;
> 
> +  volatile NVME_SQ               *Sq;
> 
> +  volatile NVME_CQ               *Cq;
> 
>    UINT16                         QueueId;
> 
>    UINT16                         QueueSize;
> 
>    UINT32                         Bytes;
> 
> @@ -581,7 +581,7 @@ NvmExpressPassThru (
> 
>      return EFI_INVALID_PARAMETER;
> 
>    }
> 
> 
> 
> -  ZeroMem (Sq, sizeof (NVME_SQ));
> 
> +  ZeroMem ((VOID *)Sq, sizeof (NVME_SQ));
> 
>    Sq->Opc  = (UINT8)Packet->NvmeCmd->Cdw0.Opcode;
> 
>    Sq->Fuse = (UINT8)Packet->NvmeCmd->Cdw0.FusedOperation;
> 
>    Sq->Cid  = Private->Cid[QueueId]++;
> 
> @@ -815,14 +815,14 @@ NvmExpressPassThru (
> 
>        // Dump every completion entry status for debugging.
> 
>        //
> 
>        DEBUG_CODE_BEGIN ();
> 
> -      NvmeDumpStatus (Cq);
> 
> +      NvmeDumpStatus ((NVME_CQ *)Cq);
> 
>        DEBUG_CODE_END ();
> 
>      }
> 
> 
> 
>      //
> 
>      // Copy the Respose Queue entry for this command to the callers
> response buffer
> 
>      //
> 
> -    CopyMem (Packet->NvmeCompletion, Cq, sizeof
> (EFI_NVM_EXPRESS_COMPLETION));
> 
> +    CopyMem (Packet->NvmeCompletion, (VOID *)Cq, sizeof
> (EFI_NVM_EXPRESS_COMPLETION));
> 
>    } else {
> 
>      //
> 
>      // Timeout occurs for an NVMe command. Reset the controller to abort
> the
> 
> --
> 
> 2.39.2
> 
> 
> 
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#103263):
> https://edk2.groups.io/g/devel/message/103263
> Mute This Topic: https://groups.io/mt/98378948/1712937
> Group Owner: [email protected]
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]]
> -=-=-=-=-=-=
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103265): https://edk2.groups.io/g/devel/message/103265
Mute This Topic: https://groups.io/mt/98378948/21656
Group Owner: [email protected]
Unsubscribe: 
https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to