From 33dadb270b4e72da565c6fcb0094916b1363cd03 Mon Sep 17 00:00:00 2001 From: snowpiaoling <1972997989@qq.com> Date: Fri, 7 Aug 2026 12:30:07 +0800 Subject: [PATCH] EmbeddedPkg: normalize mmc interaction latency to 1us Upon inspecting the source code, I found that the original implementation of eMMC timeout in MmcDxe is affected by the CPU execution speed. With higher-performance CPUs, the actual timeout duration would be shortened as it was not based on wall clock. Add a precise 1us delay to each iteration of the wait loop to make the actual duration of the delay clock- and performance-agnostic. Signed-off-by: snowpiaoling <1972997989@qq.com> --- EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c | 4 ++++ EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c index 69987e9f1a..52908f92cf 100644 --- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c +++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c @@ -210,6 +210,8 @@ MmcTransferBlock ( break; // Prevents delay once finished } } + + gBS->Stall (1); } if (BufferSize > This->Media->BlockSize) { @@ -323,6 +325,8 @@ MmcIoBlocks ( if (!EFI_ERROR (Status)) { MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Response); } + + gBS->Stall (1); } if (0 == Timeout) { diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c index fed1646b27..858836cfc6 100755 --- a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c +++ b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c @@ -596,6 +596,10 @@ MmcIdentificationMode ( return Status; } + if (!OcrResponse.Ocr.PowerUp) { + gBS->Stall (1); + } + Timeout--; } while (!OcrResponse.Ocr.PowerUp && (Timeout > 0));