linux/drivers/usb/mtu3/mtu3_trace.h
Linus Torvalds 965a9d75e3 Tracing updates for 5.20 / 6.0
- Runtime verification infrastructure
   This is the biggest change for this pull request. It introduces the
   runtime verification that is necessary for running Linux on safety
   critical systems. It allows for deterministic automata models to be
   inserted into the kernel that will attach to tracepoints, where the
   information on these tracepoints will move the model from state to state.
   If a state is encountered that does not belong to the model, it will then
   activate a given reactor, that could just inform the user or even panic
   the kernel (for which safety critical systems will detect and can recover
   from).
 
 - Two monitor models are also added: Wakeup In Preemptive (WIP - not to be
   confused with "work in progress"), and Wakeup While Not Running (WWNR).
 
 - Added __vstring() helper to the TRACE_EVENT() macro to replace several
   vsnprintf() usages that were all doing it wrong.
 
 - eprobes now can have their event autogenerated when the event name is left
   off.
 
 - The rest is various cleanups and fixes.
 -----BEGIN PGP SIGNATURE-----
 
 iIoEABYIADIWIQRRSw7ePDh/lE+zeZMp5XQQmuv6qgUCYu0yzRQccm9zdGVkdEBn
 b29kbWlzLm9yZwAKCRAp5XQQmuv6qj4HAP4tQtV55rjj4DQ5XIXmtI3/64PmyRSJ
 +y4DEXi1UvEUCQD/QAuQfWoT/7gh35ltkfeS4t3ockzy14rrkP5drZigiQA=
 =kEtM
 -----END PGP SIGNATURE-----

Merge tag 'trace-v6.0' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace

Pull tracing updates from Steven Rostedt:

 - Runtime verification infrastructure

   This is the biggest change here. It introduces the runtime
   verification that is necessary for running Linux on safety critical
   systems.

   It allows for deterministic automata models to be inserted into the
   kernel that will attach to tracepoints, where the information on
   these tracepoints will move the model from state to state.

   If a state is encountered that does not belong to the model, it will
   then activate a given reactor, that could just inform the user or
   even panic the kernel (for which safety critical systems will detect
   and can recover from).

 - Two monitor models are also added: Wakeup In Preemptive (WIP - not to
   be confused with "work in progress"), and Wakeup While Not Running
   (WWNR).

 - Added __vstring() helper to the TRACE_EVENT() macro to replace
   several vsnprintf() usages that were all doing it wrong.

 - eprobes now can have their event autogenerated when the event name is
   left off.

 - The rest is various cleanups and fixes.

* tag 'trace-v6.0' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (50 commits)
  rv: Unlock on error path in rv_unregister_reactor()
  tracing: Use alignof__(struct {type b;}) instead of offsetof()
  tracing/eprobe: Show syntax error logs in error_log file
  scripts/tracing: Fix typo 'the the' in comment
  tracepoints: It is CONFIG_TRACEPOINTS not CONFIG_TRACEPOINT
  tracing: Use free_trace_buffer() in allocate_trace_buffers()
  tracing: Use a struct alignof to determine trace event field alignment
  rv/reactor: Add the panic reactor
  rv/reactor: Add the printk reactor
  rv/monitor: Add the wwnr monitor
  rv/monitor: Add the wip monitor
  rv/monitor: Add the wip monitor skeleton created by dot2k
  Documentation/rv: Add deterministic automata instrumentation documentation
  Documentation/rv: Add deterministic automata monitor synthesis documentation
  tools/rv: Add dot2k
  Documentation/rv: Add deterministic automaton documentation
  tools/rv: Add dot2c
  Documentation/rv: Add a basic documentation
  rv/include: Add instrumentation helper functions
  rv/include: Add deterministic automata monitor definition via C macros
  ...
2022-08-05 09:41:12 -07:00

