[PATCH] usb: typec: ucsi: recover from silent PPM completion in sync_control
From: Chia-Lin Kao (AceLan)
Date: Mon Jun 15 2026 - 22:01:39 EST
Some firmware completes UCSI commands and sets COMMAND_COMPLETE (or
ACK_COMPLETE for ACK_CC_CI) in CCI but never fires the ACPI notify that
would wake ucsi_sync_control_common(). The driver then times out after
5 seconds and returns -ETIMEDOUT, even though the EC finished the command
successfully.
Fix this by polling CCI once via poll_cci() on timeout. If the relevant
completion bit is already set, the EC finished silently; fall through to
out_clear_bit so the normal read_cci()/read_message_in() path retrieves
the data and ucsi_run_command() issues ACK_CC_CI as usual. Only return
-ETIMEDOUT when the EC has genuinely not completed the command.
Fixes: 584e8df58942 ("usb: typec: ucsi: extract common code for command handling")
Signed-off-by: Chia-Lin Kao (AceLan) <acelan.kao@xxxxxxxxxxxxx>
---
drivers/usb/typec/ucsi/ucsi.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index 9eeb38e7472c0..ed5b10d8b58ef 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -91,8 +91,28 @@ int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci,
if (ret)
goto out_clear_bit;
- if (!wait_for_completion_timeout(&ucsi->complete, 5 * HZ))
- ret = -ETIMEDOUT;
+ if (!wait_for_completion_timeout(&ucsi->complete, 5 * HZ)) {
+ u32 polled_cci = 0;
+
+ /*
+ * Notification from EC did not arrive. Poll once to check
+ * whether the PPM actually finished without firing a notify.
+ * If poll_cci() fails, polled_cci stays 0 and we correctly
+ * report -ETIMEDOUT below.
+ */
+ ucsi->ops->poll_cci(ucsi, &polled_cci);
+
+ if ((ack && (polled_cci & UCSI_CCI_ACK_COMPLETE)) ||
+ (!ack && (polled_cci & UCSI_CCI_COMMAND_COMPLETE))) {
+ /*
+ * EC completed the command silently. Proceed to
+ * out_clear_bit which reads CCI+data normally, and
+ * ucsi_run_command() will issue ACK_CC_CI as usual.
+ */
+ } else {
+ ret = -ETIMEDOUT;
+ }
+ }
out_clear_bit:
if (ack)
--
2.53.0