diff mbox series

[v3,2/2] usb: typec: tcpm: AMS for PD2.0

Message ID 20190920032437.242187-3-kyletso@google.com (mailing list archive)
State New, archived
Headers show
Series tcpm: AMS and Collision Avoidance | expand

Commit Message

Kyle Tso Sept. 20, 2019, 3:24 a.m. UTC
AMS is defined in PD2.0 as well. Remove the filter in tcpm_ams_start
and change the CC for Collision Avoidance only if the negotiated
revision is higher than PD2.0.

Signed-off-by: Kyle Tso <kyletso@google.com>
---
Changelog since v2:
- N/A; This is the first version.

 drivers/usb/typec/tcpm/tcpm.c | 129 +++++++++++++++-------------------
 1 file changed, 57 insertions(+), 72 deletions(-)

Comments

kernel test robot Sept. 21, 2019, 4:02 p.m. UTC | #1
Hi Kyle,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[cannot apply to v5.3 next-20190919]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Kyle-Tso/usb-typec-tcpm-AMS-and-Collision-Avoidance/20190920-112652
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.4.0-13) 7.4.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 
:::::: branch date: 7 hours ago
:::::: commit date: 7 hours ago

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

   drivers/usb/typec/tcpm/tcpm.c: In function 'tcpm_ams_start':
>> drivers/usb/typec/tcpm/tcpm.c:1144:5: warning: 'cc_req' may be used uninitialized in this function [-Wmaybe-uninitialized]
        tcpm_set_state(port, AMS_START,
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                cc_req == SINK_TX_OK ?
                ~~~~~~~~~~~~~~~~~~~~~~
                PD_T_SINK_TX : 0);
                ~~~~~~~~~~~~~~~~~

# https://github.com/0day-ci/linux/commit/59e8594ebb63b2f2f6d8ec5a9c9c914f6c476cae
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 59e8594ebb63b2f2f6d8ec5a9c9c914f6c476cae
vim +/cc_req +1144 drivers/usb/typec/tcpm/tcpm.c

