ANDROID: vendor_hooks: Add vendor hook for tcpm logs

Context: https://lore.kernel.org/lkml/CAPTae5LbWVc4Bdiwe69cwwxEGfSYvRv=419dUGR1u8n-WUkYAA@mail.gmail.com/t/

Logs in /sys/kernel/debug/usb/tcpm* are key to debug issues related to
USB charging or data. However, tcpm logbuffer logs do not wraparound once full. Whereas we want it to wrap around so that we capture relevant info in the bugreport when the user collects one. There is sentiment in upstream to get rid of the logbuffer altogether and move to tracing. But trace events are not default enabled in Android, so that implies, even if user can somehow enable the trace event, user would have repro the issue and collect the bugreport. That would cause inconvenience to the end user. The vendor hooks is needed till upstream either allows wrapping around logs (or) Android has a generic way to default enable trace events which can be captured in bugreport.

bypass_log is set to true by the handler if logging into logbuffer is
not needed.

Bug: 189792358
Bug: 271294543
Change-Id: Icacfed2264b6c49b8e803c62f8bd820a146c169a
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
(cherry picked from commit bcfe28b62f)
This commit is contained in:
Badhri Jagan Sridharan
2021-05-31 15:19:54 -07:00
parent b499bac439
commit bbc22694d4
3 changed files with 10 additions and 1 deletions

View File

@@ -175,3 +175,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_typec_tcpci_get_vbus);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_store_partner_src_caps);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpm_get_timer);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpm_modify_src_caps);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpm_log);

View File

@@ -607,6 +607,7 @@ static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
char tmpbuffer[LOG_BUFFER_ENTRY_SIZE];
u64 ts_nsec = local_clock();
unsigned long rem_nsec;
bool bypass_log = false;
mutex_lock(&port->logbuffer_lock);
if (!port->logbuffer[port->logbuffer_head]) {
@@ -619,6 +620,9 @@ static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
}
vsnprintf(tmpbuffer, sizeof(tmpbuffer), fmt, args);
trace_android_vh_typec_tcpm_log(tmpbuffer, &bypass_log);
if (bypass_log)
goto abort;
if (tcpm_log_full(port)) {
port->logbuffer_head = max(port->logbuffer_head - 1, 0);

View File

@@ -50,6 +50,10 @@ DECLARE_HOOK(android_vh_typec_tcpm_modify_src_caps,
TP_PROTO(unsigned int *nr_src_pdo, u32 (*src_pdo)[], bool *modified),
TP_ARGS(nr_src_pdo, src_pdo, modified));
#endif /* _TRACE_HOOK_TYPEC_H */
DECLARE_HOOK(android_vh_typec_tcpm_log,
TP_PROTO(const char *log, bool *bypass),
TP_ARGS(log, bypass));
#endif /* _TRACE_HOOK_UFSHCD_H */
/* This part must be outside protection */
#include <trace/define_trace.h>