* [PATCH usb v2] usb: typec: tcpm: align SOP' Soft Reset handling with SOP [not found] <avw6CtZkJqvwj4eL@black.igk.intel.com> @ 2026-11-17 11:36 ` memoriaru 2026-11-20 13:16 ` Heikki Krogerus 0 siblings, 1 reply; 2+ 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] 2+ messages in thread
* Re: [PATCH usb v2] usb: typec: tcpm: align SOP' Soft Reset handling with SOP 2026-11-17 11:36 ` [PATCH usb v2] usb: typec: tcpm: align SOP' Soft Reset handling with SOP memoriaru @ 2026-11-20 13:16 ` Heikki Krogerus 0 siblings, 0 replies; 2+ messages in thread From: Heikki Krogerus @ 2026-11-20 13:16 UTC (permalink / raw) To: memoriaru; +Cc: linux-usb, badhri, gregkh, stable On Tue, Nov 17, 2026 at 07:36:21PM +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'") > 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 How did you prepare this patch? It doesn't apply. I do hope you have actually compiled this at some point. Thanks, > @@ -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] 2+ messages in thread
end of thread, other threads:[~2026-11-20 13:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <avw6CtZkJqvwj4eL@black.igk.intel.com>
2026-11-17 11:36 ` [PATCH usb v2] usb: typec: tcpm: align SOP' Soft Reset handling with SOP memoriaru
2026-11-20 13:16 ` Heikki Krogerus
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox