Thanks all the Tested-by and Reviewed-by.

The new UEFI spec 2.7a has been published at 
http://www.uefi.org/sites/default/files/resources/UEFI%20Spec%202_7_A%20Sept%206.pdf
which includes the spec change "1815 OpenProtocol() / EFI_ALREADY_STARTED 
should output existent Interface" that is required for this patch.

If no more comments, I will go to push this patch. :)


Thanks,
Star
-----Original Message-----
From: Laszlo Ersek [mailto:ler...@redhat.com] 
Sent: Wednesday, June 28, 2017 10:14 PM
To: Zeng, Star <star.z...@intel.com>; edk2-devel@lists.01.org
Cc: Amit Kumar <amit...@samsung.com>; Kinney, Michael D 
<michael.d.kin...@intel.com>; Gao, Liming <liming....@intel.com>; Gabriel Somlo 
<gso...@gmail.com>
Subject: Re: [PATCH V5] MdeModulePkg/DxeCore: Fixed Interface returned by 
CoreOpenProtocol

On 06/28/17 15:22, Star Zeng wrote:
> From: Amit Kumar <amit...@samsung.com>
> 
> Change since v4: Revise the patch based on V4 sent by Amit Kumar
> 1) Only return the corresponding protocol interface in *Interface if 
> the return status is EFI_SUCCESS or EFI_ALREADY_STARTED.
> 2) Interface is returned unmodified for all error conditions except 
> EFI_UNSUPPORTED and EFI_ALREADY_STARTED, NULL will be returned in 
> *Interface when EFI_UNSUPPORTED and Attributes is not 
> EFI_OPEN_PROTOCOL_TEST_PROTOCOL, the protocol interface will be 
> returned in *Interface when EFI_ALREADY_STARTED.
> 
> Change since v3:
> 1) Fixed issue when Attributes = EFI_OPEN_PROTOCOL_TEST_PROTOCOL and 
> Inteface = NULL case. [Reported by:star.zeng at intel.com]
> 
> Change Since v2:
> 1) Modified to use EFI_ERROR to get status code
> 
> Change since v1:
> 1) Fixed typo protocal to protocol
> 2) Fixed coding style
> 
> Cc: Laszlo Ersek <ler...@redhat.com>
> Cc: Amit Kumar <amit...@samsung.com>
> Cc: Michael D Kinney <michael.d.kin...@intel.com>
> Cc: Liming Gao <liming....@intel.com>
> Cc: Gabriel Somlo <gso...@gmail.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Amit Kumar <amit...@samsung.com>
> Signed-off-by: Star Zeng <star.z...@intel.com>
> ---
>  MdeModulePkg/Core/Dxe/Hand/Handle.c | 36 
> +++++++++++++++++++++++-------------
>  1 file changed, 23 insertions(+), 13 deletions(-)

Reviewed-by: Laszlo Ersek <ler...@redhat.com>
Tested-by: Laszlo Ersek <ler...@redhat.com>

Thanks!
Laszlo

> diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c 
> b/MdeModulePkg/Core/Dxe/Hand/Handle.c
> index 59b89148c8f0..3862a3876f4a 100644
> --- a/MdeModulePkg/Core/Dxe/Hand/Handle.c
> +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c
> @@ -1006,12 +1006,8 @@ CoreOpenProtocol (
>    //
>    // Check for invalid Interface
>    //
> -  if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
> -    if (Interface == NULL) {
> -      return EFI_INVALID_PARAMETER;
> -    } else {
> -      *Interface = NULL;
> -    }
> +  if ((Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) && (Interface == 
> NULL)) {
> +    return EFI_INVALID_PARAMETER;
>    }
>  
>    //
> @@ -1078,12 +1074,6 @@ CoreOpenProtocol (
>      goto Done;
>    }
>  
> -  //
> -  // This is the protocol interface entry for this protocol
> -  //
> -  if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
> -    *Interface = Prot->Interface;
> -  }
>    Status = EFI_SUCCESS;
>  
>    ByDriver        = FALSE;
> @@ -1177,8 +1167,28 @@ CoreOpenProtocol (
>    }
>  
>  Done:
> +
> +  if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
> +    //
> +    // Keep Interface unmodified in case of any Error
> +    // except EFI_ALREADY_STARTED and EFI_UNSUPPORTED.
> +    //
> +    if (!EFI_ERROR (Status) || Status == EFI_ALREADY_STARTED) {
> +      //
> +      // EFI_ALREADY_STARTED is not an error for bus driver.
> +      // Return the corresponding protocol interface. 
> +      //
> +      *Interface = Prot->Interface;
> +    } else if (Status == EFI_UNSUPPORTED) {
> +      //
> +      // Return NULL Interface if Unsupported Protocol.
> +      //
> +      *Interface = NULL;
> +    }
> +  }
> +
>    //
> -  // Done. Release the database lock are return
> +  // Done. Release the database lock and return
>    //
>    CoreReleaseProtocolLock ();
>    return Status;
> 

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to