* [PATCH] usb: typec: ucsi: recover from silent PPM completion in sync_control
@ 2026-06-16 2:00 Chia-Lin Kao (AceLan)
2026-06-16 2:26 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Chia-Lin Kao (AceLan) @ 2026-06-16 2:00 UTC (permalink / raw)
To: heikki.krogerus, gregkh
Cc: bleung, jthies, myrrhperiwinkle, pooja.katiyar, abelvesa,
yuanhsinte, johan, dmitry.baryshkov, linux-usb, linux-kernel
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@canonical.com>
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] usb: typec: ucsi: recover from silent PPM completion in sync_control
2026-06-16 2:00 [PATCH] usb: typec: ucsi: recover from silent PPM completion in sync_control Chia-Lin Kao (AceLan)
@ 2026-06-16 2:26 ` Greg KH
2026-07-08 2:17 ` [PATCH v2] " Chia-Lin Kao (AceLan)
2026-07-08 2:24 ` AceLan Kao
0 siblings, 2 replies; 5+ messages in thread
From: Greg KH @ 2026-06-16 2:26 UTC (permalink / raw)
To: Chia-Lin Kao (AceLan)
Cc: heikki.krogerus, bleung, jthies, myrrhperiwinkle, pooja.katiyar,
abelvesa, yuanhsinte, johan, dmitry.baryshkov, linux-usb,
linux-kernel
On Tue, Jun 16, 2026 at 10:00:44AM +0800, Chia-Lin Kao (AceLan) wrote:
> 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@canonical.com>
> ---
> 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
>
>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- You have marked a patch with a "Fixes:" tag for a commit that is in an
older released kernel, yet you do not have a cc: stable line in the
signed-off-by area at all, which means that the patch will not be
applied to any older kernel releases. To properly fix this, please
follow the documented rules in the
Documentation/process/stable-kernel-rules.rst file for how to resolve
this.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] usb: typec: ucsi: recover from silent PPM completion in sync_control
2026-06-16 2:26 ` Greg KH
@ 2026-07-08 2:17 ` Chia-Lin Kao (AceLan)
2026-07-08 2:24 ` AceLan Kao
1 sibling, 0 replies; 5+ messages in thread
From: Chia-Lin Kao (AceLan) @ 2026-07-08 2:17 UTC (permalink / raw)
To: Heikki Krogerus, Greg Kroah-Hartman
Cc: Benson Leung, Jameson Thies, Myrrh Periwinkle, Pooja Katiyar,
Hsin-Te Yuan, Johan Hovold, Dmitry Baryshkov, linux-usb,
linux-kernel
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>
---
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 | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index 9eeb38e7472c..deda7123b5d1 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -91,8 +91,29 @@ 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() 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 ((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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2] usb: typec: ucsi: recover from silent PPM completion in sync_control
2026-06-16 2:26 ` Greg KH
2026-07-08 2:17 ` [PATCH v2] " Chia-Lin Kao (AceLan)
@ 2026-07-08 2:24 ` AceLan Kao
2026-07-08 5:09 ` Greg Kroah-Hartman
1 sibling, 1 reply; 5+ messages in thread
From: AceLan Kao @ 2026-07-08 2:24 UTC (permalink / raw)
To: Heikki Krogerus, Greg Kroah-Hartman
Cc: Benson Leung, Jameson Thies, Myrrh Periwinkle, Pooja Katiyar,
Hsin-Te Yuan, Johan Hovold, Dmitry Baryshkov, linux-usb,
linux-kernel
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>
---
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 | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index 9eeb38e7472c..deda7123b5d1 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -91,8 +91,29 @@ 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() 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 ((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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] usb: typec: ucsi: recover from silent PPM completion in sync_control
2026-07-08 2:24 ` AceLan Kao
@ 2026-07-08 5:09 ` Greg Kroah-Hartman
0 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2026-07-08 5:09 UTC (permalink / raw)
To: AceLan Kao
Cc: Heikki Krogerus, Benson Leung, Jameson Thies, Myrrh Periwinkle,
Pooja Katiyar, Hsin-Te Yuan, Johan Hovold, Dmitry Baryshkov,
linux-usb, linux-kernel
On Wed, Jul 08, 2026 at 10:24:20AM +0800, AceLan Kao wrote:
> 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>
>
> ---
> 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 | 25 +++++++++++++++++++++++--
> 1 file changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index 9eeb38e7472c..deda7123b5d1 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -91,8 +91,29 @@ 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() 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 ((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;
> + }
This is an odd way to write an if () statement, why not reverse it so
that there is no need for an else {} at all?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-08 5:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-16 2:00 [PATCH] usb: typec: ucsi: recover from silent PPM completion in sync_control Chia-Lin Kao (AceLan)
2026-06-16 2:26 ` Greg KH
2026-07-08 2:17 ` [PATCH v2] " Chia-Lin Kao (AceLan)
2026-07-08 2:24 ` AceLan Kao
2026-07-08 5:09 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox