Skip to contentSkip to conversation

TCPM logbuffer wraparound

PATCH In review Badhri Jagan Sridharan 2 participants 3 messages Nov 3, 2025

Subsystems (3)
lore
Share & tools
lore

Badhri Jagan Sridharan

author maintainer
#0 lore raw

v2 cover TCPM logbuffer wraparound

This is a follow up on a previous discussion:
https://lore.kernel.org/lkml/[email protected]/.

With this change, TCPM log buffer will now wrap around when full and will not self-clear upon being read (dumped). A Kconfig option and a corresponding debugfs file node are introduced to allow opt-in back to the previous, non-wrapping, self-clearing behavior if required. This is an interim step while TCPM logging infrastructure is migrated to the standard event trace system.

Badhri Jagan Sridharan (1):
tcpm: Wraparound tcpm log and dont clear them when read

 drivers/usb/typec/tcpm/Kconfig |  8 ++++++
 drivers/usb/typec/tcpm/tcpm.c  | 51 ++++++++++++++++++++++++++++++++--
 2 files changed, 57 insertions(+), 2 deletions(-)

base-commit: 18514fd70ea4ca9de137bb3bceeac1bac4bcad75

Signature · 1 line
2.51.1.930.gacf6e81ea2-goog
author maintainer
#1 lore raw

PATCH v2 1/1 tcpm: Wraparound tcpm log and dont clear them when read

TCPM log do not wraparound by default and gets cleared when read. This results in logs overflowing over time and the recent logs containing relevant context to debug get dropped. Change this behavior to wraparound the log by default and do not clear the log when dumped.

Adding the Kconfig option, TCPM_LOG_DISABLE_WRAPAROUND, to disable wrap around and clear the log when read. Also adding a a debugfs file node, tcpm_log_disable_wraparound, to switch between the two during run time.

---
Changes since v1:
* Make wrapping around when full as the default behavior.
* Added a Kconfig and a debugfs node option to switch between the two behaviors.

---
 drivers/usb/typec/tcpm/Kconfig |  8 ++++++
 drivers/usb/typec/tcpm/tcpm.c  | 51 ++++++++++++++++++++++++++++++++--
 2 files changed, 57 insertions(+), 2 deletions(-)
drivers/usb/typec/tcpm/Kconfig +8 -0
index 8cdd84ca5d6f..4bb69f66c7bb 100644
@@ -11,6 +11,14 @@ config TYPEC_TCPM
 
 if TYPEC_TCPM
 
+config TCPM_LOG_DISABLE_WRAPAROUND
+	bool "Disable TCPM log wraparound"
+	depends on DEBUG_FS
+	help
+	  When set, TCPM log do not wraparound and clears when dumped.
+	  When not set(i.e. default), TCPM log wraps around when full and do
+	  not clear when dumped.
+
 config TYPEC_TCPCI
 	tristate "Type-C Port Controller Interface driver"
 	depends on I2C
drivers/usb/typec/tcpm/tcpm.c +49 -2

90 lines not on this page · raw message

Signature · 1 line
2.51.1.930.gacf6e81ea2-goog
maintainer
#2 lore raw
In reply to Badhri Jagan Sridharan
Quoted 9 lines · Badhri Jagan Sridharan

This is a follow up on a previous discussion:
https://lore.kernel.org/lkml/[email protected]/.

With this change, TCPM log buffer will now wrap around when full and will not self-clear upon being read (dumped). A Kconfig option and a corresponding debugfs file node are introduced to allow opt-in back to the previous, non-wrapping, self-clearing behavior if required. This is an interim step while TCPM logging infrastructure is migrated to the standard event trace system.

Ick, no, let's just move to the standard trace format instead. That should be much simpler and get rid of custom user/kernel apis and Kconfig options. Overall you should end up removing a bunch of code instead of adding new complexity like this.

thanks,

greg k-h