mirror of https://github.com/acidanthera/audk.git
Error handling refinement at UsbIoResetPort() to avoid device state machine getting corrupted when the device disconnect happens
Signed-off-by: erictian Reviewed-by: niruiyu git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12204 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
ef949581ea
commit
c4b8c2d807
|
@ -818,7 +818,6 @@ UsbIoPortReset (
|
||||||
USB_INTERFACE *UsbIf;
|
USB_INTERFACE *UsbIf;
|
||||||
USB_INTERFACE *HubIf;
|
USB_INTERFACE *HubIf;
|
||||||
USB_DEVICE *Dev;
|
USB_DEVICE *Dev;
|
||||||
UINT8 Address;
|
|
||||||
EFI_TPL OldTpl;
|
EFI_TPL OldTpl;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
@ -843,26 +842,25 @@ UsbIoPortReset (
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Reset the device to its current address. The device now has a
|
// Reset the device to its current address. The device now has an address
|
||||||
// address of ZERO, so need to set Dev->Address to zero first for
|
// of ZERO after port reset, so need to set Dev->Address to the device again for
|
||||||
// host to communicate with the device
|
// host to communicate with it.
|
||||||
//
|
//
|
||||||
Address = Dev->Address;
|
Status = UsbSetAddress (Dev, Dev->Address);
|
||||||
Dev->Address = 0;
|
|
||||||
Status = UsbSetAddress (Dev, Address);
|
|
||||||
|
|
||||||
gBS->Stall (USB_SET_DEVICE_ADDRESS_STALL);
|
gBS->Stall (USB_SET_DEVICE_ADDRESS_STALL);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
|
//
|
||||||
|
// It may fail due to device disconnection or other reasons.
|
||||||
|
//
|
||||||
DEBUG (( EFI_D_ERROR, "UsbIoPortReset: failed to set address for device %d - %r\n",
|
DEBUG (( EFI_D_ERROR, "UsbIoPortReset: failed to set address for device %d - %r\n",
|
||||||
Address, Status));
|
Dev->Address, Status));
|
||||||
|
|
||||||
goto ON_EXIT;
|
goto ON_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dev->Address = Address;
|
DEBUG (( EFI_D_INFO, "UsbIoPortReset: device is now ADDRESSED at %d\n", Dev->Address));
|
||||||
|
|
||||||
DEBUG (( EFI_D_INFO, "UsbIoPortReset: device is now ADDRESSED at %d\n", Address));
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Reset the current active configure, after this device
|
// Reset the current active configure, after this device
|
||||||
|
@ -873,7 +871,7 @@ UsbIoPortReset (
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG (( EFI_D_ERROR, "UsbIoPortReset: failed to set configure for device %d - %r\n",
|
DEBUG (( EFI_D_ERROR, "UsbIoPortReset: failed to set configure for device %d - %r\n",
|
||||||
Address, Status));
|
Dev->Address, Status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue