Some Type-C controllers toggle muxes themselves. Other controllers like the TUSB320 report the mode to the host, so it can control the muxes.
To improve debuggability of both kinds of drivers, add a trace point that can be used to keep track of the mode being set inside the Type-C framework: echo 1 > /sys/kernel/debug/tracing/events/typec/typec_mode/enable Signed-off-by: Ahmad Fatoum <[email protected]> --- MAINTAINERS | 1 + drivers/usb/typec/class.c | 9 ++++++++- include/trace/events/typec.h | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index c8d4b913f26c..ddd59e5e6eaf 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -27753,6 +27753,7 @@ F: Documentation/ABI/testing/sysfs-class-typec F: Documentation/driver-api/usb/typec.rst F: drivers/usb/typec/ F: include/linux/usb/typec.h +F: include/trace/events/typec*.h USB TYPEC INTEL PMC MUX DRIVER M: Heikki Krogerus <[email protected]> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 0977581ad1b6..9316d067f19a 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -20,6 +20,9 @@ #include "class.h" #include "pd.h" +#define CREATE_TRACE_POINTS +#include <trace/events/typec.h> + static DEFINE_IDA(typec_index_ida); const struct class typec_class = { @@ -2427,10 +2430,14 @@ EXPORT_SYMBOL_GPL(typec_get_orientation); int typec_set_mode(struct typec_port *port, int mode) { struct typec_mux_state state = { }; + int ret; state.mode = mode; - return typec_mux_set(port->mux, &state); + ret = typec_mux_set(port->mux, &state); + trace_typec_mode(port, mode, ret); + + return ret; } EXPORT_SYMBOL_GPL(typec_set_mode); diff --git a/include/trace/events/typec.h b/include/trace/events/typec.h new file mode 100644 index 000000000000..a7dcb9f3fd49 --- /dev/null +++ b/include/trace/events/typec.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM typec + +#if !defined(_TRACE_TYPEC_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_TYPEC_H + +#include <linux/usb/typec.h> +#include <linux/tracepoint.h> + +TRACE_EVENT(typec_mode, + + TP_PROTO(struct typec_port *port, int mode, int err), + + TP_ARGS(port, mode, err), + + TP_STRUCT__entry( + __string(device, dev_name(&port->dev)) + __field(int, mode) + __field(int, err) + ), + + TP_fast_assign( + __assign_str(device); + __entry->mode = mode; + __entry->err = err; + ), + + TP_printk("%s mode=%d (%d)", + __get_str(device), __entry->mode, __entry->err) +); + +#endif /* if !defined(_TRACE_TYPEC_H) || defined(TRACE_HEADER_MULTI_READ) */ + +/* This part must be outside protection */ +#include <trace/define_trace.h> --- base-commit: 8cd9520d35a6c38db6567e97dd93b1f11f185dc6 change-id: 20260617-typec_set_mode-tracepoint-011fc43feaca Best regards, -- Ahmad Fatoum <[email protected]>
