platform/chrome: cros_ec: Add trace event to trace EC commands
Subsystems (2)
PATCH v6 1/1 platform/chrome: cros_ec: Add trace event to trace EC commands
This is useful to see which EC commands are being executed and when.
To enable:
echo 1 > /sys/kernel/debug/tracing/events/cros_ec/enable
Example:
/* cros_ec_cmd: version: 0, command: EC_CMD_GET_VERSION */
/* cros_ec_cmd: version: 0, command: EC_CMD_GET_PROTOCOL_INFO */
/* cros_ec_cmd: version: 1, command: EC_CMD_GET_CMD_VERSIONS */
/* cros_ec_cmd: version: 1, command: EC_CMD_USB_PD_CONTROL */---
I did not add cros_ec_commands.h as an include to cros_ec_trace.c. It's not strictly required because the macro doesn't get evaluated until after cros_ec_trace.h has been included. That transitively brings in cros_ec_ommands.h. I did try it, but since cros_ec_commands.h doesn't include linux/types.h it fails to find uint32_t. I could have included both headers, but since they aren't required I just skipped it.
My reasoning for not putting EC_CMDS in the cros_ec_trace.h was that I didn't want to clutter the file. I think it's visually easier to find all the trace events without having to parse through all the implementation details.
Changes in v6:
- Added script to generate the EC_CMDS trace symbols. They were originally sorted by value, now they are sorted by declaration order. There is one duplicate: EC_CMD_PORT80_LAST_BOOT and EC_CMD_PORT80_READ. They both resolve to the same value. Not sure if this is a bug in the cros_ec_commands.h file or not. Anyway it doesn't hurt anything.
- Changed the example in the commit
Changes in v5:
- Rebased on upstream/master. It turns out upstream/master is missing a lot of changes to cros_ec_commands.h.
- Replace SYM with SYMBOL in macro name.
Changes in v4:
- Use the full command name so go to definition continues to work in my editor.
Changes in v3:
- Use a macro to avoid duplicating the ec command names.
Changes in v2:
- Changed comment style to match other cros_ec files.
- Fixed commit tag.
drivers/platform/chrome/Makefile | 5 +- drivers/platform/chrome/cros_ec_proto.c | 4 + drivers/platform/chrome/cros_ec_trace.c | 124 ++++++++++++++++++++++++ drivers/platform/chrome/cros_ec_trace.h | 51 ++++++++++ 4 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 drivers/platform/chrome/cros_ec_trace.c create mode 100644 drivers/platform/chrome/cros_ec_trace.h
drivers/platform/chrome/Makefile +4 -1
@@ -1,5 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 +# tell define_trace.h where to find the cros ec trace header +CFLAGS_cros_ec_trace.o:= -I$(src) + obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o obj-$(CONFIG_CHROMEOS_PSTORE) += chromeos_pstore.o obj-$(CONFIG_CHROMEOS_TBMC) += chromeos_tbmc.o
@@ -8,7 +11,7 @@ obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o cros_ec_lpcs-objs := cros_ec_lpc.o cros_ec_lpc_reg.o cros_ec_lpcs-$(CONFIG_CROS_EC_LPC_MEC) += cros_ec_lpc_mec.o obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpcs.o -obj-$(CONFIG_CROS_EC_PROTO) += cros_ec_proto.o +obj-$(CONFIG_CROS_EC_PROTO) += cros_ec_proto.o cros_ec_trace.o obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT) += cros_kbd_led_backlight.o obj-$(CONFIG_CROS_EC_LIGHTBAR) += cros_ec_lightbar.o obj-$(CONFIG_CROS_EC_VBC) += cros_ec_vbc.o
drivers/platform/chrome/cros_ec_proto.c +4 -0
@@ -10,6 +10,8 @@#include <linux/slab.h> #include <asm/unaligned.h> +#include "cros_ec_trace.h" +#define EC_COMMAND_RETRIES 50 static int prepare_packet(struct cros_ec_device *ec_dev,
@@ -51,6 +53,8 @@ static int send_command(struct cros_ec_device *ec_dev,int ret;int (*xfer_fxn)(struct cros_ec_device *ec,struct cros_ec_command *msg); +trace_cros_ec_cmd (msg); +if (ec_dev->proto_version >2 ) xfer_fxn = ec_dev->pkt_xfer;else
drivers/platform/chrome/cros_ec_trace.c new file +124 -0
124 lines not on this page · raw message
drivers/platform/chrome/cros_ec_trace.h new file +51 -0
51 lines not on this page · raw message
Signature · 1 line
2.21.0.392.gf8f6787159e-goog
Quoted 54 lines · Raul E Rangel
This is useful to see which EC commands are being executed and when.
To enable:
echo 1 >
/sys/kernel/debug/tracing/events/cros_ec/enableExample:
/* cros_ec_cmd: version: 0, command: EC_CMD_GET_VERSION */ /* cros_ec_cmd: version: 0, command: EC_CMD_GET_PROTOCOL_INFO */ /* cros_ec_cmd: version: 1, command: EC_CMD_GET_CMD_VERSIONS */ /* cros_ec_cmd: version: 1, command: EC_CMD_USB_PD_CONTROL */Signed-off-by Raul E Rangel <[email protected]>Reviewed-by Ross Zwisler <[email protected]>Reviewed-by Steven Rostedt (VMware) <[email protected]>---
I did not addcros_ec_commands.has an include tocros_ec_trace.c. It's not strictly required because the macro doesn't get evaluated until aftercros_ec_trace.hhas been included. That transitively brings incros_ec_ommands.h. I did try it, but sincecros_ec_commands.hdoesn't includelinux/types.hit fails to finduint32_t. I could have included both headers, but since they aren't required I just skipped it.My reasoning for not putting
EC_CMDSin thecros_ec_trace.hwas that I didn't want to clutter the file. I think it's visually easier to find all the trace events without having to parse through all the implementation details.Changes in v6:
- Added script to generate theEC_CMDStrace symbols. They were originally sorted by value, now they are sorted by declaration order. There is one duplicate:EC_CMD_PORT80_LAST_BOOTandEC_CMD_PORT80_READ. They both resolve to the same value. Not sure if this is a bug in thecros_ec_commands.hfile or not. Anyway it doesn't hurt anything.
- Changed the example in the commitChanges in v5:
- Rebased on upstream/master. It turns out upstream/master is missing a lot of changes tocros_ec_commands.h.
- Replace SYM with SYMBOL in macro name.Changes in v4:
- Use the full command name so go to definition continues to work in my editor.Changes in v3:
- Use a macro to avoid duplicating the ec command names.Changes in v2:
- Changed comment style to match othercros_ecfiles.
- Fixed commit tag.
Quoted 8 lines
drivers/platform/chrome/Makefile | 5 +- drivers/platform/chrome/cros_ec_proto.c | 4 + drivers/platform/chrome/cros_ec_trace.c | 124 ++++++++++++++++++++++++ drivers/platform/chrome/cros_ec_trace.h | 51 ++++++++++ 4 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 drivers/platform/chrome/cros_ec_trace.c create mode 100644 drivers/platform/chrome/cros_ec_trace.h
Tweaked a bit the commit message and applied for 5.2
Thanks,
Enric