From e3076d9f7365d94aaf8e94836d58a7f624122a7e Mon Sep 17 00:00:00 2001 From: John Stultz Date: Tue, 25 Oct 2016 15:01:33 -0700 Subject: [PATCH] HiKeyFastboot: Add short delay after flush to avoid reboot hang We've frequently seen hangs after flashing partitions on HiKey. It tends to happen when the flash and reboot commands happen very close together: $ fastboot flash ; fastboot reboot; Tracing through this, the Flush completes, and then we process the fastboot reboot command, which issues the PSCI_RESET command and we seem to hang in PSCI_RESET. This seems to point to some sort of a hardware issue where the RESET command may not actually trigger the hardware to reset if there's some sort of IO still in flight. The flush command shouldn't return early, but something is not quite right here. In order to avoid the issue, this patch adds a short delay after the flush command. With this delay, I can no longer trigger the reset hang. Change-Id: I9ccbcdcc597c4546808777c06ecd3f252df15008 Signed-off-by: John Stultz --- Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastboot.c | 2 ++ Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.inf | 1 + 2 files changed, 3 insertions(+) diff --git a/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastboot.c b/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastboot.c index d4176fe3..49551ae1 100644 --- a/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastboot.c +++ b/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastboot.c @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -557,6 +558,7 @@ HiKeyFastbootPlatformFlashPartition ( } BlockIo->FlushBlocks(BlockIo); + MicroSecondDelay (50000); return Status; } diff --git a/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.inf b/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.inf index e59b2fc7..25c09d2a 100644 --- a/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.inf +++ b/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.inf @@ -35,6 +35,7 @@ UefiBootServicesTableLib UefiRuntimeServicesTableLib UefiDriverEntryPoint + TimerLib [Protocols] gAndroidFastbootPlatformProtocolGuid