]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
usb: core: Add tracepoints for device allocation and state changes
authorKuen-Han Tsai <khtsai@google.com>
Tue, 14 Oct 2025 19:50:52 +0000 (03:50 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Oct 2025 08:58:30 +0000 (10:58 +0200)
commit071786e27d81d3e8ae11f078357c9373fc4ce2e8
treec6e682fb2d8098ddd53e8e85661469c1905338e6
parentc05ebd0ec91e27408767c46dd16c291cbff2213d
usb: core: Add tracepoints for device allocation and state changes

Introduce new tracepoints to the USB core to improve debuggability of
USB device lifecycle events.

The following tracepoints are added:

- usb_alloc_dev: Triggered when a new USB device structure is allocated,
providing insights into early device setup.
- usb_set_device_state: Triggered when the USB device state changes,
allowing observation of the device's state transitions.

These tracepoints capture detailed information about the USB device,
including its name, speed, state, bus current value, and authorized
flag. This will aid developers in diagnosing issues related to device
enumeration within the USB subsystem.

Examples:
 usb_alloc_dev: usb 1-1 speed UNKNOWN state attached 0mA [authorized]
 usb_set_device_state: usb 1-1 speed UNKNOWN state powered 0mA [authorized]
 usb_set_device_state: usb 1-1 speed full-speed state default 500mA [authorized]
 usb_set_device_state: usb 1-1 speed full-speed state default 500mA [authorized]
 usb_set_device_state: usb 1-1 speed full-speed state addressed 500mA [authorized]
 usb_set_device_state: usb 1-1 speed full-speed state configured 500mA [authorized]
 usb_set_device_state: usb 1-1 speed full-speed state suspended 500mA [authorized]
 usb_set_device_state: usb 1-1 speed full-speed state not attached 500mA [authorized]

Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://patch.msgid.link/20251015-usbcore-tracing-v2-2-5a14b5b9d4e0@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/Makefile
drivers/usb/core/hub.c
drivers/usb/core/trace.c [new file with mode: 0644]
drivers/usb/core/trace.h [new file with mode: 0644]
drivers/usb/core/usb.c