From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Alexey Charkov <alchark@flipper.net>
Cc: Badhri Jagan Sridharan <badhri@google.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
RD Babiera <rdbabiera@google.com>,
Sebastian Reichel <sebastian.reichel@collabora.com>,
linux-usb@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2 1/4] usb: typec: tcpm: Keep the Soft_Reset target apart from the VDM one
Date: Fri, 20 Nov 2026 15:31:46 +0100 [thread overview]
Message-ID: <awBZ0h0zdaTwGwlA@black.igk.intel.com> (raw)
In-Reply-To: <20261118-tcpm-soft-reset-sop-v2-1-b6decdc95e66@flipper.net>
On Wed, Nov 18, 2026 at 11:26:39AM +0400, Alexey Charkov wrote:
> tx_sop_type holds the SOP* of the VDM being sent, for its retries, and
> SOFT_RESET_SEND also reads it to tell a Soft_Reset for the cable plug,
> after a VCONN Swap, from one for the port partner. Nothing sets it back
> after a VDM, so once a VDM has gone to the cable plug, such as Discover
> Identity on SOP' before the first contract, every Soft_Reset meant for
> the port partner goes to the cable plug instead. The cable plug accepts
> it and the port goes back to its ready state, but the port partner never
> sees the Soft_Reset: a source whose Source_Capabilities got Not_Supported
> is then left without a contract. The VCONN Swap, in turn, overwrites the
> SOP* of a VDM that may still be pending. This left a FUSB302B-based
> source without a contract until it was unplugged, after its partner
> missed a message following Discover Identity to an e-marked cable.
>
> Keep one target per context: vdm_sop_type for the VDM and its retries,
> and soft_reset_sop_type for the next Soft_Reset. Point the latter at the
> cable plug only for the VCONN Swap, only once, and back at SOP whenever
> the protocol layer starts over or a Soft_Reset of the port partner
> starts, along with the SOP' MessageID counters.
>
> Fixes: 6bd181ba60e1 ("usb: typec: tcpm: add control message support to sop'")
> Cc: stable@vger.kernel.org
> Signed-off-by: Alexey Charkov <alchark@flipper.net>
Hopefully Badhri or RD have time to take a look, but LGTM:
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/tcpm/tcpm.c | 28 +++++++++++++++++-----------
> 1 file changed, 17 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index bb90211660ca..8c5be904d772 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -675,12 +675,13 @@ struct tcpm_port {
>
> /* SOP* Related Fields */
> /*
> - * tx_sop_type determines which SOP* a message is being sent on.
> - * For messages that are queued and not sent immediately such as in
> - * tcpm_queue_message or messages that send after state changes,
> - * the tx_sop_type is set accordingly.
> + * Messages that are not sent right away carry their SOP* separately,
> + * one per context so that one cannot redirect another:
> + * vdm_sop_type for the VDM being sent, including its retries, and
> + * soft_reset_sop_type for the next Soft_Reset.
> */
> - enum tcpm_transmit_type tx_sop_type;
> + enum tcpm_transmit_type vdm_sop_type;
> + enum tcpm_transmit_type soft_reset_sop_type;
> /*
> * Prior to discovering the port partner's Specification Revision, the
> * Vconn source and cable plug will use the lower of their two revisions.
> @@ -2003,7 +2004,7 @@ static void tcpm_queue_vdm(struct tcpm_port *port, const u32 header,
> port->vdm_state = VDM_STATE_READY;
> port->vdm_sm_running = true;
>
> - port->tx_sop_type = tx_sop_type;
> + port->vdm_sop_type = tx_sop_type;
>
> mod_vdm_delayed_work(port, 0);
> }
> @@ -3065,7 +3066,7 @@ static void vdm_run_state_machine(struct tcpm_port *port)
> } else {
> tcpm_ams_finish(port);
> port->vdo_data[0] = 0;
> - if (port->tx_sop_type == TCPC_TX_SOP)
> + if (port->vdm_sop_type == TCPC_TX_SOP)
> break;
> /* Handle SOP' Transmission Errors */
> switch (PD_VDO_CMD(vdo_hdr)) {
> @@ -3102,7 +3103,7 @@ static void vdm_run_state_machine(struct tcpm_port *port)
> case VDM_STATE_SEND_MESSAGE:
> /* Prepare and send VDM */
> memset(&msg, 0, sizeof(msg));
> - if (port->tx_sop_type == TCPC_TX_SOP_PRIME) {
> + if (port->vdm_sop_type == TCPC_TX_SOP_PRIME) {
> msg.header = PD_HEADER_LE(PD_DATA_VENDOR_DEF,
> 0, /* Cable Plug Indicator for DFP/UFP */
> 0, /* Reserved */
> @@ -3119,7 +3120,7 @@ static void vdm_run_state_machine(struct tcpm_port *port)
> }
> for (i = 0; i < port->vdo_count; i++)
> msg.payload[i] = cpu_to_le32(port->vdo_data[i]);
> - res = tcpm_pd_transmit(port, port->tx_sop_type, &msg);
> + res = tcpm_pd_transmit(port, port->vdm_sop_type, &msg);
> if (res < 0) {
> port->vdm_state = VDM_STATE_ERR_SEND;
> } else {
> @@ -5529,6 +5530,7 @@ static void run_state_machine(struct tcpm_port *port)
> port->message_id_prime = 0;
> port->rx_msgid = -1;
> port->rx_msgid_prime = -1;
> + port->soft_reset_sop_type = TCPC_TX_SOP;
> port->explicit_contract = false;
> /* SNK -> SRC POWER/FAST_ROLE_SWAP finished */
> if (port->ams == POWER_ROLE_SWAP ||
> @@ -5801,6 +5803,7 @@ static void run_state_machine(struct tcpm_port *port)
> port->message_id_prime = 0;
> port->rx_msgid = -1;
> port->rx_msgid_prime = -1;
> + port->soft_reset_sop_type = TCPC_TX_SOP;
> port->explicit_contract = false;
>
> if (port->ams == POWER_ROLE_SWAP ||
> @@ -6193,6 +6196,7 @@ static void run_state_machine(struct tcpm_port *port)
> case SOFT_RESET:
> port->message_id = 0;
> port->rx_msgid = -1;
> + port->soft_reset_sop_type = TCPC_TX_SOP;
> /* remove existing capabilities */
> tcpm_partner_source_caps_reset(port);
> tcpm_pd_send_control(port, PD_CTRL_ACCEPT, TCPC_TX_SOP);
> @@ -6210,6 +6214,7 @@ static void run_state_machine(struct tcpm_port *port)
> case SNK_SOFT_RESET:
> if (port->ams != NONE_AMS)
> tcpm_ams_finish(port);
> + port->soft_reset_sop_type = TCPC_TX_SOP;
> port->upcoming_state = SOFT_RESET_SEND;
> tcpm_ams_start(port, SOFT_RESET_AMS);
> break;
> @@ -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 {
>
> --
> 2.56.0
>
--
heikki
next prev parent reply other threads:[~2026-11-20 14:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 7:26 [PATCH v2 0/4] usb: typec: tcpm: Fixes for talking to the cable plug as a VCONN source Alexey Charkov
2026-11-18 7:26 ` [PATCH v2 1/4] usb: typec: tcpm: Keep the Soft_Reset target apart from the VDM one Alexey Charkov
2026-11-18 7:32 ` sashiko-bot
2026-11-20 14:31 ` Heikki Krogerus [this message]
2026-11-18 7:26 ` [PATCH v2 2/4] usb: typec: tcpm: Stop replaying Source_Capabilities after cable discovery Alexey Charkov
2026-11-18 7:39 ` sashiko-bot
2026-11-20 14:32 ` Heikki Krogerus
2026-11-18 7:26 ` [PATCH v2 3/4] usb: typec: tcpm: Leave SRC_VDM_IDENTITY_REQUEST whatever the cable answers Alexey Charkov
2026-11-18 8:08 ` sashiko-bot
2026-11-18 7:26 ` [PATCH v2 4/4] usb: typec: tcpm: Keep cable plug messages away from the port partner Alexey Charkov
2026-11-18 7:51 ` sashiko-bot
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=awBZ0h0zdaTwGwlA@black.igk.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=alchark@flipper.net \
--cc=badhri@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=rdbabiera@google.com \
--cc=sebastian.reichel@collabora.com \
--cc=stable@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox