diff options
author | Henz, Patrick <patrick.henz@hpe.com> | 2023-10-31 11:51:14 -0500 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-12-22 22:10:54 +0000 |
commit | fbbf4206c13e95d54ace7646d508523adae4b126 (patch) | |
tree | 2c60fc65697bc3b4154cc0791a318d0eb96b33ee | |
parent | 896930edc93be754675af5854dba9b39d8647e5e (diff) | |
download | edk2-fbbf4206c13e95d54ace7646d508523adae4b126.tar.gz |
MdeModulePkg/XhciDxe: Non-zero start/stop values in XhcGetElapsedTicks
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4578
The implementation of XhcGetElapsedTicks did not account for
non-zero start and stop values for the performance counter
timer, potentially resulting in an incorrect elapsed tick
count getting returned to the caller. Account for non-zero
start and stop values when calculating the elapsed tick
count.
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Patrick Henz <patrick.henz@hpe.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Hao A Wu <hao.a.wu@intel.com>
Message-ID: <c3038878c4d30c54e60cce7192cf1aa60c30ad2e.1698770394.git.patrick.henz@hpe.com>
Resolve rebase conflict from commit ff4c49a5ee38 ("MdeModulePkg/Bus: Fix
XhciDxe Linker Issues", 2023-12-06): rename "mPerformanceCounter*" to
"mXhciPerformanceCounter*".
Signed-off-by: Laszlo Ersek <laszlo.ersek@posteo.net>
-rw-r--r-- | MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c index a9d7e3616e..c830db66a1 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c +++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c @@ -2397,7 +2397,7 @@ XhcGetElapsedTicks ( // Counter counts upwards, check for an overflow condition
//
if (*PreviousTick > CurrentTick) {
- Delta = (mXhciPerformanceCounterEndValue - *PreviousTick) + CurrentTick;
+ Delta = (CurrentTick - mXhciPerformanceCounterStartValue) + (mXhciPerformanceCounterEndValue - *PreviousTick);
} else {
Delta = CurrentTick - *PreviousTick;
}
@@ -2406,7 +2406,7 @@ XhcGetElapsedTicks ( // Counter counts downwards, check for an underflow condition
//
if (*PreviousTick < CurrentTick) {
- Delta = (mXhciPerformanceCounterStartValue - CurrentTick) + *PreviousTick;
+ Delta = (mXhciPerformanceCounterStartValue - CurrentTick) + (*PreviousTick - mXhciPerformanceCounterEndValue);
} else {
Delta = *PreviousTick - CurrentTick;
}
|