Skip to contentSkip to conversation

USB: typec: various patches

PATCH In review Greg Kroah-Hartman 4 participants 18 messages Dec 10, 2020 – Dec 11, 2020

Subsystems (3)
lore
Share & tools
lore

Greg Kroah-Hartman

author maintainer
#0 lore raw

cover USB: typec: various patches

In digging through a large set of proposed typec patches for the Android common kernel, I've picked out 5 "easy" patches that should all go upstream (they all should go upstream, just will take a while to clean them up it seems...)

Badhri Jagan Sridharan (2):
USB: typec: tcpm: Prevent log overflow by removing old entries
USB: typec: tcpci: Add Bleed discharge to POWER_CONTROL definition

Kyle Tso (2):
USB: typec: tcpm: Fix PR_SWAP error handling
USB: typec: tcpm: Add a 30ms room for tPSSourceOn in PR_SWAP

pumahsu (1):
USB: typec: tcpm: Hard Reset after not receiving a Request

 drivers/usb/typec/tcpm/tcpci.h |  1 +
 drivers/usb/typec/tcpm/tcpm.c  | 30 +++++++++++++++---------------
 include/linux/usb/pd.h         |  1 +
 3 files changed, 17 insertions(+), 15 deletions(-)
Signature · 1 line
2.29.2
author maintainer
#1 lore raw

PATCH 1/5 USB: typec: tcpm: Prevent log overflow by removing old entries

From: Badhri Jagan Sridharan <[email protected]>

TCPM logs overflow once the logbuffer is full. Clear old entries and allow logging the newer ones as the newer would be more relevant to the issue being debugged.

Also, do not reset the logbuffer tail as end users might take back to back bugreports which would result in an empty buffer.

---
 drivers/usb/typec/tcpm/tcpm.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +3 -13
index cedc6cf82d61..0ceeab50ed64 100644
@@ -470,12 +470,6 @@ static bool tcpm_port_is_disconnected(struct tcpm_port *port)
 
 #ifdef CONFIG_DEBUG_FS
 
