2 * xHCI host controller driver
4 * Copyright (C) 2013 Xenia Ragiadakou
6 * Author: Xenia Ragiadakou
7 * Email : burzalodowa@gmail.com
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
15 #define TRACE_SYSTEM xhci-hcd
18 * The TRACE_SYSTEM_VAR defaults to TRACE_SYSTEM, but must be a
19 * legitimate C variable. It is not exported to user space.
21 #undef TRACE_SYSTEM_VAR
22 #define TRACE_SYSTEM_VAR xhci_hcd
24 #if !defined(__XHCI_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
25 #define __XHCI_TRACE_H
27 #include <linux/tracepoint.h>
30 #define XHCI_MSG_MAX 500
32 DECLARE_EVENT_CLASS(xhci_log_msg
,
33 TP_PROTO(struct va_format
*vaf
),
35 TP_STRUCT__entry(__dynamic_array(char, msg
, XHCI_MSG_MAX
)),
37 vsnprintf(__get_str(msg
), XHCI_MSG_MAX
, vaf
->fmt
, *vaf
->va
);
39 TP_printk("%s", __get_str(msg
))
42 DEFINE_EVENT(xhci_log_msg
, xhci_dbg_address
,
43 TP_PROTO(struct va_format
*vaf
),
47 DEFINE_EVENT(xhci_log_msg
, xhci_dbg_context_change
,
48 TP_PROTO(struct va_format
*vaf
),
52 DEFINE_EVENT(xhci_log_msg
, xhci_dbg_quirks
,
53 TP_PROTO(struct va_format
*vaf
),
57 DEFINE_EVENT(xhci_log_msg
, xhci_dbg_reset_ep
,
58 TP_PROTO(struct va_format
*vaf
),
62 DEFINE_EVENT(xhci_log_msg
, xhci_dbg_cancel_urb
,
63 TP_PROTO(struct va_format
*vaf
),
67 DEFINE_EVENT(xhci_log_msg
, xhci_dbg_init
,
68 TP_PROTO(struct va_format
*vaf
),
72 DEFINE_EVENT(xhci_log_msg
, xhci_dbg_ring_expansion
,
73 TP_PROTO(struct va_format
*vaf
),
77 DECLARE_EVENT_CLASS(xhci_log_ctx
,
78 TP_PROTO(struct xhci_hcd
*xhci
, struct xhci_container_ctx
*ctx
,
80 TP_ARGS(xhci
, ctx
, ep_num
),
83 __field(unsigned, ctx_type
)
84 __field(dma_addr_t
, ctx_dma
)
86 __field(unsigned, ctx_ep_num
)
88 __dynamic_array(u32
, ctx_data
,
89 ((HCC_64BYTE_CONTEXT(xhci
->hcc_params
) + 1) * 8) *
90 ((ctx
->type
== XHCI_CTX_TYPE_INPUT
) + ep_num
+ 1))
93 struct usb_device
*udev
;
95 udev
= to_usb_device(xhci_to_hcd(xhci
)->self
.controller
);
96 __entry
->ctx_64
= HCC_64BYTE_CONTEXT(xhci
->hcc_params
);
97 __entry
->ctx_type
= ctx
->type
;
98 __entry
->ctx_dma
= ctx
->dma
;
99 __entry
->ctx_va
= ctx
->bytes
;
100 __entry
->slot_id
= udev
->slot_id
;
101 __entry
->ctx_ep_num
= ep_num
;
102 memcpy(__get_dynamic_array(ctx_data
), ctx
->bytes
,
103 ((HCC_64BYTE_CONTEXT(xhci
->hcc_params
) + 1) * 32) *
104 ((ctx
->type
== XHCI_CTX_TYPE_INPUT
) + ep_num
+ 1));
106 TP_printk("ctx_64=%d, ctx_type=%u, ctx_dma=@%llx, ctx_va=@%p",
107 __entry
->ctx_64
, __entry
->ctx_type
,
108 (unsigned long long) __entry
->ctx_dma
, __entry
->ctx_va
112 DEFINE_EVENT(xhci_log_ctx
, xhci_address_ctx
,
113 TP_PROTO(struct xhci_hcd
*xhci
, struct xhci_container_ctx
*ctx
,
114 unsigned int ep_num
),
115 TP_ARGS(xhci
, ctx
, ep_num
)
118 DECLARE_EVENT_CLASS(xhci_log_trb
,
119 TP_PROTO(struct xhci_ring
*ring
, struct xhci_generic_trb
*trb
),
129 __entry
->type
= ring
->type
;
130 __entry
->field0
= le32_to_cpu(trb
->field
[0]);
131 __entry
->field1
= le32_to_cpu(trb
->field
[1]);
132 __entry
->field2
= le32_to_cpu(trb
->field
[2]);
133 __entry
->field3
= le32_to_cpu(trb
->field
[3]);
135 TP_printk("%s: %s", xhci_ring_type_string(__entry
->type
),
136 xhci_decode_trb(__entry
->field0
, __entry
->field1
,
137 __entry
->field2
, __entry
->field3
)
141 DEFINE_EVENT(xhci_log_trb
, xhci_handle_event
,
142 TP_PROTO(struct xhci_ring
*ring
, struct xhci_generic_trb
*trb
),
146 DEFINE_EVENT(xhci_log_trb
, xhci_handle_command
,
147 TP_PROTO(struct xhci_ring
*ring
, struct xhci_generic_trb
*trb
),
151 DEFINE_EVENT(xhci_log_trb
, xhci_handle_transfer
,
152 TP_PROTO(struct xhci_ring
*ring
, struct xhci_generic_trb
*trb
),
156 DEFINE_EVENT(xhci_log_trb
, xhci_queue_trb
,
157 TP_PROTO(struct xhci_ring
*ring
, struct xhci_generic_trb
*trb
),
161 DECLARE_EVENT_CLASS(xhci_log_virt_dev
,
162 TP_PROTO(struct xhci_virt_device
*vdev
),
165 __field(void *, vdev
)
166 __field(unsigned long long, out_ctx
)
167 __field(unsigned long long, in_ctx
)
173 __field(int, slot_id
)
176 __entry
->vdev
= vdev
;
177 __entry
->in_ctx
= (unsigned long long) vdev
->in_ctx
->dma
;
178 __entry
->out_ctx
= (unsigned long long) vdev
->out_ctx
->dma
;
179 __entry
->devnum
= vdev
->udev
->devnum
;
180 __entry
->state
= vdev
->udev
->state
;
181 __entry
->speed
= vdev
->udev
->speed
;
182 __entry
->portnum
= vdev
->udev
->portnum
;
183 __entry
->level
= vdev
->udev
->level
;
184 __entry
->slot_id
= vdev
->udev
->slot_id
;
186 TP_printk("vdev %p ctx %llx | %llx num %d state %d speed %d port %d level %d slot %d",
187 __entry
->vdev
, __entry
->in_ctx
, __entry
->out_ctx
,
188 __entry
->devnum
, __entry
->state
, __entry
->speed
,
189 __entry
->portnum
, __entry
->level
, __entry
->slot_id
193 DEFINE_EVENT(xhci_log_virt_dev
, xhci_alloc_virt_device
,
194 TP_PROTO(struct xhci_virt_device
*vdev
),
198 DEFINE_EVENT(xhci_log_virt_dev
, xhci_free_virt_device
,
199 TP_PROTO(struct xhci_virt_device
*vdev
),
203 DEFINE_EVENT(xhci_log_virt_dev
, xhci_setup_device
,
204 TP_PROTO(struct xhci_virt_device
*vdev
),
208 DEFINE_EVENT(xhci_log_virt_dev
, xhci_setup_addressable_virt_device
,
209 TP_PROTO(struct xhci_virt_device
*vdev
),
213 DEFINE_EVENT(xhci_log_virt_dev
, xhci_stop_device
,
214 TP_PROTO(struct xhci_virt_device
*vdev
),
218 DECLARE_EVENT_CLASS(xhci_log_urb
,
219 TP_PROTO(struct urb
*urb
),
223 __field(unsigned int, pipe
)
224 __field(unsigned int, stream
)
226 __field(unsigned int, flags
)
227 __field(int, num_mapped_sgs
)
228 __field(int, num_sgs
)
234 __field(int, slot_id
)
238 __entry
->pipe
= urb
->pipe
;
239 __entry
->stream
= urb
->stream_id
;
240 __entry
->status
= urb
->status
;
241 __entry
->flags
= urb
->transfer_flags
;
242 __entry
->num_mapped_sgs
= urb
->num_mapped_sgs
;
243 __entry
->num_sgs
= urb
->num_sgs
;
244 __entry
->length
= urb
->transfer_buffer_length
;
245 __entry
->actual
= urb
->actual_length
;
246 __entry
->epnum
= usb_endpoint_num(&urb
->ep
->desc
);
247 __entry
->dir_in
= usb_endpoint_dir_in(&urb
->ep
->desc
);
248 __entry
->type
= usb_endpoint_type(&urb
->ep
->desc
);
249 __entry
->slot_id
= urb
->dev
->slot_id
;
251 TP_printk("ep%d%s-%s: urb %p pipe %u slot %d length %d/%d sgs %d/%d stream %d flags %08x",
252 __entry
->epnum
, __entry
->dir_in
? "in" : "out",
254 switch (__entry
->type
) {
255 case USB_ENDPOINT_XFER_INT
:
258 case USB_ENDPOINT_XFER_CONTROL
:
261 case USB_ENDPOINT_XFER_BULK
:
264 case USB_ENDPOINT_XFER_ISOC
:
269 } s
; }), __entry
->urb
, __entry
->pipe
, __entry
->slot_id
,
270 __entry
->actual
, __entry
->length
, __entry
->num_mapped_sgs
,
271 __entry
->num_sgs
, __entry
->stream
, __entry
->flags
275 DEFINE_EVENT(xhci_log_urb
, xhci_urb_enqueue
,
276 TP_PROTO(struct urb
*urb
),
280 DEFINE_EVENT(xhci_log_urb
, xhci_urb_giveback
,
281 TP_PROTO(struct urb
*urb
),
285 DEFINE_EVENT(xhci_log_urb
, xhci_urb_dequeue
,
286 TP_PROTO(struct urb
*urb
),
290 DECLARE_EVENT_CLASS(xhci_log_ep_ctx
,
291 TP_PROTO(struct xhci_ep_ctx
*ctx
),
297 __field(u32
, tx_info
)
300 __entry
->info
= le32_to_cpu(ctx
->ep_info
);
301 __entry
->info2
= le32_to_cpu(ctx
->ep_info2
);
302 __entry
->deq
= le64_to_cpu(ctx
->deq
);
303 __entry
->tx_info
= le32_to_cpu(ctx
->tx_info
);
305 TP_printk("%s", xhci_decode_ep_context(__entry
->info
,
306 __entry
->info2
, __entry
->deq
, __entry
->tx_info
)
310 DEFINE_EVENT(xhci_log_ep_ctx
, xhci_handle_cmd_stop_ep
,
311 TP_PROTO(struct xhci_ep_ctx
*ctx
),
315 DEFINE_EVENT(xhci_log_ep_ctx
, xhci_handle_cmd_set_deq_ep
,
316 TP_PROTO(struct xhci_ep_ctx
*ctx
),
320 DEFINE_EVENT(xhci_log_ep_ctx
, xhci_handle_cmd_reset_ep
,
321 TP_PROTO(struct xhci_ep_ctx
*ctx
),
325 DEFINE_EVENT(xhci_log_ep_ctx
, xhci_handle_cmd_config_ep
,
326 TP_PROTO(struct xhci_ep_ctx
*ctx
),
330 DECLARE_EVENT_CLASS(xhci_log_slot_ctx
,
331 TP_PROTO(struct xhci_slot_ctx
*ctx
),
336 __field(u32
, tt_info
)
340 __entry
->info
= le32_to_cpu(ctx
->dev_info
);
341 __entry
->info2
= le32_to_cpu(ctx
->dev_info2
);
342 __entry
->tt_info
= le64_to_cpu(ctx
->tt_info
);
343 __entry
->state
= le32_to_cpu(ctx
->dev_state
);
345 TP_printk("%s", xhci_decode_slot_context(__entry
->info
,
346 __entry
->info2
, __entry
->tt_info
,
351 DEFINE_EVENT(xhci_log_slot_ctx
, xhci_alloc_dev
,
352 TP_PROTO(struct xhci_slot_ctx
*ctx
),
356 DEFINE_EVENT(xhci_log_slot_ctx
, xhci_free_dev
,
357 TP_PROTO(struct xhci_slot_ctx
*ctx
),
361 DEFINE_EVENT(xhci_log_slot_ctx
, xhci_handle_cmd_disable_slot
,
362 TP_PROTO(struct xhci_slot_ctx
*ctx
),
366 DEFINE_EVENT(xhci_log_slot_ctx
, xhci_discover_or_reset_device
,
367 TP_PROTO(struct xhci_slot_ctx
*ctx
),
371 DEFINE_EVENT(xhci_log_slot_ctx
, xhci_setup_device_slot
,
372 TP_PROTO(struct xhci_slot_ctx
*ctx
),
376 DEFINE_EVENT(xhci_log_slot_ctx
, xhci_handle_cmd_addr_dev
,
377 TP_PROTO(struct xhci_slot_ctx
*ctx
),
381 DEFINE_EVENT(xhci_log_slot_ctx
, xhci_handle_cmd_reset_dev
,
382 TP_PROTO(struct xhci_slot_ctx
*ctx
),
386 DEFINE_EVENT(xhci_log_slot_ctx
, xhci_handle_cmd_set_deq
,
387 TP_PROTO(struct xhci_slot_ctx
*ctx
),
391 DECLARE_EVENT_CLASS(xhci_log_ring
,
392 TP_PROTO(struct xhci_ring
*ring
),
396 __field(void *, ring
)
397 __field(dma_addr_t
, enq
)
398 __field(dma_addr_t
, deq
)
399 __field(dma_addr_t
, enq_seg
)
400 __field(dma_addr_t
, deq_seg
)
401 __field(unsigned int, num_segs
)
402 __field(unsigned int, stream_id
)
403 __field(unsigned int, cycle_state
)
404 __field(unsigned int, num_trbs_free
)
405 __field(unsigned int, bounce_buf_len
)
408 __entry
->ring
= ring
;
409 __entry
->type
= ring
->type
;
410 __entry
->num_segs
= ring
->num_segs
;
411 __entry
->stream_id
= ring
->stream_id
;
412 __entry
->enq_seg
= ring
->enq_seg
->dma
;
413 __entry
->deq_seg
= ring
->deq_seg
->dma
;
414 __entry
->cycle_state
= ring
->cycle_state
;
415 __entry
->num_trbs_free
= ring
->num_trbs_free
;
416 __entry
->bounce_buf_len
= ring
->bounce_buf_len
;
417 __entry
->enq
= xhci_trb_virt_to_dma(ring
->enq_seg
, ring
->enqueue
);
418 __entry
->deq
= xhci_trb_virt_to_dma(ring
->deq_seg
, ring
->dequeue
);
420 TP_printk("%s %p: enq %pad(%pad) deq %pad(%pad) segs %d stream %d free_trbs %d bounce %d cycle %d",
421 xhci_ring_type_string(__entry
->type
), __entry
->ring
,
422 &__entry
->enq
, &__entry
->enq_seg
,
423 &__entry
->deq
, &__entry
->deq_seg
,
426 __entry
->num_trbs_free
,
427 __entry
->bounce_buf_len
,
432 DEFINE_EVENT(xhci_log_ring
, xhci_ring_alloc
,
433 TP_PROTO(struct xhci_ring
*ring
),
437 DEFINE_EVENT(xhci_log_ring
, xhci_ring_free
,
438 TP_PROTO(struct xhci_ring
*ring
),
442 DEFINE_EVENT(xhci_log_ring
, xhci_ring_expansion
,
443 TP_PROTO(struct xhci_ring
*ring
),
447 DEFINE_EVENT(xhci_log_ring
, xhci_inc_enq
,
448 TP_PROTO(struct xhci_ring
*ring
),
452 DEFINE_EVENT(xhci_log_ring
, xhci_inc_deq
,
453 TP_PROTO(struct xhci_ring
*ring
),
456 #endif /* __XHCI_TRACE_H */
458 /* this part must be outside header guard */
460 #undef TRACE_INCLUDE_PATH
461 #define TRACE_INCLUDE_PATH .
463 #undef TRACE_INCLUDE_FILE
464 #define TRACE_INCLUDE_FILE xhci-trace
466 #include <trace/define_trace.h>