FILE
cdns2-trace.h
File preview with syntax highlighting.
linux-6.19.14/drivers/usb/gadget/udc/cdns2/cdns2-trace.h
1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * USBHS-DEV device controller driver. 4 * Trace support header file. 5 * 6 * Copyright (C) 2023 Cadence. 7 * 8 * Author: Pawel Laszczak <pawell@cadence.com> 9 */ 10 11#undef TRACE_SYSTEM 12#define TRACE_SYSTEM cdns2-dev 13 14/* 15 * The TRACE_SYSTEM_VAR defaults to TRACE_SYSTEM, but must be a 16 * legitimate C variable. It is not exported to user space. 17 */ 18#undef TRACE_SYSTEM_VAR 19#define TRACE_SYSTEM_VAR cdns2_dev 20 21#if !defined(__LINUX_CDNS2_TRACE) || defined(TRACE_HEADER_MULTI_READ) 22#define __LINUX_CDNS2_TRACE 23 24#include <linux/types.h> 25#include <linux/tracepoint.h> 26#include <asm/byteorder.h> 27#include <linux/usb/ch9.h> 28#include "cdns2-gadget.h" 29#include "cdns2-debug.h" 30 31#define CDNS2_MSG_MAX 500 32 33DECLARE_EVENT_CLASS(cdns2_log_enable_disable, 34 TP_PROTO(int set), 35 TP_ARGS(set), 36 TP_STRUCT__entry( 37 __field(int, set) 38 ), 39 TP_fast_assign( 40 __entry->set = set; 41 ), 42 TP_printk("%s", __entry->set ? "enabled" : "disabled") 43); 44 45DEFINE_EVENT(cdns2_log_enable_disable, cdns2_pullup, 46 TP_PROTO(int set), 47 TP_ARGS(set) 48); 49 50DECLARE_EVENT_CLASS(cdns2_log_simple, 51 TP_PROTO(char *msg), 52 TP_ARGS(msg), 53 TP_STRUCT__entry( 54 __string(text, msg) 55 ), 56 TP_fast_assign( 57 __assign_str(text); 58 ), 59 TP_printk("%s", __get_str(text)) 60); 61 62DEFINE_EVENT(cdns2_log_simple, cdns2_no_room_on_ring, 63 TP_PROTO(char *msg), 64 TP_ARGS(msg) 65); 66 67DEFINE_EVENT(cdns2_log_simple, cdns2_ep0_status_stage, 68 TP_PROTO(char *msg), 69 TP_ARGS(msg) 70); 71 72DEFINE_EVENT(cdns2_log_simple, cdns2_ep0_setup, 73 TP_PROTO(char *msg), 74 TP_ARGS(msg) 75); 76 77DEFINE_EVENT(cdns2_log_simple, cdns2_device_state, 78 TP_PROTO(char *msg), 79 TP_ARGS(msg) 80); 81 82TRACE_EVENT(cdns2_ep_halt, 83 TP_PROTO(struct cdns2_endpoint *ep_priv, u8 halt, u8 flush), 84 TP_ARGS(ep_priv, halt, flush), 85 TP_STRUCT__entry( 86 __string(name, ep_priv->name) 87 __field(u8, halt) 88 __field(u8, flush) 89 ), 90 TP_fast_assign( 91 __assign_str(name); 92 __entry->halt = halt; 93 __entry->flush = flush; 94 ), 95 TP_printk("Halt %s for %s: %s", __entry->flush ? " and flush" : "", 96 __get_str(name), __entry->halt ? "set" : "cleared") 97); 98 99TRACE_EVENT(cdns2_wa1, 100 TP_PROTO(struct cdns2_endpoint *ep_priv, char *msg), 101 TP_ARGS(ep_priv, msg), 102 TP_STRUCT__entry( 103 __string(ep_name, ep_priv->name) 104 __string(msg, msg) 105 ), 106 TP_fast_assign( 107 __assign_str(ep_name); 108 __assign_str(msg); 109 ), 110 TP_printk("WA1: %s %s", __get_str(ep_name), __get_str(msg)) 111); 112 113DECLARE_EVENT_CLASS(cdns2_log_doorbell, 114 TP_PROTO(struct cdns2_endpoint *pep, u32 ep_trbaddr), 115 TP_ARGS(pep, ep_trbaddr), 116 TP_STRUCT__entry( 117 __string(name, pep->num ? pep->name : 118 (pep->dir ? "ep0in" : "ep0out")) 119 __field(u32, ep_trbaddr) 120 ), 121 TP_fast_assign( 122 __assign_str(name); 123 __entry->ep_trbaddr = ep_trbaddr; 124 ), 125 TP_printk("%s, ep_trbaddr %08x", __get_str(name), 126 __entry->ep_trbaddr) 127); 128 129DEFINE_EVENT(cdns2_log_doorbell, cdns2_doorbell_ep0, 130 TP_PROTO(struct cdns2_endpoint *pep, u32 ep_trbaddr), 131 TP_ARGS(pep, ep_trbaddr) 132); 133 134DEFINE_EVENT(cdns2_log_doorbell, cdns2_doorbell_epx, 135 TP_PROTO(struct cdns2_endpoint *pep, u32 ep_trbaddr), 136 TP_ARGS(pep, ep_trbaddr) 137); 138 139DECLARE_EVENT_CLASS(cdns2_log_usb_irq, 140 TP_PROTO(u32 usb_irq, u32 ext_irq), 141 TP_ARGS(usb_irq, ext_irq), 142 TP_STRUCT__entry( 143 __field(u32, usb_irq) 144 __field(u32, ext_irq) 145 ), 146 TP_fast_assign( 147 __entry->usb_irq = usb_irq; 148 __entry->ext_irq = ext_irq; 149 ), 150 TP_printk("%s", cdns2_decode_usb_irq(__get_buf(CDNS2_MSG_MAX), 151 CDNS2_MSG_MAX, 152 __entry->usb_irq, 153 __entry->ext_irq)) 154); 155 156DEFINE_EVENT(cdns2_log_usb_irq, cdns2_usb_irq, 157 TP_PROTO(u32 usb_irq, u32 ext_irq), 158 TP_ARGS(usb_irq, ext_irq) 159); 160 161TRACE_EVENT(cdns2_dma_ep_ists, 162 TP_PROTO(u32 dma_ep_ists), 163 TP_ARGS(dma_ep_ists), 164 TP_STRUCT__entry( 165 __field(u32, dma_ep_ists) 166 ), 167 TP_fast_assign( 168 __entry->dma_ep_ists = dma_ep_ists; 169 ), 170 TP_printk("OUT: 0x%04x, IN: 0x%04x", (u16)__entry->dma_ep_ists, 171 __entry->dma_ep_ists >> 16) 172); 173 174DECLARE_EVENT_CLASS(cdns2_log_epx_irq, 175 TP_PROTO(struct cdns2_device *pdev, struct cdns2_endpoint *pep), 176 TP_ARGS(pdev, pep), 177 TP_STRUCT__entry( 178 __string(ep_name, pep->name) 179 __field(u32, ep_sts) 180 __field(u32, ep_ists) 181 __field(u32, ep_traddr) 182 ), 183 TP_fast_assign( 184 __assign_str(ep_name); 185 __entry->ep_sts = readl(&pdev->adma_regs->ep_sts); 186 __entry->ep_ists = readl(&pdev->adma_regs->ep_ists); 187 __entry->ep_traddr = readl(&pdev->adma_regs->ep_traddr); 188 ), 189 TP_printk("%s, ep_traddr: %08x", 190 cdns2_decode_epx_irq(__get_buf(CDNS2_MSG_MAX), CDNS2_MSG_MAX, 191 __get_str(ep_name), 192 __entry->ep_ists, __entry->ep_sts), 193 __entry->ep_traddr) 194); 195 196DEFINE_EVENT(cdns2_log_epx_irq, cdns2_epx_irq, 197 TP_PROTO(struct cdns2_device *pdev, struct cdns2_endpoint *pep), 198 TP_ARGS(pdev, pep) 199); 200 201DECLARE_EVENT_CLASS(cdns2_log_ep0_irq, 202 TP_PROTO(struct cdns2_device *pdev), 203 TP_ARGS(pdev), 204 TP_STRUCT__entry( 205 __field(int, ep_dir) 206 __field(u32, ep_ists) 207 __field(u32, ep_sts) 208 ), 209 TP_fast_assign( 210 __entry->ep_dir = pdev->selected_ep; 211 __entry->ep_ists = readl(&pdev->adma_regs->ep_ists); 212 __entry->ep_sts = readl(&pdev->adma_regs->ep_sts); 213 ), 214 TP_printk("%s", cdns2_decode_ep0_irq(__get_buf(CDNS2_MSG_MAX), 215 CDNS2_MSG_MAX, 216 __entry->ep_ists, __entry->ep_sts, 217 __entry->ep_dir)) 218); 219 220DEFINE_EVENT(cdns2_log_ep0_irq, cdns2_ep0_irq, 221 TP_PROTO(struct cdns2_device *pdev), 222 TP_ARGS(pdev) 223); 224 225DECLARE_EVENT_CLASS(cdns2_log_ctrl, 226 TP_PROTO(struct usb_ctrlrequest *ctrl), 227 TP_ARGS(ctrl), 228 TP_STRUCT__entry( 229 __field(u8, bRequestType) 230 __field(u8, bRequest) 231 __field(u16, wValue) 232 __field(u16, wIndex) 233 __field(u16, wLength) 234 ), 235 TP_fast_assign( 236 __entry->bRequestType = ctrl->bRequestType; 237 __entry->bRequest = ctrl->bRequest; 238 __entry->wValue = le16_to_cpu(ctrl->wValue); 239 __entry->wIndex = le16_to_cpu(ctrl->wIndex); 240 __entry->wLength = le16_to_cpu(ctrl->wLength); 241 ), 242 TP_printk("%s", usb_decode_ctrl(__get_buf(CDNS2_MSG_MAX), CDNS2_MSG_MAX, 243 __entry->bRequestType, 244 __entry->bRequest, __entry->wValue, 245 __entry->wIndex, __entry->wLength) 246 ) 247); 248 249DEFINE_EVENT(cdns2_log_ctrl, cdns2_ctrl_req, 250 TP_PROTO(struct usb_ctrlrequest *ctrl), 251 TP_ARGS(ctrl) 252); 253 254DECLARE_EVENT_CLASS(cdns2_log_request, 255 TP_PROTO(struct cdns2_request *preq), 256 TP_ARGS(preq), 257 TP_STRUCT__entry( 258 __string(name, preq->pep->name) 259 __field(struct usb_request *, request) 260 __field(struct cdns2_request *, preq) 261 __field(void *, buf) 262 __field(unsigned int, actual) 263 __field(unsigned int, length) 264 __field(int, status) 265 __field(dma_addr_t, dma) 266 __field(int, zero) 267 __field(int, short_not_ok) 268 __field(int, no_interrupt) 269 __field(struct scatterlist*, sg) 270 __field(unsigned int, num_sgs) 271 __field(unsigned int, num_mapped_sgs) 272 __field(int, start_trb) 273 __field(int, end_trb) 274 ), 275 TP_fast_assign( 276 __assign_str(name); 277 __entry->request = &preq->request; 278 __entry->preq = preq; 279 __entry->buf = preq->request.buf; 280 __entry->actual = preq->request.actual; 281 __entry->length = preq->request.length; 282 __entry->status = preq->request.status; 283 __entry->dma = preq->request.dma; 284 __entry->zero = preq->request.zero; 285 __entry->short_not_ok = preq->request.short_not_ok; 286 __entry->no_interrupt = preq->request.no_interrupt; 287 __entry->sg = preq->request.sg; 288 __entry->num_sgs = preq->request.num_sgs; 289 __entry->num_mapped_sgs = preq->request.num_mapped_sgs; 290 __entry->start_trb = preq->start_trb; 291 __entry->end_trb = preq->end_trb; 292 ), 293 TP_printk("%s: req: %p, preq: %p, req buf: %p, length: %u/%u, status: %d," 294 "buf dma: (%pad), %s%s%s, sg: %p, num_sgs: %d, num_m_sgs: %d," 295 "trb: [start: %d, end: %d]", 296 __get_str(name), __entry->request, __entry->preq, 297 __entry->buf, __entry->actual, __entry->length, 298 __entry->status, &__entry->dma, 299 __entry->zero ? "Z" : "z", 300 __entry->short_not_ok ? "S" : "s", 301 __entry->no_interrupt ? "I" : "i", 302 __entry->sg, __entry->num_sgs, __entry->num_mapped_sgs, 303 __entry->start_trb, 304 __entry->end_trb 305 ) 306); 307 308DEFINE_EVENT(cdns2_log_request, cdns2_request_enqueue, 309 TP_PROTO(struct cdns2_request *preq), 310 TP_ARGS(preq) 311); 312 313DEFINE_EVENT(cdns2_log_request, cdns2_request_enqueue_error, 314 TP_PROTO(struct cdns2_request *preq), 315 TP_ARGS(preq) 316); 317 318DEFINE_EVENT(cdns2_log_request, cdns2_alloc_request, 319 TP_PROTO(struct cdns2_request *preq), 320 TP_ARGS(preq) 321); 322 323DEFINE_EVENT(cdns2_log_request, cdns2_free_request, 324 TP_PROTO(struct cdns2_request *preq), 325 TP_ARGS(preq) 326); 327 328DEFINE_EVENT(cdns2_log_request, cdns2_request_dequeue, 329 TP_PROTO(struct cdns2_request *preq), 330 TP_ARGS(preq) 331); 332 333DEFINE_EVENT(cdns2_log_request, cdns2_request_giveback, 334 TP_PROTO(struct cdns2_request *preq), 335 TP_ARGS(preq) 336); 337 338DECLARE_EVENT_CLASS(cdns2_log_trb, 339 TP_PROTO(struct cdns2_endpoint *pep, struct cdns2_trb *trb), 340 TP_ARGS(pep, trb), 341 TP_STRUCT__entry( 342 __string(name, pep->name) 343 __field(struct cdns2_trb *, trb) 344 __field(u32, buffer) 345 __field(u32, length) 346 __field(u32, control) 347 __field(u32, type) 348 ), 349 TP_fast_assign( 350 __assign_str(name); 351 __entry->trb = trb; 352 __entry->buffer = le32_to_cpu(trb->buffer); 353 __entry->length = le32_to_cpu(trb->length); 354 __entry->control = le32_to_cpu(trb->control); 355 __entry->type = usb_endpoint_type(pep->endpoint.desc); 356 ), 357 TP_printk("%s: trb V: %p, dma buf: P: 0x%08x, %s", 358 __get_str(name), __entry->trb, __entry->buffer, 359 cdns2_decode_trb(__get_buf(CDNS2_MSG_MAX), CDNS2_MSG_MAX, 360 __entry->control, __entry->length, 361 __entry->buffer)) 362); 363 364DEFINE_EVENT(cdns2_log_trb, cdns2_queue_trb, 365 TP_PROTO(struct cdns2_endpoint *pep, struct cdns2_trb *trb), 366 TP_ARGS(pep, trb) 367); 368 369DEFINE_EVENT(cdns2_log_trb, cdns2_complete_trb, 370 TP_PROTO(struct cdns2_endpoint *pep, struct cdns2_trb *trb), 371 TP_ARGS(pep, trb) 372); 373 374DECLARE_EVENT_CLASS(cdns2_log_ring, 375 TP_PROTO(struct cdns2_endpoint *pep), 376 TP_ARGS(pep), 377 TP_STRUCT__entry( 378 __dynamic_array(u8, tr_seg, TR_SEG_SIZE) 379 __dynamic_array(u8, pep, sizeof(struct cdns2_endpoint)) 380 __dynamic_array(char, buffer, 381 (TRBS_PER_SEGMENT * 65) + CDNS2_MSG_MAX) 382 ), 383 TP_fast_assign( 384 memcpy(__get_dynamic_array(pep), pep, 385 sizeof(struct cdns2_endpoint)); 386 memcpy(__get_dynamic_array(tr_seg), pep->ring.trbs, 387 TR_SEG_SIZE); 388 ), 389 390 TP_printk("%s", 391 cdns2_raw_ring((struct cdns2_endpoint *)__get_str(pep), 392 (struct cdns2_trb *)__get_str(tr_seg), 393 __get_str(buffer), 394 (TRBS_PER_SEGMENT * 65) + CDNS2_MSG_MAX)) 395); 396 397DEFINE_EVENT(cdns2_log_ring, cdns2_ring, 398 TP_PROTO(struct cdns2_endpoint *pep), 399 TP_ARGS(pep) 400); 401 402DECLARE_EVENT_CLASS(cdns2_log_ep, 403 TP_PROTO(struct cdns2_endpoint *pep), 404 TP_ARGS(pep), 405 TP_STRUCT__entry( 406 __string(name, pep->name) 407 __field(unsigned int, maxpacket) 408 __field(unsigned int, maxpacket_limit) 409 __field(unsigned int, flags) 410 __field(unsigned int, dir) 411 __field(u8, enqueue) 412 __field(u8, dequeue) 413 ), 414 TP_fast_assign( 415 __assign_str(name); 416 __entry->maxpacket = pep->endpoint.maxpacket; 417 __entry->maxpacket_limit = pep->endpoint.maxpacket_limit; 418 __entry->flags = pep->ep_state; 419 __entry->dir = pep->dir; 420 __entry->enqueue = pep->ring.enqueue; 421 __entry->dequeue = pep->ring.dequeue; 422 ), 423 TP_printk("%s: mps: %d/%d, enq idx: %d, deq idx: %d, " 424 "flags: %s%s%s%s, dir: %s", 425 __get_str(name), __entry->maxpacket, 426 __entry->maxpacket_limit, __entry->enqueue, 427 __entry->dequeue, 428 __entry->flags & EP_ENABLED ? "EN | " : "", 429 __entry->flags & EP_STALLED ? "STALLED | " : "", 430 __entry->flags & EP_WEDGE ? "WEDGE | " : "", 431 __entry->flags & EP_RING_FULL ? "RING FULL |" : "", 432 __entry->dir ? "IN" : "OUT" 433 ) 434); 435 436DEFINE_EVENT(cdns2_log_ep, cdns2_gadget_ep_enable, 437 TP_PROTO(struct cdns2_endpoint *pep), 438 TP_ARGS(pep) 439); 440 441DEFINE_EVENT(cdns2_log_ep, cdns2_gadget_ep_disable, 442 TP_PROTO(struct cdns2_endpoint *pep), 443 TP_ARGS(pep) 444); 445 446DEFINE_EVENT(cdns2_log_ep, cdns2_ep_busy_try_halt_again, 447 TP_PROTO(struct cdns2_endpoint *pep), 448 TP_ARGS(pep) 449); 450 451DECLARE_EVENT_CLASS(cdns2_log_request_handled, 452 TP_PROTO(struct cdns2_request *priv_req, int current_index, 453 int handled), 454 TP_ARGS(priv_req, current_index, handled), 455 TP_STRUCT__entry( 456 __field(struct cdns2_request *, priv_req) 457 __field(unsigned int, dma_position) 458 __field(unsigned int, handled) 459 __field(unsigned int, dequeue_idx) 460 __field(unsigned int, enqueue_idx) 461 __field(unsigned int, start_trb) 462 __field(unsigned int, end_trb) 463 ), 464 TP_fast_assign( 465 __entry->priv_req = priv_req; 466 __entry->dma_position = current_index; 467 __entry->handled = handled; 468 __entry->dequeue_idx = priv_req->pep->ring.dequeue; 469 __entry->enqueue_idx = priv_req->pep->ring.enqueue; 470 __entry->start_trb = priv_req->start_trb; 471 __entry->end_trb = priv_req->end_trb; 472 ), 473 TP_printk("Req: %p %s, DMA pos: %d, ep deq: %d, ep enq: %d," 474 " start trb: %d, end trb: %d", 475 __entry->priv_req, 476 __entry->handled ? "handled" : "not handled", 477 __entry->dma_position, __entry->dequeue_idx, 478 __entry->enqueue_idx, __entry->start_trb, 479 __entry->end_trb 480 ) 481); 482 483DEFINE_EVENT(cdns2_log_request_handled, cdns2_request_handled, 484 TP_PROTO(struct cdns2_request *priv_req, int current_index, 485 int handled), 486 TP_ARGS(priv_req, current_index, handled) 487); 488 489DECLARE_EVENT_CLASS(cdns2_log_epx_reg_config, 490 TP_PROTO(struct cdns2_device *pdev, struct cdns2_endpoint *pep), 491 TP_ARGS(pdev, pep), 492 TP_STRUCT__entry( 493 __string(ep_name, pep->name) 494 __field(u8, burst_size) 495 __field(__le16, maxpack_reg) 496 __field(__u8, con_reg) 497 __field(u32, ep_sel_reg) 498 __field(u32, ep_sts_en_reg) 499 __field(u32, ep_cfg_reg) 500 ), 501 TP_fast_assign( 502 __assign_str(ep_name); 503 __entry->burst_size = pep->trb_burst_size; 504 __entry->maxpack_reg = pep->dir ? readw(&pdev->epx_regs->txmaxpack[pep->num - 1]) : 505 readw(&pdev->epx_regs->rxmaxpack[pep->num - 1]); 506 __entry->con_reg = pep->dir ? readb(&pdev->epx_regs->ep[pep->num - 1].txcon) : 507 readb(&pdev->epx_regs->ep[pep->num - 1].rxcon); 508 __entry->ep_sel_reg = readl(&pdev->adma_regs->ep_sel); 509 __entry->ep_sts_en_reg = readl(&pdev->adma_regs->ep_sts_en); 510 __entry->ep_cfg_reg = readl(&pdev->adma_regs->ep_cfg); 511 ), 512 513 TP_printk("%s, maxpack: %d, con: %02x, dma_ep_sel: %08x, dma_ep_sts_en: %08x" 514 " dma_ep_cfg %08x", 515 __get_str(ep_name), __entry->maxpack_reg, __entry->con_reg, 516 __entry->ep_sel_reg, __entry->ep_sts_en_reg, 517 __entry->ep_cfg_reg 518 ) 519); 520 521DEFINE_EVENT(cdns2_log_epx_reg_config, cdns2_epx_hw_cfg, 522 TP_PROTO(struct cdns2_device *pdev, struct cdns2_endpoint *pep), 523 TP_ARGS(pdev, pep) 524); 525 526#endif /* __LINUX_CDNS2_TRACE */ 527 528/* This part must be outside header guard. */ 529 530#undef TRACE_INCLUDE_PATH 531#define TRACE_INCLUDE_PATH . 532 533#undef TRACE_INCLUDE_FILE 534#define TRACE_INCLUDE_FILE cdns2-trace 535 536#include <trace/define_trace.h>
~/
Read-only file preview.