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 __dynamic_array(char, str
, CDNS3_MSG_MAX
)
128 __assign_str(ep_name
, priv_ep
->name
);
129 __entry
->ep_sts
= readl(&priv_dev
->regs
->ep_sts
);
130 __entry
->ep_traddr
= readl(&priv_dev
->regs
->ep_traddr
);
132 TP_printk("%s, ep_traddr: %08x",
133 cdns3_decode_epx_irq(__get_str(str
),
139 DEFINE_EVENT(cdns3_log_epx_irq
, cdns3_epx_irq
,
140 TP_PROTO(struct cdns3_device
*priv_dev
, struct cdns3_endpoint
*priv_ep
),
141 TP_ARGS(priv_dev
, priv_ep
)
144 DECLARE_EVENT_CLASS(cdns3_log_ep0_irq
,
145 TP_PROTO(struct cdns3_device
*priv_dev
, u32 ep_sts
),
146 TP_ARGS(priv_dev
, ep_sts
),
150 __dynamic_array(char, str
, CDNS3_MSG_MAX
)
153 __entry
->ep_dir
= priv_dev
->selected_ep
;
154 __entry
->ep_sts
= ep_sts
;
156 TP_printk("%s", cdns3_decode_ep0_irq(__get_str(str
),
161 DEFINE_EVENT(cdns3_log_ep0_irq
, cdns3_ep0_irq
,
162 TP_PROTO(struct cdns3_device
*priv_dev
, u32 ep_sts
),
163 TP_ARGS(priv_dev
, ep_sts
)
166 DECLARE_EVENT_CLASS(cdns3_log_ctrl
,
167 TP_PROTO(struct usb_ctrlrequest
*ctrl
),
170 __field(u8
, bRequestType
)
171 __field(u8
, bRequest
)
174 __field(u16
, wLength
)
175 __dynamic_array(char, str
, CDNS3_MSG_MAX
)
178 __entry
->bRequestType
= ctrl
->bRequestType
;
179 __entry
->bRequest
= ctrl
->bRequest
;
180 __entry
->wValue
= le16_to_cpu(ctrl
->wValue
);
181 __entry
->wIndex
= le16_to_cpu(ctrl
->wIndex
);
182 __entry
->wLength
= le16_to_cpu(ctrl
->wLength
);
184 TP_printk("%s", usb_decode_ctrl(__get_str(str
), CDNS3_MSG_MAX
,
185 __entry
->bRequestType
,
186 __entry
->bRequest
, __entry
->wValue
,
187 __entry
->wIndex
, __entry
->wLength
)
191 DEFINE_EVENT(cdns3_log_ctrl
, cdns3_ctrl_req
,
192 TP_PROTO(struct usb_ctrlrequest
*ctrl
),
196 DECLARE_EVENT_CLASS(cdns3_log_request
,
197 TP_PROTO(struct cdns3_request
*req
),
200 __string(name
, req
->priv_ep
->name
)
201 __field(struct cdns3_request
*, req
)
203 __field(unsigned int, actual
)
204 __field(unsigned int, length
)
207 __field(int, short_not_ok
)
208 __field(int, no_interrupt
)
209 __field(int, start_trb
)
210 __field(int, end_trb
)
211 __field(struct cdns3_trb
*, start_trb_addr
)
215 __assign_str(name
, req
->priv_ep
->name
);
217 __entry
->buf
= req
->request
.buf
;
218 __entry
->actual
= req
->request
.actual
;
219 __entry
->length
= req
->request
.length
;
220 __entry
->status
= req
->request
.status
;
221 __entry
->zero
= req
->request
.zero
;
222 __entry
->short_not_ok
= req
->request
.short_not_ok
;
223 __entry
->no_interrupt
= req
->request
.no_interrupt
;
224 __entry
->start_trb
= req
->start_trb
;
225 __entry
->end_trb
= req
->end_trb
;
226 __entry
->start_trb_addr
= req
->trb
;
227 __entry
->flags
= req
->flags
;
229 TP_printk("%s: req: %p, req buff %p, length: %u/%u %s%s%s, status: %d,"
230 " trb: [start:%d, end:%d: virt addr %pa], flags:%x ",
231 __get_str(name
), __entry
->req
, __entry
->buf
, __entry
->actual
,
233 __entry
->zero
? "Z" : "z",
234 __entry
->short_not_ok
? "S" : "s",
235 __entry
->no_interrupt
? "I" : "i",
239 __entry
->start_trb_addr
,
244 DEFINE_EVENT(cdns3_log_request
, cdns3_alloc_request
,
245 TP_PROTO(struct cdns3_request
*req
),
249 DEFINE_EVENT(cdns3_log_request
, cdns3_free_request
,
250 TP_PROTO(struct cdns3_request
*req
),
254 DEFINE_EVENT(cdns3_log_request
, cdns3_ep_queue
,
255 TP_PROTO(struct cdns3_request
*req
),
259 DEFINE_EVENT(cdns3_log_request
, cdns3_ep_dequeue
,
260 TP_PROTO(struct cdns3_request
*req
),
264 DEFINE_EVENT(cdns3_log_request
, cdns3_gadget_giveback
,
265 TP_PROTO(struct cdns3_request
*req
),
269 TRACE_EVENT(cdns3_ep0_queue
,
270 TP_PROTO(struct cdns3_device
*dev_priv
, struct usb_request
*request
),
271 TP_ARGS(dev_priv
, request
),
277 __entry
->dir
= dev_priv
->ep0_data_dir
;
278 __entry
->length
= request
->length
;
280 TP_printk("Queue to ep0%s length: %u", __entry
->dir
? "in" : "out",
284 DECLARE_EVENT_CLASS(cdns3_log_aligned_request
,
285 TP_PROTO(struct cdns3_request
*priv_req
),
288 __string(name
, priv_req
->priv_ep
->name
)
289 __field(struct usb_request
*, req
)
291 __field(dma_addr_t
, dma
)
292 __field(void *, aligned_buf
)
293 __field(dma_addr_t
, aligned_dma
)
294 __field(u32
, aligned_buf_size
)
297 __assign_str(name
, priv_req
->priv_ep
->name
);
298 __entry
->req
= &priv_req
->request
;
299 __entry
->buf
= priv_req
->request
.buf
;
300 __entry
->dma
= priv_req
->request
.dma
;
301 __entry
->aligned_buf
= priv_req
->aligned_buf
->buf
;
302 __entry
->aligned_dma
= priv_req
->aligned_buf
->dma
;
303 __entry
->aligned_buf_size
= priv_req
->aligned_buf
->size
;
305 TP_printk("%s: req: %p, req buf %p, dma %pad a_buf %p a_dma %pad, size %d",
306 __get_str(name
), __entry
->req
, __entry
->buf
, &__entry
->dma
,
307 __entry
->aligned_buf
, &__entry
->aligned_dma
,
308 __entry
->aligned_buf_size
312 DEFINE_EVENT(cdns3_log_aligned_request
, cdns3_free_aligned_request
,
313 TP_PROTO(struct cdns3_request
*req
),
317 DEFINE_EVENT(cdns3_log_aligned_request
, cdns3_prepare_aligned_request
,
318 TP_PROTO(struct cdns3_request
*req
),
322 DECLARE_EVENT_CLASS(cdns3_log_trb
,
323 TP_PROTO(struct cdns3_endpoint
*priv_ep
, struct cdns3_trb
*trb
),
324 TP_ARGS(priv_ep
, trb
),
326 __string(name
, priv_ep
->name
)
327 __field(struct cdns3_trb
*, trb
)
330 __field(u32
, control
)
334 __assign_str(name
, priv_ep
->name
);
336 __entry
->buffer
= le32_to_cpu(trb
->buffer
);
337 __entry
->length
= le32_to_cpu(trb
->length
);
338 __entry
->control
= le32_to_cpu(trb
->control
);
339 __entry
->type
= usb_endpoint_type(priv_ep
->endpoint
.desc
);
341 TP_printk("%s: trb %p, dma buf: 0x%08x, size: %ld, burst: %d ctrl: 0x%08x (%s%s%s%s%s%s%s)",
342 __get_str(name
), __entry
->trb
, __entry
->buffer
,
343 TRB_LEN(__entry
->length
),
344 (u8
)TRB_BURST_LEN_GET(__entry
->length
),
346 __entry
->control
& TRB_CYCLE
? "C=1, " : "C=0, ",
347 __entry
->control
& TRB_TOGGLE
? "T=1, " : "T=0, ",
348 __entry
->control
& TRB_ISP
? "ISP, " : "",
349 __entry
->control
& TRB_FIFO_MODE
? "FIFO, " : "",
350 __entry
->control
& TRB_CHAIN
? "CHAIN, " : "",
351 __entry
->control
& TRB_IOC
? "IOC, " : "",
352 TRB_FIELD_TO_TYPE(__entry
->control
) == TRB_NORMAL
? "Normal" : "LINK"
356 DEFINE_EVENT(cdns3_log_trb
, cdns3_prepare_trb
,
357 TP_PROTO(struct cdns3_endpoint
*priv_ep
, struct cdns3_trb
*trb
),
358 TP_ARGS(priv_ep
, trb
)
361 DEFINE_EVENT(cdns3_log_trb
, cdns3_complete_trb
,
362 TP_PROTO(struct cdns3_endpoint
*priv_ep
, struct cdns3_trb
*trb
),
363 TP_ARGS(priv_ep
, trb
)
366 DECLARE_EVENT_CLASS(cdns3_log_ring
,
367 TP_PROTO(struct cdns3_endpoint
*priv_ep
),
370 __dynamic_array(u8
, ring
, TRB_RING_SIZE
)
371 __dynamic_array(u8
, priv_ep
, sizeof(struct cdns3_endpoint
))
372 __dynamic_array(char, buffer
,
373 (TRBS_PER_SEGMENT
* 65) + CDNS3_MSG_MAX
)
376 memcpy(__get_dynamic_array(priv_ep
), priv_ep
,
377 sizeof(struct cdns3_endpoint
));
378 memcpy(__get_dynamic_array(ring
), priv_ep
->trb_pool
,
383 cdns3_dbg_ring((struct cdns3_endpoint
*)__get_str(priv_ep
),
384 (struct cdns3_trb
*)__get_str(ring
),
388 DEFINE_EVENT(cdns3_log_ring
, cdns3_ring
,
389 TP_PROTO(struct cdns3_endpoint
*priv_ep
),
393 DECLARE_EVENT_CLASS(cdns3_log_ep
,
394 TP_PROTO(struct cdns3_endpoint
*priv_ep
),
397 __string(name
, priv_ep
->name
)
398 __field(unsigned int, maxpacket
)
399 __field(unsigned int, maxpacket_limit
)
400 __field(unsigned int, max_streams
)
401 __field(unsigned int, maxburst
)
402 __field(unsigned int, flags
)
403 __field(unsigned int, dir
)
408 __assign_str(name
, priv_ep
->name
);
409 __entry
->maxpacket
= priv_ep
->endpoint
.maxpacket
;
410 __entry
->maxpacket_limit
= priv_ep
->endpoint
.maxpacket_limit
;
411 __entry
->max_streams
= priv_ep
->endpoint
.max_streams
;
412 __entry
->maxburst
= priv_ep
->endpoint
.maxburst
;
413 __entry
->flags
= priv_ep
->flags
;
414 __entry
->dir
= priv_ep
->dir
;
415 __entry
->enqueue
= priv_ep
->enqueue
;
416 __entry
->dequeue
= priv_ep
->dequeue
;
418 TP_printk("%s: mps: %d/%d. streams: %d, burst: %d, enq idx: %d, "
419 "deq idx: %d, flags %s%s%s%s%s%s%s%s, dir: %s",
420 __get_str(name
), __entry
->maxpacket
,
421 __entry
->maxpacket_limit
, __entry
->max_streams
,
422 __entry
->maxburst
, __entry
->enqueue
,
424 __entry
->flags
& EP_ENABLED
? "EN | " : "",
425 __entry
->flags
& EP_STALLED
? "STALLED | " : "",
426 __entry
->flags
& EP_WEDGE
? "WEDGE | " : "",
427 __entry
->flags
& EP_TRANSFER_STARTED
? "STARTED | " : "",
428 __entry
->flags
& EP_UPDATE_EP_TRBADDR
? "UPD TRB | " : "",
429 __entry
->flags
& EP_PENDING_REQUEST
? "REQ PEN | " : "",
430 __entry
->flags
& EP_RING_FULL
? "RING FULL |" : "",
431 __entry
->flags
& EP_CLAIMED
? "CLAIMED " : "",
432 __entry
->dir
? "IN" : "OUT"
436 DEFINE_EVENT(cdns3_log_ep
, cdns3_gadget_ep_enable
,
437 TP_PROTO(struct cdns3_endpoint
*priv_ep
),
441 DEFINE_EVENT(cdns3_log_ep
, cdns3_gadget_ep_disable
,
442 TP_PROTO(struct cdns3_endpoint
*priv_ep
),
446 DECLARE_EVENT_CLASS(cdns3_log_request_handled
,
447 TP_PROTO(struct cdns3_request
*priv_req
, int current_index
,
449 TP_ARGS(priv_req
, current_index
, handled
),
451 __field(struct cdns3_request
*, priv_req
)
452 __field(unsigned int, dma_position
)
453 __field(unsigned int, handled
)
454 __field(unsigned int, dequeue_idx
)
455 __field(unsigned int, enqueue_idx
)
456 __field(unsigned int, start_trb
)
457 __field(unsigned int, end_trb
)
460 __entry
->priv_req
= priv_req
;
461 __entry
->dma_position
= current_index
;
462 __entry
->handled
= handled
;
463 __entry
->dequeue_idx
= priv_req
->priv_ep
->dequeue
;
464 __entry
->enqueue_idx
= priv_req
->priv_ep
->enqueue
;
465 __entry
->start_trb
= priv_req
->start_trb
;
466 __entry
->end_trb
= priv_req
->end_trb
;
468 TP_printk("Req: %p %s, DMA pos: %d, ep deq: %d, ep enq: %d,"
469 " start trb: %d, end trb: %d",
471 __entry
->handled
? "handled" : "not handled",
472 __entry
->dma_position
, __entry
->dequeue_idx
,
473 __entry
->enqueue_idx
, __entry
->start_trb
,
478 DEFINE_EVENT(cdns3_log_request_handled
, cdns3_request_handled
,
479 TP_PROTO(struct cdns3_request
*priv_req
, int current_index
,
481 TP_ARGS(priv_req
, current_index
, handled
)
483 #endif /* __LINUX_CDNS3_TRACE */
485 /* this part must be outside header guard */
487 #undef TRACE_INCLUDE_PATH
488 #define TRACE_INCLUDE_PATH .
490 #undef TRACE_INCLUDE_FILE
491 #define TRACE_INCLUDE_FILE trace
493 #include <trace/define_trace.h>