278 lines
6.8 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
/**
* mtu3_trace.h - trace support
*
* Copyright (C) 2019 MediaTek Inc.
*
* Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
*/
#undef TRACE_SYSTEM
#define TRACE_SYSTEM mtu3
#if !defined(__MTU3_TRACE_H__) || defined(TRACE_HEADER_MULTI_READ)
#define __MTU3_TRACE_H__
#include <linux/types.h>
#include <linux/tracepoint.h>
#include "mtu3.h"
TRACE_EVENT(mtu3_log,
TP_PROTO(struct device *dev, struct va_format *vaf),
TP_ARGS(dev, vaf),
TP_STRUCT__entry(
__string(name, dev_name(dev))
__vstring(msg, vaf->fmt, vaf->va)
),
TP_fast_assign(
__assign_str(name, dev_name(dev));
__assign_vstr(msg, vaf->fmt, vaf->va);
),
TP_printk("%s: %s", __get_str(name), __get_str(msg))
);
TRACE_EVENT(mtu3_u3_ltssm_isr,
TP_PROTO(u32 intr),
TP_ARGS(intr),
TP_STRUCT__entry(
__field(u32, intr)
),
TP_fast_assign(
__entry->intr = intr;
),
TP_printk("(%08x) %s %s %s %s %s %s", __entry->intr,
__entry->intr & HOT_RST_INTR ? "HOT_RST" : "",
__entry->intr & WARM_RST_INTR ? "WARM_RST" : "",
__entry->intr & ENTER_U3_INTR ? "ENT_U3" : "",
__entry->intr & EXIT_U3_INTR ? "EXIT_U3" : "",
__entry->intr & VBUS_RISE_INTR ? "VBUS_RISE" : "",
__entry->intr & VBUS_FALL_INTR ? "VBUS_FALL" : ""
)
);
TRACE_EVENT(mtu3_u2_common_isr,
TP_PROTO(u32 intr),
TP_ARGS(intr),
TP_STRUCT__entry(
__field(u32, intr)
),
TP_fast_assign(
__entry->intr = intr;
),
TP_printk("(%08x) %s %s %s", __entry->intr,
__entry->intr & SUSPEND_INTR ? "SUSPEND" : "",
__entry->intr & RESUME_INTR ? "RESUME" : "",
__entry->intr & RESET_INTR ? "RESET" : ""
)
);
TRACE_EVENT(mtu3_qmu_isr,
TP_PROTO(u32 done_intr, u32 exp_intr),
TP_ARGS(done_intr, exp_intr),
TP_STRUCT__entry(
__field(u32, done_intr)
__field(u32, exp_intr)
),
TP_fast_assign(
__entry->done_intr = done_intr;
__entry->exp_intr = exp_intr;
),
TP_printk("done (tx %04x, rx %04x), exp (%08x)",
__entry->done_intr & 0xffff,
__entry->done_intr >> 16,
__entry->exp_intr
)
);
DECLARE_EVENT_CLASS(mtu3_log_setup,
TP_PROTO(struct usb_ctrlrequest *setup),
TP_ARGS(setup),
TP_STRUCT__entry(
__field(__u8, bRequestType)
__field(__u8, bRequest)
__field(__u16, wValue)
__field(__u16, wIndex)
__field(__u16, wLength)
),
TP_fast_assign(
__entry->bRequestType = setup->bRequestType;
__entry->bRequest = setup->bRequest;
__entry->wValue = le16_to_cpu(setup->wValue);
__entry->wIndex = le16_to_cpu(setup->wIndex);
__entry->wLength = le16_to_cpu(setup->wLength);
),
TP_printk("setup - %02x %02x %04x %04x %04x",
__entry->bRequestType, __entry->bRequest,
__entry->wValue, __entry->wIndex, __entry->wLength
)
);
DEFINE_EVENT(mtu3_log_setup, mtu3_handle_setup,
TP_PROTO(struct usb_ctrlrequest *setup),
TP_ARGS(setup)
);
DECLARE_EVENT_CLASS(mtu3_log_request,
TP_PROTO(struct mtu3_request *mreq),
TP_ARGS(mreq),
TP_STRUCT__entry(
__string(name, mreq->mep->name)
__field(struct mtu3_request *, mreq)
__field(struct qmu_gpd *, gpd)
__field(unsigned int, actual)
__field(unsigned int, length)
__field(int, status)
__field(int, zero)
__field(int, no_interrupt)
),
TP_fast_assign(
__assign_str(name, mreq->mep->name);
__entry->mreq = mreq;
__entry->gpd = mreq->gpd;
__entry->actual = mreq->request.actual;
__entry->length = mreq->request.length;
__entry->status = mreq->request.status;
__entry->zero = mreq->request.zero;
__entry->no_interrupt = mreq->request.no_interrupt;
),
TP_printk("%s: req %p gpd %p len %u/%u %s%s --> %d",
__get_str(name), __entry->mreq, __entry->gpd,
__entry->actual, __entry->length,
__entry->zero ? "Z" : "z",
__entry->no_interrupt ? "i" : "I",
__entry->status
)
);
DEFINE_EVENT(mtu3_log_request, mtu3_alloc_request,
TP_PROTO(struct mtu3_request *req),
TP_ARGS(req)
);
DEFINE_EVENT(mtu3_log_request, mtu3_free_request,
TP_PROTO(struct mtu3_request *req),
TP_ARGS(req)
);
DEFINE_EVENT(mtu3_log_request, mtu3_gadget_queue,
TP_PROTO(struct mtu3_request *req),
TP_ARGS(req)
);
DEFINE_EVENT(mtu3_log_request, mtu3_gadget_dequeue,
TP_PROTO(struct mtu3_request *req),
TP_ARGS(req)
);
DEFINE_EVENT(mtu3_log_request, mtu3_req_complete,
TP_PROTO(struct mtu3_request *req),
TP_ARGS(req)
);
DECLARE_EVENT_CLASS(mtu3_log_gpd,
TP_PROTO(struct mtu3_ep *mep, struct qmu_gpd *gpd),
TP_ARGS(mep, gpd),
TP_STRUCT__entry(
__string(name, mep->name)
__field(struct qmu_gpd *, gpd)
__field(u32, dw0)
__field(u32, dw1)
__field(u32, dw2)
__field(u32, dw3)
),
TP_fast_assign(
__assign_str(name, mep->name);
__entry->gpd = gpd;
__entry->dw0 = le32_to_cpu(gpd->dw0_info);
__entry->dw1 = le32_to_cpu(gpd->next_gpd);
__entry->dw2 = le32_to_cpu(gpd->buffer);
__entry->dw3 = le32_to_cpu(gpd->dw3_info);
),
TP_printk("%s: gpd %p - %08x %08x %08x %08x",
__get_str(name), __entry->gpd,
__entry->dw0, __entry->dw1,
__entry->dw2, __entry->dw3
)
);
DEFINE_EVENT(mtu3_log_gpd, mtu3_prepare_gpd,
TP_PROTO(struct mtu3_ep *mep, struct qmu_gpd *gpd),
TP_ARGS(mep, gpd)
);
DEFINE_EVENT(mtu3_log_gpd, mtu3_complete_gpd,
TP_PROTO(struct mtu3_ep *mep, struct qmu_gpd *gpd),
TP_ARGS(mep, gpd)
);
DEFINE_EVENT(mtu3_log_gpd, mtu3_zlp_exp_gpd,
TP_PROTO(struct mtu3_ep *mep, struct qmu_gpd *gpd),
TP_ARGS(mep, gpd)
);
DECLARE_EVENT_CLASS(mtu3_log_ep,
TP_PROTO(struct mtu3_ep *mep),
TP_ARGS(mep),
TP_STRUCT__entry(
__string(name, mep->name)
__field(unsigned int, type)
__field(unsigned int, slot)
__field(unsigned int, maxp)
__field(unsigned int, mult)
__field(unsigned int, maxburst)
__field(unsigned int, flags)
__field(unsigned int, direction)
__field(struct mtu3_gpd_ring *, gpd_ring)
),
TP_fast_assign(
__assign_str(name, mep->name);
__entry->type = mep->type;
__entry->slot = mep->slot;
__entry->maxp = mep->ep.maxpacket;
__entry->mult = mep->ep.mult;
__entry->maxburst = mep->ep.maxburst;
__entry->flags = mep->flags;
__entry->direction = mep->is_in;
__entry->gpd_ring = &mep->gpd_ring;
),
TP_printk("%s: type %s maxp %d slot %d mult %d burst %d ring %p/%pad flags %c:%c%c%c:%c",
__get_str(name), usb_ep_type_string(__entry->type),
__entry->maxp, __entry->slot,
__entry->mult, __entry->maxburst,
__entry->gpd_ring, &__entry->gpd_ring->dma,
__entry->flags & MTU3_EP_ENABLED ? 'E' : 'e',
__entry->flags & MTU3_EP_STALL ? 'S' : 's',
__entry->flags & MTU3_EP_WEDGE ? 'W' : 'w',
__entry->flags & MTU3_EP_BUSY ? 'B' : 'b',
__entry->direction ? '<' : '>'
)
);
DEFINE_EVENT(mtu3_log_ep, mtu3_gadget_ep_enable,
TP_PROTO(struct mtu3_ep *mep),
TP_ARGS(mep)
);
DEFINE_EVENT(mtu3_log_ep, mtu3_gadget_ep_disable,
TP_PROTO(struct mtu3_ep *mep),
TP_ARGS(mep)
);
DEFINE_EVENT(mtu3_log_ep, mtu3_gadget_ep_set_halt,
TP_PROTO(struct mtu3_ep *mep),
TP_ARGS(mep)
);
#endif /* __MTU3_TRACE_H__ */
/* this part has to be here */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE mtu3_trace
#include <trace/define_trace.h>