0ea47e4d06fe89 Kyle Tso 2019-09-20  1095  
0ea47e4d06fe89 Kyle Tso 2019-09-20  1096  static int tcpm_ams_start(struct tcpm_port *port, enum tcpm_ams ams)
0ea47e4d06fe89 Kyle Tso 2019-09-20  1097  {
0ea47e4d06fe89 Kyle Tso 2019-09-20  1098  	int ret = 0;
0ea47e4d06fe89 Kyle Tso 2019-09-20  1099  
0ea47e4d06fe89 Kyle Tso 2019-09-20  1100  	tcpm_log(port, "AMS %s start", tcpm_ams_str[ams]);
0ea47e4d06fe89 Kyle Tso 2019-09-20  1101  
0ea47e4d06fe89 Kyle Tso 2019-09-20  1102  	if (!tcpm_ams_interruptible(port) && ams != HARD_RESET) {
0ea47e4d06fe89 Kyle Tso 2019-09-20  1103  		port->upcoming_state = INVALID_STATE;
0ea47e4d06fe89 Kyle Tso 2019-09-20  1104  		tcpm_log(port, "AMS %s not interruptible, aborting",
0ea47e4d06fe89 Kyle Tso 2019-09-20  1105  			 tcpm_ams_str[port->ams]);
0ea47e4d06fe89 Kyle Tso 2019-09-20  1106  		return -EAGAIN;
0ea47e4d06fe89 Kyle Tso 2019-09-20  1107  	}
0ea47e4d06fe89 Kyle Tso 2019-09-20  1108  
0ea47e4d06fe89 Kyle Tso 2019-09-20  1109  	if (port->pwr_role == TYPEC_SOURCE) {
0ea47e4d06fe89 Kyle Tso 2019-09-20  1110  		enum typec_cc_status cc_req;
0ea47e4d06fe89 Kyle Tso 2019-09-20  1111  
0ea47e4d06fe89 Kyle Tso 2019-09-20  1112  		port->ams = ams;
0ea47e4d06fe89 Kyle Tso 2019-09-20  1113  
0ea47e4d06fe89 Kyle Tso 2019-09-20  1114  		if (ams == HARD_RESET) {
0ea47e4d06fe89 Kyle Tso 2019-09-20  1115  			tcpm_set_cc(port, tcpm_rp_cc(port));
0ea47e4d06fe89 Kyle Tso 2019-09-20  1116  			tcpm_pd_transmit(port, TCPC_TX_HARD_RESET, NULL);
0ea47e4d06fe89 Kyle Tso 2019-09-20  1117  			tcpm_set_state(port, HARD_RESET_START, 0);
0ea47e4d06fe89 Kyle Tso 2019-09-20  1118  			return ret;
0ea47e4d06fe89 Kyle Tso 2019-09-20  1119  		} else if (ams == SOFT_RESET_AMS) {
0ea47e4d06fe89 Kyle Tso 2019-09-20  1120  			if (!port->explicit_contract) {
0ea47e4d06fe89 Kyle Tso 2019-09-20  1121  				port->upcoming_state = INVALID_STATE;
0ea47e4d06fe89 Kyle Tso 2019-09-20  1122  				tcpm_set_cc(port, tcpm_rp_cc(port));
0ea47e4d06fe89 Kyle Tso 2019-09-20  1123  				return ret;
0ea47e4d06fe89 Kyle Tso 2019-09-20  1124  			}
0ea47e4d06fe89 Kyle Tso 2019-09-20  1125  		} else if (tcpm_vdm_ams(port)) {
0ea47e4d06fe89 Kyle Tso 2019-09-20  1126  			/* tSinkTx is enforced in vdm_run_state_machine */
59e8594ebb63b2 Kyle Tso 2019-09-20  1127  			if (port->negotiated_rev >= PD_REV30)
0ea47e4d06fe89 Kyle Tso 2019-09-20  1128  				tcpm_set_cc(port, SINK_TX_NG);
0ea47e4d06fe89 Kyle Tso 2019-09-20  1129  			return ret;
0ea47e4d06fe89 Kyle Tso 2019-09-20  1130  		}
0ea47e4d06fe89 Kyle Tso 2019-09-20  1131  
59e8594ebb63b2 Kyle Tso 2019-09-20  1132  		if (port->negotiated_rev >= PD_REV30) {
0ea47e4d06fe89 Kyle Tso 2019-09-20  1133  			cc_req = port->cc_req;
0ea47e4d06fe89 Kyle Tso 2019-09-20  1134  			tcpm_set_cc(port, SINK_TX_NG);
59e8594ebb63b2 Kyle Tso 2019-09-20  1135  		}
59e8594ebb63b2 Kyle Tso 2019-09-20  1136  
59e8594ebb63b2 Kyle Tso 2019-09-20  1137  		switch (port->state) {
59e8594ebb63b2 Kyle Tso 2019-09-20  1138  		case SRC_READY:
59e8594ebb63b2 Kyle Tso 2019-09-20  1139  		case SRC_STARTUP:
59e8594ebb63b2 Kyle Tso 2019-09-20  1140  		case SRC_SOFT_RESET_WAIT_SNK_TX:
59e8594ebb63b2 Kyle Tso 2019-09-20  1141  		case SOFT_RESET:
59e8594ebb63b2 Kyle Tso 2019-09-20  1142  		case SOFT_RESET_SEND:
59e8594ebb63b2 Kyle Tso 2019-09-20  1143  			if (port->negotiated_rev >= PD_REV30)
59e8594ebb63b2 Kyle Tso 2019-09-20 @1144  				tcpm_set_state(port, AMS_START,
59e8594ebb63b2 Kyle Tso 2019-09-20  1145  					       cc_req == SINK_TX_OK ?
0ea47e4d06fe89 Kyle Tso 2019-09-20  1146  					       PD_T_SINK_TX : 0);
0ea47e4d06fe89 Kyle Tso 2019-09-20  1147  			else
59e8594ebb63b2 Kyle Tso 2019-09-20  1148  				tcpm_set_state(port, AMS_START, 0);
59e8594ebb63b2 Kyle Tso 2019-09-20  1149  			break;
59e8594ebb63b2 Kyle Tso 2019-09-20  1150  		default:
59e8594ebb63b2 Kyle Tso 2019-09-20  1151  			if (port->negotiated_rev >= PD_REV30)
59e8594ebb63b2 Kyle Tso 2019-09-20  1152  				tcpm_set_state(port, SRC_READY,
59e8594ebb63b2 Kyle Tso 2019-09-20  1153  					       cc_req == SINK_TX_OK ?
0ea47e4d06fe89 Kyle Tso 2019-09-20  1154  					       PD_T_SINK_TX : 0);
59e8594ebb63b2 Kyle Tso 2019-09-20  1155  			else
59e8594ebb63b2 Kyle Tso 2019-09-20  1156  				tcpm_set_state(port, SRC_READY, 0);
59e8594ebb63b2 Kyle Tso 2019-09-20  1157  			break;
59e8594ebb63b2 Kyle Tso 2019-09-20  1158  		}
0ea47e4d06fe89 Kyle Tso 2019-09-20  1159  	} else {
59e8594ebb63b2 Kyle Tso 2019-09-20  1160  		if (port->negotiated_rev >= PD_REV30 &&
59e8594ebb63b2 Kyle Tso 2019-09-20  1161  		    !tcpm_sink_tx_ok(port) &&
0ea47e4d06fe89 Kyle Tso 2019-09-20  1162  		    ams != SOFT_RESET_AMS &&
0ea47e4d06fe89 Kyle Tso 2019-09-20  1163  		    ams != HARD_RESET) {
0ea47e4d06fe89 Kyle Tso 2019-09-20  1164  			port->upcoming_state = INVALID_STATE;
0ea47e4d06fe89 Kyle Tso 2019-09-20  1165  			tcpm_log(port, "Sink TX No Go");
0ea47e4d06fe89 Kyle Tso 2019-09-20  1166  			return -EAGAIN;
0ea47e4d06fe89 Kyle Tso 2019-09-20  1167  		}
0ea47e4d06fe89 Kyle Tso 2019-09-20  1168  
0ea47e4d06fe89 Kyle Tso 2019-09-20  1169  		port->ams = ams;
0ea47e4d06fe89 Kyle Tso 2019-09-20  1170  
0ea47e4d06fe89 Kyle Tso 2019-09-20  1171  		if (ams == HARD_RESET) {
0ea47e4d06fe89 Kyle Tso 2019-09-20  1172  			tcpm_pd_transmit(port, TCPC_TX_HARD_RESET, NULL);
0ea47e4d06fe89 Kyle Tso 2019-09-20  1173  			tcpm_set_state(port, HARD_RESET_START, 0);
0ea47e4d06fe89 Kyle Tso 2019-09-20  1174  			return ret;
0ea47e4d06fe89 Kyle Tso 2019-09-20  1175  		} else if (tcpm_vdm_ams(port)) {
0ea47e4d06fe89 Kyle Tso 2019-09-20  1176  			return ret;
0ea47e4d06fe89 Kyle Tso 2019-09-20  1177  		}
0ea47e4d06fe89 Kyle Tso 2019-09-20  1178  
0ea47e4d06fe89 Kyle Tso 2019-09-20  1179  		if (port->state == SNK_READY ||
0ea47e4d06fe89 Kyle Tso 2019-09-20  1180  		    port->state == SNK_SOFT_RESET)
0ea47e4d06fe89 Kyle Tso 2019-09-20  1181  			tcpm_set_state(port, AMS_START, 0);
0ea47e4d06fe89 Kyle Tso 2019-09-20  1182  		else
0ea47e4d06fe89 Kyle Tso 2019-09-20  1183  			tcpm_set_state(port, SNK_READY, 0);
0ea47e4d06fe89 Kyle Tso 2019-09-20  1184  	}
0ea47e4d06fe89 Kyle Tso 2019-09-20  1185  
0ea47e4d06fe89 Kyle Tso 2019-09-20  1186  	return ret;
0ea47e4d06fe89 Kyle Tso 2019-09-20  1187  }
0ea47e4d06fe89 Kyle Tso 2019-09-20  1188  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 7d1c30c33097..aca1c5bbe870 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -391,6 +391,12 @@  struct pd_rx_event {
 	struct pd_message msg;
 };
 
