* [PATCH usb] usb: typec: tcpm: align SOP' Soft Reset handling with SOP
@ 2026-11-13 22:20 memoriaru
2026-11-17 11:27 ` Heikki Krogerus
0 siblings, 1 reply; 3+ messages in thread
From: memoriaru @ 2026-11-13 22:20 UTC (permalink / raw)
To: linux-usb; +Cc: heikki.krogerus, badhri, gregkh, memoriaru
From: Zhang Hewei <memoriaru@foxmail.com>
The PD message duplicate-check and the SOFT_RESET state handling treat
the SOP and SOP' channels differently:
- tcpm_pd_rx_handler() exempts PD_CTRL_SOFT_RESET from the MessageID
duplicate check on the SOP path (the USB PD spec 6.6.1.2 note: a
Soft_Reset Message always carries MessageID zero, so the duplicate
check must not drop it), but the SOP' branch of the same switch has
no such exemption. A cable that sends a second Soft Reset over SOP'
(MessageID zero again) has that message silently dropped by the
stale rx_msgid_prime comparison, and the cable-side re-negotiation
stalls.
- run_state_machine()'s SOFT_RESET case resets message_id/rx_msgid but
not message_id_prime/rx_msgid_prime, while the initiator path
(SOFT_RESET_SEND, SOP_PRIME branch) resets both counter pairs. After
a responder-side soft reset the prime counters stay stale.
Reset the prime counters together with the SOP counters and exempt
Soft Reset from the SOP' duplicate check, aligning the SOP' handling
with the SOP path.
Found by code inspection; a software TCPC stub was built for the
responder path.
Fixes: 6bd181ba60 ("usb: typec: tcpm: add control message support to sop'")
Signed-off-by: Zhang Hewei <memoriaru@foxmail.com>
---
tcpm.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tcpm.c b/tcpm.c
index bb90211..95f748d 100644
--- a/tcpm.c
+++ b/tcpm.c
@@ -4200,7 +4200,8 @@ static void tcpm_pd_rx_handler(struct kthread_work *work)
*/
switch (rx_sop_type) {
case TCPC_TX_SOP_PRIME:
- if (msgid == port->rx_msgid_prime)
+ if (msgid == port->rx_msgid_prime &&
+ type != PD_CTRL_SOFT_RESET)
goto done;
port->rx_msgid_prime = msgid;
break;
@@ -6193,6 +6194,8 @@ static void run_state_machine(struct tcpm_port *port)
case SOFT_RESET:
port->message_id = 0;
port->rx_msgid = -1;
+ port->message_id_prime = 0;
+ port->rx_msgid_prime = -1;
/* remove existing capabilities */
tcpm_partner_source_caps_reset(port);
tcpm_pd_send_control(port, PD_CTRL_ACCEPT, TCPC_TX_SOP);
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH usb] usb: typec: tcpm: align SOP' Soft Reset handling with SOP
2026-11-13 22:20 [PATCH usb] usb: typec: tcpm: align SOP' Soft Reset handling with SOP memoriaru
@ 2026-11-17 11:27 ` Heikki Krogerus
2026-11-17 11:36 ` [PATCH usb v2] " memoriaru
0 siblings, 1 reply; 3+ messages in thread
From: Heikki Krogerus @ 2026-11-17 11:27 UTC (permalink / raw)
To: memoriaru, RD Babiera; +Cc: linux-usb, badhri, gregkh
On Sat, Nov 14, 2026 at 06:20:54AM +0800, memoriaru@foxmail.com wrote:
> From: Zhang Hewei <memoriaru@foxmail.com>
>
> The PD message duplicate-check and the SOFT_RESET state handling treat
> the SOP and SOP' channels differently:
>
> - tcpm_pd_rx_handler() exempts PD_CTRL_SOFT_RESET from the MessageID
> duplicate check on the SOP path (the USB PD spec 6.6.1.2 note: a
> Soft_Reset Message always carries MessageID zero, so the duplicate
> check must not drop it), but the SOP' branch of the same switch has
> no such exemption. A cable that sends a second Soft Reset over SOP'
> (MessageID zero again) has that message silently dropped by the
> stale rx_msgid_prime comparison, and the cable-side re-negotiation
> stalls.
>
> - run_state_machine()'s SOFT_RESET case resets message_id/rx_msgid but
> not message_id_prime/rx_msgid_prime, while the initiator path
> (SOFT_RESET_SEND, SOP_PRIME branch) resets both counter pairs. After
> a responder-side soft reset the prime counters stay stale.
>
> Reset the prime counters together with the SOP counters and exempt
> Soft Reset from the SOP' duplicate check, aligning the SOP' handling
> with the SOP path.
>
> Found by code inspection; a software TCPC stub was built for the
> responder path.
>
> Fixes: 6bd181ba60 ("usb: typec: tcpm: add control message support to sop'")
+RD
> Signed-off-by: Zhang Hewei <memoriaru@foxmail.com>
You should CC stable:
https://docs.kernel.org/process/submitting-patches.html#select-the-recipients-for-your-patch
Thanks,
> ---
> tcpm.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tcpm.c b/tcpm.c
> index bb90211..95f748d 100644
> --- a/tcpm.c
> +++ b/tcpm.c
> @@ -4200,7 +4200,8 @@ static void tcpm_pd_rx_handler(struct kthread_work *work)
> */
> switch (rx_sop_type) {
> case TCPC_TX_SOP_PRIME:
> - if (msgid == port->rx_msgid_prime)
> + if (msgid == port->rx_msgid_prime &&
> + type != PD_CTRL_SOFT_RESET)
> goto done;
> port->rx_msgid_prime = msgid;
> break;
> @@ -6193,6 +6194,8 @@ static void run_state_machine(struct tcpm_port *port)
> case SOFT_RESET:
> port->message_id = 0;
> port->rx_msgid = -1;
> + port->message_id_prime = 0;
> + port->rx_msgid_prime = -1;
> /* remove existing capabilities */
> tcpm_partner_source_caps_reset(port);
> tcpm_pd_send_control(port, PD_CTRL_ACCEPT, TCPC_TX_SOP);
> --
> 2.39.5 (Apple Git-154)
--
heikki
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH usb v2] usb: typec: tcpm: align SOP' Soft Reset handling with SOP
2026-11-17 11:27 ` Heikki Krogerus
@ 2026-11-17 11:36 ` memoriaru
0 siblings, 0 replies; 3+ messages in thread
From: memoriaru @ 2026-11-17 11:36 UTC (permalink / raw)
To: linux-usb; +Cc: heikki.krogerus, badhri, gregkh, stable, memoriaru
From: Zhang Hewei <memoriaru@foxmail.com>
The PD message duplicate-check and the SOFT_RESET state handling treat
the SOP and SOP' channels differently:
- tcpm_pd_rx_handler() exempts PD_CTRL_SOFT_RESET from the MessageID
duplicate check on the SOP path (the USB PD spec 6.6.1.2 note: a
Soft_Reset Message always carries MessageID zero, so the duplicate
check must not drop it), but the SOP' branch of the same switch has
no such exemption. A cable that sends a second Soft Reset over SOP'
(MessageID zero again) has that message silently dropped by the
stale rx_msgid_prime comparison, and the cable-side re-negotiation
stalls.
- run_state_machine()'s SOFT_RESET case resets message_id/rx_msgid but
not message_id_prime/rx_msgid_prime, while the initiator path
(SOFT_RESET_SEND, SOP_PRIME branch) resets both counter pairs. After
a responder-side soft reset the prime counters stay stale.
Reset the prime counters together with the SOP counters and exempt
Soft Reset from the SOP' duplicate check, aligning the SOP' handling
with the SOP path.
Found by code inspection; a software TCPC stub was built for the
responder path.
Fixes: 6bd181ba60 ("usb: typec: tcpm: add control message support to sop'")
Cc: stable@vger.kernel.org
Signed-off-by: Zhang Hewei <memoriaru@foxmail.com>
---
tcpm.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tcpm.c b/tcpm.c
index bb90211..95f748d 100644
--- a/tcpm.c
+++ b/tcpm.c
@@ -4200,7 +4200,8 @@ static void tcpm_pd_rx_handler(struct kthread_work *work)
*/
switch (rx_sop_type) {
case TCPC_TX_SOP_PRIME:
- if (msgid == port->rx_msgid_prime)
+ if (msgid == port->rx_msgid_prime &&
+ type != PD_CTRL_SOFT_RESET)
goto done;
port->rx_msgid_prime = msgid;
break;
@@ -6193,6 +6194,8 @@ static void run_state_machine(struct tcpm_port *port)
case SOFT_RESET:
port->message_id = 0;
port->rx_msgid = -1;
+ port->message_id_prime = 0;
+ port->rx_msgid_prime = -1;
/* remove existing capabilities */
tcpm_partner_source_caps_reset(port);
tcpm_pd_send_control(port, PD_CTRL_ACCEPT, TCPC_TX_SOP);
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-17 11:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13 22:20 [PATCH usb] usb: typec: tcpm: align SOP' Soft Reset handling with SOP memoriaru
2026-11-17 11:27 ` Heikki Krogerus
2026-11-17 11:36 ` [PATCH usb v2] " memoriaru
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox