* [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; 6+ 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] 6+ 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 2026-11-20 18:34 ` memoriaru ` (2 more replies) 0 siblings, 3 replies; 6+ 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] 6+ messages in thread
* Re: [PATCH usb v2] usb: typec: tcpm: align SOP' Soft Reset handling with SOP 2026-11-20 13:16 ` Heikki Krogerus @ 2026-11-20 18:34 ` memoriaru 2026-11-20 19:25 ` memoriaru [not found] ` <1795204200.cover.tcpm-v4@foxmail.com> 2 siblings, 0 replies; 6+ messages in thread From: memoriaru @ 2026-11-20 18:34 UTC (permalink / raw) To: heikki.krogerus; +Cc: linux-usb, badhri, gregkh, stable From: Zhang Hewei <memoriaru@foxmail.com> Resending as plain text -- the previous two copies went out in HTML format and were rejected by the vger list infrastructure. Please use this one and disregard the duplicates. Hi Heikki, Apologies -- you are right, and thanks for catching it. The patch doesn't apply because I generated the diff from inside drivers/usb/typec/tcpm/ and shipped it with the short paths (a/tcpm.c instead of a/drivers/usb/typec/tcpm/tcpm.c), so git apply fails at the root of the tree. I had not verified it with `git apply --check` from the top before sending. Lesson taken. The base itself was the real tree: the index blob bb90211 in the v2 diff is the master tcpm.c blob, and the two hunks apply cleanly and build with the corrected paths. I've verified v3 end to end on a fresh master tree: git apply --check passes at the root (forward and reverse), and with CONFIG_TYPEC_TCPM=y the patched tcpm.c compiles clean (tcpm.o, zero warnings). The rebased v3 below is content-identical to v2 (same index blob bb90211 -- the base was the real tree, only the paths were wrong): From: Zhang Hewei <memoriaru@foxmail.com> Subject: [PATCH usb v3] usb: typec: tcpm: align SOP' Soft Reset handling with SOP 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 (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> --- drivers/usb/typec/tcpm/tcpm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index bb90211..95f748d 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/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] 6+ messages in thread
* Re: [PATCH usb v2] usb: typec: tcpm: align SOP' Soft Reset handling with SOP 2026-11-20 13:16 ` Heikki Krogerus 2026-11-20 18:34 ` memoriaru @ 2026-11-20 19:25 ` memoriaru [not found] ` <1795204200.cover.tcpm-v4@foxmail.com> 2 siblings, 0 replies; 6+ messages in thread From: memoriaru @ 2026-11-20 19:25 UTC (permalink / raw) To: heikki.krogerus; +Cc: linux-usb, badhri, gregkh, stable From: Zhang Hewei <memoriaru@foxmail.com> Hi Heikki, Thanks for catching the broken v2/v3 submissions. The Sashiko review findings on the resend were all valid, and re-checking the tree showed my changelog misdescribed the initiator path as well: - SOFT_RESET_SEND branches on the SOP* type and resets only the counters of the channel being reset (PD 3.0 sec 6.3.13, "targeted at a specific entity"), not both pairs as I wrote. So v4 drops the second hunk: unconditionally resetting message_id_prime/rx_msgid_prime from the responder SOFT_RESET case is wrong for the same reason -- a SOP-channel soft reset must not clear cable-channel state. That said, while re-checking I noticed the responder side of SOP' Soft Reset looks mis-handled overall in the current tree: - tcpm_pd_handle_msg() has no SOP* type parameter, so the SOFT_RESET case cannot tell which channel the reset came from; it always resets the SOP counters and sends PD_CTRL_ACCEPT on TCPC_TX_SOP. - A Soft_Reset received on SOP' therefore gets its ACCEPT sent on SOP, and its prime counters are not reset. A complete fix would thread the SOP* type through tcpm_pd_handle_msg() and mirror the SOFT_RESET_SEND per-channel handling on the responder side. I'm happy to prepare that if you prefer -- it touches more call sites, so I did not fold it into this resend. v4 below keeps only the duplicate-check exemption (first hunk), with the changelog facts corrected. Thanks, ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <1795204200.cover.tcpm-v4@foxmail.com>]
* [PATCH usb v4] usb: typec: tcpm: exempt Soft Reset from the SOP' MessageID duplicate check [not found] ` <1795204200.cover.tcpm-v4@foxmail.com> @ 2026-11-20 19:25 ` memoriaru 2026-11-21 9:16 ` Greg KH 0 siblings, 1 reply; 6+ messages in thread From: memoriaru @ 2026-11-20 19:25 UTC (permalink / raw) To: heikki.krogerus; +Cc: linux-usb, badhri, gregkh, stable 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 (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 rx_msgid_prime comparison, and the cable-side re-negotiation stalls. Exempt Soft Reset on the SOP' path the same way the SOP path does. Found by code inspection; a software TCPC stub was built for the responder path. Fixes: 6bd181ba60e1 ("usb: typec: tcpm: add control message support to sop'") Cc: stable@vger.kernel.org Signed-off-by: Zhang Hewei <memoriaru@foxmail.com> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index bb90211..89e280b 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/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; -- 2.39.5 (Apple Git-154) ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH usb v4] usb: typec: tcpm: exempt Soft Reset from the SOP' MessageID duplicate check 2026-11-20 19:25 ` [PATCH usb v4] usb: typec: tcpm: exempt Soft Reset from the SOP' MessageID duplicate check memoriaru @ 2026-11-21 9:16 ` Greg KH 0 siblings, 0 replies; 6+ messages in thread From: Greg KH @ 2026-11-21 9:16 UTC (permalink / raw) To: memoriaru; +Cc: heikki.krogerus, linux-usb, badhri, stable On Sat, Nov 21, 2026 at 03:25:35AM +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 (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 rx_msgid_prime comparison, and > the cable-side re-negotiation stalls. > > Exempt Soft Reset on the SOP' path the same way the SOP path does. > > Found by code inspection; a software TCPC stub was built for the > responder path. > > Fixes: 6bd181ba60e1 ("usb: typec: tcpm: add control message support to sop'") > Cc: stable@vger.kernel.org > Signed-off-by: Zhang Hewei <memoriaru@foxmail.com> > > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c > index bb90211..89e280b 100644 > --- a/drivers/usb/typec/tcpm/tcpm.c > +++ b/drivers/usb/typec/tcpm/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; > -- > 2.39.5 (Apple Git-154) > > 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: - This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what needs to be done here to properly describe 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] 6+ messages in thread
end of thread, other threads:[~2026-11-21 9:16 UTC | newest]
Thread overview: 6+ 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
2026-11-20 18:34 ` memoriaru
2026-11-20 19:25 ` memoriaru
[not found] ` <1795204200.cover.tcpm-v4@foxmail.com>
2026-11-20 19:25 ` [PATCH usb v4] usb: typec: tcpm: exempt Soft Reset from the SOP' MessageID duplicate check memoriaru
2026-11-21 9:16 ` Greg KH
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox