<p>Philipp Deppenwiese <strong>merged</strong> this change.</p><p><a href="https://review.coreboot.org/25322">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  build bot (Jenkins): Verified
  Paul Menzel: Looks good to me, but someone else must approve
  Philipp Deppenwiese: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">drivers/pc80/tpm: Add some optional delay to tis_readresponse()<br><br>Certain TPMs (observed on Infineon SLB9635 installed on revolve 810 g1)<br>seem to need some delay between tis_wait_valid() and<br>tis_has_valid_data(), or tis_has_valid_data() may invalidly return 0,<br>ending the loop immaturely with some bytes left unread, and fail to<br>pass the check below, causing the current command not finalized by<br>tis_command_ready(), and blocking any later tis_wait_ready().<br><br>This time the added delay is controlled by a Kconfig option<br>TPM_RDRESP_NEED_DELAY.<br><br>Change-Id: Ic2a2f252e72a0bbce51e2863f8e46647b1570ba5<br>Signed-off-by: Bill XIE <persmule@gmail.com><br>Reviewed-on: https://review.coreboot.org/25322<br>Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net><br>Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com><br>Tested-by: build bot (Jenkins) <no-reply@coreboot.org><br>---<br>M src/drivers/pc80/tpm/Kconfig<br>M src/drivers/pc80/tpm/tis.c<br>2 files changed, 17 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/drivers/pc80/tpm/Kconfig b/src/drivers/pc80/tpm/Kconfig</span><br><span>index 3bd9083..879b4a2 100644</span><br><span>--- a/src/drivers/pc80/tpm/Kconfig</span><br><span>+++ b/src/drivers/pc80/tpm/Kconfig</span><br><span>@@ -46,3 +46,12 @@</span><br><span>     depends on LPC_TPM</span><br><span>   help</span><br><span>           Deactivate TPM by issuing deactivate command.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+config TPM_RDRESP_NEED_DELAY</span><br><span style="color: hsl(120, 100%, 40%);">+       bool "Enable Delay Workaround for TPM"</span><br><span style="color: hsl(120, 100%, 40%);">+      default n</span><br><span style="color: hsl(120, 100%, 40%);">+     depends on LPC_TPM</span><br><span style="color: hsl(120, 100%, 40%);">+    help</span><br><span style="color: hsl(120, 100%, 40%);">+    Certain TPMs seem to need some delay when reading response</span><br><span style="color: hsl(120, 100%, 40%);">+    to work around a race-condition-related issue, possibly</span><br><span style="color: hsl(120, 100%, 40%);">+       caused by ill-programmed TPM firmware.</span><br><span>diff --git a/src/drivers/pc80/tpm/tis.c b/src/drivers/pc80/tpm/tis.c</span><br><span>index 9802654..714b7e5 100644</span><br><span>--- a/src/drivers/pc80/tpm/tis.c</span><br><span>+++ b/src/drivers/pc80/tpm/tis.c</span><br><span>@@ -595,6 +595,14 @@</span><br><span>                 if (offset == expected_count)</span><br><span>                        break;  /* We got all we need */</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+          /*</span><br><span style="color: hsl(120, 100%, 40%);">+             * Certain TPMs seem to need some delay between tis_wait_valid()</span><br><span style="color: hsl(120, 100%, 40%);">+               * and tis_has_valid_data(), or some race-condition-related</span><br><span style="color: hsl(120, 100%, 40%);">+            * issue will occur.</span><br><span style="color: hsl(120, 100%, 40%);">+           */</span><br><span style="color: hsl(120, 100%, 40%);">+           if (IS_ENABLED(CONFIG_TPM_RDRESP_NEED_DELAY))</span><br><span style="color: hsl(120, 100%, 40%);">+                 udelay(10);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>        } while (tis_has_valid_data(locality));</span><br><span> </span><br><span>  /* * Make sure we indeed read all there was. */</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/25322">change 25322</a>. To unsubscribe, or for help writing mail filters, 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/25322"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Ic2a2f252e72a0bbce51e2863f8e46647b1570ba5 </div>
<div style="display:none"> Gerrit-Change-Number: 25322 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: Bill XIE <persmule@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Bill XIE <persmule@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Furquan Shaikh <furquan@google.com> </div>
<div style="display:none"> Gerrit-Reviewer: Paul Menzel <paulepanter@users.sourceforge.net> </div>
<div style="display:none"> Gerrit-Reviewer: Philipp Deppenwiese <zaolin.daisuki@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org> </div>
<div style="display:none"> Gerrit-CC: Aaron Durbin <adurbin@chromium.org> </div>