> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Sean
> Rhodes
> Sent: Tuesday, September 20, 2022 9:14 PM
> To: devel@edk2.groups.io
> Cc: Rhodes, Sean <sean@starlabs.systems>; Wu, Hao A
> <hao.a...@intel.com>; Ni, Ray <ray...@intel.com>
> Subject: [edk2-devel] [PATCH 2/2] MdeModulePkg/UsbBusDxe: Reset the
> device on error
> 
> Try a port reset if GetPortStatus returns and error.
> 
> Cc: Hao A Wu <hao.a...@intel.com>
> Cc: Ray Ni <ray...@intel.com>
> Signed-off-by: Sean Rhodes <sean@starlabs.systems>
> ---
>  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
> b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
> index 7fc567898a..13112be2a5 100644
> --- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
> +++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
> @@ -992,7 +992,9 @@ UsbEnumeratePort (
>      // Now, new device connected, enumerate and configure the device
> 
>      //
> 
>      DEBUG ((DEBUG_INFO, "UsbEnumeratePort: new device connected at
> port %d\n", Port));
> 
> -    if (USB_BIT_IS_SET (PortState.PortChangeStatus,
> USB_PORT_STAT_C_RESET)) {
> 
> +    if (USB_BIT_IS_SET (PortState.PortChangeStatus,
> USB_PORT_STAT_C_RESET) &&
> 
> +        (Status != EFI_DEVICE_ERROR))


Sorry, I do not understand the purpose of the patch.

Looking into the current implementation of function UsbEnumeratePort(), if the 
execution flow reaches here, the local variable 'Status' must have a value of 
EFI_SUCCESS.

My take is that this check:
  Status = HubApi->GetPortStatus (HubIf, Port, &PortState);

  if (EFI_ERROR (Status)) {
    DEBUG ((DEBUG_ERROR, "UsbEnumeratePort: failed to get state of port %d\n", 
Port));
    return Status;
  }
will make the function return if the value of 'Status' does not equals to 
EFI_SUCCESS.

Did I miss something for the above understanding?

Best Regards,
Hao Wu


> 
> +    {
> 
>        Status = UsbEnumerateNewDev (HubIf, Port, FALSE);
> 
>      } else {
> 
>        Status = UsbEnumerateNewDev (HubIf, Port, TRUE);
> 
> --
> 2.34.1
> 
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#93990): https://edk2.groups.io/g/devel/message/93990
> Mute This Topic: https://groups.io/mt/93802899/1768737
> Group Owner: devel+ow...@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [hao.a...@intel.com]
> -=-=-=-=-=-=
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#94045): https://edk2.groups.io/g/devel/message/94045
Mute This Topic: https://groups.io/mt/93802899/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to