From: sashiko-bot@kernel.org
To: "Alexey Charkov" <alchark@flipper.net>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH 1/3] usb: typec: tcpm: Keep the Soft_Reset target apart from the VDM one
Date: Tue, 17 Nov 2026 11:30:23 +0000 [thread overview]
Message-ID: <sashiko-outbox-218712@kernel.org> (raw)
In-Reply-To: <20261117-tcpm-soft-reset-sop-v1-1-c7e1543828c0@flipper.net>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] usb: typec: tcpm: stale upcoming_state in run_state_machine()
sends SOP reset
--
commit 2100338173ee82724a16da9e2eef51514fc95f54
Author: Alexey Charkov <alchark@flipper.net>
usb: typec: tcpm: Keep the Soft_Reset target apart from the VDM one
This commit splits tx_sop_type into vdm_sop_type and soft_reset_sop_type so
that VDM transmissions and Soft_Reset messages do not overwrite each other's
SOP* target.
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index bb90211660cae..8c5be904d7725 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
[ ... ]
> @@ -6220,7 +6225,8 @@ static void run_state_machine(struct tcpm_port *port)
> * A Soft_Reset Message Shall be targeted at a specific entity
> * depending on the type of SOP* packet used.
> */
> - if (port->tx_sop_type == TCPC_TX_SOP_PRIME) {
> + if (port->soft_reset_sop_type == TCPC_TX_SOP_PRIME) {
> + port->soft_reset_sop_type = TCPC_TX_SOP;
> port->message_id_prime = 0;
> port->rx_msgid_prime = -1;
> tcpm_pd_send_control(port, PD_CTRL_SOFT_RESET, TCPC_TX_SOP_PRIME);
> @@ -6439,7 +6445,7 @@ static void run_state_machine(struct tcpm_port *port)
> case VCONN_SWAP_SEND_SOFT_RESET:
> tcpm_swap_complete(port, port->swap_status);
> if (tcpm_can_communicate_sop_prime(port)) {
> - port->tx_sop_type = TCPC_TX_SOP_PRIME;
> + port->soft_reset_sop_type = TCPC_TX_SOP_PRIME;
> port->upcoming_state = SOFT_RESET_SEND;
> tcpm_ams_start(port, SOFT_RESET_AMS);
> } else {
[Severity: Medium]
When port->pwr_role is TYPEC_SOURCE, can resetting port->soft_reset_sop_type
to TCPC_TX_SOP in SOFT_RESET_SEND cause an unintended SOP Soft_Reset to be
sent to the port partner right after the SOP' Soft_Reset finishes?
In VCONN_SWAP_SEND_SOFT_RESET, port->upcoming_state is set to
SOFT_RESET_SEND before calling tcpm_ams_start(port, SOFT_RESET_AMS). When
port->pwr_role == TYPEC_SOURCE, tcpm_ams_start() transitions directly to
SOFT_RESET_SEND without going through AMS_START, leaving
port->upcoming_state set to SOFT_RESET_SEND:
drivers/usb/typec/tcpm/tcpm.c:tcpm_ams_start() {
...
} else if (ams == SOFT_RESET_AMS) {
if (!port->explicit_contract)
tcpm_set_cc(port, tcpm_rp_cc(port));
tcpm_set_state(port, SOFT_RESET_SEND, 0);
return ret;
}
...
}
Once the SOP' Soft_Reset completes and the state machine returns to
SRC_READY, SRC_READY consumes the leftover port->upcoming_state and
re-enters SOFT_RESET_SEND:
drivers/usb/typec/tcpm/tcpm.c:run_state_machine() {
...
if (port->upcoming_state != INVALID_STATE) {
upcoming_state = port->upcoming_state;
port->upcoming_state = INVALID_STATE;
tcpm_set_state(port, upcoming_state, 0);
break;
}
...
}
Because the first pass through SOFT_RESET_SEND already reset
port->soft_reset_sop_type to TCPC_TX_SOP, the second pass takes the else
branch, clears the partner source capabilities and SOP message IDs, and
sends an unintended PD_CTRL_SOFT_RESET on TCPC_TX_SOP to the port partner,
forcing a full contract renegotiation.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117-tcpm-soft-reset-sop-v1-0-c7e1543828c0@flipper.net?part=1
next prev parent reply other threads:[~2026-11-17 11:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 11:15 [PATCH 0/3] usb: typec: tcpm: Fixes for talking to the cable plug as a VCONN source Alexey Charkov
2026-11-17 11:15 ` [PATCH 1/3] usb: typec: tcpm: Keep the Soft_Reset target apart from the VDM one Alexey Charkov
2026-11-17 11:30 ` sashiko-bot [this message]
2026-11-17 12:01 ` Alexey Charkov
2026-11-17 11:15 ` [PATCH 2/3] usb: typec: tcpm: Leave SRC_VDM_IDENTITY_REQUEST whatever the cable answers Alexey Charkov
2026-11-17 11:39 ` sashiko-bot
2026-11-17 12:02 ` Alexey Charkov
2026-11-17 11:15 ` [PATCH 3/3] usb: typec: tcpm: Keep cable plug messages away from the port partner Alexey Charkov
2026-11-17 11:42 ` sashiko-bot
2026-11-17 12:08 ` Alexey Charkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-218712@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alchark@flipper.net \
--cc=linux-usb@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.