* [PATCH] usb: udc: Add trace event for usb_gadget_set_state
@ 2025-08-18 8:27 Kuen-Han Tsai
0 siblings, 0 replies; only message in thread
From: Kuen-Han Tsai @ 2025-08-18 8:27 UTC (permalink / raw)
To: gregkh, royluo, jkeeping, stern; +Cc: linux-usb, linux-kernel, Kuen-Han Tsai
While the userspace program can be notified of gadget state changes,
timing issue can lead to missed transitions when reading the state
value.
Introduce a trace event for usb_gadget_set_state to reliably track state
transitions.
Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
---
drivers/usb/gadget/udc/core.c | 1 +
drivers/usb/gadget/udc/trace.h | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index d709e24c1fd4..e28fea614496 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -1125,6 +1125,7 @@ void usb_gadget_set_state(struct usb_gadget *gadget,
{
gadget->state = state;
schedule_work(&gadget->work);
+ trace_usb_gadget_set_state(gadget, 0);
}
EXPORT_SYMBOL_GPL(usb_gadget_set_state);
diff --git a/drivers/usb/gadget/udc/trace.h b/drivers/usb/gadget/udc/trace.h
index 4e334298b0e8..fa3e6ddf0a12 100644
--- a/drivers/usb/gadget/udc/trace.h
+++ b/drivers/usb/gadget/udc/trace.h
@@ -81,6 +81,11 @@ DECLARE_EVENT_CLASS(udc_log_gadget,
__entry->ret)
);
+DEFINE_EVENT(udc_log_gadget, usb_gadget_set_state,
+ TP_PROTO(struct usb_gadget *g, int ret),
+ TP_ARGS(g, ret)
+);
+
DEFINE_EVENT(udc_log_gadget, usb_gadget_frame_number,
TP_PROTO(struct usb_gadget *g, int ret),
TP_ARGS(g, ret)
--
2.51.0.rc1.163.g2494970778-goog
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-08-18 8:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-18 8:27 [PATCH] usb: udc: Add trace event for usb_gadget_set_state Kuen-Han Tsai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).