platform/chrome: cros_ec_proto: Add response tracing
Add the ability to view response codes as well. I dropped the EVENT_CLASS since there is only one event per class. cros_ec_cmd has now been renamed to cros_ec_request_start. Example: $ echo 1 > /sys/kernel/debug/tracing/events/cros_ec/enable $ cat /sys/kernel/debug/tracing/trace 369.416372: cros_ec_request_start: version: 0, command: EC_CMD_USB_PD_POWER_INFO 369.420528: cros_ec_request_done: version: 0, command: EC_CMD_USB_PD_POWER_INFO, ec result: EC_RES_SUCCESS, retval: 16 369.420529: cros_ec_request_start: version: 0, command: EC_CMD_USB_PD_DISCOVERY 369.421383: cros_ec_request_done: version: 0, command: EC_CMD_USB_PD_DISCOVERY, ec result: EC_RES_SUCCESS, retval: 5 Signed-off-by: Raul E Rangel <rrangel@chromium.org> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
This commit is contained in:
committed by
Enric Balletbo i Serra
parent
086338df1d
commit
205c9326fd
@ -54,8 +54,6 @@ static int send_command(struct cros_ec_device *ec_dev,
|
|||||||
int ret;
|
int ret;
|
||||||
int (*xfer_fxn)(struct cros_ec_device *ec, struct cros_ec_command *msg);
|
int (*xfer_fxn)(struct cros_ec_device *ec, struct cros_ec_command *msg);
|
||||||
|
|
||||||
trace_cros_ec_cmd(msg);
|
|
||||||
|
|
||||||
if (ec_dev->proto_version > 2)
|
if (ec_dev->proto_version > 2)
|
||||||
xfer_fxn = ec_dev->pkt_xfer;
|
xfer_fxn = ec_dev->pkt_xfer;
|
||||||
else
|
else
|
||||||
@ -72,7 +70,9 @@ static int send_command(struct cros_ec_device *ec_dev,
|
|||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trace_cros_ec_request_start(msg);
|
||||||
ret = (*xfer_fxn)(ec_dev, msg);
|
ret = (*xfer_fxn)(ec_dev, msg);
|
||||||
|
trace_cros_ec_request_done(msg, ret);
|
||||||
if (msg->result == EC_RES_IN_PROGRESS) {
|
if (msg->result == EC_RES_IN_PROGRESS) {
|
||||||
int i;
|
int i;
|
||||||
struct cros_ec_command *status_msg;
|
struct cros_ec_command *status_msg;
|
||||||
@ -95,7 +95,9 @@ static int send_command(struct cros_ec_device *ec_dev,
|
|||||||
for (i = 0; i < EC_COMMAND_RETRIES; i++) {
|
for (i = 0; i < EC_COMMAND_RETRIES; i++) {
|
||||||
usleep_range(10000, 11000);
|
usleep_range(10000, 11000);
|
||||||
|
|
||||||
|
trace_cros_ec_request_start(status_msg);
|
||||||
ret = (*xfer_fxn)(ec_dev, status_msg);
|
ret = (*xfer_fxn)(ec_dev, status_msg);
|
||||||
|
trace_cros_ec_request_done(status_msg, ret);
|
||||||
if (ret == -EAGAIN)
|
if (ret == -EAGAIN)
|
||||||
continue;
|
continue;
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -182,5 +182,29 @@
|
|||||||
TRACE_SYMBOL(EC_CMD_BOARD_SPECIFIC_BASE), \
|
TRACE_SYMBOL(EC_CMD_BOARD_SPECIFIC_BASE), \
|
||||||
TRACE_SYMBOL(EC_CMD_BOARD_SPECIFIC_LAST)
|
TRACE_SYMBOL(EC_CMD_BOARD_SPECIFIC_LAST)
|
||||||
|
|
||||||
|
/* See the enum ec_status in include/linux/platform_data/cros_ec_commands.h */
|
||||||
|
#define EC_RESULT \
|
||||||
|
TRACE_SYMBOL(EC_RES_SUCCESS), \
|
||||||
|
TRACE_SYMBOL(EC_RES_INVALID_COMMAND), \
|
||||||
|
TRACE_SYMBOL(EC_RES_ERROR), \
|
||||||
|
TRACE_SYMBOL(EC_RES_INVALID_PARAM), \
|
||||||
|
TRACE_SYMBOL(EC_RES_ACCESS_DENIED), \
|
||||||
|
TRACE_SYMBOL(EC_RES_INVALID_RESPONSE), \
|
||||||
|
TRACE_SYMBOL(EC_RES_INVALID_VERSION), \
|
||||||
|
TRACE_SYMBOL(EC_RES_INVALID_CHECKSUM), \
|
||||||
|
TRACE_SYMBOL(EC_RES_IN_PROGRESS), \
|
||||||
|
TRACE_SYMBOL(EC_RES_UNAVAILABLE), \
|
||||||
|
TRACE_SYMBOL(EC_RES_TIMEOUT), \
|
||||||
|
TRACE_SYMBOL(EC_RES_OVERFLOW), \
|
||||||
|
TRACE_SYMBOL(EC_RES_INVALID_HEADER), \
|
||||||
|
TRACE_SYMBOL(EC_RES_REQUEST_TRUNCATED), \
|
||||||
|
TRACE_SYMBOL(EC_RES_RESPONSE_TOO_BIG), \
|
||||||
|
TRACE_SYMBOL(EC_RES_BUS_ERROR), \
|
||||||
|
TRACE_SYMBOL(EC_RES_BUSY), \
|
||||||
|
TRACE_SYMBOL(EC_RES_INVALID_HEADER_VERSION), \
|
||||||
|
TRACE_SYMBOL(EC_RES_INVALID_HEADER_CRC), \
|
||||||
|
TRACE_SYMBOL(EC_RES_INVALID_DATA_CRC), \
|
||||||
|
TRACE_SYMBOL(EC_RES_DUP_UNAVAILABLE)
|
||||||
|
|
||||||
#define CREATE_TRACE_POINTS
|
#define CREATE_TRACE_POINTS
|
||||||
#include "cros_ec_trace.h"
|
#include "cros_ec_trace.h"
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include <linux/tracepoint.h>
|
#include <linux/tracepoint.h>
|
||||||
|
|
||||||
DECLARE_EVENT_CLASS(cros_ec_cmd_class,
|
TRACE_EVENT(cros_ec_request_start,
|
||||||
TP_PROTO(struct cros_ec_command *cmd),
|
TP_PROTO(struct cros_ec_command *cmd),
|
||||||
TP_ARGS(cmd),
|
TP_ARGS(cmd),
|
||||||
TP_STRUCT__entry(
|
TP_STRUCT__entry(
|
||||||
@ -33,10 +33,26 @@ DECLARE_EVENT_CLASS(cros_ec_cmd_class,
|
|||||||
__print_symbolic(__entry->command, EC_CMDS))
|
__print_symbolic(__entry->command, EC_CMDS))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
TRACE_EVENT(cros_ec_request_done,
|
||||||
DEFINE_EVENT(cros_ec_cmd_class, cros_ec_cmd,
|
TP_PROTO(struct cros_ec_command *cmd, int retval),
|
||||||
TP_PROTO(struct cros_ec_command *cmd),
|
TP_ARGS(cmd, retval),
|
||||||
TP_ARGS(cmd)
|
TP_STRUCT__entry(
|
||||||
|
__field(uint32_t, version)
|
||||||
|
__field(uint32_t, command)
|
||||||
|
__field(uint32_t, result)
|
||||||
|
__field(int, retval)
|
||||||
|
),
|
||||||
|
TP_fast_assign(
|
||||||
|
__entry->version = cmd->version;
|
||||||
|
__entry->command = cmd->command;
|
||||||
|
__entry->result = cmd->result;
|
||||||
|
__entry->retval = retval;
|
||||||
|
),
|
||||||
|
TP_printk("version: %u, command: %s, ec result: %s, retval: %d",
|
||||||
|
__entry->version,
|
||||||
|
__print_symbolic(__entry->command, EC_CMDS),
|
||||||
|
__print_symbolic(__entry->result, EC_RESULT),
|
||||||
|
__entry->retval)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user