spmi: add command tracepoints for SPMI
Subsystems (3)
PATCH v3 1/1 spmi: add command tracepoints for SPMI
Add tracepoints to retrieve information about read, write and non-data commands. For performance measurement support tracepoints are added at the beginning and at the end of transfers. Following is a list showing the new tracepoint events. The "cmd" parameter here represents the opcode, SID, and full 16-bit address.
spmi_write_begin: cmd and data buffer.spmi_write_end : cmd and return value.spmi_read_begin : cmd.spmi_read_end : cmd, return value and data buffer.spmi_cmd : cmd.
The reason that cmd appears at both the beginning and at the end event is that SPMI drivers can request commands concurrently. cmd helps in matching the corresponding events.
SPMI tracepoints can be enabled like:
echo 1 >/sys/kernel/debug/tracing/events/spmi/enable
and will dump messages that can be viewed in/sys/kernel/debug/tracing/trace that look like:
... spmi_read_begin: opc=56 sid=00 addr=0x0000
... spmi_read_end: opc=56 sid=00 addr=0x0000 ret=0 len=02 buf=0x[01-40] ... spmi_write_begin: opc=48 sid=00 addr=0x0000 len=3 buf=0x[ff-ff-ff]
---
Changes since V2:
- change back len type from size_t to u8.
---
Changes since V1:
- signed-off-by author moved to the end.
- changes len type from u8 to size_t.
---
drivers/spmi/spmi.c | 22 +++++++- include/trace/events/spmi.h | 135 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 include/trace/events/spmi.h
drivers/spmi/spmi.c +19 -3
@@ -21,6 +21,8 @@#include <linux/pm_runtime.h> #include <dt-bindings/spmi/spmi.h> +#define CREATE_TRACE_POINTS +#include <trace/events/spmi.h> static DEFINE_IDA (ctrl_ida);
@@ -95,28 +97,42 @@ EXPORT_SYMBOL_GPL(spmi_device_remove);static inline int spmi_cmd (struct spmi_controller *ctrl,u8 opcode,u8 sid) { +int ret; +if (!ctrl || !ctrl->cmd || ctrl->dev.type != &spmi_ctrl_type)return -EINVAL ; -return ctrl->cmd (ctrl, opcode, sid); + ret = ctrl->cmd (ctrl, opcode, sid); +trace_spmi_cmd (opcode, sid, ret); +return ret; }static inline int spmi_read_cmd (struct spmi_controller *ctrl,u8 opcode,u8 sid,u16 addr,u8 *buf,size_t len) { +int ret; +if (!ctrl || !ctrl->read_cmd || ctrl->dev.type != &spmi_ctrl_type)return -EINVAL ; -return ctrl->read_cmd (ctrl, opcode, sid, addr, buf, len); +trace_spmi_read_begin (opcode, sid, addr); + ret = ctrl->read_cmd (ctrl, opcode, sid, addr, buf, len); +trace_spmi_read_end (opcode, sid, addr, ret, len, buf); +return ret; }static inline int spmi_write_cmd (struct spmi_controller *ctrl,u8 opcode,u8 sid,u16 addr,const u8 *buf,size_t len) { +int ret; +if (!ctrl || !ctrl->write_cmd || ctrl->dev.type != &spmi_ctrl_type)return -EINVAL ; -return ctrl->write_cmd (ctrl, opcode, sid, addr, buf, len); +trace_spmi_write_begin (opcode, sid, addr, len, buf); + ret = ctrl->write_cmd (ctrl, opcode, sid, addr, buf, len); +trace_spmi_write_end (opcode, sid, addr, ret); +return ret; }/**
include/trace/events/spmi.h new file +135 -0
135 lines not on this page · raw message
Signature · 1 line
1.8.5.2