usb: gadget: add tracepoints to the gadget API

This new set of tracepoints will help all gadget
drivers and UDC drivers when problem appears. Note
that, in order to be able to add tracepoints to
udc-core.c we had to rename that to core.c and
statically link it with trace.c to form
udc-core.o. This is to make sure that module name
stays the same.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
This commit is contained in:
Felipe Balbi 2016-05-31 13:39:21 +03:00
parent 5a8d651a2b
commit 5e42d710a1
5 changed files with 530 additions and 55 deletions

View file

@ -1,3 +1,8 @@
# define_trace.h needs to know how to find our header
CFLAGS_trace.o := -I$(src)
udc-core-y := core.o trace.o
#
# USB peripheral controller drivers
#

View file

@ -29,6 +29,8 @@
#include <linux/usb/gadget.h>
#include <linux/usb.h>
#include "trace.h"
/**
* struct usb_udc - describes one usb device controller
* @driver - the gadget driver pointer. For use by the class code
@ -72,6 +74,8 @@ void usb_ep_set_maxpacket_limit(struct usb_ep *ep,
{
ep->maxpacket_limit = maxpacket_limit;
ep->maxpacket = maxpacket_limit;
trace_usb_ep_set_maxpacket_limit(ep, 0);
}
EXPORT_SYMBOL_GPL(usb_ep_set_maxpacket_limit);
@ -97,18 +101,23 @@ EXPORT_SYMBOL_GPL(usb_ep_set_maxpacket_limit);
*/
int usb_ep_enable(struct usb_ep *ep)
{
int ret;
int ret = 0;
if (ep->enabled)
return 0;
goto out;
ret = ep->ops->enable(ep, ep->desc);
if (ret)
return ret;
if (ret) {
ret = ret;
goto out;
}
ep->enabled = true;
return 0;
out:
trace_usb_ep_enable(ep, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_ep_enable);
@ -126,18 +135,23 @@ EXPORT_SYMBOL_GPL(usb_ep_enable);
*/
int usb_ep_disable(struct usb_ep *ep)
{
int ret;
int ret = 0;
if (!ep->enabled)
return 0;
goto out;
ret = ep->ops->disable(ep);
if (ret)
return ret;
if (ret) {
ret = ret;
goto out;
}
ep->enabled = false;
return 0;
out:
trace_usb_ep_disable(ep, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_ep_disable);
@ -158,7 +172,13 @@ EXPORT_SYMBOL_GPL(usb_ep_disable);
struct usb_request *usb_ep_alloc_request(struct usb_ep *ep,
gfp_t gfp_flags)
{
return ep->ops->alloc_request(ep, gfp_flags);
struct usb_request *req = NULL;
req = ep->ops->alloc_request(ep, gfp_flags);
trace_usb_ep_alloc_request(ep, req, req ? 0 : -ENOMEM);
return req;
}
EXPORT_SYMBOL_GPL(usb_ep_alloc_request);
@ -175,6 +195,7 @@ void usb_ep_free_request(struct usb_ep *ep,
struct usb_request *req)
{
ep->ops->free_request(ep, req);
trace_usb_ep_free_request(ep, req, 0);
}
EXPORT_SYMBOL_GPL(usb_ep_free_request);
@ -238,10 +259,19 @@ EXPORT_SYMBOL_GPL(usb_ep_free_request);
int usb_ep_queue(struct usb_ep *ep,
struct usb_request *req, gfp_t gfp_flags)
{
if (WARN_ON_ONCE(!ep->enabled && ep->address))
return -ESHUTDOWN;
int ret = 0;
return ep->ops->queue(ep, req, gfp_flags);
if (WARN_ON_ONCE(!ep->enabled && ep->address)) {
ret = -ESHUTDOWN;
goto out;
}
ret = ep->ops->queue(ep, req, gfp_flags);
out:
trace_usb_ep_queue(ep, req, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_ep_queue);
@ -262,7 +292,12 @@ EXPORT_SYMBOL_GPL(usb_ep_queue);
*/
int usb_ep_dequeue(struct usb_ep *ep, struct usb_request *req)
{
return ep->ops->dequeue(ep, req);
int ret;
ret = ep->ops->dequeue(ep, req);
trace_usb_ep_dequeue(ep, req, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_ep_dequeue);
@ -289,7 +324,12 @@ EXPORT_SYMBOL_GPL(usb_ep_dequeue);
*/
int usb_ep_set_halt(struct usb_ep *ep)
{
return ep->ops->set_halt(ep, 1);
int ret;
ret = ep->ops->set_halt(ep, 1);
trace_usb_ep_set_halt(ep, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_ep_set_halt);
@ -308,7 +348,12 @@ EXPORT_SYMBOL_GPL(usb_ep_set_halt);
*/
int usb_ep_clear_halt(struct usb_ep *ep)
{
return ep->ops->set_halt(ep, 0);
int ret;
ret = ep->ops->set_halt(ep, 0);
trace_usb_ep_clear_halt(ep, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_ep_clear_halt);
@ -324,10 +369,16 @@ EXPORT_SYMBOL_GPL(usb_ep_clear_halt);
*/
int usb_ep_set_wedge(struct usb_ep *ep)
{
int ret;
if (ep->ops->set_wedge)
return ep->ops->set_wedge(ep);
ret = ep->ops->set_wedge(ep);
else
return ep->ops->set_halt(ep, 1);
ret = ep->ops->set_halt(ep, 1);
trace_usb_ep_set_wedge(ep, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_ep_set_wedge);
@ -348,10 +399,16 @@ EXPORT_SYMBOL_GPL(usb_ep_set_wedge);
*/
int usb_ep_fifo_status(struct usb_ep *ep)
{
int ret;
if (ep->ops->fifo_status)
return ep->ops->fifo_status(ep);
ret = ep->ops->fifo_status(ep);
else
return -EOPNOTSUPP;
ret = -EOPNOTSUPP;
trace_usb_ep_fifo_status(ep, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_ep_fifo_status);
@ -368,6 +425,8 @@ void usb_ep_fifo_flush(struct usb_ep *ep)
{
if (ep->ops->fifo_flush)
ep->ops->fifo_flush(ep);
trace_usb_ep_fifo_flush(ep, 0);
}
EXPORT_SYMBOL_GPL(usb_ep_fifo_flush);
@ -382,7 +441,13 @@ EXPORT_SYMBOL_GPL(usb_ep_fifo_flush);
*/
int usb_gadget_frame_number(struct usb_gadget *gadget)
{
return gadget->ops->get_frame(gadget);
int ret;
ret = gadget->ops->get_frame(gadget);
trace_usb_gadget_frame_number(gadget, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_gadget_frame_number);
@ -401,9 +466,19 @@ EXPORT_SYMBOL_GPL(usb_gadget_frame_number);
*/
int usb_gadget_wakeup(struct usb_gadget *gadget)
{
if (!gadget->ops->wakeup)
return -EOPNOTSUPP;
return gadget->ops->wakeup(gadget);
int ret = 0;
if (!gadget->ops->wakeup) {
ret = -EOPNOTSUPP;
goto out;
}
ret = gadget->ops->wakeup(gadget);
out:
trace_usb_gadget_wakeup(gadget, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_gadget_wakeup);
@ -418,9 +493,19 @@ EXPORT_SYMBOL_GPL(usb_gadget_wakeup);
*/
int usb_gadget_set_selfpowered(struct usb_gadget *gadget)
{
if (!gadget->ops->set_selfpowered)
return -EOPNOTSUPP;
return gadget->ops->set_selfpowered(gadget, 1);
int ret = 0;
if (!gadget->ops->set_selfpowered) {
ret = -EOPNOTSUPP;
goto out;
}
ret = gadget->ops->set_selfpowered(gadget, 1);
out:
trace_usb_gadget_set_selfpowered(gadget, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_gadget_set_selfpowered);
@ -436,9 +521,19 @@ EXPORT_SYMBOL_GPL(usb_gadget_set_selfpowered);
*/
int usb_gadget_clear_selfpowered(struct usb_gadget *gadget)
{
if (!gadget->ops->set_selfpowered)
return -EOPNOTSUPP;
return gadget->ops->set_selfpowered(gadget, 0);
int ret = 0;
if (!gadget->ops->set_selfpowered) {
ret = -EOPNOTSUPP;
goto out;
}
ret = gadget->ops->set_selfpowered(gadget, 0);
out:
trace_usb_gadget_clear_selfpowered(gadget, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_gadget_clear_selfpowered);
@ -457,9 +552,19 @@ EXPORT_SYMBOL_GPL(usb_gadget_clear_selfpowered);
*/
int usb_gadget_vbus_connect(struct usb_gadget *gadget)
{
if (!gadget->ops->vbus_session)
return -EOPNOTSUPP;
return gadget->ops->vbus_session(gadget, 1);
int ret = 0;
if (!gadget->ops->vbus_session) {
ret = -EOPNOTSUPP;
goto out;
}
ret = gadget->ops->vbus_session(gadget, 1);
out:
trace_usb_gadget_vbus_connect(gadget, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_gadget_vbus_connect);
@ -477,9 +582,21 @@ EXPORT_SYMBOL_GPL(usb_gadget_vbus_connect);
*/
int usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
{
if (!gadget->ops->vbus_draw)
return -EOPNOTSUPP;
return gadget->ops->vbus_draw(gadget, mA);
int ret = 0;
if (!gadget->ops->vbus_draw) {
ret = -EOPNOTSUPP;
goto out;
}
ret = gadget->ops->vbus_draw(gadget, mA);
if (!ret)
gadget->mA = mA;
out:
trace_usb_gadget_vbus_draw(gadget, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_gadget_vbus_draw);
@ -496,9 +613,19 @@ EXPORT_SYMBOL_GPL(usb_gadget_vbus_draw);
*/
int usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
{
if (!gadget->ops->vbus_session)
return -EOPNOTSUPP;
return gadget->ops->vbus_session(gadget, 0);
int ret = 0;
if (!gadget->ops->vbus_session) {
ret = -EOPNOTSUPP;
goto out;
}
ret = gadget->ops->vbus_session(gadget, 0);
out:
trace_usb_gadget_vbus_disconnect(gadget, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_gadget_vbus_disconnect);
@ -515,10 +642,12 @@ EXPORT_SYMBOL_GPL(usb_gadget_vbus_disconnect);
*/
int usb_gadget_connect(struct usb_gadget *gadget)
{
int ret;
int ret = 0;
if (!gadget->ops->pullup)
return -EOPNOTSUPP;
if (!gadget->ops->pullup) {
ret = -EOPNOTSUPP;
goto out;
}
if (gadget->deactivated) {
/*
@ -526,12 +655,16 @@ int usb_gadget_connect(struct usb_gadget *gadget)
* Gadget will be connected automatically after activation.
*/
gadget->connected = true;
return 0;
goto out;
}
ret = gadget->ops->pullup(gadget, 1);
if (!ret)
gadget->connected = 1;
out:
trace_usb_gadget_connect(gadget, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_gadget_connect);
@ -548,10 +681,12 @@ EXPORT_SYMBOL_GPL(usb_gadget_connect);
*/
int usb_gadget_disconnect(struct usb_gadget *gadget)
{
int ret;
int ret = 0;
if (!gadget->ops->pullup)
return -EOPNOTSUPP;
if (!gadget->ops->pullup) {
ret = -EOPNOTSUPP;
goto out;
}
if (gadget->deactivated) {
/*
@ -559,12 +694,16 @@ int usb_gadget_disconnect(struct usb_gadget *gadget)
* Gadget will stay disconnected after activation.
*/
gadget->connected = false;
return 0;
goto out;
}
ret = gadget->ops->pullup(gadget, 0);
if (!ret)
gadget->connected = 0;
out:
trace_usb_gadget_disconnect(gadget, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_gadget_disconnect);
@ -582,15 +721,16 @@ EXPORT_SYMBOL_GPL(usb_gadget_disconnect);
*/
int usb_gadget_deactivate(struct usb_gadget *gadget)
{
int ret;
int ret = 0;
if (gadget->deactivated)
return 0;
goto out;
if (gadget->connected) {
ret = usb_gadget_disconnect(gadget);
if (ret)
return ret;
goto out;
/*
* If gadget was being connected before deactivation, we want
* to reconnect it in usb_gadget_activate().
@ -599,7 +739,10 @@ int usb_gadget_deactivate(struct usb_gadget *gadget)
}
gadget->deactivated = true;
return 0;
out:
trace_usb_gadget_deactivate(gadget, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_gadget_deactivate);
@ -614,8 +757,10 @@ EXPORT_SYMBOL_GPL(usb_gadget_deactivate);
*/
int usb_gadget_activate(struct usb_gadget *gadget)
{
int ret = 0;
if (!gadget->deactivated)
return 0;
goto out;
gadget->deactivated = false;
@ -624,9 +769,12 @@ int usb_gadget_activate(struct usb_gadget *gadget)
* while it was being deactivated, we call usb_gadget_connect().
*/
if (gadget->connected)
return usb_gadget_connect(gadget);
ret = usb_gadget_connect(gadget);
return 0;
out:
trace_usb_gadget_activate(gadget, ret);
return ret;
}
EXPORT_SYMBOL_GPL(usb_gadget_activate);
@ -714,6 +862,8 @@ void usb_gadget_giveback_request(struct usb_ep *ep,
if (likely(req->status == 0))
usb_led_activity(USB_LED_EVENT_GADGET);
trace_usb_gadget_giveback_request(ep, req, 0);
req->complete(ep, req);
}
EXPORT_SYMBOL_GPL(usb_gadget_giveback_request);

View file

@ -0,0 +1,18 @@
/**
* trace.c - USB Gadget Framework Trace Support
*
* Copyright (C) 2016 Intel Corporation
* Author: Felipe Balbi <felipe.balbi@linux.intel.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 of
* the License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#define CREATE_TRACE_POINTS
#include "trace.h"

View file

@ -0,0 +1,298 @@
/**
* udc.c - Core UDC Framework
*
* Copyright (C) 2016 Intel Corporation
* Author: Felipe Balbi <felipe.balbi@linux.intel.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 of
* the License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#undef TRACE_SYSTEM
#define TRACE_SYSTEM gadget
#if !defined(__UDC_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
#define __UDC_TRACE_H
#include <linux/types.h>
#include <linux/tracepoint.h>
#include <asm/byteorder.h>
#include <linux/usb/gadget.h>
DECLARE_EVENT_CLASS(udc_log_gadget,
TP_PROTO(struct usb_gadget *g, int ret),
TP_ARGS(g, ret),
TP_STRUCT__entry(
__field(enum usb_device_speed, speed)
__field(enum usb_device_speed, max_speed)
__field(enum usb_device_state, state)
__field(unsigned, mA)
__field(unsigned, sg_supported)
__field(unsigned, is_otg)
__field(unsigned, is_a_peripheral)
__field(unsigned, b_hnp_enable)
__field(unsigned, a_hnp_support)
__field(unsigned, hnp_polling_support)
__field(unsigned, host_request_flag)
__field(unsigned, quirk_ep_out_aligned_size)
__field(unsigned, quirk_altset_not_supp)
__field(unsigned, quirk_stall_not_supp)
__field(unsigned, quirk_zlp_not_supp)
__field(unsigned, is_selfpowered)
__field(unsigned, deactivated)
__field(unsigned, connected)
__field(int, ret)
),
TP_fast_assign(
__entry->speed = g->speed;
__entry->max_speed = g->max_speed;
__entry->state = g->state;
__entry->mA = g->mA;
__entry->sg_supported = g->sg_supported;
__entry->is_otg = g->is_otg;
__entry->is_a_peripheral = g->is_a_peripheral;
__entry->b_hnp_enable = g->b_hnp_enable;
__entry->a_hnp_support = g->a_hnp_support;
__entry->hnp_polling_support = g->hnp_polling_support;
__entry->host_request_flag = g->host_request_flag;
__entry->quirk_ep_out_aligned_size = g->quirk_ep_out_aligned_size;
__entry->quirk_altset_not_supp = g->quirk_altset_not_supp;
__entry->quirk_stall_not_supp = g->quirk_stall_not_supp;
__entry->quirk_zlp_not_supp = g->quirk_zlp_not_supp;
__entry->is_selfpowered = g->is_selfpowered;
__entry->deactivated = g->deactivated;
__entry->connected = g->connected;
__entry->ret = ret;
),
TP_printk("speed %d/%d state %d %dmA [%s%s%s%s%s%s%s%s%s%s%s%s%s%s] --> %d",
__entry->speed, __entry->max_speed, __entry->state, __entry->mA,
__entry->sg_supported ? "sg:" : "",
__entry->is_otg ? "OTG:" : "",
__entry->is_a_peripheral ? "a_peripheral:" : "",
__entry->b_hnp_enable ? "b_hnp:" : "",
__entry->a_hnp_support ? "a_hnp:" : "",
__entry->hnp_polling_support ? "hnp_poll:" : "",
__entry->host_request_flag ? "hostreq:" : "",
__entry->quirk_ep_out_aligned_size ? "out_aligned:" : "",
__entry->quirk_altset_not_supp ? "no_altset:" : "",
__entry->quirk_stall_not_supp ? "no_stall:" : "",
__entry->quirk_zlp_not_supp ? "no_zlp" : "",
__entry->is_selfpowered ? "self-powered:" : "bus-powered:",
__entry->deactivated ? "deactivated:" : "activated:",
__entry->connected ? "connected" : "disconnected",
__entry->ret)
);
DEFINE_EVENT(udc_log_gadget, usb_gadget_frame_number,
TP_PROTO(struct usb_gadget *g, int ret),
TP_ARGS(g, ret)
);
DEFINE_EVENT(udc_log_gadget, usb_gadget_wakeup,
TP_PROTO(struct usb_gadget *g, int ret),
TP_ARGS(g, ret)
);
DEFINE_EVENT(udc_log_gadget, usb_gadget_set_selfpowered,
TP_PROTO(struct usb_gadget *g, int ret),
TP_ARGS(g, ret)
);
DEFINE_EVENT(udc_log_gadget, usb_gadget_clear_selfpowered,
TP_PROTO(struct usb_gadget *g, int ret),
TP_ARGS(g, ret)
);
DEFINE_EVENT(udc_log_gadget, usb_gadget_vbus_connect,
TP_PROTO(struct usb_gadget *g, int ret),
TP_ARGS(g, ret)
);
DEFINE_EVENT(udc_log_gadget, usb_gadget_vbus_draw,
TP_PROTO(struct usb_gadget *g, int ret),
TP_ARGS(g, ret)
);
DEFINE_EVENT(udc_log_gadget, usb_gadget_vbus_disconnect,
TP_PROTO(struct usb_gadget *g, int ret),
TP_ARGS(g, ret)
);
DEFINE_EVENT(udc_log_gadget, usb_gadget_connect,
TP_PROTO(struct usb_gadget *g, int ret),
TP_ARGS(g, ret)
);
DEFINE_EVENT(udc_log_gadget, usb_gadget_disconnect,
TP_PROTO(struct usb_gadget *g, int ret),
TP_ARGS(g, ret)
);
DEFINE_EVENT(udc_log_gadget, usb_gadget_deactivate,
TP_PROTO(struct usb_gadget *g, int ret),
TP_ARGS(g, ret)
);
DEFINE_EVENT(udc_log_gadget, usb_gadget_activate,
TP_PROTO(struct usb_gadget *g, int ret),
TP_ARGS(g, ret)
);
DECLARE_EVENT_CLASS(udc_log_ep,
TP_PROTO(struct usb_ep *ep, int ret),
TP_ARGS(ep, ret),
TP_STRUCT__entry(
__dynamic_array(char, name, UDC_TRACE_STR_MAX)
__field(unsigned, maxpacket)
__field(unsigned, maxpacket_limit)
__field(unsigned, max_streams)
__field(unsigned, mult)
__field(unsigned, maxburst)
__field(u8, address)
__field(bool, claimed)
__field(bool, enabled)
__field(int, ret)
),
TP_fast_assign(
snprintf(__get_str(name), UDC_TRACE_STR_MAX, "%s", ep->name);
__entry->maxpacket = ep->maxpacket;
__entry->maxpacket_limit = ep->maxpacket_limit;
__entry->max_streams = ep->max_streams;
__entry->mult = ep->mult;
__entry->maxburst = ep->maxburst;
__entry->address = ep->address,
__entry->claimed = ep->claimed;
__entry->enabled = ep->enabled;
__entry->ret = ret;
),
TP_printk("%s: mps %d/%d streams %d mult %d burst %d addr %02x %s%s --> %d",
__get_str(name), __entry->maxpacket, __entry->maxpacket_limit,
__entry->max_streams, __entry->mult, __entry->maxburst,
__entry->address, __entry->claimed ? "claimed:" : "released:",
__entry->enabled ? "enabled" : "disabled", ret)
);
DEFINE_EVENT(udc_log_ep, usb_ep_set_maxpacket_limit,
TP_PROTO(struct usb_ep *ep, int ret),
TP_ARGS(ep, ret)
);
DEFINE_EVENT(udc_log_ep, usb_ep_enable,
TP_PROTO(struct usb_ep *ep, int ret),
TP_ARGS(ep, ret)
);
DEFINE_EVENT(udc_log_ep, usb_ep_disable,
TP_PROTO(struct usb_ep *ep, int ret),
TP_ARGS(ep, ret)
);
DEFINE_EVENT(udc_log_ep, usb_ep_set_halt,
TP_PROTO(struct usb_ep *ep, int ret),
TP_ARGS(ep, ret)
);
DEFINE_EVENT(udc_log_ep, usb_ep_clear_halt,
TP_PROTO(struct usb_ep *ep, int ret),
TP_ARGS(ep, ret)
);
DEFINE_EVENT(udc_log_ep, usb_ep_set_wedge,
TP_PROTO(struct usb_ep *ep, int ret),
TP_ARGS(ep, ret)
);
DEFINE_EVENT(udc_log_ep, usb_ep_fifo_status,
TP_PROTO(struct usb_ep *ep, int ret),
TP_ARGS(ep, ret)
);
DEFINE_EVENT(udc_log_ep, usb_ep_fifo_flush,
TP_PROTO(struct usb_ep *ep, int ret),
TP_ARGS(ep, ret)
);
DECLARE_EVENT_CLASS(udc_log_req,
TP_PROTO(struct usb_ep *ep, struct usb_request *req, int ret),
TP_ARGS(ep, req, ret),
TP_STRUCT__entry(
__dynamic_array(char, name, UDC_TRACE_STR_MAX)
__field(unsigned, length)
__field(unsigned, actual)
__field(unsigned, num_sgs)
__field(unsigned, num_mapped_sgs)
__field(unsigned, stream_id)
__field(unsigned, no_interrupt)
__field(unsigned, zero)
__field(unsigned, short_not_ok)
__field(int, status)
__field(int, ret)
),
TP_fast_assign(
snprintf(__get_str(name), UDC_TRACE_STR_MAX, "%s", ep->name);
__entry->length = req->length;
__entry->actual = req->actual;
__entry->num_sgs = req->num_sgs;
__entry->num_mapped_sgs = req->num_mapped_sgs;
__entry->stream_id = req->stream_id;
__entry->no_interrupt = req->no_interrupt;
__entry->zero = req->zero;
__entry->short_not_ok = req->short_not_ok;
__entry->status = req->status;
__entry->ret = ret;
),
TP_printk("%s: length %d/%d sgs %d/%d stream %d %s%s%s status %d --> %d",
__get_str(name), __entry->actual, __entry->length,
__entry->num_mapped_sgs, __entry->num_sgs, __entry->stream_id,
__entry->zero ? "Z" : "z",
__entry->short_not_ok ? "S" : "s",
__entry->no_interrupt ? "i" : "I",
__entry->status, __entry->ret
)
);
DEFINE_EVENT(udc_log_req, usb_ep_alloc_request,
TP_PROTO(struct usb_ep *ep, struct usb_request *req, int ret),
TP_ARGS(ep, req, ret)
);
DEFINE_EVENT(udc_log_req, usb_ep_free_request,
TP_PROTO(struct usb_ep *ep, struct usb_request *req, int ret),
TP_ARGS(ep, req, ret)
);
DEFINE_EVENT(udc_log_req, usb_ep_queue,
TP_PROTO(struct usb_ep *ep, struct usb_request *req, int ret),
TP_ARGS(ep, req, ret)
);
DEFINE_EVENT(udc_log_req, usb_ep_dequeue,
TP_PROTO(struct usb_ep *ep, struct usb_request *req, int ret),
TP_ARGS(ep, req, ret)
);
DEFINE_EVENT(udc_log_req, usb_gadget_giveback_request,
TP_PROTO(struct usb_ep *ep, struct usb_request *req, int ret),
TP_ARGS(ep, req, ret)
);
#endif /* __UDC_TRACE_H */
/* this part has to be here */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE trace
#include <trace/define_trace.h>

View file

@ -25,6 +25,8 @@
#include <linux/workqueue.h>
#include <linux/usb/ch9.h>
#define UDC_TRACE_STR_MAX 512
struct usb_ep;
/**
@ -324,6 +326,7 @@ struct usb_gadget_ops {
* @dev: Driver model state for this abstract device.
* @out_epnum: last used out ep number
* @in_epnum: last used in ep number
* @mA: last set mA value
* @otg_caps: OTG capabilities of this gadget.
* @sg_supported: true if we can handle scatter-gather
* @is_otg: True if the USB device port uses a Mini-AB jack, so that the
@ -380,6 +383,7 @@ struct usb_gadget {
struct device dev;
unsigned out_epnum;
unsigned in_epnum;
unsigned mA;
struct usb_otg_caps *otg_caps;
unsigned sg_supported:1;