mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: RD Babiera <rdbabiera@google.com>
Cc: gregkh@linuxfoundation.org, badhri@google.com,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v1] usb: typec: tcpm: properly deliver cable vdms to altmode drivers
Date: Thu, 28 Aug 2025 11:34:02 +0300	[thread overview]
Message-ID: <aLAUetrP3zKg9kg6@kuha.fi.intel.com> (raw)
In-Reply-To: <20250821203759.1720841-2-rdbabiera@google.com>

On Thu, Aug 21, 2025 at 08:37:57PM +0000, RD Babiera wrote:
> tcpm_handle_vdm_request delivers messages to the partner altmode or the
> cable altmode depending on the SVDM response type, which is incorrect.
> The partner or cable should be chosen based on the received message type
> instead.
> 
> Also add this filter to ADEV_NOTIFY_USB_AND_QUEUE_VDM, which is used when
> the Enter Mode command is responded to by a NAK on SOP or SOP' and when
> the Exit Mode command is responded to by an ACK on SOP.
> 
> Fixes: 7e7877c55eb1 ("usb: typec: tcpm: add alt mode enter/exit/vdm support for sop'")
> Cc: stable@vger.kernel.org
> Signed-off-by: RD Babiera <rdbabiera@google.com>
> Reviewed-by: Badhri Jagan Sridharan <badhri@google.com>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tcpm/tcpm.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 1f6fdfaa34bf..b2a568a5bc9b 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -2426,17 +2426,21 @@ static void tcpm_handle_vdm_request(struct tcpm_port *port,
>  		case ADEV_NONE:
>  			break;
>  		case ADEV_NOTIFY_USB_AND_QUEUE_VDM:
> -			WARN_ON(typec_altmode_notify(adev, TYPEC_STATE_USB, NULL));
> -			typec_altmode_vdm(adev, p[0], &p[1], cnt);
> +			if (rx_sop_type == TCPC_TX_SOP_PRIME) {
> +				typec_cable_altmode_vdm(adev, TYPEC_PLUG_SOP_P, p[0], &p[1], cnt);
> +			} else {
> +				WARN_ON(typec_altmode_notify(adev, TYPEC_STATE_USB, NULL));
> +				typec_altmode_vdm(adev, p[0], &p[1], cnt);
> +			}
>  			break;
>  		case ADEV_QUEUE_VDM:
> -			if (response_tx_sop_type == TCPC_TX_SOP_PRIME)
> +			if (rx_sop_type == TCPC_TX_SOP_PRIME)
>  				typec_cable_altmode_vdm(adev, TYPEC_PLUG_SOP_P, p[0], &p[1], cnt);
>  			else
>  				typec_altmode_vdm(adev, p[0], &p[1], cnt);
>  			break;
>  		case ADEV_QUEUE_VDM_SEND_EXIT_MODE_ON_FAIL:
> -			if (response_tx_sop_type == TCPC_TX_SOP_PRIME) {
> +			if (rx_sop_type == TCPC_TX_SOP_PRIME) {
>  				if (typec_cable_altmode_vdm(adev, TYPEC_PLUG_SOP_P,
>  							    p[0], &p[1], cnt)) {
>  					int svdm_version = typec_get_cable_svdm_version(
> 
> base-commit: 956606bafb5fc6e5968aadcda86fc0037e1d7548
> -- 
> 2.51.0.261.g7ce5a0a67e-goog

-- 
heikki

      reply	other threads:[~2025-08-28  8:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-21 20:37 RD Babiera
2025-08-28  8:34 ` Heikki Krogerus [this message]

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=aLAUetrP3zKg9kg6@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=badhri@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=rdbabiera@google.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

all inboxes | Powered by JetHome®