Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: dwc3: Add trace event for dwc3_set_prtcap

Changes to the port capability can be indirectly observed by tracing
register writes to DWC3_GCTL. However, this requires interpreting the
raw value, which is neither intuitive nor precise for debugging.
Monitoring these mode changes is essential for resolving issues related
to USB role switching and enumeration.

Introduce a dedicated trace event to provide a human-readable log when
the port capability is configured.

Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://lore.kernel.org/r/20250822092411.173519-1-khtsai@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Kuen-Han Tsai and committed by
Greg Kroah-Hartman
55f4ac8f b570b346

+36
+1
drivers/usb/dwc3/core.c
··· 156 156 dwc3_writel(dwc->regs, DWC3_GCTL, reg); 157 157 158 158 dwc->current_dr_role = mode; 159 + trace_dwc3_set_prtcap(mode); 159 160 } 160 161 161 162 static void __dwc3_set_mode(struct work_struct *work)
+18
drivers/usb/dwc3/debug.h
··· 14 14 #include "core.h" 15 15 16 16 /** 17 + * dwc3_mode_string - returns mode name 18 + * @mode: GCTL.PrtCapDir value 19 + */ 20 + static inline const char *dwc3_mode_string(u32 mode) 21 + { 22 + switch (mode) { 23 + case DWC3_GCTL_PRTCAP_HOST: 24 + return "host"; 25 + case DWC3_GCTL_PRTCAP_DEVICE: 26 + return "device"; 27 + case DWC3_GCTL_PRTCAP_OTG: 28 + return "otg"; 29 + default: 30 + return "UNKNOWN"; 31 + } 32 + } 33 + 34 + /** 17 35 * dwc3_gadget_ep_cmd_string - returns endpoint command string 18 36 * @cmd: command code 19 37 */
+17
drivers/usb/dwc3/trace.h
··· 19 19 #include "core.h" 20 20 #include "debug.h" 21 21 22 + DECLARE_EVENT_CLASS(dwc3_log_set_prtcap, 23 + TP_PROTO(u32 mode), 24 + TP_ARGS(mode), 25 + TP_STRUCT__entry( 26 + __field(u32, mode) 27 + ), 28 + TP_fast_assign( 29 + __entry->mode = mode; 30 + ), 31 + TP_printk("mode %s", dwc3_mode_string(__entry->mode)) 32 + ); 33 + 34 + DEFINE_EVENT(dwc3_log_set_prtcap, dwc3_set_prtcap, 35 + TP_PROTO(u32 mode), 36 + TP_ARGS(mode) 37 + ); 38 + 22 39 DECLARE_EVENT_CLASS(dwc3_log_io, 23 40 TP_PROTO(void *base, u32 offset, u32 value), 24 41 TP_ARGS(base, offset, value),