public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH edk2-platforms v2 0/2] Platform/ARM/JunoPkg: Timer fixes
@ 2023-02-21  1:02 Rebecca Cran
  2023-02-21  1:02 ` [PATCH edk2-platforms v2 1/2] Platform/ARM/JunoPkg: Switch to MdeModulePkg/Universal/Metronome driver Rebecca Cran
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Rebecca Cran @ 2023-02-21  1:02 UTC (permalink / raw)
  To: devel, Pierre Gondois, Ard Biesheuvel, Sami Mujawar,
	Thomas Abraham
  Cc: Rebecca Cran

The use of the EmbeddedPkg/MetronomeDxe driver on Juno can cause problems
with drivers that use gBS->Stall, since it takes 10x longer than
requested. For example requesting a timeout of 1 ms when doing a USB 
bulk transfer results in it taking 100 ms. Switching to the
MdeModulePkg/Universal/Metronome driver fixes this since it assumes the
timer clock ticks at least every 100 ns.

While here, set the PCD value of the timer frequency to 0 so it gets
read from the SoC instead of hard-coding it.

Changes in v2:

Dropped the patch to set PcdTimerPeriod.

Rebecca Cran (2):
  Platform/ARM/JunoPkg: Switch to MdeModulePkg/Universal/Metronome
    driver
  Platform/ARM/JunoPkg: Set PcdArmArchTimerFreqInHz to 0 to read from
    CNTFRQ_EL0

 Platform/ARM/JunoPkg/ArmJuno.dsc | 6 +++---
 Platform/ARM/JunoPkg/ArmJuno.fdf | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH edk2-platforms v2 1/2] Platform/ARM/JunoPkg: Switch to MdeModulePkg/Universal/Metronome driver
  2023-02-21  1:02 [PATCH edk2-platforms v2 0/2] Platform/ARM/JunoPkg: Timer fixes Rebecca Cran
@ 2023-02-21  1:02 ` Rebecca Cran
  2023-02-21  8:44   ` Ard Biesheuvel
  2023-02-21  1:02 ` [PATCH edk2-platforms v2 2/2] Platform/ARM/JunoPkg: Set PcdArmArchTimerFreqInHz to 0 to read from CNTFRQ_EL0 Rebecca Cran
  2023-02-21  8:49 ` [PATCH edk2-platforms v2 0/2] Platform/ARM/JunoPkg: Timer fixes Ard Biesheuvel
  2 siblings, 1 reply; 5+ messages in thread
From: Rebecca Cran @ 2023-02-21  1:02 UTC (permalink / raw)
  To: devel, Pierre Gondois, Ard Biesheuvel, Sami Mujawar,
	Thomas Abraham
  Cc: Rebecca Cran

The MetronomeDxe driver uses the PCD PcdMetronomeTickPeriod to calculate
how many ticks to wait in MicroSecondDelay. Given that the timer clock
on Juno runs at 50 MHz, it ticks every 20 ns; therefore, a setting of
1000 is wrong: for example it causes a call to gBS->Stall (1) to take
10 us.

The driver in MdeModulePkg/Universal/Metronome assumes the clock ticks
at least every 100 ns, which is the minimum allowed by the Metronome
protocol. Since that's the case on Juno, switch from
EmbeddedPkg/MetronomeDxe to MdeModulePkg/Universal/Metronome.

Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
---
 Platform/ARM/JunoPkg/ArmJuno.dsc | 3 +--
 Platform/ARM/JunoPkg/ArmJuno.fdf | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc b/Platform/ARM/JunoPkg/ArmJuno.dsc
index a00b866c5e9a..9cde4c862651 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.dsc
+++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
@@ -189,7 +189,6 @@
   # ARM Architectural Timer Frequency
   #
   gArmTokenSpaceGuid.PcdArmArchTimerFreqInHz|50000000
-  gEmbeddedTokenSpaceGuid.PcdMetronomeTickPeriod|1000
 
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
 
@@ -248,10 +247,10 @@
   MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
+  MdeModulePkg/Universal/Metronome/Metronome.inf
   MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
   MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
   EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
-  EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
 
   MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
   MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
diff --git a/Platform/ARM/JunoPkg/ArmJuno.fdf b/Platform/ARM/JunoPkg/ArmJuno.fdf
index fca5a78cee6c..836d3cde8781 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.fdf
+++ b/Platform/ARM/JunoPkg/ArmJuno.fdf
@@ -96,10 +96,10 @@ FvNameGuid         = B73FE497-B92E-416e-8326-45AD0D270092
   INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
   INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
   INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
+  INF MdeModulePkg/Universal/Metronome/Metronome.inf
   INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
   INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
   INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
-  INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
 
   INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
   INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH edk2-platforms v2 2/2] Platform/ARM/JunoPkg: Set PcdArmArchTimerFreqInHz to 0 to read from CNTFRQ_EL0
  2023-02-21  1:02 [PATCH edk2-platforms v2 0/2] Platform/ARM/JunoPkg: Timer fixes Rebecca Cran
  2023-02-21  1:02 ` [PATCH edk2-platforms v2 1/2] Platform/ARM/JunoPkg: Switch to MdeModulePkg/Universal/Metronome driver Rebecca Cran