+static const char * const pd_rev[] = {
+	[PD_REV10]		= "rev1",
+	[PD_REV20]		= "rev2",
+	[PD_REV30]		= "rev3",
+};
+
 #define tcpm_cc_is_sink(cc) \
 	((cc) == TYPEC_CC_RP_DEF || (cc) == TYPEC_CC_RP_1_5 || \
 	 (cc) == TYPEC_CC_RP_3_0)
@@ -431,8 +437,6 @@  struct pd_rx_event {
 	(tcpm_port_is_sink(port) && \
 	((port)->cc1 == TYPEC_CC_RP_3_0 || (port)->cc2 == TYPEC_CC_RP_3_0))
 
-#define support_ams(port)       ((port)->negotiated_rev >= PD_REV30)
-
 static enum tcpm_state tcpm_default_state(struct tcpm_port *port)
 {
 	if (port->port_type == TYPEC_PORT_DRP) {
@@ -679,14 +683,9 @@  static int tcpm_ams_finish(struct tcpm_port *port)
 {
 	int ret = 0;
 
-	if (!support_ams(port)) {
-		port->upcoming_state = INVALID_STATE;
-		return -EOPNOTSUPP;
-	}
-
 	tcpm_log(port, "AMS %s finished", tcpm_ams_str[port->ams]);
 
-	if (port->pwr_role == TYPEC_SOURCE)
+	if (port->negotiated_rev >= PD_REV30 && port->pwr_role == TYPEC_SOURCE)
 		tcpm_set_cc(port, SINK_TX_OK);
 
 	port->in_ams = false;
@@ -723,12 +722,13 @@  static int tcpm_pd_transmit(struct tcpm_port *port,
 	case TCPC_TX_SUCCESS:
 		port->message_id = (port->message_id + 1) & PD_HEADER_ID_MASK;
 		/*
+		 * USB PD rev 2.0, 8.3.2.2.1:
 		 * USB PD rev 3.0, 8.3.2.1.3:
 		 * "... Note that every AMS is Interruptible until the first
 		 * Message in the sequence has been successfully sent (GoodCRC
 		 * Message received)."
 		 */
-		if (support_ams(port) && port->ams != NONE_AMS)
+		if (port->ams != NONE_AMS)
 			port->in_ams = true;
 		break;
 	case TCPC_TX_DISCARDED:
@@ -994,20 +994,18 @@  static void tcpm_set_state(struct tcpm_port *port, enum tcpm_state state,
 			   unsigned int delay_ms)
 {
 	if (delay_ms) {
-		tcpm_log(port, "pending state change %s -> %s @ %u ms%s%s",
+		tcpm_log(port, "pending state change %s -> %s @ %u ms [%s %s]",
 			 tcpm_states[port->state], tcpm_states[state], delay_ms,
-			 support_ams(port) ? " in AMS " : "",
-			 support_ams(port) ? tcpm_ams_str[port->ams] : "");
+			 pd_rev[port->negotiated_rev], tcpm_ams_str[port->ams]);
 		port->delayed_state = state;
 		mod_delayed_work(port->wq, &port->state_machine,
 				 msecs_to_jiffies(delay_ms));
 		port->delayed_runtime = jiffies + msecs_to_jiffies(delay_ms);
 		port->delay_ms = delay_ms;
 	} else {
-		tcpm_log(port, "state change %s -> %s%s%s",
+		tcpm_log(port, "state change %s -> %s [%s %s]",
 			 tcpm_states[port->state], tcpm_states[state],
-			 support_ams(port) ? " in AMS " : "",
-			 support_ams(port) ? tcpm_ams_str[port->ams] : "");
+			 pd_rev[port->negotiated_rev], tcpm_ams_str[port->ams]);
 		port->delayed_state = INVALID_STATE;
 		port->prev_state = port->state;
 		port->state = state;
@@ -1029,12 +1027,11 @@  static void tcpm_set_state_cond(struct tcpm_port *port, enum tcpm_state state,
 		tcpm_set_state(port, state, delay_ms);
 	else
 		tcpm_log(port,
-			 "skipped %sstate change %s -> %s [%u ms], context state %s%s%s",
+			 "skipped %sstate change %s -> %s [%u ms], context state %s [%s %s]",
 			 delay_ms ? "delayed " : "",
 			 tcpm_states[port->state], tcpm_states[state],
 			 delay_ms, tcpm_states[port->enter_state],
-			 support_ams(port) ? " in AMS " : "",
-			 support_ams(port) ? tcpm_ams_str[port->ams] : "");
+			 pd_rev[port->negotiated_rev], tcpm_ams_str[port->ams]);
 }
 
 static void tcpm_queue_message(struct tcpm_port *port,
@@ -1100,11 +1097,6 @@  static int tcpm_ams_start(struct tcpm_port *port, enum tcpm_ams ams)
 {
 	int ret = 0;
 
-	if (!support_ams(port)) {
-		port->upcoming_state = INVALID_STATE;
-		return -EOPNOTSUPP;
-	}
-
 	tcpm_log(port, "AMS %s start", tcpm_ams_str[ams]);
 
 	if (!tcpm_ams_interruptible(port) && ams != HARD_RESET) {
@@ -1132,24 +1124,41 @@  static int tcpm_ams_start(struct tcpm_port *port, enum tcpm_ams ams)
 			}
 		} else if (tcpm_vdm_ams(port)) {
 			/* tSinkTx is enforced in vdm_run_state_machine */
-			tcpm_set_cc(port, SINK_TX_NG);
+			if (port->negotiated_rev >= PD_REV30)
+				tcpm_set_cc(port, SINK_TX_NG);
 			return ret;
 		}
 
-		cc_req = port->cc_req;
-		tcpm_set_cc(port, SINK_TX_NG);
-		if (port->state == SRC_READY ||
-		    port->state == SRC_STARTUP ||
-		    port->state == SRC_SOFT_RESET_WAIT_SNK_TX ||
-		    port->state == SOFT_RESET ||
-		    port->state == SOFT_RESET_SEND)
-			tcpm_set_state(port, AMS_START, cc_req == SINK_TX_OK ?
-				       PD_T_SINK_TX : 0);
-		else
-			tcpm_set_state(port, SRC_READY, cc_req == SINK_TX_OK ?
-				       PD_T_SINK_TX : 0);
+		if (port->negotiated_rev >= PD_REV30) {
+			cc_req = port->cc_req;
+			tcpm_set_cc(port, SINK_TX_NG);
+		}
+
+		switch (port->state) {
+		case SRC_READY:
+		case SRC_STARTUP:
+		case SRC_SOFT_RESET_WAIT_SNK_TX:
+		case SOFT_RESET:
+		case SOFT_RESET_SEND:
+			if (port->negotiated_rev >= PD_REV30)
+				tcpm_set_state(port, AMS_START,
+					       cc_req == SINK_TX_OK ?
+					       PD_T_SINK_TX : 0);
+			else
+				tcpm_set_state(port, AMS_START, 0);
+			break;
+		default:
+			if (port->negotiated_rev >= PD_REV30)
+				tcpm_set_state(port, SRC_READY,
+					       cc_req == SINK_TX_OK ?
+					       PD_T_SINK_TX : 0);
+			else
+				tcpm_set_state(port, SRC_READY, 0);
+			break;
+		}
 	} else {
-		if (!tcpm_sink_tx_ok(port) &&
+		if (port->negotiated_rev >= PD_REV30 &&
+		    !tcpm_sink_tx_ok(port) &&
 		    ams != SOFT_RESET_AMS &&
 		    ams != HARD_RESET) {
 			port->upcoming_state = INVALID_STATE;
@@ -1565,13 +1574,13 @@  static void vdm_run_state_machine(struct tcpm_port *port)
 				break;
 			}
 
-			if (res == -EAGAIN)
+			if (res < 0)
 				return;
 		}
 
 		port->vdm_state = VDM_STATE_SEND_MESSAGE;
 		mod_delayed_work(port->wq, &port->vdm_state_machine,
-				 (res != -EOPNOTSUPP) &&
+				 (port->negotiated_rev >= PD_REV30) &&
 				 (port->pwr_role == TYPEC_SOURCE) &&
 				 (PD_VDO_CMDT(port->vdo_data[0]) == CMDT_INIT) ?
 				 PD_T_SINK_TX : 0);
@@ -1975,7 +1984,6 @@  static void tcpm_pd_ctrl_request(struct tcpm_port *port,
 {
 	enum pd_ctrl_msg_type type = pd_header_type_le(msg->header);
 	enum tcpm_state next_state;
-	int ret = 0;
 
 	switch (type) {
 	case PD_CTRL_GOOD_CRC:
@@ -2094,11 +2102,7 @@  static void tcpm_pd_ctrl_request(struct tcpm_port *port,
 				tcpm_ams_finish(port);
 			if (port->pwr_role == TYPEC_SOURCE) {
 				port->upcoming_state = SRC_SEND_CAPABILITIES;
-				ret = tcpm_ams_start(port, POWER_NEGOTIATION);
-				if (ret == -EOPNOTSUPP)
-					tcpm_set_state(port,
-						       SRC_SEND_CAPABILITIES,
-						       0);
+				tcpm_ams_start(port, POWER_NEGOTIATION);
 			} else {
 				tcpm_set_state(port, SNK_WAIT_CAPABILITIES, 0);
 			}
@@ -3254,9 +3258,7 @@  static void run_state_machine(struct tcpm_port *port)
 		    port->ams == FAST_ROLE_SWAP)
 			tcpm_ams_finish(port);
 		port->upcoming_state = SRC_SEND_CAPABILITIES;
-		ret = tcpm_ams_start(port, POWER_NEGOTIATION);
-		if (ret == -EOPNOTSUPP)
-			tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0);
+		tcpm_ams_start(port, POWER_NEGOTIATION);
 		break;
 	case SRC_SEND_CAPABILITIES:
 		port->caps_count++;
@@ -3620,11 +3622,7 @@  static void run_state_machine(struct tcpm_port *port)
 		 * thus set upcoming_state to INVALID_STATE.
 		 */
 		port->upcoming_state = INVALID_STATE;
-		ret = tcpm_ams_start(port, HARD_RESET);
-		if (ret == -EOPNOTSUPP) {
-			tcpm_pd_transmit(port, TCPC_TX_HARD_RESET, NULL);
-			tcpm_set_state(port, HARD_RESET_START, 0);
-		}
+		tcpm_ams_start(port, HARD_RESET);
 		break;
 	case HARD_RESET_START:
 		port->hard_reset_count++;
@@ -3709,9 +3707,7 @@  static void run_state_machine(struct tcpm_port *port)
 		tcpm_pd_send_control(port, PD_CTRL_ACCEPT);
 		if (port->pwr_role == TYPEC_SOURCE) {
 			port->upcoming_state = SRC_SEND_CAPABILITIES;
-			ret = tcpm_ams_start(port, POWER_NEGOTIATION);
-			if (ret == -EOPNOTSUPP)
-				tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0);
+			tcpm_ams_start(port, POWER_NEGOTIATION);
 		} else {
 			tcpm_set_state(port, SNK_WAIT_CAPABILITIES, 0);
 		}
@@ -3721,9 +3717,7 @@  static void run_state_machine(struct tcpm_port *port)
 		if (port->ams != NONE_AMS)
 			tcpm_ams_finish(port);
 		port->upcoming_state = SOFT_RESET_SEND;
-		ret = tcpm_ams_start(port, SOFT_RESET_AMS);
-		if (ret == -EOPNOTSUPP)
-			tcpm_set_state(port, SOFT_RESET_SEND, 0);
+		tcpm_ams_start(port, SOFT_RESET_AMS);
 		break;
 	case SOFT_RESET_SEND:
 		port->message_id = 0;
@@ -3930,7 +3924,7 @@  static void run_state_machine(struct tcpm_port *port)
 			       port->vbus_present ? PD_T_PS_SOURCE_OFF : 0);
 		break;
 
-	/* Collision Avoidance state */
+	/* AMS intermediate state */
 	case AMS_START:
 		if (port->upcoming_state == INVALID_STATE) {
 			tcpm_set_state(port, port->pwr_role == TYPEC_SOURCE ?
@@ -4392,9 +4386,6 @@  static int tcpm_dr_set(const struct typec_capability *cap,
 		if (ret == -EAGAIN) {
 			port->upcoming_state = INVALID_STATE;
 			goto port_unlock;
-		} else if (ret == -EOPNOTSUPP) {
-			port->upcoming_state = INVALID_STATE;
-			tcpm_set_state(port, DR_SWAP_SEND, 0);
 		}
 	}
 
@@ -4447,9 +4438,6 @@  static int tcpm_pr_set(const struct typec_capability *cap,
 	if (ret == -EAGAIN) {
 		port->upcoming_state = INVALID_STATE;
 		goto port_unlock;
-	} else if (ret == -EOPNOTSUPP) {
-		port->upcoming_state = INVALID_STATE;
-		tcpm_set_state(port, PR_SWAP_SEND, 0);
 	}
 
 	port->swap_status = 0;
@@ -4496,9 +4484,6 @@  static int tcpm_vconn_set(const struct typec_capability *cap,
 	if (ret == -EAGAIN) {
 		port->upcoming_state = INVALID_STATE;
 		goto port_unlock;
-	} else if (ret == -EOPNOTSUPP) {
-		port->upcoming_state = INVALID_STATE;
-		tcpm_set_state(port, VCONN_SWAP_SEND, 0);
 	}
 
 	port->swap_status = 0;
@@ -4570,7 +4555,7 @@  static int tcpm_pps_set_op_curr(struct tcpm_port *port, u16 op_curr)
 
 	port->upcoming_state = SNK_NEGOTIATE_PPS_CAPABILITIES;
 	ret = tcpm_ams_start(port, POWER_NEGOTIATION);
-	if (ret == -EAGAIN || ret == -EOPNOTSUPP) {
+	if (ret == -EAGAIN) {
 		port->upcoming_state = INVALID_STATE;
 		goto port_unlock;
 	}
@@ -4632,7 +4617,7 @@  static int tcpm_pps_set_out_volt(struct tcpm_port *port, u16 out_volt)
 
 	port->upcoming_state = SNK_NEGOTIATE_PPS_CAPABILITIES;
 	ret = tcpm_ams_start(port, POWER_NEGOTIATION);
-	if (ret == -EAGAIN || ret == -EOPNOTSUPP) {
+	if (ret == -EAGAIN) {
 		port->upcoming_state = INVALID_STATE;
 		goto port_unlock;
 	}
@@ -4688,7 +4673,7 @@  static int tcpm_pps_activate(struct tcpm_port *port, bool activate)
 	else
 		port->upcoming_state = SNK_NEGOTIATE_CAPABILITIES;
 	ret = tcpm_ams_start(port, POWER_NEGOTIATION);
-	if (ret == -EAGAIN || ret == -EOPNOTSUPP) {
+	if (ret == -EAGAIN) {
 		port->upcoming_state = INVALID_STATE;
 		goto port_unlock;
 	}