1 /* SPDX-License-Identifier: GPL-2.0 */
3 * USBSS device controller driver.
4 * Trace support header file.
6 * Copyright (C) 2018-2019 Cadence.
8 * Author: Pawel Laszczak <pawell@cadence.com>
12 #define TRACE_SYSTEM cdns3
14 #if !defined(__LINUX_CDNS3_TRACE) || defined(TRACE_HEADER_MULTI_READ)
15 #define __LINUX_CDNS3_TRACE
17 #include <linux/types.h>
18 #include <linux/tracepoint.h>
19 #include <asm/byteorder.h>
20 #include <linux/usb/ch9.h>
25 #define CDNS3_MSG_MAX 500
27 TRACE_EVENT(cdns3_halt
,
28 TP_PROTO(struct cdns3_endpoint
*ep_priv
, u8 halt
, u8 flush
),
29 TP_ARGS(ep_priv
, halt
, flush
),
31 __string(name
, ep_priv
->name
)
36 __assign_str(name
, ep_priv
->name
);
38 __entry
->flush
= flush
;
40 TP_printk("Halt %s for %s: %s", __entry
->flush
? " and flush" : "",
41 __get_str(name
), __entry
->halt
? "set" : "cleared")
44 TRACE_EVENT(cdns3_wa1
,
45 TP_PROTO(struct cdns3_endpoint
*ep_priv
, char *msg
),
46 TP_ARGS(ep_priv
, msg
),
48 __string(ep_name
, ep_priv
->name
)
52 __assign_str(ep_name
, ep_priv
->name
);
53 __assign_str(msg
, msg
);
55 TP_printk("WA1: %s %s", __get_str(ep_name
), __get_str(msg
))
58 TRACE_EVENT(cdns3_wa2
,
59 TP_PROTO(struct cdns3_endpoint
*ep_priv
, char *msg
),
60 TP_ARGS(ep_priv
, msg
),
62 __string(ep_name
, ep_priv
->name
)
66 __assign_str(ep_name
, ep_priv
->name
);
67 __assign_str(msg
, msg
);
69 TP_printk("WA2: %s %s", __get_str(ep_name
), __get_str(msg
))
72 DECLARE_EVENT_CLASS(cdns3_log_doorbell
,
73 TP_PROTO(const char *ep_name
, u32 ep_trbaddr
),
74 TP_ARGS(ep_name
, ep_trbaddr
),
76 __string(name
, ep_name
)
77 __field(u32
, ep_trbaddr
)
80 __assign_str(name
, ep_name
);
81 __entry
->ep_trbaddr
= ep_trbaddr
;
83 TP_printk("%s, ep_trbaddr %08x", __get_str(name
),
87 DEFINE_EVENT(cdns3_log_doorbell
, cdns3_doorbell_ep0
,
88 TP_PROTO(const char *ep_name
, u32 ep_trbaddr
),
89 TP_ARGS(ep_name
, ep_trbaddr
)
92 DEFINE_EVENT(cdns3_log_doorbell
, cdns3_doorbell_epx
,
93 TP_PROTO(const char *ep_name
, u32 ep_trbaddr
),
94 TP_ARGS(ep_name
, ep_trbaddr
)
97 DECLARE_EVENT_CLASS(cdns3_log_usb_irq
,
98 TP_PROTO(struct cdns3_device
*priv_dev
, u32 usb_ists
),
99 TP_ARGS(priv_dev
, usb_ists
),
101 __field(enum usb_device_speed
, speed
)
102 __field(u32
, usb_ists
)
103 __dynamic_array(char, str
, CDNS3_MSG_MAX
)
106 __entry
->speed
= cdns3_get_speed(priv_dev
);
107 __entry
->usb_ists
= usb_ists
;
109 TP_printk("%s", cdns3_decode_usb_irq(__get_str(str
), __entry
->speed
,
113 DEFINE_EVENT(cdns3_log_usb_irq
, cdns3_usb_irq
,
114 TP_PROTO(struct cdns3_device
*priv_dev
, u32 usb_ists
),
115 TP_ARGS(priv_dev
, usb_ists
)
118 DECLARE_EVENT_CLASS(cdns3_log_epx_irq
,
119 TP_PROTO(struct cdns3_device
*priv_dev
, struct cdns3_endpoint
*priv_ep
),
120 TP_ARGS(priv_dev
, priv_ep
),
122 __string(ep_name
, priv_ep
->name
)
124 __field(u32
, ep_traddr
)
125 __field(u32
, ep_last_sid
)
126 __field(u32
, use_streams
)
127 __dynamic_array(char, str
, CDNS3_MSG_MAX
)
130 __assign_str(ep_name
, priv_ep
->name
);
131 __entry
->ep_sts
= readl(&priv_dev
->regs
->ep_sts
);
132 __entry
->ep_traddr
= readl(&priv_dev
->regs
->ep_traddr
);
133 __entry
->ep_last_sid
= priv_ep
->last_stream_id
;
134 __entry
->use_streams
= priv_ep
->use_streams
;
136 TP_printk("%s, ep_traddr: %08x ep_last_sid: %08x use_streams: %d",
137 cdns3_decode_epx_irq(__get_str(str
),
141 __entry
->ep_last_sid
,
142 __entry
->use_streams
)
145 DEFINE_EVENT(cdns3_log_epx_irq
, cdns3_epx_irq
,
146 TP_PROTO(struct cdns3_device
*priv_dev
, struct cdns3_endpoint
*priv_ep
),
147 TP_ARGS(priv_dev
, priv_ep
)
150 DECLARE_EVENT_CLASS(cdns3_log_ep0_irq
,
151 TP_PROTO(struct cdns3_device
*priv_dev
, u32 ep_sts
),
152 TP_ARGS(priv_dev
, ep_sts
),
156 __dynamic_array(char, str
, CDNS3_MSG_MAX
)
159 __entry
->ep_dir
= priv_dev
->ep0_data_dir
;
160 __entry
->ep_sts
= ep_sts
;
162 TP_printk("%s", cdns3_decode_ep0_irq(__get_str(str
),
167 DEFINE_EVENT(cdns3_log_ep0_irq
, cdns3_ep0_irq
,
168 TP_PROTO(struct cdns3_device
*priv_dev
, u32 ep_sts
),
169 TP_ARGS(priv_dev
, ep_sts
)
172 DECLARE_EVENT_CLASS(cdns3_log_ctrl
,
173 TP_PROTO(struct usb_ctrlrequest
*ctrl
),
176 __field(u8
, bRequestType
)
177 __field(u8
, bRequest
)
180 __field(u16
, wLength
)
181 __dynamic_array(char, str
, CDNS3_MSG_MAX
)
184 __entry
->bRequestType
= ctrl
->bRequestType
;
185 __entry
->bRequest
= ctrl
->bRequest
;
186 __entry
->wValue
= le16_to_cpu(ctrl
->wValue
);
187 __entry
->wIndex
= le16_to_cpu(ctrl
->wIndex
);
188 __entry
->wLength
= le16_to_cpu(ctrl
->wLength
);
190 TP_printk("%s", usb_decode_ctrl(__get_str(str
), CDNS3_MSG_MAX
,
191 __entry
->bRequestType
,
192 __entry
->bRequest
, __entry
->wValue
,
193 __entry
->wIndex
, __entry
->wLength
)
197 DEFINE_EVENT(cdns3_log_ctrl
, cdns3_ctrl_req
,
198 TP_PROTO(struct usb_ctrlrequest
*ctrl
),
202 DECLARE_EVENT_CLASS(cdns3_log_request
,
203 TP_PROTO(struct cdns3_request
*req
),
206 __string(name
, req
->priv_ep
->name
)
207 __field(struct cdns3_request
*, req
)
209 __field(unsigned int, actual
)
210 __field(unsigned int, length
)
213 __field(int, short_not_ok
)
214 __field(int, no_interrupt
)
215 __field(int, start_trb
)
216 __field(int, end_trb
)
217 __field(struct cdns3_trb
*, start_trb_addr
)
219 __field(unsigned int, stream_id
)
222 __assign_str(name
, req
->priv_ep
->name
);
224 __entry
->buf
= req
->request
.buf
;
225 __entry
->actual
= req
->request
.actual
;
226 __entry
->length
= req
->request
.length
;
227 __entry
->status
= req
->request
.status
;
228 __entry
->zero
= req
->request
.zero
;
229 __entry
->short_not_ok
= req
->request
.short_not_ok
;
230 __entry
->no_interrupt
= req
->request
.no_interrupt
;
231 __entry
->start_trb
= req
->start_trb
;
232 __entry
->end_trb
= req
->end_trb
;
233 __entry
->start_trb_addr
= req
->trb
;
234 __entry
->flags
= req
->flags
;
235 __entry
->stream_id
= req
->request
.stream_id
;
237 TP_printk("%s: req: %p, req buff %p, length: %u/%u %s%s%s, status: %d,"
238 " trb: [start:%d, end:%d: virt addr %pa], flags:%x SID: %u",
239 __get_str(name
), __entry
->req
, __entry
->buf
, __entry
->actual
,
241 __entry
->zero
? "Z" : "z",
242 __entry
->short_not_ok
? "S" : "s",
243 __entry
->no_interrupt
? "I" : "i",
247 __entry
->start_trb_addr
,
253 DEFINE_EVENT(cdns3_log_request
, cdns3_alloc_request
,
254 TP_PROTO(struct cdns3_request
*req
),
258 DEFINE_EVENT(cdns3_log_request
, cdns3_free_request
,
259 TP_PROTO(struct cdns3_request
*req
),
263 DEFINE_EVENT(cdns3_log_request
, cdns3_ep_queue
,
264 TP_PROTO(struct cdns3_request
*req
),
268 DEFINE_EVENT(cdns3_log_request
, cdns3_ep_dequeue
,
269 TP_PROTO(struct cdns3_request
*req
),
273 DEFINE_EVENT(cdns3_log_request
, cdns3_gadget_giveback
,
274 TP_PROTO(struct cdns3_request
*req
),
278 TRACE_EVENT(cdns3_ep0_queue
,
279 TP_PROTO(struct cdns3_device
*dev_priv
, struct usb_request
*request
),
280 TP_ARGS(dev_priv
, request
),
286 __entry
->dir
= dev_priv
->ep0_data_dir
;
287 __entry
->length
= request
->length
;
289 TP_printk("Queue to ep0%s length: %u", __entry
->dir
? "in" : "out",
293 DECLARE_EVENT_CLASS(cdns3_stream_split_transfer_len
,
294 TP_PROTO(struct cdns3_request
*req
),
297 __string(name
, req
->priv_ep
->name
)
298 __field(struct cdns3_request
*, req
)
299 __field(unsigned int, length
)
300 __field(unsigned int, actual
)
301 __field(unsigned int, stream_id
)
304 __assign_str(name
, req
->priv_ep
->name
);
306 __entry
->actual
= req
->request
.length
;
307 __entry
->length
= req
->request
.actual
;
308 __entry
->stream_id
= req
->request
.stream_id
;
310 TP_printk("%s: req: %p,request length: %u actual length: %u SID: %u",
311 __get_str(name
), __entry
->req
, __entry
->length
,
312 __entry
->actual
, __entry
->stream_id
)
315 DEFINE_EVENT(cdns3_stream_split_transfer_len
, cdns3_stream_transfer_split
,
316 TP_PROTO(struct cdns3_request
*req
),
320 DEFINE_EVENT(cdns3_stream_split_transfer_len
,
321 cdns3_stream_transfer_split_next_part
,
322 TP_PROTO(struct cdns3_request
*req
),
326 DECLARE_EVENT_CLASS(cdns3_log_aligned_request
,
327 TP_PROTO(struct cdns3_request
*priv_req
),
330 __string(name
, priv_req
->priv_ep
->name
)
331 __field(struct usb_request
*, req
)
333 __field(dma_addr_t
, dma
)
334 __field(void *, aligned_buf
)
335 __field(dma_addr_t
, aligned_dma
)
336 __field(u32
, aligned_buf_size
)
339 __assign_str(name
, priv_req
->priv_ep
->name
);
340 __entry
->req
= &priv_req
->request
;
341 __entry
->buf
= priv_req
->request
.buf
;
342 __entry
->dma
= priv_req
->request
.dma
;
343 __entry
->aligned_buf
= priv_req
->aligned_buf
->buf
;
344 __entry
->aligned_dma
= priv_req
->aligned_buf
->dma
;
345 __entry
->aligned_buf_size
= priv_req
->aligned_buf
->size
;
347 TP_printk("%s: req: %p, req buf %p, dma %pad a_buf %p a_dma %pad, size %d",
348 __get_str(name
), __entry
->req
, __entry
->buf
, &__entry
->dma
,
349 __entry
->aligned_buf
, &__entry
->aligned_dma
,
350 __entry
->aligned_buf_size
354 DEFINE_EVENT(cdns3_log_aligned_request
, cdns3_free_aligned_request
,
355 TP_PROTO(struct cdns3_request
*req
),
359 DEFINE_EVENT(cdns3_log_aligned_request
, cdns3_prepare_aligned_request
,
360 TP_PROTO(struct cdns3_request
*req
),
364 DECLARE_EVENT_CLASS(cdns3_log_map_request
,
365 TP_PROTO(struct cdns3_request
*priv_req
),
368 __string(name
, priv_req
->priv_ep
->name
)
369 __field(struct usb_request
*, req
)
371 __field(dma_addr_t
, dma
)
374 __assign_str(name
, priv_req
->priv_ep
->name
);
375 __entry
->req
= &priv_req
->request
;
376 __entry
->buf
= priv_req
->request
.buf
;
377 __entry
->dma
= priv_req
->request
.dma
;
379 TP_printk("%s: req: %p, req buf %p, dma %p",
380 __get_str(name
), __entry
->req
, __entry
->buf
, &__entry
->dma
383 DEFINE_EVENT(cdns3_log_map_request
, cdns3_map_request
,
384 TP_PROTO(struct cdns3_request
*req
),
387 DEFINE_EVENT(cdns3_log_map_request
, cdns3_mapped_request
,
388 TP_PROTO(struct cdns3_request
*req
),
392 DECLARE_EVENT_CLASS(cdns3_log_trb
,
393 TP_PROTO(struct cdns3_endpoint
*priv_ep
, struct cdns3_trb
*trb
),
394 TP_ARGS(priv_ep
, trb
),
396 __string(name
, priv_ep
->name
)
397 __field(struct cdns3_trb
*, trb
)
400 __field(u32
, control
)
402 __field(unsigned int, last_stream_id
)
405 __assign_str(name
, priv_ep
->name
);
407 __entry
->buffer
= trb
->buffer
;
408 __entry
->length
= trb
->length
;
409 __entry
->control
= trb
->control
;
410 __entry
->type
= usb_endpoint_type(priv_ep
->endpoint
.desc
);
411 __entry
->last_stream_id
= priv_ep
->last_stream_id
;
413 TP_printk("%s: trb %p, dma buf: 0x%08x, size: %ld, burst: %d ctrl: 0x%08x (%s%s%s%s%s%s%s) SID:%lu LAST_SID:%u",
414 __get_str(name
), __entry
->trb
, __entry
->buffer
,
415 TRB_LEN(__entry
->length
),
416 (u8
)TRB_BURST_LEN_GET(__entry
->length
),
418 __entry
->control
& TRB_CYCLE
? "C=1, " : "C=0, ",
419 __entry
->control
& TRB_TOGGLE
? "T=1, " : "T=0, ",
420 __entry
->control
& TRB_ISP
? "ISP, " : "",
421 __entry
->control
& TRB_FIFO_MODE
? "FIFO, " : "",
422 __entry
->control
& TRB_CHAIN
? "CHAIN, " : "",
423 __entry
->control
& TRB_IOC
? "IOC, " : "",
424 TRB_FIELD_TO_TYPE(__entry
->control
) == TRB_NORMAL
? "Normal" : "LINK",
425 TRB_FIELD_TO_STREAMID(__entry
->control
),
426 __entry
->last_stream_id
430 DEFINE_EVENT(cdns3_log_trb
, cdns3_prepare_trb
,
431 TP_PROTO(struct cdns3_endpoint
*priv_ep
, struct cdns3_trb
*trb
),
432 TP_ARGS(priv_ep
, trb
)
435 DEFINE_EVENT(cdns3_log_trb
, cdns3_complete_trb
,
436 TP_PROTO(struct cdns3_endpoint
*priv_ep
, struct cdns3_trb
*trb
),
437 TP_ARGS(priv_ep
, trb
)
440 DECLARE_EVENT_CLASS(cdns3_log_ring
,
441 TP_PROTO(struct cdns3_endpoint
*priv_ep
),
444 __dynamic_array(u8
, ring
, TRB_RING_SIZE
)
445 __dynamic_array(u8
, priv_ep
, sizeof(struct cdns3_endpoint
))
446 __dynamic_array(char, buffer
,
447 (TRBS_PER_SEGMENT
* 65) + CDNS3_MSG_MAX
)
450 memcpy(__get_dynamic_array(priv_ep
), priv_ep
,
451 sizeof(struct cdns3_endpoint
));
452 memcpy(__get_dynamic_array(ring
), priv_ep
->trb_pool
,
457 cdns3_dbg_ring((struct cdns3_endpoint
*)__get_str(priv_ep
),
458 (struct cdns3_trb
*)__get_str(ring
),
462 DEFINE_EVENT(cdns3_log_ring
, cdns3_ring
,
463 TP_PROTO(struct cdns3_endpoint
*priv_ep
),
467 DECLARE_EVENT_CLASS(cdns3_log_ep
,
468 TP_PROTO(struct cdns3_endpoint
*priv_ep
),
471 __string(name
, priv_ep
->name
)
472 __field(unsigned int, maxpacket
)
473 __field(unsigned int, maxpacket_limit
)
474 __field(unsigned int, max_streams
)
475 __field(unsigned int, use_streams
)
476 __field(unsigned int, maxburst
)
477 __field(unsigned int, flags
)
478 __field(unsigned int, dir
)
483 __assign_str(name
, priv_ep
->name
);
484 __entry
->maxpacket
= priv_ep
->endpoint
.maxpacket
;
485 __entry
->maxpacket_limit
= priv_ep
->endpoint
.maxpacket_limit
;
486 __entry
->max_streams
= priv_ep
->endpoint
.max_streams
;
487 __entry
->use_streams
= priv_ep
->use_streams
;
488 __entry
->maxburst
= priv_ep
->endpoint
.maxburst
;
489 __entry
->flags
= priv_ep
->flags
;
490 __entry
->dir
= priv_ep
->dir
;
491 __entry
->enqueue
= priv_ep
->enqueue
;
492 __entry
->dequeue
= priv_ep
->dequeue
;
494 TP_printk("%s: mps: %d/%d. streams: %d, stream enable: %d, burst: %d, "
495 "enq idx: %d, deq idx: %d, flags %s%s%s%s%s%s%s%s, dir: %s",
496 __get_str(name
), __entry
->maxpacket
,
497 __entry
->maxpacket_limit
, __entry
->max_streams
,
498 __entry
->use_streams
,
499 __entry
->maxburst
, __entry
->enqueue
,
501 __entry
->flags
& EP_ENABLED
? "EN | " : "",
502 __entry
->flags
& EP_STALLED
? "STALLED | " : "",
503 __entry
->flags
& EP_WEDGE
? "WEDGE | " : "",
504 __entry
->flags
& EP_TRANSFER_STARTED
? "STARTED | " : "",
505 __entry
->flags
& EP_UPDATE_EP_TRBADDR
? "UPD TRB | " : "",
506 __entry
->flags
& EP_PENDING_REQUEST
? "REQ PEN | " : "",
507 __entry
->flags
& EP_RING_FULL
? "RING FULL |" : "",
508 __entry
->flags
& EP_CLAIMED
? "CLAIMED " : "",
509 __entry
->dir
? "IN" : "OUT"
513 DEFINE_EVENT(cdns3_log_ep
, cdns3_gadget_ep_enable
,
514 TP_PROTO(struct cdns3_endpoint
*priv_ep
),
518 DEFINE_EVENT(cdns3_log_ep
, cdns3_gadget_ep_disable
,
519 TP_PROTO(struct cdns3_endpoint
*priv_ep
),
523 DECLARE_EVENT_CLASS(cdns3_log_request_handled
,
524 TP_PROTO(struct cdns3_request
*priv_req
, int current_index
,
526 TP_ARGS(priv_req
, current_index
, handled
),
528 __field(struct cdns3_request
*, priv_req
)
529 __field(unsigned int, dma_position
)
530 __field(unsigned int, handled
)
531 __field(unsigned int, dequeue_idx
)
532 __field(unsigned int, enqueue_idx
)
533 __field(unsigned int, start_trb
)
534 __field(unsigned int, end_trb
)
537 __entry
->priv_req
= priv_req
;
538 __entry
->dma_position
= current_index
;
539 __entry
->handled
= handled
;
540 __entry
->dequeue_idx
= priv_req
->priv_ep
->dequeue
;
541 __entry
->enqueue_idx
= priv_req
->priv_ep
->enqueue
;
542 __entry
->start_trb
= priv_req
->start_trb
;
543 __entry
->end_trb
= priv_req
->end_trb
;
545 TP_printk("Req: %p %s, DMA pos: %d, ep deq: %d, ep enq: %d,"
546 " start trb: %d, end trb: %d",
548 __entry
->handled
? "handled" : "not handled",
549 __entry
->dma_position
, __entry
->dequeue_idx
,
550 __entry
->enqueue_idx
, __entry
->start_trb
,
555 DEFINE_EVENT(cdns3_log_request_handled
, cdns3_request_handled
,
556 TP_PROTO(struct cdns3_request
*priv_req
, int current_index
,
558 TP_ARGS(priv_req
, current_index
, handled
)
560 #endif /* __LINUX_CDNS3_TRACE */
562 /* this part must be outside header guard */
564 #undef TRACE_INCLUDE_PATH
565 #define TRACE_INCLUDE_PATH .
567 #undef TRACE_INCLUDE_FILE
568 #define TRACE_INCLUDE_FILE trace
570 #include <trace/define_trace.h>