mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] usb: typec: tcpm: advance vdm_discovery_state on Discover Identity Not_Supported
@ 2026-09-16  4:39 Xu Yang
  2026-09-22 10:50 ` Heikki Krogerus
  2026-09-28 12:58 ` Heikki Krogerus
  0 siblings, 2 replies; 4+ messages in thread
From: Xu Yang @ 2026-09-16  4:39 UTC (permalink / raw)
  To: badhri, heikki.krogerus, gregkh; +Cc: linux-usb, linux-kernel, imx, jun.li

From: Xu Yang <xu.yang_2@nxp.com>

Commit Fixes: 205dc9cb39f5 ("usb: typec: tcpm: implement retry mechanism
for Discover Identity VDMs") advances vdm_discovery_state to
VDM_DISCOVERY_COMPLETE when a CMDT_RSP_NAK is received, but it does not
advance the state when a non-modal port returns PD_CTRL_NOT_SUPP.

This can re-arm another vdm_discovery_work if the port is going to
respond with PD_CTRL_NOT_SUPP to the partner.

  tcpm_pd_handle_msg(port, PD_MSG_CTRL_NOT_SUPP, NONE_AMS);
    tcpm_queue_message();
      mod_tcpm_delayed_work();
        tcpm_state_machine_work()
          tcpm_send_queued_message()  -> send PD_MSG_CTRL_NOT_SUPP
          run_state_machine()
            case SRC_READY:
            case SNK_READY:
              mod_vdm_discovery_delayed_work(port, 0);

If both the port and its partner do not support modal operation, they
will send DISCOVER_IDENTITY to each other infinitely.

Advance vdm_discovery_state to VDM_DISCOVERY_COMPLETE in this path as
well. In particular, update the state to VDM_DISCOVERY_COMPLETE if it comes
from the port partner, and to VDM_DISCOVERY_CABLE_IDENT if it comes from a
cable.

Fixes: 205dc9cb39f5 ("usb: typec: tcpm: implement retry mechanism for Discover Identity VDMs")
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>

---
Changes in v2:
 - cover a cable returns PD_CTRL_NOT_SUPP case reported by sashiko
 - kick off vdm_discovery work to continue working
 - correct previous wrong fix commit id
---
 drivers/usb/typec/tcpm/tcpm.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 2d6b14aa2085..5cea820e00c4 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -3891,6 +3891,16 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
 		case SRC_READY:
 		case SNK_READY:
 			if (port->vdm_state > VDM_STATE_READY) {
+				if (port->ams == DISCOVER_IDENTITY) {
+					if (rx_sop_type == TCPC_TX_SOP) {
+						tcpm_update_vdm_discovery_state(port,
+								VDM_DISCOVERY_COMPLETE);
+					} else if (rx_sop_type == TCPC_TX_SOP_PRIME) {
+						tcpm_update_vdm_discovery_state(port,
+								VDM_DISCOVERY_CABLE_IDENT);
+						mod_vdm_discovery_delayed_work(port, 0);
+					}
+				}
 				port->vdm_state = VDM_STATE_DONE;
 				if (tcpm_vdm_ams(port))
 					tcpm_ams_finish(port);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] usb: typec: tcpm: advance vdm_discovery_state on Discover Identity Not_Supported
  2026-09-16  4:39 [PATCH v2] usb: typec: tcpm: advance vdm_discovery_state on Discover Identity Not_Supported Xu Yang
@ 2026-09-22 10:50 ` Heikki Krogerus
  2026-09-24 17:34   ` RD Babiera
  2026-09-28 12:58 ` Heikki Krogerus
  1 sibling, 1 reply; 4+ messages in thread
From: Heikki Krogerus @ 2026-09-22 10:50 UTC (permalink / raw)
  To: Xu Yang; +Cc: badhri, gregkh, linux-usb, linux-kernel, imx, jun.li, RD Babiera

+RD

On Wed, Sep 16, 2026 at 12:39:57PM +0800, Xu Yang wrote:
> From: Xu Yang <xu.yang_2@nxp.com>
> 
> Commit Fixes: 205dc9cb39f5 ("usb: typec: tcpm: implement retry mechanism
> for Discover Identity VDMs") advances vdm_discovery_state to
> VDM_DISCOVERY_COMPLETE when a CMDT_RSP_NAK is received, but it does not
> advance the state when a non-modal port returns PD_CTRL_NOT_SUPP.
> 
> This can re-arm another vdm_discovery_work if the port is going to
> respond with PD_CTRL_NOT_SUPP to the partner.
> 
>   tcpm_pd_handle_msg(port, PD_MSG_CTRL_NOT_SUPP, NONE_AMS);
>     tcpm_queue_message();
>       mod_tcpm_delayed_work();
>         tcpm_state_machine_work()
>           tcpm_send_queued_message()  -> send PD_MSG_CTRL_NOT_SUPP
>           run_state_machine()
>             case SRC_READY:
>             case SNK_READY:
>               mod_vdm_discovery_delayed_work(port, 0);
> 
> If both the port and its partner do not support modal operation, they
> will send DISCOVER_IDENTITY to each other infinitely.
> 
> Advance vdm_discovery_state to VDM_DISCOVERY_COMPLETE in this path as
> well. In particular, update the state to VDM_DISCOVERY_COMPLETE if it comes
> from the port partner, and to VDM_DISCOVERY_CABLE_IDENT if it comes from a
> cable.
> 
> Fixes: 205dc9cb39f5 ("usb: typec: tcpm: implement retry mechanism for Discover Identity VDMs")
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> 
> ---
> Changes in v2:
>  - cover a cable returns PD_CTRL_NOT_SUPP case reported by sashiko
>  - kick off vdm_discovery work to continue working
>  - correct previous wrong fix commit id
> ---
>  drivers/usb/typec/tcpm/tcpm.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 2d6b14aa2085..5cea820e00c4 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -3891,6 +3891,16 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
>  		case SRC_READY:
>  		case SNK_READY:
>  			if (port->vdm_state > VDM_STATE_READY) {
> +				if (port->ams == DISCOVER_IDENTITY) {
> +					if (rx_sop_type == TCPC_TX_SOP) {
> +						tcpm_update_vdm_discovery_state(port,
> +								VDM_DISCOVERY_COMPLETE);
> +					} else if (rx_sop_type == TCPC_TX_SOP_PRIME) {
> +						tcpm_update_vdm_discovery_state(port,
> +								VDM_DISCOVERY_CABLE_IDENT);
> +						mod_vdm_discovery_delayed_work(port, 0);
> +					}
> +				}
>  				port->vdm_state = VDM_STATE_DONE;
>  				if (tcpm_vdm_ams(port))
>  					tcpm_ams_finish(port);
> -- 
> 2.34.1

-- 
heikki

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] usb: typec: tcpm: advance vdm_discovery_state on Discover Identity Not_Supported
  2026-09-22 10:50 ` Heikki Krogerus
@ 2026-09-24 17:34   ` RD Babiera
  0 siblings, 0 replies; 4+ messages in thread
From: RD Babiera @ 2026-09-24 17:34 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: Xu Yang, badhri, gregkh, linux-usb, linux-kernel, imx, jun.li

Thanks for tagging me here Heikki.

On Tue, Sep 22, 2026 at 3:50 AM Heikki Krogerus
<heikki.krogerus@linux.intel.com> wrote:
>
> +RD
>
> On Wed, Sep 16, 2026 at 12:39:57PM +0800, Xu Yang wrote:
> > From: Xu Yang <xu.yang_2@nxp.com>
> >
> > Commit Fixes: 205dc9cb39f5 ("usb: typec: tcpm: implement retry mechanism
> > for Discover Identity VDMs") advances vdm_discovery_state to
> > VDM_DISCOVERY_COMPLETE when a CMDT_RSP_NAK is received, but it does not
> > advance the state when a non-modal port returns PD_CTRL_NOT_SUPP.
> >
> > This can re-arm another vdm_discovery_work if the port is going to
> > respond with PD_CTRL_NOT_SUPP to the partner.
> >
> >   tcpm_pd_handle_msg(port, PD_MSG_CTRL_NOT_SUPP, NONE_AMS);
> >     tcpm_queue_message();
> >       mod_tcpm_delayed_work();
> >         tcpm_state_machine_work()
> >           tcpm_send_queued_message()  -> send PD_MSG_CTRL_NOT_SUPP
> >           run_state_machine()
> >             case SRC_READY:
> >             case SNK_READY:
> >               mod_vdm_discovery_delayed_work(port, 0);
> >
> > If both the port and its partner do not support modal operation, they
> > will send DISCOVER_IDENTITY to each other infinitely.
> >
> > Advance vdm_discovery_state to VDM_DISCOVERY_COMPLETE in this path as
> > well. In particular, update the state to VDM_DISCOVERY_COMPLETE if it comes
> > from the port partner, and to VDM_DISCOVERY_CABLE_IDENT if it comes from a
> > cable.
> >
> > Fixes: 205dc9cb39f5 ("usb: typec: tcpm: implement retry mechanism for Discover Identity VDMs")
> > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>

Reviewed-by: RD Babiera <rdbabiera@google.com>

> >
> > ---
> > Changes in v2:
> >  - cover a cable returns PD_CTRL_NOT_SUPP case reported by sashiko

PD Spec indicates that unsupported cable VDMs get ignored, but it is
very much valid to keep the filter in case a non-compliant cable returns
Not_Supported.

> >  - kick off vdm_discovery work to continue working
> >  - correct previous wrong fix commit id
> > ---
> >  drivers/usb/typec/tcpm/tcpm.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> > index 2d6b14aa2085..5cea820e00c4 100644
> > --- a/drivers/usb/typec/tcpm/tcpm.c
> > +++ b/drivers/usb/typec/tcpm/tcpm.c
> > @@ -3891,6 +3891,16 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
> >               case SRC_READY:
> >               case SNK_READY:
> >                       if (port->vdm_state > VDM_STATE_READY) {
> > +                             if (port->ams == DISCOVER_IDENTITY) {
> > +                                     if (rx_sop_type == TCPC_TX_SOP) {
> > +                                             tcpm_update_vdm_discovery_state(port,
> > +                                                             VDM_DISCOVERY_COMPLETE);
> > +                                     } else if (rx_sop_type == TCPC_TX_SOP_PRIME) {
> > +                                             tcpm_update_vdm_discovery_state(port,
> > +                                                             VDM_DISCOVERY_CABLE_IDENT);
> > +                                             mod_vdm_discovery_delayed_work(port, 0);
> > +                                     }
> > +                             }
> >                               port->vdm_state = VDM_STATE_DONE;
> >                               if (tcpm_vdm_ams(port))
> >                                       tcpm_ams_finish(port);
> > --
> > 2.34.1
>
> --
> heikki

Best,
RD

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] usb: typec: tcpm: advance vdm_discovery_state on Discover Identity Not_Supported
  2026-09-16  4:39 [PATCH v2] usb: typec: tcpm: advance vdm_discovery_state on Discover Identity Not_Supported Xu Yang
  2026-09-22 10:50 ` Heikki Krogerus
@ 2026-09-28 12:58 ` Heikki Krogerus
  1 sibling, 0 replies; 4+ messages in thread
From: Heikki Krogerus @ 2026-09-28 12:58 UTC (permalink / raw)
  To: Xu Yang; +Cc: badhri, gregkh, linux-usb, linux-kernel, imx, jun.li

On Wed, Sep 16, 2026 at 12:39:57PM +0800, Xu Yang wrote:
> From: Xu Yang <xu.yang_2@nxp.com>
> 
> Commit Fixes: 205dc9cb39f5 ("usb: typec: tcpm: implement retry mechanism
> for Discover Identity VDMs") advances vdm_discovery_state to
> VDM_DISCOVERY_COMPLETE when a CMDT_RSP_NAK is received, but it does not
> advance the state when a non-modal port returns PD_CTRL_NOT_SUPP.
> 
> This can re-arm another vdm_discovery_work if the port is going to
> respond with PD_CTRL_NOT_SUPP to the partner.
> 
>   tcpm_pd_handle_msg(port, PD_MSG_CTRL_NOT_SUPP, NONE_AMS);
>     tcpm_queue_message();
>       mod_tcpm_delayed_work();
>         tcpm_state_machine_work()
>           tcpm_send_queued_message()  -> send PD_MSG_CTRL_NOT_SUPP
>           run_state_machine()
>             case SRC_READY:
>             case SNK_READY:
>               mod_vdm_discovery_delayed_work(port, 0);
> 
> If both the port and its partner do not support modal operation, they
> will send DISCOVER_IDENTITY to each other infinitely.
> 
> Advance vdm_discovery_state to VDM_DISCOVERY_COMPLETE in this path as
> well. In particular, update the state to VDM_DISCOVERY_COMPLETE if it comes
> from the port partner, and to VDM_DISCOVERY_CABLE_IDENT if it comes from a
> cable.
> 
> Fixes: 205dc9cb39f5 ("usb: typec: tcpm: implement retry mechanism for Discover Identity VDMs")
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>

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

> ---
> Changes in v2:
>  - cover a cable returns PD_CTRL_NOT_SUPP case reported by sashiko
>  - kick off vdm_discovery work to continue working
>  - correct previous wrong fix commit id
> ---
>  drivers/usb/typec/tcpm/tcpm.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 2d6b14aa2085..5cea820e00c4 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -3891,6 +3891,16 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
>  		case SRC_READY:
>  		case SNK_READY:
>  			if (port->vdm_state > VDM_STATE_READY) {
> +				if (port->ams == DISCOVER_IDENTITY) {
> +					if (rx_sop_type == TCPC_TX_SOP) {
> +						tcpm_update_vdm_discovery_state(port,
> +								VDM_DISCOVERY_COMPLETE);
> +					} else if (rx_sop_type == TCPC_TX_SOP_PRIME) {
> +						tcpm_update_vdm_discovery_state(port,
> +								VDM_DISCOVERY_CABLE_IDENT);
> +						mod_vdm_discovery_delayed_work(port, 0);
> +					}
> +				}
>  				port->vdm_state = VDM_STATE_DONE;
>  				if (tcpm_vdm_ams(port))
>  					tcpm_ams_finish(port);
> -- 
> 2.34.1

-- 
heikki

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-28 12:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16  4:39 [PATCH v2] usb: typec: tcpm: advance vdm_discovery_state on Discover Identity Not_Supported Xu Yang
2026-09-22 10:50 ` Heikki Krogerus
2026-09-24 17:34   ` RD Babiera
2026-09-28 12:58 ` Heikki Krogerus

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®