Skip to content

Commit

Permalink
MdeModulePkg/XhciDxe: Non-zero start/stop values in XhcGetElapsedTicks
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Ray Ni <[email protected]>
Signed-off-by: Patrick Henz <[email protected]>
Reviewed-by: Laszlo Ersek <[email protected]>
Acked-by: Hao A Wu <[email protected]>
Message-ID: <c3038878c4d30c54e60cce7192cf1aa60c30ad2e.1698770394.git.patrick.henz@hpe.com>

Resolve rebase conflict from commit ff4c49a ("MdeModulePkg/Bus: Fix
XhciDxe Linker Issues", 2023-12-06): rename "mPerformanceCounter*" to
"mXhciPerformanceCounter*".

Signed-off-by: Laszlo Ersek <[email protected]>
  • Loading branch information
patrick-henz authored and mergify[bot] committed Dec 22, 2024
1 parent 896930e commit fbbf420
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit fbbf420

Please sign in to comment.