-static bool tcpm_log_full(struct tcpm_port *port)
-{
-	return port->logbuffer_tail ==
-		(port->logbuffer_head + 1) % LOG_BUFFER_ENTRIES;
-}
-
 __printf(2, 0)
 static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
 {
@@ -495,11 +489,6 @@ static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
 
 	vsnprintf(tmpbuffer, sizeof(tmpbuffer), fmt, args);
 
-	if (tcpm_log_full(port)) {
-		port->logbuffer_head = max(port->logbuffer_head - 1, 0);
-		strcpy(tmpbuffer, "overflow");
-	}
-
 	if (port->logbuffer_head < 0 ||
 	    port->logbuffer_head >= LOG_BUFFER_ENTRIES) {
 		dev_warn(port->dev,
@@ -519,6 +508,9 @@ static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
 		  (unsigned long)ts_nsec, rem_nsec / 1000,
 		  tmpbuffer);
 	port->logbuffer_head = (port->logbuffer_head + 1) % LOG_BUFFER_ENTRIES;
+	if (port->logbuffer_head == port->logbuffer_tail)
+		port->logbuffer_tail =
+			(port->logbuffer_tail + 1) % LOG_BUFFER_ENTRIES;
 
 abort:
 	mutex_unlock(&port->logbuffer_lock);
@@ -622,8 +614,6 @@ static int tcpm_debug_show(struct seq_file *s, void *v)
 		seq_printf(s, "%s\n", port->logbuffer[tail]);
 		tail = (tail + 1) % LOG_BUFFER_ENTRIES;
 	}
-	if (!seq_has_overflowed(s))
-		port->logbuffer_tail = tail;
 	mutex_unlock(&port->logbuffer_lock);
 
 	return 0;
Signature · 1 line
2.29.2
#2 lore raw

Re: [PATCH 1/5] USB: typec: tcpm: Prevent log overflow by removing old entries

Quoted 9 lines · Greg Kroah-Hartman

From: Badhri Jagan Sridharan <[email protected]>

TCPM logs overflow once the logbuffer is full. Clear old entries and allow logging the newer ones as the newer would be more relevant to the issue being debugged.

Also, do not reset the logbuffer tail as end users might take back to back bugreports which would result in an empty buffer.

Historically, the reason for not doing this was that, once a problem occurs, the log would fill up quickly (typically with reconnect attempts), and the actual reason for the problem would be overwritten. Maybe that reasoning no longer applies; I just wanted to point out that there _was_ a reason for not clearing old log entries.

Guenter

Quoted 61 lines
---
 drivers/usb/typec/tcpm/tcpm.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +3 -13
index cedc6cf82d61..0ceeab50ed64 100644
@@ -470,12 +470,6 @@ static bool tcpm_port_is_disconnected(struct tcpm_port *port)
 
 #ifdef CONFIG_DEBUG_FS
 
-static bool tcpm_log_full(struct tcpm_port *port)
-{
-	return port->logbuffer_tail ==
-		(port->logbuffer_head + 1) % LOG_BUFFER_ENTRIES;
-}
-
 __printf(2, 0)
 static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
 {
@@ -495,11 +489,6 @@ static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
 
 	vsnprintf(tmpbuffer, sizeof(tmpbuffer), fmt, args);
 
-	if (tcpm_log_full(port)) {
-		port->logbuffer_head = max(port->logbuffer_head - 1, 0);
-		strcpy(tmpbuffer, "overflow");
-	}
-
 	if (port->logbuffer_head < 0 ||
 	    port->logbuffer_head >= LOG_BUFFER_ENTRIES) {
 		dev_warn(port->dev,
@@ -519,6 +508,9 @@ static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
 		  (unsigned long)ts_nsec, rem_nsec / 1000,
 		  tmpbuffer);
 	port->logbuffer_head = (port->logbuffer_head + 1) % LOG_BUFFER_ENTRIES;
+	if (port->logbuffer_head == port->logbuffer_tail)
+		port->logbuffer_tail =
+			(port->logbuffer_tail + 1) % LOG_BUFFER_ENTRIES;
 
 abort:
 	mutex_unlock(&port->logbuffer_lock);
@@ -622,8 +614,6 @@ static int tcpm_debug_show(struct seq_file *s, void *v)
 		seq_printf(s, "%s\n", port->logbuffer[tail]);
 		tail = (tail + 1) % LOG_BUFFER_ENTRIES;
 	}
-	if (!seq_has_overflowed(s))
-		port->logbuffer_tail = tail;
 	mutex_unlock(&port->logbuffer_lock);
 
 	return 0;
Signature · 1 line
2.29.2
#3 lore raw

Re: [PATCH 1/5] USB: typec: tcpm: Prevent log overflow by removing old entries

Hi Guenter,

While I agree with what you are saying, since the logbuffer does not have the intelligence to drop older entries where no issues were seen, logbuffer gets full pretty quickly with good instances and there is no space left to log the bad instance. Should wrapping this in a config option be a better way to go about this ? When the config optioin is set, old entries will be dropped.
Please let me know, I can update the patch and resend.

Thanks,
Badhri

Quoted 81 lines · Guenter Roeck
Quoted 9 lines · Greg Kroah-Hartman

From: Badhri Jagan Sridharan <[email protected]>

TCPM logs overflow once the logbuffer is full. Clear old entries and allow logging the newer ones as the newer would be more relevant to the issue being debugged.

Also, do not reset the logbuffer tail as end users might take back to back bugreports which would result in an empty buffer.

Historically, the reason for not doing this was that, once a problem occurs, the log would fill up quickly (typically with reconnect attempts), and the actual reason for the problem would be overwritten. Maybe that reasoning no longer applies; I just wanted to point out that there _was_ a reason for not clearing old log entries.

Guenter

Quoted 61 lines
---
 drivers/usb/typec/tcpm/tcpm.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +3 -14
index cedc6cf82d61..0ceeab50ed64 100644
@@ -470,12 +470,6 @@ static bool tcpm_port_is_disconnected(struct tcpm_port *port)
 
 #ifdef CONFIG_DEBUG_FS
 
-static bool tcpm_log_full(struct tcpm_port *port)
-{
-     return port->logbuffer_tail ==
-             (port->logbuffer_head + 1) % LOG_BUFFER_ENTRIES;
-}
-
 __printf(2, 0)
 static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
 {
@@ -495,11 +489,6 @@ static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
 
      vsnprintf(tmpbuffer, sizeof(tmpbuffer), fmt, args);
 
-     if (tcpm_log_full(port)) {
-             port->logbuffer_head = max(port->logbuffer_head - 1, 0);
-             strcpy(tmpbuffer, "overflow");
-     }
-
      if (port->logbuffer_head < 0 ||
          port->logbuffer_head >= LOG_BUFFER_ENTRIES) {
              dev_warn(port->dev,
@@ -519,6 +508,9 @@ static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
                (unsigned long)ts_nsec, rem_nsec / 1000,
                tmpbuffer);
      port->logbuffer_head = (port->logbuffer_head + 1) % LOG_BUFFER_ENTRIES;
+     if (port->logbuffer_head == port->logbuffer_tail)
+             port->logbuffer_tail =
+                     (port->logbuffer_tail + 1) % LOG_BUFFER_ENTRIES;
 
 abort:
      mutex_unlock(&port->logbuffer_lock);
@@ -622,8 +614,6 @@ static int tcpm_debug_show(struct seq_file *s, void *v)
              seq_printf(s, "%s\n", port->logbuffer[tail]);
              tail = (tail + 1) % LOG_BUFFER_ENTRIES;
      }
-     if (!seq_has_overflowed(s))
-             port->logbuffer_tail = tail;
      mutex_unlock(&port->logbuffer_lock);
 
      return 0;
--

2.29.2

#4 lore raw

Re: [PATCH 1/5] USB: typec: tcpm: Prevent log overflow by removing old entries

Quoted 6 lines · Badhri Jagan Sridharan

Hi Guenter,

While I agree with what you are saying, since the logbuffer does not have the intelligence to drop older entries where no issues were seen, logbuffer gets full pretty quickly with good instances and there is no space left to log the bad instance. Should wrapping this in a config

For my use case, it was typically sufficient to clear the log buffer by reading it if needed. However, as I said, my original reason may no longer apply. After all, the code is much more stable than it used to be, and maybe the endless conection attempts after an initial error are no longer seen. At this point I don't really have a strong opinion either way.

Quoted 2 lines

option be a better way to go about this ? When the config optioin is set, old entries will be dropped.

A config option (assuming you mean Kconfig) seems bad. Maybe we could have a writeable debugfs file which defines the approach to use (not sure if that would be acceptable, though).

Note that I also considered changing logging to tracing, but that has the disadvantage that it needs to be explicitly activated and doesn't provide any kind of history in the "normal" case. On a higher level, it would be nice to have a logging option like the one implemented here in the infrastucture. But that is really a completely different issue.

Thanks,
Guenter

Quoted 89 lines

Please let me know, I can update the patch and resend.

Thanks,
Badhri

Quoted 81 lines · Guenter Roeck
Quoted 9 lines · Greg Kroah-Hartman

From: Badhri Jagan Sridharan <[email protected]>

TCPM logs overflow once the logbuffer is full. Clear old entries and allow logging the newer ones as the newer would be more relevant to the issue being debugged.

Also, do not reset the logbuffer tail as end users might take back to back bugreports which would result in an empty buffer.

Historically, the reason for not doing this was that, once a problem occurs, the log would fill up quickly (typically with reconnect attempts), and the actual reason for the problem would be overwritten. Maybe that reasoning no longer applies; I just wanted to point out that there _was_ a reason for not clearing old log entries.

Guenter

Quoted 61 lines
---
 drivers/usb/typec/tcpm/tcpm.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +3 -14
index cedc6cf82d61..0ceeab50ed64 100644
@@ -470,12 +470,6 @@ static bool tcpm_port_is_disconnected(struct tcpm_port *port)
 
 #ifdef CONFIG_DEBUG_FS
 
-static bool tcpm_log_full(struct tcpm_port *port)
-{
-     return port->logbuffer_tail ==
-             (port->logbuffer_head + 1) % LOG_BUFFER_ENTRIES;
-}
-
 __printf(2, 0)
 static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
 {
@@ -495,11 +489,6 @@ static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
 
      vsnprintf(tmpbuffer, sizeof(tmpbuffer), fmt, args);
 
-     if (tcpm_log_full(port)) {
-             port->logbuffer_head = max(port->logbuffer_head - 1, 0);
-             strcpy(tmpbuffer, "overflow");
-     }
-
      if (port->logbuffer_head < 0 ||
          port->logbuffer_head >= LOG_BUFFER_ENTRIES) {
              dev_warn(port->dev,
@@ -519,6 +508,9 @@ static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
                (unsigned long)ts_nsec, rem_nsec / 1000,
                tmpbuffer);
      port->logbuffer_head = (port->logbuffer_head + 1) % LOG_BUFFER_ENTRIES;
+     if (port->logbuffer_head == port->logbuffer_tail)
+             port->logbuffer_tail =
+                     (port->logbuffer_tail + 1) % LOG_BUFFER_ENTRIES;
 
 abort:
      mutex_unlock(&port->logbuffer_lock);
@@ -622,8 +614,6 @@ static int tcpm_debug_show(struct seq_file *s, void *v)
              seq_printf(s, "%s\n", port->logbuffer[tail]);
              tail = (tail + 1) % LOG_BUFFER_ENTRIES;
      }
-     if (!seq_has_overflowed(s))
-             port->logbuffer_tail = tail;
      mutex_unlock(&port->logbuffer_lock);
 
      return 0;
--

2.29.2

author maintainer
#5 lore raw

PATCH 2/5 USB: typec: tcpm: Hard Reset after not receiving a Request

In reply to Greg Kroah-Hartman

From: pumahsu <[email protected]>

PD 3.0 spec 8.3.3.2.3, A Get_Source_Cap message is sent to a UUT that is in the PE_SRC_Ready state. After sending a Source_Capabilities message, the UUT should then expect a Request message in response. When one is not received, the UUT should timeout to PE_SRC_Hard_Reset.

Cc Guenter Roeck <[email protected]>
Cc Heikki Krogerus <[email protected]>
Cc Badhri Jagan Sridharan <[email protected]>
---
 drivers/usb/typec/tcpm/tcpm.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpm.c +11 -1
index 0ceeab50ed64..0efda59bb104 100644
@@ -2218,6 +2218,7 @@ static int tcpm_pd_send_control(struct tcpm_port *port,
 static bool tcpm_send_queued_message(struct tcpm_port *port)
 {
 	enum pd_msg_request queued_message;
+	int ret;
 
 	do {
 		queued_message = port->queued_message;
@@ -2237,7 +2238,16 @@ static bool tcpm_send_queued_message(struct tcpm_port *port)
 			tcpm_pd_send_sink_caps(port);
 			break;
 		case PD_MSG_DATA_SOURCE_CAP:
-			tcpm_pd_send_source_caps(port);
+			ret = tcpm_pd_send_source_caps(port);
+			if (ret < 0) {
+				tcpm_log(port,
+					 "Unable to send src caps, ret=%d",
+					 ret);
+				tcpm_set_state(port, SOFT_RESET_SEND, 0);
+			} else if (port->pwr_role == TYPEC_SOURCE) {
+				tcpm_set_state(port, HARD_RESET_SEND,
+					       PD_T_SENDER_RESPONSE);
+			}
 			break;
 		default:
 			break;
Signature · 1 line
2.29.2
Reviewed-by on v1 2/5
#6 lore raw

Re: [PATCH 2/5] USB: typec: tcpm: Hard Reset after not receiving a Request

Quoted 8 lines · Greg Kroah-Hartman

From: pumahsu <[email protected]>

PD 3.0 spec 8.3.3.2.3, A Get_Source_Cap message is sent to a UUT that is in the PE_SRC_Ready state. After sending a Source_Capabilities message, the UUT should then expect a Request message in response. When one is not received, the UUT should timeout to PE_SRC_Hard_Reset.

Quoted 7 lines
Cc Guenter Roeck <[email protected]>
Cc Heikki Krogerus <[email protected]>
Cc Badhri Jagan Sridharan <[email protected]>
Quoted 37 lines
---
 drivers/usb/typec/tcpm/tcpm.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpm.c +11 -1
index 0ceeab50ed64..0efda59bb104 100644
@@ -2218,6 +2218,7 @@ static int tcpm_pd_send_control(struct tcpm_port *port,
 static bool tcpm_send_queued_message(struct tcpm_port *port)
 {
 	enum pd_msg_request queued_message;
+	int ret;
 
 	do {
 		queued_message = port->queued_message;
@@ -2237,7 +2238,16 @@ static bool tcpm_send_queued_message(struct tcpm_port *port)
 			tcpm_pd_send_sink_caps(port);
 			break;
 		case PD_MSG_DATA_SOURCE_CAP:
-			tcpm_pd_send_source_caps(port);
+			ret = tcpm_pd_send_source_caps(port);
+			if (ret < 0) {
+				tcpm_log(port,
+					 "Unable to send src caps, ret=%d",
+					 ret);
+				tcpm_set_state(port, SOFT_RESET_SEND, 0);
+			} else if (port->pwr_role == TYPEC_SOURCE) {
+				tcpm_set_state(port, HARD_RESET_SEND,
+					       PD_T_SENDER_RESPONSE);
+			}
 			break;
 		default:
 			break;
Signature · 1 line
2.29.2
author maintainer
#7 lore raw

PATCH 3/5 USB: typec: tcpm: Fix PR_SWAP error handling

In reply to Greg Kroah-Hartman

From: Kyle Tso <[email protected]>

PD rev3.0 8.3.3.16.3.6 PE_PRS_SRC_SNK_Wait_Source_on State The Policy Enging Shall transition to the ErrorRecovery state when the PSSourceOnTimer times out ...

Cc Guenter Roeck <[email protected]>
Cc Heikki Krogerus <[email protected]>
Cc Badhri Jagan Sridharan <[email protected]>
---
 drivers/usb/typec/tcpm/tcpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpm.c +1 -1
index 0efda59bb104..d51c45961893 100644
@@ -3728,7 +3728,7 @@ static void run_state_machine(struct tcpm_port *port)
 			tcpm_set_state(port, ERROR_RECOVERY, 0);
 			break;
 		}
-		tcpm_set_state_cond(port, SNK_UNATTACHED, PD_T_PS_SOURCE_ON);
+		tcpm_set_state(port, ERROR_RECOVERY, PD_T_PS_SOURCE_ON);
 		break;
 	case PR_SWAP_SRC_SNK_SINK_ON:
 		/* Set the vbus disconnect threshold for implicit contract */
Signature · 1 line
2.29.2
Reviewed-by on v1 3/5
#8 lore raw

Re: [PATCH 3/5] USB: typec: tcpm: Fix PR_SWAP error handling

Quoted 6 lines · Greg Kroah-Hartman

From: Kyle Tso <[email protected]>

PD rev3.0 8.3.3.16.3.6 PE_PRS_SRC_SNK_Wait_Source_on State The Policy Enging Shall transition to the ErrorRecovery state when the PSSourceOnTimer times out ...

Quoted 6 lines
Cc Guenter Roeck <[email protected]>
Cc Heikki Krogerus <[email protected]>
Cc Badhri Jagan Sridharan <[email protected]>
Quoted 20 lines
---
 drivers/usb/typec/tcpm/tcpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpm.c +1 -1
index 0efda59bb104..d51c45961893 100644
@@ -3728,7 +3728,7 @@ static void run_state_machine(struct tcpm_port *port)
 			tcpm_set_state(port, ERROR_RECOVERY, 0);
 			break;
 		}
-		tcpm_set_state_cond(port, SNK_UNATTACHED, PD_T_PS_SOURCE_ON);
+		tcpm_set_state(port, ERROR_RECOVERY, PD_T_PS_SOURCE_ON);
 		break;
 	case PR_SWAP_SRC_SNK_SINK_ON:
 		/* Set the vbus disconnect threshold for implicit contract */
Signature · 1 line
2.29.2
author maintainer
#9 lore raw

PATCH 4/5 USB: typec: tcpm: Add a 30ms room for tPSSourceOn in PR_SWAP

In reply to Greg Kroah-Hartman

From: Kyle Tso <[email protected]>

TCPM state machine needs 20-25ms to enter the ErrorRecovery state after tPSSourceOn timer timeouts. Change the timer from max 480ms to 450ms to ensure that the timer complies with the Spec. In order to keep the flexibility for other usecases using tPSSourceOn, add another timer only for PR_SWAP.

Cc Guenter Roeck <[email protected]>
Cc Heikki Krogerus <[email protected]>
Cc Badhri Jagan Sridharan <[email protected]>
---
 drivers/usb/typec/tcpm/tcpm.c | 2 +-
 include/linux/usb/pd.h        | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpm.c +1 -1
index d51c45961893..5ed78194a1bd 100644
@@ -3728,7 +3728,7 @@ static void run_state_machine(struct tcpm_port *port)
 			tcpm_set_state(port, ERROR_RECOVERY, 0);
 			break;
 		}
-		tcpm_set_state(port, ERROR_RECOVERY, PD_T_PS_SOURCE_ON);
+		tcpm_set_state(port, ERROR_RECOVERY, PD_T_PS_SOURCE_ON_PRS);
 		break;
 	case PR_SWAP_SRC_SNK_SINK_ON:
 		/* Set the vbus disconnect threshold for implicit contract */
include/linux/usb/pd.h +1 -0
index 63a66dd5d832..bb9a782e1411 100644
@@ -466,6 +466,7 @@ static inline unsigned int rdo_max_power(u32 rdo)
 #define PD_T_DRP_SRC		30
 #define PD_T_PS_SOURCE_OFF	920
 #define PD_T_PS_SOURCE_ON	480
+#define PD_T_PS_SOURCE_ON_PRS	450	/* 390 - 480ms */
 #define PD_T_PS_HARD_RESET	30
 #define PD_T_SRC_RECOVER	760
 #define PD_T_SRC_RECOVER_MAX	1000
Signature · 1 line
2.29.2
Reviewed-by on v1 4/5
#10 lore raw

Re: [PATCH 4/5] USB: typec: tcpm: Add a 30ms room for tPSSourceOn in PR_SWAP

Quoted 8 lines · Greg Kroah-Hartman

From: Kyle Tso <[email protected]>

TCPM state machine needs 20-25ms to enter the ErrorRecovery state after tPSSourceOn timer timeouts. Change the timer from max 480ms to 450ms to ensure that the timer complies with the Spec. In order to keep the flexibility for other usecases using tPSSourceOn, add another timer only for PR_SWAP.

Quoted 6 lines
Cc Guenter Roeck <[email protected]>
Cc Heikki Krogerus <[email protected]>
Cc Badhri Jagan Sridharan <[email protected]>
Quoted 33 lines
---
 drivers/usb/typec/tcpm/tcpm.c | 2 +-
 include/linux/usb/pd.h        | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpm.c +1 -1
index d51c45961893..5ed78194a1bd 100644
@@ -3728,7 +3728,7 @@ static void run_state_machine(struct tcpm_port *port)
 			tcpm_set_state(port, ERROR_RECOVERY, 0);
 			break;
 		}
-		tcpm_set_state(port, ERROR_RECOVERY, PD_T_PS_SOURCE_ON);
+		tcpm_set_state(port, ERROR_RECOVERY, PD_T_PS_SOURCE_ON_PRS);
 		break;
 	case PR_SWAP_SRC_SNK_SINK_ON:
 		/* Set the vbus disconnect threshold for implicit contract */
include/linux/usb/pd.h +1 -0
index 63a66dd5d832..bb9a782e1411 100644
@@ -466,6 +466,7 @@ static inline unsigned int rdo_max_power(u32 rdo)
 #define PD_T_DRP_SRC		30
 #define PD_T_PS_SOURCE_OFF	920
 #define PD_T_PS_SOURCE_ON	480
+#define PD_T_PS_SOURCE_ON_PRS	450	/* 390 - 480ms */
 #define PD_T_PS_HARD_RESET	30
 #define PD_T_SRC_RECOVER	760
 #define PD_T_SRC_RECOVER_MAX	1000
Signature · 1 line
2.29.2
author maintainer
#11 lore raw

PATCH 5/5 USB: typec: tcpci: Add Bleed discharge to POWER_CONTROL definition

In reply to Greg Kroah-Hartman

From: Badhri Jagan Sridharan <[email protected]>

"Table 4-19. POWER_CONTROL Register Definition" from tcpci spec defines BIT(3) as the control bit for bleed discharge.

---
 drivers/usb/typec/tcpm/tcpci.h | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/typec/tcpm/tcpci.h +1 -0
index 116a69c85e38..c3c7d07d9b4e 100644
@@ -72,6 +72,7 @@
 
 #define TCPC_POWER_CTRL			0x1c
 #define TCPC_POWER_CTRL_VCONN_ENABLE	BIT(0)
+#define TCPC_POWER_CTRL_BLEED_DISCHARGE	BIT(3)
 #define TCPC_POWER_CTRL_AUTO_DISCHARGE	BIT(4)
 #define TCPC_FAST_ROLE_SWAP_EN		BIT(7)
 
Signature · 1 line
2.29.2
Reviewed-by on v1 5/5
#12 lore raw

Re: [PATCH 5/5] USB: typec: tcpci: Add Bleed discharge to POWER_CONTROL definition

Quoted 11 lines · Greg Kroah-Hartman

From: Badhri Jagan Sridharan <[email protected]>

"Table 4-19. POWER_CONTROL Register Definition" from tcpci spec defines BIT(3) as the control bit for bleed discharge.

Just wondering - is that going to be used in a follow-up commit ?

Guenter

Quoted 19 lines
---
 drivers/usb/typec/tcpm/tcpci.h | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/typec/tcpm/tcpci.h +1 -0
index 116a69c85e38..c3c7d07d9b4e 100644
@@ -72,6 +72,7 @@
 
 #define TCPC_POWER_CTRL			0x1c
 #define TCPC_POWER_CTRL_VCONN_ENABLE	BIT(0)
+#define TCPC_POWER_CTRL_BLEED_DISCHARGE	BIT(3)
 #define TCPC_POWER_CTRL_AUTO_DISCHARGE	BIT(4)
 #define TCPC_FAST_ROLE_SWAP_EN		BIT(7)
 
Signature · 1 line
2.29.2
#13 lore raw

Re: [PATCH 5/5] USB: typec: tcpci: Add Bleed discharge to POWER_CONTROL definition

Hi Guenter,

Yes I will send a follow up patch to update tcpci_maxim.c.

Thanks,
Badhri

Quoted 39 lines · Guenter Roeck
Quoted 11 lines · Greg Kroah-Hartman

From: Badhri Jagan Sridharan <[email protected]>

"Table 4-19. POWER_CONTROL Register Definition" from tcpci spec defines BIT(3) as the control bit for bleed discharge.

Just wondering - is that going to be used in a follow-up commit ?

Guenter

Quoted 19 lines
---
 drivers/usb/typec/tcpm/tcpci.h | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/typec/tcpm/tcpci.h +1 -1
index 116a69c85e38..c3c7d07d9b4e 100644
@@ -72,6 +72,7 @@
 
 #define TCPC_POWER_CTRL                      0x1c
 #define TCPC_POWER_CTRL_VCONN_ENABLE BIT(0)
+#define TCPC_POWER_CTRL_BLEED_DISCHARGE      BIT(3)
 #define TCPC_POWER_CTRL_AUTO_DISCHARGE       BIT(4)
 #define TCPC_FAST_ROLE_SWAP_EN               BIT(7)
 
--

2.29.2

#14 lore raw

Re: [PATCH 5/5] USB: typec: tcpci: Add Bleed discharge to POWER_CONTROL definition

Hi Greg,

I have a patch ready to enable BLEED_DISCHARGE in tcpci code. I will send that in once you merge this patch to usb-next.

Thanks,
Badhri

Quoted 49 lines · Badhri Jagan Sridharan

Hi Guenter,

Yes I will send a follow up patch to update tcpci_maxim.c.

Thanks,
Badhri

Quoted 39 lines · Guenter Roeck
Quoted 11 lines · Greg Kroah-Hartman

From: Badhri Jagan Sridharan <[email protected]>

"Table 4-19. POWER_CONTROL Register Definition" from tcpci spec defines BIT(3) as the control bit for bleed discharge.

Just wondering - is that going to be used in a follow-up commit ?

Guenter

Quoted 19 lines
---
 drivers/usb/typec/tcpm/tcpci.h | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/typec/tcpm/tcpci.h +1 -1
index 116a69c85e38..c3c7d07d9b4e 100644
@@ -72,6 +72,7 @@
 
 #define TCPC_POWER_CTRL                      0x1c
 #define TCPC_POWER_CTRL_VCONN_ENABLE BIT(0)
+#define TCPC_POWER_CTRL_BLEED_DISCHARGE      BIT(3)
 #define TCPC_POWER_CTRL_AUTO_DISCHARGE       BIT(4)
 #define TCPC_FAST_ROLE_SWAP_EN               BIT(7)
 
--

2.29.2

author maintainer
#15 lore raw

Re: [PATCH 5/5] USB: typec: tcpci: Add Bleed discharge to POWER_CONTROL definition

Quoted 4 lines · Badhri Jagan Sridharan

Hi Greg,

I have a patch ready to enable BLEED_DISCHARGE in tcpci code. I will send that in once you merge this patch to usb-next.

Feel free to send that now, no need to wait :)

thanks,

greg k-h

maintainer Acked-by on the v1 series
#16 lore raw
In reply to Greg Kroah-Hartman
Quoted 4 lines · Greg Kroah-Hartman

In digging through a large set of proposed typec patches for the Android common kernel, I've picked out 5 "easy" patches that should all go upstream (they all should go upstream, just will take a while to clean them up it seems...)

Cool. Is there already support for the new Enter_USB message? Badhri, maybe you know more about this, if somebody is working on that or not?

FWIW, for all except the first patch 1/5:

Quoted 8 lines

Badhri Jagan Sridharan (2):
USB: typec: tcpm: Prevent log overflow by removing old entries
USB: typec: tcpci: Add Bleed discharge to POWER_CONTROL definition

Kyle Tso (2):
USB: typec: tcpm: Fix PR_SWAP error handling
USB: typec: tcpm: Add a 30ms room for tPSSourceOn in PR_SWAP

Quoted 10 lines

pumahsu (1):
USB: typec: tcpm: Hard Reset after not receiving a Request

 drivers/usb/typec/tcpm/tcpci.h |  1 +
 drivers/usb/typec/tcpm/tcpm.c  | 30 +++++++++++++++---------------
 include/linux/usb/pd.h         |  1 +
 3 files changed, 17 insertions(+), 15 deletions(-)
Signature · 1 line
2.29.2

thanks,

Signature · 1 line
heikki
author maintainer
#17 lore raw
Quoted 6 lines · Heikki Krogerus
Quoted 4 lines · Greg Kroah-Hartman

In digging through a large set of proposed typec patches for the Android common kernel, I've picked out 5 "easy" patches that should all go upstream (they all should go upstream, just will take a while to clean them up it seems...)

Quoted 6 lines

Cool. Is there already support for the new Enter_USB message? Badhri, maybe you know more about this, if somebody is working on that or not?

FWIW, for all except the first patch 1/5:

Thanks, will drop patch 1 from the queue.

greg k-h