[edk2-devel] [PATCH] MdeModulePkg/XhciDxe: Non-zero start/stop values in XhcGetElapsedTicks

Henz, Patrick posted 1 patch 6 months ago
Failed in applying to current master (apply log)
MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[edk2-devel] [PATCH] MdeModulePkg/XhciDxe: Non-zero start/stop values in XhcGetElapsedTicks
Posted by Henz, Patrick 6 months ago
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:
---
 MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
index 7a2e32a9dd..6cb97b7452 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
@@ -2389,7 +2389,7 @@ XhcGetElapsedTicks (
     // Counter counts upwards, check for an overflow condition
     //
     if (*PreviousTick > CurrentTick) {
-      Delta = (mPerformanceCounterEndValue - *PreviousTick) + CurrentTick;
+      Delta = (CurrentTick - mPerformanceCounterStartValue) + (mPerformanceCounterEndValue - *PreviousTick);
     } else {
       Delta = CurrentTick - *PreviousTick;
     }
@@ -2398,7 +2398,7 @@ XhcGetElapsedTicks (
     // Counter counts downwards, check for an underflow condition
     //
     if (*PreviousTick < CurrentTick) {
-      Delta = (mPerformanceCounterStartValue - CurrentTick) + *PreviousTick;
+      Delta = (mPerformanceCounterStartValue - CurrentTick) + (*PreviousTick - mPerformanceCounterEndValue);
     } else {
       Delta = *PreviousTick - CurrentTick;
     }
-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110434): https://edk2.groups.io/g/devel/message/110434
Mute This Topic: https://groups.io/mt/102301510/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH] MdeModulePkg/XhciDxe: Non-zero start/stop values in XhcGetElapsedTicks
Posted by Mike Maslenkin 5 months, 4 weeks ago
On Tue, Oct 31, 2023 at 7:52 PM Henz, Patrick <patrick.henz@hpe.com> wrote:
>
> 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:
> ---
>  MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
> index 7a2e32a9dd..6cb97b7452 100644
> --- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
> +++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
> @@ -2389,7 +2389,7 @@ XhcGetElapsedTicks (
>      // Counter counts upwards, check for an overflow condition
>      //
>      if (*PreviousTick > CurrentTick) {
> -      Delta = (mPerformanceCounterEndValue - *PreviousTick) + CurrentTick;
> +      Delta = (CurrentTick - mPerformanceCounterStartValue) + (mPerformanceCounterEndValue - *PreviousTick);
>      } else {
>        Delta = CurrentTick - *PreviousTick;
>      }
> @@ -2398,7 +2398,7 @@ XhcGetElapsedTicks (
>      // Counter counts downwards, check for an underflow condition
>      //
>      if (*PreviousTick < CurrentTick) {
> -      Delta = (mPerformanceCounterStartValue - CurrentTick) + *PreviousTick;
> +      Delta = (mPerformanceCounterStartValue - CurrentTick) + (*PreviousTick - mPerformanceCounterEndValue);
>      } else {
>        Delta = *PreviousTick - CurrentTick;
>      }
> --
> 2.34.1
>
>
>
> ------------
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#110434): https://edk2.groups.io/g/devel/message/110434
> Mute This Topic: https://groups.io/mt/102301510/1770412
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [mike.maslenkin@gmail.com]
> ------------
>
>
Hello, All

Just curious why this patch was broken by google groups.

Some patches to edk2 and edk2-redfish-client have unintended line
breaks marked with "=",  additional "0D" and additional "3D" to "="
Web shows https://edk2.groups.io/g/devel/message/110434 exactly as it
saved by mailer.
What do sender should setup to avoid this?

Regards,
Mike.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110459): https://edk2.groups.io/g/devel/message/110459
Mute This Topic: https://groups.io/mt/102301510/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH] MdeModulePkg/XhciDxe: Non-zero start/stop values in XhcGetElapsedTicks
Posted by Laszlo Ersek 6 months ago
On 10/31/23 17:51, Henz, Patrick wrote:
> 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:
> ---
>  MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
> index 7a2e32a9dd..6cb97b7452 100644
> --- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
> +++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
> @@ -2389,7 +2389,7 @@ XhcGetElapsedTicks (
>      // Counter counts upwards, check for an overflow condition
>      //
>      if (*PreviousTick > CurrentTick) {
> -      Delta = (mPerformanceCounterEndValue - *PreviousTick) + CurrentTick;
> +      Delta = (CurrentTick - mPerformanceCounterStartValue) + (mPerformanceCounterEndValue - *PreviousTick);
>      } else {
>        Delta = CurrentTick - *PreviousTick;
>      }
> @@ -2398,7 +2398,7 @@ XhcGetElapsedTicks (
>      // Counter counts downwards, check for an underflow condition
>      //
>      if (*PreviousTick < CurrentTick) {
> -      Delta = (mPerformanceCounterStartValue - CurrentTick) + *PreviousTick;
> +      Delta = (mPerformanceCounterStartValue - CurrentTick) + (*PreviousTick - mPerformanceCounterEndValue);
>      } else {
>        Delta = *PreviousTick - CurrentTick;
>      }

Reviewed-by: Laszlo Ersek <lersek@redhat.com>



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110450): https://edk2.groups.io/g/devel/message/110450
Mute This Topic: https://groups.io/mt/102301510/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076/xyzzy [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-