@ 2023-02-21  1:02 ` Rebecca Cran
  2023-02-21  8:49 ` [PATCH edk2-platforms v2 0/2] Platform/ARM/JunoPkg: Timer fixes Ard Biesheuvel
  2 siblings, 0 replies; 5+ messages in thread
From: Rebecca Cran @ 2023-02-21  1:02 UTC (permalink / raw)
  To: devel, Pierre Gondois, Ard Biesheuvel, Sami Mujawar,
	Thomas Abraham
  Cc: Rebecca Cran

If PcdArmArchTimerFreqInHz is zero, the value of the timer frequency
will be read from CNTFRQ_EL0. Avoid hard-coding the value in ArmJuno.dsc
and instead let the ArmArchTimerLib driver read it from the SoC.

Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
---
 Platform/ARM/JunoPkg/ArmJuno.dsc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc b/Platform/ARM/JunoPkg/ArmJuno.dsc
index 9cde4c862651..d3bb205aa6f2 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.dsc
+++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
@@ -188,7 +188,8 @@
   #
   # ARM Architectural Timer Frequency
   #
-  gArmTokenSpaceGuid.PcdArmArchTimerFreqInHz|50000000
+  # Set to 0 so ArmArchTimerLib will read its value from CNTFRQ_EL0
+  gArmTokenSpaceGuid.PcdArmArchTimerFreqInHz|0
 
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH edk2-platforms v2 1/2] Platform/ARM/JunoPkg: Switch to MdeModulePkg/Universal/Metronome driver
  2023-02-21  1:02 ` [PATCH edk2-platforms v2 1/2] Platform/ARM/JunoPkg: Switch to MdeModulePkg/Universal/Metronome driver Rebecca Cran
@ 2023-02-21  8:44   ` Ard Biesheuvel
  0 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2023-02-21  8:44 UTC (permalink / raw)
  To: Rebecca Cran
  Cc: devel, Pierre Gondois, Ard Biesheuvel, Sami Mujawar,
	Thomas Abraham

Hi Rebecca,

Thanks for the effort to fix this.


On Tue, 21 Feb 2023 at 02:03, Rebecca Cran <rebecca@quicinc.com> wrote:
>
> The MetronomeDxe driver uses the PCD PcdMetronomeTickPeriod to calculate
> how many ticks to wait in MicroSecondDelay. Given that the timer clock
> on Juno runs at 50 MHz, it ticks every 20 ns; therefore, a setting of
> 1000 is wrong: for example it causes a call to gBS->Stall (1) to take
> 10 us.
>
> The driver in MdeModulePkg/Universal/Metronome assumes the clock ticks
> at least every 100 ns, which is the minimum allowed by the Metronome
> protocol. Since that's the case on Juno, switch from
> EmbeddedPkg/MetronomeDxe to MdeModulePkg/Universal/Metronome.
>
> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>

Makes sense. It wonder why we still have the EmbeddedPkg version in
the first place, given that the MdeModulePkg does the same thing but
better.

> ---
>  Platform/ARM/JunoPkg/ArmJuno.dsc | 3 +--
>  Platform/ARM/JunoPkg/ArmJuno.fdf | 2 +-
>  2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc b/Platform/ARM/JunoPkg/ArmJuno.dsc
> index a00b866c5e9a..9cde4c862651 100644
> --- a/Platform/ARM/JunoPkg/ArmJuno.dsc
> +++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
> @@ -189,7 +189,6 @@
>    # ARM Architectural Timer Frequency
>    #
>    gArmTokenSpaceGuid.PcdArmArchTimerFreqInHz|50000000
> -  gEmbeddedTokenSpaceGuid.PcdMetronomeTickPeriod|1000
>
>    gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
>
> @@ -248,10 +247,10 @@
>    MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
>    MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
>    MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
> +  MdeModulePkg/Universal/Metronome/Metronome.inf
>    MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
>    MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
>    EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
> -  EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
>
>    MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
>    MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
> diff --git a/Platform/ARM/JunoPkg/ArmJuno.fdf b/Platform/ARM/JunoPkg/ArmJuno.fdf
> index fca5a78cee6c..836d3cde8781 100644
> --- a/Platform/ARM/JunoPkg/ArmJuno.fdf
> +++ b/Platform/ARM/JunoPkg/ArmJuno.fdf
> @@ -96,10 +96,10 @@ FvNameGuid         = B73FE497-B92E-416e-8326-45AD0D270092
>    INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
>    INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
>    INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
> +  INF MdeModulePkg/Universal/Metronome/Metronome.inf
>    INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
>    INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
>    INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
> -  INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
>
>    INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
>    INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
> --
> 2.30.2
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH edk2-platforms v2 0/2] Platform/ARM/JunoPkg: Timer fixes
  2023-02-21  1:02 [PATCH edk2-platforms v2 0/2] Platform/ARM/JunoPkg: Timer fixes Rebecca Cran
  2023-02-21  1:02 ` [PATCH edk2-platforms v2 1/2] Platform/ARM/JunoPkg: Switch to MdeModulePkg/Universal/Metronome driver Rebecca Cran
  2023-02-21  1:02 ` [PATCH edk2-platforms v2 2/2] Platform/ARM/JunoPkg: Set PcdArmArchTimerFreqInHz to 0 to read from CNTFRQ_EL0 Rebecca Cran
@ 2023-02-21  8:49 ` Ard Biesheuvel
  2 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2023-02-21  8:49 UTC (permalink / raw)
  To: Rebecca Cran
  Cc: devel, Pierre Gondois, Ard Biesheuvel, Sami Mujawar,
	Thomas Abraham

On Tue, 21 Feb 2023 at 02:03, Rebecca Cran <rebecca@quicinc.com> wrote:
>
> The use of the EmbeddedPkg/MetronomeDxe driver on Juno can cause problems
> with drivers that use gBS->Stall, since it takes 10x longer than
> requested. For example requesting a timeout of 1 ms when doing a USB
> bulk transfer results in it taking 100 ms. Switching to the
> MdeModulePkg/Universal/Metronome driver fixes this since it assumes the
> timer clock ticks at least every 100 ns.
>
> While here, set the PCD value of the timer frequency to 0 so it gets
> read from the SoC instead of hard-coding it.
>
> Changes in v2:
>
> Dropped the patch to set PcdTimerPeriod.
>
> Rebecca Cran (2):
>   Platform/ARM/JunoPkg: Switch to MdeModulePkg/Universal/Metronome
>     driver
>   Platform/ARM/JunoPkg: Set PcdArmArchTimerFreqInHz to 0 to read from
>     CNTFRQ_EL0
>

Reviewed-by: Ard Biesheuvel <ardb@kernel.org>

Pushed as 81ec441723a0..e20ee6e3a65d

Thanks!

>  Platform/ARM/JunoPkg/ArmJuno.dsc | 6 +++---
>  Platform/ARM/JunoPkg/ArmJuno.fdf | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> --
> 2.30.2
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-02-21  8:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-21  1:02 [PATCH edk2-platforms v2 0/2] Platform/ARM/JunoPkg: Timer fixes Rebecca Cran
2023-02-21  1:02 ` [PATCH edk2-platforms v2 1/2] Platform/ARM/JunoPkg: Switch to MdeModulePkg/Universal/Metronome driver Rebecca Cran
2023-02-21  8:44   ` Ard Biesheuvel
2023-02-21  1:02 ` [PATCH edk2-platforms v2 2/2] Platform/ARM/JunoPkg: Set PcdArmArchTimerFreqInHz to 0 to read from CNTFRQ_EL0 Rebecca Cran
2023-02-21  8:49 ` [PATCH edk2-platforms v2 0/2] Platform/ARM/JunoPkg: Timer fixes Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox