public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Jeff Fan <jeff.fan@intel.com>
To: edk2-devel@lists.01.org
Cc: Feng Tian <feng.tian@intel.com>,
	Kinney, Michael D <michael.d.kinney@intel.com>,
	Ruiyu Ni <ruiyu.ni@intel.com>
Subject: [PATCH 5/6] UefiCpuPkg/MpInitLib: Disable and restore system timer interrupt
Date: Mon, 26 Dec 2016 19:21:01 +0800	[thread overview]
Message-ID: <20161226112102.25512-6-jeff.fan@intel.com> (raw)
In-Reply-To: <20161226112102.25512-1-jeff.fan@intel.com>

We need to disable system timer interrup to avoid generating the pending
interrupt on the old BSP.

Cc: Feng Tian <feng.tian@intel.com>
Cc: Kinney, Michael D <michael.d.kinney@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
---
 UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf |  3 +++
 UefiCpuPkg/Library/MpInitLib/DxeMpLib.c       | 31 ++++++++++++++++++++++++++-
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
index cc4f2e9..9751ba1 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
@@ -57,6 +57,9 @@
   UefiBootServicesTableLib
   DebugAgentLib
 
+[Protocols]
+  gEfiTimerArchProtocolGuid                     ## SOMETIMES_CONSUMES
+
 [Guids]
   gEfiEventExitBootServicesGuid                 ## CONSUMES  ## Event
   gEfiEventLegacyBootGuid                       ## CONSUMES  ## Event
diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index 733a9fb..5e50b4c 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -18,6 +18,8 @@
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/DebugAgentLib.h>
 
+#include <Protocol/Timer.h>
+
 #define  AP_CHECK_INTERVAL     (EFI_TIMER_PERIOD_MILLISECONDS (100))
 #define  AP_SAFE_STACK_SIZE    128
 
@@ -645,11 +647,38 @@ MpInitLibSwitchBSP (
   IN BOOLEAN                   EnableOldBSP
   )
 {
-  EFI_STATUS            Status;
+  EFI_STATUS                   Status;
+  EFI_TIMER_ARCH_PROTOCOL      *Timer;
+  UINT64                       TimerPeriod;
 
+  //
+  // Locate Timer Arch Protocol
+  //
+  Status = gBS->LocateProtocol (&gEfiTimerArchProtocolGuid, NULL, (VOID **) &Timer);
+  if (EFI_ERROR (Status)) {
+    Timer = NULL;
+  }
+
+  if (Timer != NULL) {
+    //
+    // Save current rate of DXE Timer
+    //
+    Timer->GetTimerPeriod (Timer, &TimerPeriod);
+    //
+    // Disable DXE Timer and drain pending interrupts
+    //
+    Timer->SetTimerPeriod (Timer, 0);
+  }
 
   Status = SwitchBSPWorker (ProcessorNumber, EnableOldBSP);
 
+  if (Timer != NULL) {
+    //
+    // Enable and restore rate of DXE Timer
+    //
+    Timer->SetTimerPeriod (Timer, TimerPeriod);
+  }
+
   return Status;
 }
 
-- 
2.9.3.windows.2



  parent reply	other threads:[~2016-12-26 11:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-26 11:20 [PATCH 0/6] Support source debugging on DXE AP function Jeff Fan
2016-12-26 11:20 ` [PATCH 1/6] UefiCpuPkg/DxeMpInitLib: Support source debugging on " Jeff Fan
2016-12-26 11:20 ` [PATCH 2/6] UefiCpuPkg/MpInitLib: Sync BSP's local APIC timer settings to APs Jeff Fan
2016-12-26 11:20 ` [PATCH 3/6] UefiCpuPkg/MpInitLib: Move save/restore interrupt to SwitchBSPWorker() Jeff Fan
2016-12-26 11:21 ` [PATCH 4/6] UefiCpuPkg/MpInitLib: Swap local APIC timer interrupt state Jeff Fan
2016-12-26 11:21 ` Jeff Fan [this message]
2016-12-26 11:21 ` [PATCH 6/6] UefiCpuPkg/MpInitLib: Set new AP to idle state after switching BSP Jeff Fan
2016-12-28  7:33 ` [PATCH 0/6] Support source debugging on DXE AP function Tian, Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161226112102.25512-6-jeff.fan@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox