@@ -18,6 +18,12 @@ config TYPEC_TCPCI
help
Type-C Port Controller driver for TCPCI-compliant controller.
+config TCPM_LOG_WRAPAROUND
+ bool "Enable TCPM log wraparound"
+ help
+ When set, wraps around TCPM logs and does not clear the logs when dumped. TCPM logs by
+ default gets cleared when dumped and does not wraparound when full.
+
if TYPEC_TCPCI
config TYPEC_RT1711H
@@ -619,7 +619,7 @@ 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)) {
+ if (!IS_ENABLED(CONFIG_TCPM_LOG_WRAPAROUND) && tcpm_log_full(port)) {
port->logbuffer_head = max(port->logbuffer_head - 1, 0);
strcpy(tmpbuffer, "overflow");
}
@@ -644,6 +644,10 @@ static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
tmpbuffer);
port->logbuffer_head = (port->logbuffer_head + 1) % LOG_BUFFER_ENTRIES;
+ if (IS_ENABLED(CONFIG_TCPM_LOG_WRAPAROUND) && port->logbuffer_head == port->logbuffer_tail)
+ port->logbuffer_tail =
+ (port->logbuffer_tail + 1) % LOG_BUFFER_ENTRIES;
+
abort:
mutex_unlock(&port->logbuffer_lock);
}
@@ -746,7 +750,8 @@ 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))
+
+ if (!IS_ENABLED(CONFIG_TCPM_LOG_WRAPAROUND) && !seq_has_overflowed(s))
port->logbuffer_tail = tail;
mutex_unlock(&port->logbuffer_lock);
This change adds CONFIG_TCPM_LOG_WRAPAROUND which when set allows the logs to be wrapped around. Additionally, when set, does not clear the TCPM logs when dumped. Signed-off-by: Badhri Jagan Sridharan <badhri@google.com> --- drivers/usb/typec/tcpm/Kconfig | 6 ++++++ drivers/usb/typec/tcpm/tcpm.c | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)