[coreboot-gerrit] Change in libgfxinit[master]: gma skl: Prevent race by late timeout initialization

Nico Huber (Code Review) gerrit at coreboot.org
Wed Jul 19 14:47:34 CEST 2017


Nico Huber has uploaded this change for review. ( https://review.coreboot.org/20647


Change subject: gma skl: Prevent race by late timeout initialization
......................................................................

gma skl: Prevent race by late timeout initialization

We initialized a timeout variable before the first event on the other
side (i.e. us sending a request to PCODE). With very slow debug output
sending the request itself might take longer than the timeout period.

Reorder the code to initialize the timeout after the first request and
thereby make sure that we always try at least twice.

Change-Id: I8cdeb3e36d7eafbef8a1a8e13670f3f9838a2f38
Signed-off-by: Nico Huber <nico.huber at secunet.com>
---
M common/skylake/hw-gfx-gma-power_and_clocks_skylake.adb
1 file changed, 13 insertions(+), 6 deletions(-)



  git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/47/20647/1

diff --git a/common/skylake/hw-gfx-gma-power_and_clocks_skylake.adb b/common/skylake/hw-gfx-gma-power_and_clocks_skylake.adb
index 5c9231e..9ccad81 100644
--- a/common/skylake/hw-gfx-gma-power_and_clocks_skylake.adb
+++ b/common/skylake/hw-gfx-gma-power_and_clocks_skylake.adb
@@ -282,21 +282,28 @@
         (Register    => Registers.LCPLL1_CTL,
          Mask        => LCPLL1_CTL_PLL_LOCK);
 
+      GT_Mailbox_Write
+        (MBox        => SKL_PCODE_CDCLK_CONTROL,
+         Value       => SKL_CDCLK_PREPARE_FOR_CHANGE);
+      -- Start counting *after* the first request!
       CDClk_Change_Timeout := Time.MS_From_Now (3);
       loop
-         GT_Mailbox_Write
-           (MBox        => SKL_PCODE_CDCLK_CONTROL,
-            Value       => SKL_CDCLK_PREPARE_FOR_CHANGE);
          Timed_Out := Time.Timed_Out (CDClk_Change_Timeout);
          Registers.Read (Registers.GT_MAILBOX_DATA, MBox_Data0);
-         if (MBox_Data0 and SKL_CDCLK_READY_FOR_CHANGE) =
-            SKL_CDCLK_READY_FOR_CHANGE
-         then
+         if (MBox_Data0 and SKL_CDCLK_READY_FOR_CHANGE) /= 0 then
+            -- Ignore timeout if we succeeded anyway.
             Timed_Out := False;
             exit;
          end if;
          exit when Timed_Out;
+
+         -- Repeat request:
+         GT_Mailbox_Write
+           (MBox        => SKL_PCODE_CDCLK_CONTROL,
+            Value       => SKL_CDCLK_PREPARE_FOR_CHANGE);
       end loop;
+      pragma Debug (Timed_Out, Debug.Put_Line
+        ("ERROR: PCODE not ready for frequency change after 3ms."));
 
       if not Timed_Out then
          GT_Mailbox_Write

-- 
To view, visit https://review.coreboot.org/20647
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8cdeb3e36d7eafbef8a1a8e13670f3f9838a2f38
Gerrit-Change-Number: 20647
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h at gmx.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20170719/fc241c5a/attachment.html>


More information about the coreboot-gerrit mailing list