From: AceLan Kao <acelan.kao@canonical.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Benson Leung <bleung@chromium.org>,
Andrei Kuchynski <akuchynski@chromium.org>,
Jameson Thies <jthies@google.com>,
Pooja Katiyar <pooja.katiyar@intel.com>,
Hsin-Te Yuan <yuanhsinte@chromium.org>,
Johan Hovold <johan@kernel.org>,
Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3] usb: typec: ucsi: recover from silent PPM completion in sync_control
Date: Tue, 1 Sep 2026 10:27:54 +0800 [thread overview]
Message-ID: <20260901022754.3102934-1-acelan.kao@canonical.com> (raw)
From: "Chia-Lin Kao (AceLan)" <acelan.kao@canonical.com>
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.
Guard the poll_cci() call with a NULL check: if a backend does not
provide the op, skip the poll and keep reporting -ETIMEDOUT rather than
dereferencing a NULL function pointer.
Fixes: 584e8df58942 ("usb: typec: ucsi: extract common code for command handling")
Cc: <stable@vger.kernel.org> # 6.14+
Signed-off-by: Chia-Lin Kao (AceLan) <acelan.kao@canonical.com>
---
v2 -> v3:
- rebase and resolve conflicts against v7.2
- Invert the post-timeout completion check so the empty "silent
completion" branch falls straight through to out_clear_bit instead
of being an empty if {} with the real logic in the else, as pointed
out in Greg's review.
v1 -> v2:
- Add Cc: <stable@vger.kernel.org> # 6.14+ as flagged by Greg's patch bot:
the Fixes: tag targets a commit already in released kernels, so the fix
must be nominated for stable. Scoped to 6.14+ because poll_cci only
exists from that release (absent in 6.11-6.13).
- Guard the poll_cci() call with a NULL check to avoid dereferencing a
NULL function pointer when a backend does not provide the op.
---
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 bef3f9b71d718..0363ed127a567 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -92,8 +92,28 @@ int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci,
goto out_clear_bit;
if (!wait_for_completion_timeout(&ucsi->complete,
- msecs_to_jiffies(UCSI_TIMEOUT_MS)))
- ret = -ETIMEDOUT;
+ msecs_to_jiffies(UCSI_TIMEOUT_MS))) {
+ 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() is missing or fails, polled_cci stays 0 and we
+ * correctly report -ETIMEDOUT below.
+ */
+ if (ucsi->ops->poll_cci)
+ ucsi->ops->poll_cci(ucsi, &polled_cci);
+
+ /*
+ * If the relevant completion bit is not set, the EC has not
+ * completed the command; report the timeout. Otherwise fall
+ * through to out_clear_bit, which reads CCI+data normally,
+ * and ucsi_run_command() will issue ACK_CC_CI as usual.
+ */
+ if (!((ack && (polled_cci & UCSI_CCI_ACK_COMPLETE)) ||
+ (!ack && (polled_cci & UCSI_CCI_COMMAND_COMPLETE))))
+ ret = -ETIMEDOUT;
+ }
out_clear_bit:
if (ack)
--
2.53.0
next reply other threads:[~2026-09-01 2:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 2:27 AceLan Kao [this message]
2026-10-01 3:25 ` AceLan Kao
2026-12-03 19:26 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260901022754.3102934-1-acelan.kao@canonical.com \
--to=acelan.kao@canonical.com \
--cc=akuchynski@chromium.org \
--cc=bleung@chromium.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=johan@kernel.org \
--cc=jthies@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=pooja.katiyar@intel.com \
--cc=yuanhsinte@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®