<p>Nico Huber has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/20647">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gma skl: Prevent race by late timeout initialization<br><br>We initialized a timeout variable before the first event on the other<br>side (i.e. us sending a request to PCODE). With very slow debug output<br>sending the request itself might take longer than the timeout period.<br><br>Reorder the code to initialize the timeout after the first request and<br>thereby make sure that we always try at least twice.<br><br>Change-Id: I8cdeb3e36d7eafbef8a1a8e13670f3f9838a2f38<br>Signed-off-by: Nico Huber <nico.huber@secunet.com><br>---<br>M common/skylake/hw-gfx-gma-power_and_clocks_skylake.adb<br>1 file changed, 13 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/47/20647/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/common/skylake/hw-gfx-gma-power_and_clocks_skylake.adb b/common/skylake/hw-gfx-gma-power_and_clocks_skylake.adb<br>index 5c9231e..9ccad81 100644<br>--- a/common/skylake/hw-gfx-gma-power_and_clocks_skylake.adb<br>+++ b/common/skylake/hw-gfx-gma-power_and_clocks_skylake.adb<br>@@ -282,21 +282,28 @@<br> (Register => Registers.LCPLL1_CTL,<br> Mask => LCPLL1_CTL_PLL_LOCK);<br> <br>+ GT_Mailbox_Write<br>+ (MBox => SKL_PCODE_CDCLK_CONTROL,<br>+ Value => SKL_CDCLK_PREPARE_FOR_CHANGE);<br>+ -- Start counting *after* the first request!<br> CDClk_Change_Timeout := Time.MS_From_Now (3);<br> loop<br>- GT_Mailbox_Write<br>- (MBox => SKL_PCODE_CDCLK_CONTROL,<br>- Value => SKL_CDCLK_PREPARE_FOR_CHANGE);<br> Timed_Out := Time.Timed_Out (CDClk_Change_Timeout);<br> Registers.Read (Registers.GT_MAILBOX_DATA, MBox_Data0);<br>- if (MBox_Data0 and SKL_CDCLK_READY_FOR_CHANGE) =<br>- SKL_CDCLK_READY_FOR_CHANGE<br>- then<br>+ if (MBox_Data0 and SKL_CDCLK_READY_FOR_CHANGE) /= 0 then<br>+ -- Ignore timeout if we succeeded anyway.<br> Timed_Out := False;<br> exit;<br> end if;<br> exit when Timed_Out;<br>+<br>+ -- Repeat request:<br>+ GT_Mailbox_Write<br>+ (MBox => SKL_PCODE_CDCLK_CONTROL,<br>+ Value => SKL_CDCLK_PREPARE_FOR_CHANGE);<br> end loop;<br>+ pragma Debug (Timed_Out, Debug.Put_Line<br>+ ("ERROR: PCODE not ready for frequency change after 3ms."));<br> <br> if not Timed_Out then<br> GT_Mailbox_Write<br></pre><p>To view, visit <a href="https://review.coreboot.org/20647">change 20647</a>. To unsubscribe, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/20647"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: libgfxinit </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I8cdeb3e36d7eafbef8a1a8e13670f3f9838a2f38 </div>
<div style="display:none"> Gerrit-Change-Number: 20647 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Nico Huber <nico.h@gmx.de> </div>