* [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; 9+ 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] 9+ 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; 9+ 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] 9+ 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
2026-11-20 13:16 ` Heikki Krogerus
0 siblings, 1 reply; 9+ 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] 9+ 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] " memoriaru
@ 2026-11-20 13:16 ` Heikki Krogerus
2026-11-20 18:34 ` memoriaru
` (2 more replies)
0 siblings, 3 replies; 9+ 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] 9+ 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 18:43 ` sashiko-bot
2026-11-20 19:25 ` memoriaru
[not found] ` <1795204200.cover.tcpm-v4@foxmail.com>
2 siblings, 1 reply; 9+ 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] 9+ messages in thread
* Re: [PATCH usb v2] usb: typec: tcpm: align SOP' Soft Reset handling with SOP
2026-11-20 18:34 ` memoriaru
@ 2026-11-20 18:43 ` sashiko-bot
0 siblings, 0 replies; 9+ messages in thread
From: sashiko-bot @ 2026-11-20 18:43 UTC (permalink / raw)
To: memoriaru; +Cc: linux-usb
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] usb: typec: tcpm: SOP' MessageID desync and broken SOP' reset
in SOFT_RESET
- [Low] usb: typec: tcpm: malformed Fixes SHA, reply chatter, and wrong
claim in log
--
commit dccd2b15acd9fd37db996886a0767a44d39c3adf
Author: Zhang Hewei <memoriaru@foxmail.com>
> usb: typec: tcpm: align SOP' Soft Reset handling with SOP
>
> 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>
[Severity: Low]
The mailing-list reply notes and embedded From:/Subject: headers at the top
belong below the "---" separator rather than in the commit changelog.
The Fixes tag also uses a 10-character SHA instead of at least 12
characters:
Fixes: 6bd181ba60e1 ("usb: typec: tcpm: add control message support to sop'")
Also, is the description of SOFT_RESET_SEND accurate? In
run_state_machine(), SOFT_RESET_SEND branches on port->tx_sop_type ==
TCPC_TX_SOP_PRIME and resets only message_id_prime/rx_msgid_prime for SOP'
or only message_id/rx_msgid for SOP, not both counter pairs.
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index bf7fd632d815e..0aa38f1e36bdb 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -4206,7 +4206,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;
> @@ -6199,6 +6200,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);
[Severity: High]
Does unconditionally resetting port->message_id_prime and
port->rx_msgid_prime in SOFT_RESET desynchronize SOP' MessageID counters
with the cable plug during an SOP Soft Reset, while also mishandling an
incoming SOP' Soft Reset as an SOP reset?
SOP and SOP' maintain independent MessageID counters per USB PD 3.0
sections 6.3.13 and 6.7.1. When the port partner sends an SOP
PD_CTRL_SOFT_RESET, the cable plug does not process SOP packets and keeps
its existing SOP' MessageID state. If the port already sent one SOP' VDM
(such as CMD_DISCOVER_IDENT with MessageID 0, advancing
port->message_id_prime to 1 and leaving the cable plug's stored MessageID
at 0), resetting port->message_id_prime to 0 here causes the next SOP'
message to be sent with MessageID 0 again and dropped by the cable plug as
a duplicate.
Conversely, when PD_CTRL_SOFT_RESET arrives on TCPC_TX_SOP_PRIME,
tcpm_pd_ctrl_request() ignores rx_sop_type and enters SOFT_RESET:
drivers/usb/typec/tcpm/tcpm.c:tcpm_pd_ctrl_request() {
...
case PD_CTRL_SOFT_RESET:
port->ams = SOFT_RESET_AMS;
tcpm_set_state(port, SOFT_RESET, 0);
break;
...
}
SOFT_RESET then resets the SOP counters, clears partner source capabilities
and port->explicit_contract, sends PD_CTRL_ACCEPT on TCPC_TX_SOP instead of
TCPC_TX_SOP_PRIME, and restarts SOP power negotiation rather than
acknowledging the cable plug on SOP' and returning to ready_state(port).
--
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_3C8B79F98D619AA20768761A53496A7D6E05@qq.com?part=1
^ permalink raw reply [flat|nested] 9+ 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; 9+ 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] 9+ messages in thread
* [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-20 19:41 ` sashiko-bot
0 siblings, 1 reply; 9+ 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] 9+ 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-20 19:41 ` sashiko-bot
0 siblings, 0 replies; 9+ messages in thread
From: sashiko-bot @ 2026-11-20 19:41 UTC (permalink / raw)
To: memoriaru; +Cc: linux-usb
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] usb: typec: tcpm: SOP' PD_CTRL_SOFT_RESET still resets SOP in
SOFT_RESET
--
commit 64dabb00274a597dc73a5939c6dcd78aa8aea76c
Author: Zhang Hewei <memoriaru@foxmail.com>
usb: typec: tcpm: exempt Soft Reset from the SOP' MessageID duplicate check
This commit exempts PD_CTRL_SOFT_RESET from the MessageID duplicate check
on the SOP' receive path in tcpm_pd_rx_handler().
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index bf7fd632d815e..6a657dbf4e7ae 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -4206,7 +4206,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;
[Severity: Medium]
Does an incoming SOP' PD_CTRL_SOFT_RESET still reset the SOP channel
instead of SOP'?
When a cable sends PD_CTRL_SOFT_RESET on TCPC_TX_SOP_PRIME,
tcpm_pd_rx_handler() sets port->rx_msgid_prime = 0 and calls
tcpm_pd_ctrl_request(port, msg, TCPC_TX_SOP_PRIME), which ignores
rx_sop_type and enters SOFT_RESET:
drivers/usb/typec/tcpm/tcpm.c:tcpm_pd_ctrl_request() {
...
case PD_CTRL_SOFT_RESET:
port->ams = SOFT_RESET_AMS;
tcpm_set_state(port, SOFT_RESET, 0);
break;
...
}
drivers/usb/typec/tcpm/tcpm.c:run_state_machine() {
...
case SOFT_RESET:
port->message_id = 0;
port->rx_msgid = -1;
/* remove existing capabilities */
tcpm_partner_source_caps_reset(port);
tcpm_pd_send_control(port, PD_CTRL_ACCEPT, TCPC_TX_SOP);
port->vdm_sm_running = false;
port->explicit_contract = false;
tcpm_ams_finish(port);
if (port->pwr_role == TYPEC_SOURCE) {
port->upcoming_state = SRC_SEND_CAPABILITIES;
tcpm_ams_start(port, POWER_NEGOTIATION);
} else {
tcpm_set_state(port, SNK_WAIT_CAPABILITIES, 0);
}
break;
...
}
Because SOFT_RESET only resets the SOP state, port->message_id_prime is
not zeroed, port->rx_msgid_prime stays at 0 (so the cable's next SOP'
message with MessageID 0 is dropped as a duplicate), PD_CTRL_ACCEPT is
sent on TCPC_TX_SOP to the port partner instead of the cable, and the SOP
power contract is torn down.
The commit message also notes that "the PD message duplicate-check and
the SOFT_RESET state handling treat the SOP and SOP' channels
differently", so it looks like the tcpm_pd_ctrl_request() and SOFT_RESET
changes were omitted from the patch.
--
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_D1222948818CA62395FED66DB7F2967B1809@qq.com?part=1
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-11-20 19:41 UTC | newest]
Thread overview: 9+ 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
2026-11-20 13:16 ` Heikki Krogerus
2026-11-20 18:34 ` memoriaru
2026-11-20 18:43 ` sashiko-bot
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-20 19:41 ` sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.