From: Badhri Jagan Sridharan <badhri@google.com>
To: linux@roeck-us.net, heikki.krogerus@linux.intel.com,
gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Badhri Jagan Sridharan <badhri@google.com>
Subject: [PATCH v1] usb: typec: tcpm: Add kernel config to wrap around tcpm logs
Date: Mon, 10 Apr 2023 07:31:34 +0000 [thread overview]
Message-ID: <20230410073134.488762-1-badhri@google.com> (raw)
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(-)
diff --git a/drivers/usb/typec/tcpm/Kconfig b/drivers/usb/typec/tcpm/Kconfig
index e6b88ca4a4b9..4dd2b594dfc9 100644
--- a/drivers/usb/typec/tcpm/Kconfig
+++ b/drivers/usb/typec/tcpm/Kconfig
@@ -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
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index ab3a54662ed9..3f708749431b 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -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);
--
2.40.0.577.gac1e443424-goog
next reply other threads:[~2023-04-10 7:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-10 7:31 Badhri Jagan Sridharan [this message]
2023-04-10 7:45 ` [PATCH v1] usb: typec: tcpm: Add kernel config to wrap around tcpm logs Greg KH
2023-04-10 8:08 ` Badhri Jagan Sridharan
2023-04-10 8:26 ` Greg KH
2023-04-10 9:00 ` Badhri Jagan Sridharan
2023-04-10 9:08 ` Badhri Jagan Sridharan
2023-04-10 17:00 ` Guenter Roeck
2023-04-10 20:57 ` Badhri Jagan Sridharan
2023-04-10 22:12 ` Guenter Roeck
2023-04-10 14:13 ` Guenter Roeck
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=20230410073134.488762-1-badhri@google.com \
--to=badhri@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
/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