Skip to content
Permalink
Browse files
Input: applespi: Add trace_event module param for early tracing.
The problem is that tracing can't be set via sysfs until the module is
loaded, at which point the keyboard and trackpad initialization commands
have already been run and hence tracing can't be used to debug problems
here.

Adding this param allows tracing to be enabled for messages sent and
received during module probing. It takes comma-separated list of events,
e.g.

  trace_event=applespi_tp_ini_cmd,applespi_bad_crc

Signed-off-by: Ronald Tschalär <ronald@innovation.ch>
  • Loading branch information
roadrunner2 authored and intel-lab-lkp committed Feb 17, 2021
1 parent 8e2b716 commit 838cd23e96675132bdd30878d1b24a59b8a534e1
Showing 1 changed file with 32 additions and 0 deletions.
@@ -53,6 +53,8 @@
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/spi/spi.h>
#include <linux/string.h>
#include <linux/trace_events.h>
#include <linux/wait.h>
#include <linux/workqueue.h>

@@ -110,6 +112,10 @@ module_param_string(touchpad_dimensions, touchpad_dimensions,
sizeof(touchpad_dimensions), 0444);
MODULE_PARM_DESC(touchpad_dimensions, "The pixel dimensions of the touchpad, as XxY+W+H .");

static char *trace_event;
module_param(trace_event, charp, 0444);
MODULE_PARM_DESC(trace_event, "Enable early event tracing. It takes the form of a comma-separated list of events to enable.");

/**
* struct keyboard_protocol - keyboard message.
* message.type = 0x0110, message.length = 0x000a
@@ -1645,6 +1651,30 @@ static void applespi_save_bl_level(struct applespi_data *applespi,
"Error saving backlight level to EFI vars: %d\n", sts);
}

static void applespi_enable_early_event_tracing(struct device *dev)
{
char *buf, *event;
int sts;

if (trace_event && trace_event[0]) {
buf = kstrdup(trace_event, GFP_KERNEL);
if (!buf)
return;

while ((event = strsep(&buf, ","))) {
if (event[0]) {
sts = trace_set_clr_event("applespi", event, 1);
if (sts)
dev_warn(dev,
"Error setting trace event '%s': %d\n",
event, sts);
}
}

kfree(buf);
}
}

static int applespi_probe(struct spi_device *spi)
{
struct applespi_data *applespi;
@@ -1653,6 +1683,8 @@ static int applespi_probe(struct spi_device *spi)
int sts, i;
unsigned long long gpe, usb_status;

applespi_enable_early_event_tracing(&spi->dev);

/* check if the USB interface is present and enabled already */
acpi_sts = acpi_evaluate_integer(spi_handle, "UIST", NULL, &usb_status);
if (ACPI_SUCCESS(acpi_sts) && usb_status) {

0 comments on commit 838cd23

Please sign in to comment.