Merge tag 'tag-chrome-platform-for-v5.15' of git://git.kernel.org/pub/scm/linux/kerne...
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 8 Sep 2021 23:43:46 +0000 (16:43 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 8 Sep 2021 23:43:46 +0000 (16:43 -0700)
Pull chrome platform updates from Benson Leung:
 "cros_ec_typec:

   - make the cros_ec_typec driver to use the pre-existing
     cros_ec_check_features() function

  sensorhub:

   - add trace events for sample

  misc:

   - cros_ec_proto - re-send commands in the event of a timeout (for the
     FPMCU)

   - fix warnings in cros_ec_trace related to format output"

* tag 'tag-chrome-platform-for-v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux:
  platform/chrome: cros_ec_trace: Fix format warnings
  platform/chrome: cros_ec_typec: Use existing feature check
  platform/chrome: cros_ec_proto: Send command again when timeout occurs
  platform/chrome: sensorhub: Add trace events for sample

drivers/platform/chrome/Makefile
drivers/platform/chrome/cros_ec_proto.c
drivers/platform/chrome/cros_ec_sensorhub_ring.c
drivers/platform/chrome/cros_ec_trace.h
drivers/platform/chrome/cros_ec_typec.c

index 41baccb..f901d2e 100644 (file)
@@ -20,7 +20,7 @@ obj-$(CONFIG_CROS_EC_CHARDEV)         += cros_ec_chardev.o
 obj-$(CONFIG_CROS_EC_LIGHTBAR)         += cros_ec_lightbar.o
 obj-$(CONFIG_CROS_EC_VBC)              += cros_ec_vbc.o
 obj-$(CONFIG_CROS_EC_DEBUGFS)          += cros_ec_debugfs.o
-cros-ec-sensorhub-objs                 := cros_ec_sensorhub.o cros_ec_sensorhub_ring.o
+cros-ec-sensorhub-objs                 := cros_ec_sensorhub.o cros_ec_sensorhub_ring.o cros_ec_trace.o
 obj-$(CONFIG_CROS_EC_SENSORHUB)                += cros-ec-sensorhub.o
 obj-$(CONFIG_CROS_EC_SYSFS)            += cros_ec_sysfs.o
 obj-$(CONFIG_CROS_USBPD_LOGGER)                += cros_usbpd_logger.o
index aa7f7aa..a7404d6 100644 (file)
@@ -279,6 +279,15 @@ static int cros_ec_host_command_proto_query(struct cros_ec_device *ec_dev,
        msg->insize = sizeof(struct ec_response_get_protocol_info);
 
        ret = send_command(ec_dev, msg);
+       /*
+        * Send command once again when timeout occurred.
+        * Fingerprint MCU (FPMCU) is restarted during system boot which
+        * introduces small window in which FPMCU won't respond for any
+        * messages sent by kernel. There is no need to wait before next
+        * attempt because we waited at least EC_MSG_DEADLINE_MS.
+        */
+       if (ret == -ETIMEDOUT)
+               ret = send_command(ec_dev, msg);
 
        if (ret < 0) {
                dev_dbg(ec_dev->dev,
index 8921f24..98e3708 100644 (file)
@@ -17,6 +17,8 @@
 #include <linux/sort.h>
 #include <linux/slab.h>
 
+#include "cros_ec_trace.h"
+
 /* Precision of fixed point for the m values from the filter */
 #define M_PRECISION BIT(23)
 
@@ -291,6 +293,7 @@ cros_ec_sensor_ring_ts_filter_update(struct cros_ec_sensors_ts_filter_state
                state->median_m = 0;
                state->median_error = 0;
        }
+       trace_cros_ec_sensorhub_filter(state, dx, dy);
 }
 
 /**
@@ -427,6 +430,11 @@ cros_ec_sensor_ring_process_event(struct cros_ec_sensorhub *sensorhub,
                        if (new_timestamp - *current_timestamp > 0)
                                *current_timestamp = new_timestamp;
                }
+               trace_cros_ec_sensorhub_timestamp(in->timestamp,
+                                                 fifo_info->timestamp,
+                                                 fifo_timestamp,
+                                                 *current_timestamp,
+                                                 now);
        }
 
        if (in->flags & MOTIONSENSE_SENSOR_FLAG_ODR) {
@@ -460,6 +468,12 @@ cros_ec_sensor_ring_process_event(struct cros_ec_sensorhub *sensorhub,
 
        /* Regular sample */
        out->sensor_id = in->sensor_num;
+       trace_cros_ec_sensorhub_data(in->sensor_num,
+                                    fifo_info->timestamp,
+                                    fifo_timestamp,
+                                    *current_timestamp,
+                                    now);
+
        if (*current_timestamp - now > 0) {
                /*
                 * This fix is needed to overcome the timestamp filter putting
index f744b21..7e7cfc9 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/types.h>
 #include <linux/platform_data/cros_ec_commands.h>
 #include <linux/platform_data/cros_ec_proto.h>
+#include <linux/platform_data/cros_ec_sensorhub.h>
 
 #include <linux/tracepoint.h>
 
@@ -70,6 +71,99 @@ TRACE_EVENT(cros_ec_request_done,
                  __entry->retval)
 );
 
+TRACE_EVENT(cros_ec_sensorhub_timestamp,
+           TP_PROTO(u32 ec_sample_timestamp, u32 ec_fifo_timestamp, s64 fifo_timestamp,
+                    s64 current_timestamp, s64 current_time),
+       TP_ARGS(ec_sample_timestamp, ec_fifo_timestamp, fifo_timestamp, current_timestamp,
+               current_time),
+       TP_STRUCT__entry(
+               __field(u32, ec_sample_timestamp)
+               __field(u32, ec_fifo_timestamp)
+               __field(s64, fifo_timestamp)
+               __field(s64, current_timestamp)
+               __field(s64, current_time)
+               __field(s64, delta)
+       ),
+       TP_fast_assign(
+               __entry->ec_sample_timestamp = ec_sample_timestamp;
+               __entry->ec_fifo_timestamp = ec_fifo_timestamp;
+               __entry->fifo_timestamp = fifo_timestamp;
+               __entry->current_timestamp = current_timestamp;
+               __entry->current_time = current_time;
+               __entry->delta = current_timestamp - current_time;
+       ),
+       TP_printk("ec_ts: %9u, ec_fifo_ts: %9u, fifo_ts: %12lld, curr_ts: %12lld, curr_time: %12lld, delta %12lld",
+                 __entry->ec_sample_timestamp,
+               __entry->ec_fifo_timestamp,
+               __entry->fifo_timestamp,
+               __entry->current_timestamp,
+               __entry->current_time,
+               __entry->delta
+       )
+);
+
+TRACE_EVENT(cros_ec_sensorhub_data,
+           TP_PROTO(u32 ec_sensor_num, u32 ec_fifo_timestamp, s64 fifo_timestamp,
+                    s64 current_timestamp, s64 current_time),
+       TP_ARGS(ec_sensor_num, ec_fifo_timestamp, fifo_timestamp, current_timestamp, current_time),
+       TP_STRUCT__entry(
+               __field(u32, ec_sensor_num)
+               __field(u32, ec_fifo_timestamp)
+               __field(s64, fifo_timestamp)
+               __field(s64, current_timestamp)
+               __field(s64, current_time)
+               __field(s64, delta)
+       ),
+       TP_fast_assign(
+               __entry->ec_sensor_num = ec_sensor_num;
+               __entry->ec_fifo_timestamp = ec_fifo_timestamp;
+               __entry->fifo_timestamp = fifo_timestamp;
+               __entry->current_timestamp = current_timestamp;
+               __entry->current_time = current_time;
+               __entry->delta = current_timestamp - current_time;
+       ),
+       TP_printk("ec_num: %4u, ec_fifo_ts: %9u, fifo_ts: %12lld, curr_ts: %12lld, curr_time: %12lld, delta %12lld",
+                 __entry->ec_sensor_num,
+               __entry->ec_fifo_timestamp,
+               __entry->fifo_timestamp,
+               __entry->current_timestamp,
+               __entry->current_time,
+               __entry->delta
+       )
+);
+
+TRACE_EVENT(cros_ec_sensorhub_filter,
+           TP_PROTO(struct cros_ec_sensors_ts_filter_state *state, s64 dx, s64 dy),
+       TP_ARGS(state, dx, dy),
+       TP_STRUCT__entry(
+               __field(s64, dx)
+               __field(s64, dy)
+               __field(s64, median_m)
+               __field(s64, median_error)
+               __field(s64, history_len)
+               __field(s64, x)
+               __field(s64, y)
+       ),
+       TP_fast_assign(
+               __entry->dx = dx;
+               __entry->dy = dy;
+               __entry->median_m = state->median_m;
+               __entry->median_error = state->median_error;
+               __entry->history_len = state->history_len;
+               __entry->x = state->x_offset;
+               __entry->y = state->y_offset;
+       ),
+       TP_printk("dx: %12lld. dy: %12lld median_m: %12lld median_error: %12lld len: %lld x: %12lld y: %12lld",
+                 __entry->dx,
+               __entry->dy,
+               __entry->median_m,
+               __entry->median_error,
+               __entry->history_len,
+               __entry->x,
+               __entry->y
+       )
+);
+
 
 #endif /* _CROS_EC_TRACE_H_ */
 
index 27c068c..262a891 100644 (file)
@@ -1054,24 +1054,6 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec)
        return 0;
 }
 
-/* Check the EC feature flags to see if TYPEC_* features are supported. */
-static int cros_typec_feature_supported(struct cros_typec_data *typec, enum ec_feature_code feature)
-{
-       struct ec_response_get_features resp = {};
-       int ret;
-
-       ret = cros_typec_ec_command(typec, 0, EC_CMD_GET_FEATURES, NULL, 0,
-                                   &resp, sizeof(resp));
-       if (ret < 0) {
-               dev_warn(typec->dev,
-                        "Failed to get features, assuming typec feature=%d unsupported.\n",
-                        feature);
-               return 0;
-       }
-
-       return resp.flags[feature / 32] & EC_FEATURE_MASK_1(feature);
-}
-
 static void cros_typec_port_work(struct work_struct *work)
 {
        struct cros_typec_data *typec = container_of(work, struct cros_typec_data, port_work);
@@ -1113,6 +1095,7 @@ MODULE_DEVICE_TABLE(of, cros_typec_of_match);
 
 static int cros_typec_probe(struct platform_device *pdev)
 {
+       struct cros_ec_dev *ec_dev = NULL;
        struct device *dev = &pdev->dev;
        struct cros_typec_data *typec;
        struct ec_response_usb_pd_ports resp;
@@ -1132,10 +1115,10 @@ static int cros_typec_probe(struct platform_device *pdev)
                return ret;
        }
 
-       typec->typec_cmd_supported = !!cros_typec_feature_supported(typec,
-                                       EC_FEATURE_TYPEC_CMD);
-       typec->needs_mux_ack = !!cros_typec_feature_supported(typec,
-                                       EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK);
+       ec_dev = dev_get_drvdata(&typec->ec->ec->dev);
+       typec->typec_cmd_supported = !!cros_ec_check_features(ec_dev, EC_FEATURE_TYPEC_CMD);
+       typec->needs_mux_ack = !!cros_ec_check_features(ec_dev,
+                                                       EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK);
 
        ret = cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_PORTS, NULL, 0,
                                    &resp, sizeof(resp));