From 92229de1df4976c93654709fdc164525356b266d Mon Sep 17 00:00:00 2001 From: Keith Short Date: Thu, 2 Sep 2021 09:01:37 -0600 Subject: ps8xxx: Fix PD task hang if PS8xxx device is missing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CL:3084331 added logic to retry reading the PS8xxx FW version register to ensure the chip has woken up from low power mode. If the PS8xxx device is damaged/missing, there was an unbounded loop so the initialization never completed, hanging the corresponding PD task. BUG=b:198619831 BRANCH=none TEST=Verify herobrine boots AP when the battery and right I/O board are disconnected. Also observe "LPM recovery failed" reported on the console for the missing type-C port. Signed-off-by: Keith Short Change-Id: I578f20a9a63dd54fc777dcc0acc26a7540a1bb46 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3139975 Reviewed-by: Michał Barnaś Reviewed-by: Wai-Hong Tam Commit-Queue: Wai-Hong Tam --- driver/tcpm/ps8xxx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'driver') diff --git a/driver/tcpm/ps8xxx.c b/driver/tcpm/ps8xxx.c index 1742f19aeb..3bc85f48e8 100644 --- a/driver/tcpm/ps8xxx.c +++ b/driver/tcpm/ps8xxx.c @@ -614,6 +614,9 @@ static int ps8xxx_lpm_recovery_delay(int port) val = 0; for (;;) { + if (timestamp_expired(deadline, NULL)) + return EC_ERROR_TIMEOUT; + status = tcpc_read(port, fw_reg, &val); if (status != EC_SUCCESS) { /* wait for chip to wake up */ @@ -623,8 +626,6 @@ static int ps8xxx_lpm_recovery_delay(int port) if (val != 0) break; msleep(1); - if (timestamp_expired(deadline, NULL)) - return EC_ERROR_TIMEOUT; } return EC_SUCCESS; -- cgit v1.2.1