[edk2-devel] [PATCH] ShellPkg: Fix Ping GetTimerPeriod API failure

MohammedX Rehan posted 1 patch 2 years, 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/edk2 tags/patchew/e11d98bfcb87a2e067d47354d65e26cbae0e27a9.1644912338.git.mohammedx.rehan@intel.com
ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
[edk2-devel] [PATCH] ShellPkg: Fix Ping GetTimerPeriod API failure
Posted by MohammedX Rehan 2 years, 2 months ago
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3819

Ping GetTimerPeriod API returns sometime zero value when
StallCounter has smaller value than RttTimerTick (divide by zero)
which results some failure at ping UEFI shell command

Signed-off-by: MohammedX Rehan <mohammedx.rehan@intel.com>
---
 ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
index ec1e0a188b..6a002b15e5 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
@@ -259,9 +259,11 @@ GetTimerPeriod (
   EFI_EVENT   TimerEvent;
   UINT32      StallCounter;
   EFI_TPL     OldTpl;
+  UINT32      TimerPeriod;
 
   RttTimerTick = 0;
   StallCounter = 0;
+  TimerPeriod  = 0;
 
   Status = gBS->CreateEvent (
                   EVT_TIMER | EVT_NOTIFY_SIGNAL,
@@ -295,7 +297,12 @@ GetTimerPeriod (
   gBS->SetTimer (TimerEvent, TimerCancel, 0);
   gBS->CloseEvent (TimerEvent);
 
-  return StallCounter / RttTimerTick;
+  TimerPeriod = StallCounter / RttTimerTick;
+  if (TimerPeriod != 0) {
+    return TimerPeriod;
+  } else {
+    return 1;
+  }
 }
 
 /**
-- 
2.30.0.windows.2



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


Re: [edk2-devel] [PATCH] ShellPkg: Fix Ping GetTimerPeriod API failure
Posted by Gao, Zhichao 2 years, 2 months ago
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>

Thanks,
Zhichao

> -----Original Message-----
> From: Rehan, MohammedX <mohammedx.rehan@intel.com>
> Sent: Tuesday, February 15, 2022 4:07 PM
> To: devel@edk2.groups.io; Esakkithevar, Kathappan
> <kathappan.esakkithevar@intel.com>; Gao, Zhichao
> <zhichao.gao@intel.com>; Ni, Ray <ray.ni@intel.com>; Pethaiyan, Madhan
> <madhan.pethaiyan@intel.com>
> Cc: Thirupugal, MadhaviX <madhavix.thirupugal@intel.com>; Rehan,
> MohammedX <mohammedx.rehan@intel.com>
> Subject: [PATCH] ShellPkg: Fix Ping GetTimerPeriod API failure
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3819
> 
> Ping GetTimerPeriod API returns sometime zero value when StallCounter has
> smaller value than RttTimerTick (divide by zero) which results some failure at
> ping UEFI shell command
> 
> Signed-off-by: MohammedX Rehan <mohammedx.rehan@intel.com>
> ---
>  ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> index ec1e0a188b..6a002b15e5 100644
> --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> @@ -259,9 +259,11 @@ GetTimerPeriod (
>    EFI_EVENT   TimerEvent;   UINT32      StallCounter;   EFI_TPL     OldTpl;+
> UINT32      TimerPeriod;    RttTimerTick = 0;   StallCounter = 0;+  TimerPeriod  =
> 0;    Status = gBS->CreateEvent (                   EVT_TIMER |
> EVT_NOTIFY_SIGNAL,@@ -295,7 +297,12 @@ GetTimerPeriod (
>    gBS->SetTimer (TimerEvent, TimerCancel, 0);   gBS->CloseEvent
> (TimerEvent); -  return StallCounter / RttTimerTick;+  TimerPeriod =
> StallCounter / RttTimerTick;+  if (TimerPeriod != 0) {+    return TimerPeriod;+  }
> else {+    return 1;+  } }  /**--
> 2.30.0.windows.2



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


Re: [edk2-devel] [PATCH] ShellPkg: Fix Ping GetTimerPeriod API failure
Posted by Ni, Ray 2 years, 2 months ago
Reviewed-by: Ray Ni <ray.ni@intel.com>

-----Original Message-----
From: Gao, Zhichao <zhichao.gao@intel.com> 
Sent: Tuesday, February 15, 2022 4:10 PM
To: Rehan, MohammedX <mohammedx.rehan@intel.com>; devel@edk2.groups.io; Esakkithevar, Kathappan <kathappan.esakkithevar@intel.com>; Ni, Ray <ray.ni@intel.com>; Pethaiyan, Madhan <madhan.pethaiyan@intel.com>
Cc: Thirupugal, MadhaviX <madhavix.thirupugal@intel.com>
Subject: RE: [PATCH] ShellPkg: Fix Ping GetTimerPeriod API failure

Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>

Thanks,
Zhichao

> -----Original Message-----
> From: Rehan, MohammedX <mohammedx.rehan@intel.com>
> Sent: Tuesday, February 15, 2022 4:07 PM
> To: devel@edk2.groups.io; Esakkithevar, Kathappan 
> <kathappan.esakkithevar@intel.com>; Gao, Zhichao 
> <zhichao.gao@intel.com>; Ni, Ray <ray.ni@intel.com>; Pethaiyan, Madhan 
> <madhan.pethaiyan@intel.com>
> Cc: Thirupugal, MadhaviX <madhavix.thirupugal@intel.com>; Rehan, 
> MohammedX <mohammedx.rehan@intel.com>
> Subject: [PATCH] ShellPkg: Fix Ping GetTimerPeriod API failure
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3819
> 
> Ping GetTimerPeriod API returns sometime zero value when StallCounter 
> has smaller value than RttTimerTick (divide by zero) which results 
> some failure at ping UEFI shell command
> 
> Signed-off-by: MohammedX Rehan <mohammedx.rehan@intel.com>
> ---
>  ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> index ec1e0a188b..6a002b15e5 100644
> --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> @@ -259,9 +259,11 @@ GetTimerPeriod (
>    EFI_EVENT   TimerEvent;   UINT32      StallCounter;   EFI_TPL     OldTpl;+
> UINT32      TimerPeriod;    RttTimerTick = 0;   StallCounter = 0;+  TimerPeriod  =
> 0;    Status = gBS->CreateEvent (                   EVT_TIMER |
> EVT_NOTIFY_SIGNAL,@@ -295,7 +297,12 @@ GetTimerPeriod (
>    gBS->SetTimer (TimerEvent, TimerCancel, 0);   gBS->CloseEvent
> (TimerEvent); -  return StallCounter / RttTimerTick;+  TimerPeriod =
> StallCounter / RttTimerTick;+  if (TimerPeriod != 0) {+    return TimerPeriod;+  }
> else {+    return 1;+  } }  /**--
> 2.30.0.windows.2



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