greybus: loopback: drop dependency on internal timestamps
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>
Wed, 23 Sep 2015 01:06:37 +0000 (18:06 -0700)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 23 Sep 2015 19:39:24 +0000 (12:39 -0700)
This patch drops tracking of internal latencies, it's possible to derive
these times via kernel tracepoints and some user-space scripting. Since
there's no other use of the internal timestamp than the loopback driver we
remove the connection.c, connection.h, es1.c, es2.c and loopback.c
inter-dependency in one go.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/connection.c
drivers/staging/greybus/connection.h
drivers/staging/greybus/es1.c
drivers/staging/greybus/es2.c
drivers/staging/greybus/loopback.c

index f154131..05a9b54 100644 (file)
@@ -67,29 +67,6 @@ void greybus_data_rcvd(struct greybus_host_device *hd, u16 cport_id,
 }
 EXPORT_SYMBOL_GPL(greybus_data_rcvd);
 
-void gb_connection_push_timestamp(struct gb_connection *connection)
-{
-       struct timeval tv;
-
-       do_gettimeofday(&tv);
-       kfifo_in_locked(&connection->ts_kfifo, (void *)&tv,
-                       sizeof(struct timeval), &connection->lock);
-}
-EXPORT_SYMBOL_GPL(gb_connection_push_timestamp);
-
-int gb_connection_pop_timestamp(struct gb_connection *connection,
-                               struct timeval *tv)
-{
-       int retval;
-
-       if (!kfifo_len(&connection->ts_kfifo))
-               return -ENOMEM;
-       retval = kfifo_out_locked(&connection->ts_kfifo, (void *)tv,
-                                 sizeof(*tv), &connection->lock);
-       return retval;
-}
-EXPORT_SYMBOL_GPL(gb_connection_pop_timestamp);
-
 static ssize_t state_show(struct device *dev, struct device_attribute *attr,
                          char *buf)
 {
@@ -138,7 +115,6 @@ static void gb_connection_release(struct device *dev)
        struct gb_connection *connection = to_gb_connection(dev);
 
        destroy_workqueue(connection->wq);
-       kfifo_free(&connection->ts_kfifo);
        kfree(connection);
 }
 
@@ -234,10 +210,6 @@ gb_connection_create_range(struct greybus_host_device *hd,
        if (!connection->wq)
                goto err_free_connection;
 
-       if (kfifo_alloc(&connection->ts_kfifo, GB_CONNECTION_TS_KFIFO_LEN,
-                       GFP_KERNEL))
-               goto err_destroy_wq;
-
        connection->dev.parent = parent;
        connection->dev.bus = &greybus_bus_type;
        connection->dev.type = &greybus_connection_type;
@@ -274,8 +246,6 @@ gb_connection_create_range(struct greybus_host_device *hd,
 
        return connection;
 
-err_destroy_wq:
-       destroy_workqueue(connection->wq);
 err_free_connection:
        kfree(connection);
 err_remove_ida:
index e3ae01d..27ec597 100644 (file)
@@ -43,7 +43,6 @@ struct gb_connection {
        struct list_head                operations;
 
        struct workqueue_struct         *wq;
-       struct kfifo                    ts_kfifo;
 
        atomic_t                        op_cycle;
 
@@ -64,9 +63,6 @@ void gb_hd_connections_exit(struct greybus_host_device *hd);
 
 void greybus_data_rcvd(struct greybus_host_device *hd, u16 cport_id,
                        u8 *data, size_t length);
-void gb_connection_push_timestamp(struct gb_connection *connection);
-int gb_connection_pop_timestamp(struct gb_connection *connection,
-                               struct timeval *tv);
 
 int gb_connection_bind_protocol(struct gb_connection *connection);
 
index e44bf6c..7292815 100644 (file)
@@ -215,7 +215,6 @@ static int message_send(struct greybus_host_device *hd, u16 cport_id,
                          message->buffer, buffer_size,
                          cport_out_callback, message);
        urb->transfer_flags |= URB_ZERO_PACKET;
-       gb_connection_push_timestamp(message->operation->connection);
        retval = usb_submit_urb(urb, gfp_mask);
        if (retval) {
                pr_err("error %d submitting URB\n", retval);
index 3a5f93f..7542101 100644 (file)
@@ -319,7 +319,6 @@ static int message_send(struct greybus_host_device *hd, u16 cport_id,
                          message->buffer, buffer_size,
                          cport_out_callback, message);
        urb->transfer_flags |= URB_ZERO_PACKET;
-       gb_connection_push_timestamp(message->operation->connection);
        retval = usb_submit_urb(urb, gfp_mask);
        if (retval) {
                pr_err("error %d submitting URB\n", retval);
index 5124536..7ccf9a2 100644 (file)
@@ -57,7 +57,6 @@ struct gb_loopback_device {
 
        /* Overall stats */
        struct gb_loopback_stats latency;
-       struct gb_loopback_stats latency_gb;
        struct gb_loopback_stats throughput;
        struct gb_loopback_stats requests_per_second;
 };
@@ -76,14 +75,12 @@ struct gb_loopback {
 
        /* Per connection stats */
        struct gb_loopback_stats latency;
-       struct gb_loopback_stats latency_gb;
        struct gb_loopback_stats throughput;
        struct gb_loopback_stats requests_per_second;
 
        u32 lbid;
        u32 iteration_count;
        u64 elapsed_nsecs;
-       u64 elapsed_nsecs_gb;
        u32 error;
 };
 
@@ -266,9 +263,6 @@ static void gb_loopback_check_attr(struct gb_loopback_device *gb_dev,
 /* Time to send and receive one message */
 gb_loopback_stats_attrs(latency, dev, false);
 gb_loopback_stats_attrs(latency, con, true);
-/* Time to send and receive one message not including greybus */
-gb_loopback_stats_attrs(latency_gb, dev, false);
-gb_loopback_stats_attrs(latency_gb, con, true);
 /* Number of requests sent per second on this cport */
 gb_loopback_stats_attrs(requests_per_second, dev, false);
 gb_loopback_stats_attrs(requests_per_second, con, true);
@@ -303,9 +297,6 @@ static struct attribute *loopback_dev_attrs[] = {
        &dev_attr_latency_min_dev.attr,
        &dev_attr_latency_max_dev.attr,
        &dev_attr_latency_avg_dev.attr,
-       &dev_attr_latency_gb_min_dev.attr,
-       &dev_attr_latency_gb_max_dev.attr,
-       &dev_attr_latency_gb_avg_dev.attr,
        &dev_attr_requests_per_second_min_dev.attr,
        &dev_attr_requests_per_second_max_dev.attr,
        &dev_attr_requests_per_second_avg_dev.attr,
@@ -327,9 +318,6 @@ static struct attribute *loopback_con_attrs[] = {
        &dev_attr_latency_min_con.attr,
        &dev_attr_latency_max_con.attr,
        &dev_attr_latency_avg_con.attr,
-       &dev_attr_latency_gb_min_con.attr,
-       &dev_attr_latency_gb_max_con.attr,
-       &dev_attr_latency_gb_avg_con.attr,
        &dev_attr_requests_per_second_min_con.attr,
        &dev_attr_requests_per_second_max_con.attr,
        &dev_attr_requests_per_second_avg_con.attr,
@@ -423,11 +411,6 @@ error:
        gb_loopback_push_latency_ts(gb, &ts, &te);
        gb->elapsed_nsecs = gb_loopback_calc_latency(&ts, &te);
 
-       /* Calculate non-greybus related component of the latency */
-       gb_connection_pop_timestamp(gb->connection, &ts);
-       gb_connection_pop_timestamp(gb->connection, &te);
-       gb->elapsed_nsecs_gb = gb_loopback_calc_latency(&ts, &te);
-
        return ret;
 }
 
@@ -554,8 +537,6 @@ static void gb_loopback_reset_stats(struct gb_loopback_device *gb_dev)
                mutex_lock(&gb->mutex);
                memcpy(&gb->latency, &reset,
                       sizeof(struct gb_loopback_stats));
-               memcpy(&gb->latency_gb, &reset,
-                      sizeof(struct gb_loopback_stats));
                memcpy(&gb->throughput, &reset,
                       sizeof(struct gb_loopback_stats));
                memcpy(&gb->requests_per_second, &reset,
@@ -567,7 +548,6 @@ static void gb_loopback_reset_stats(struct gb_loopback_device *gb_dev)
        memset(&gb_dev->start, 0, sizeof(struct timeval));
        memset(&gb_dev->end, 0, sizeof(struct timeval));
        memcpy(&gb_dev->latency, &reset, sizeof(struct gb_loopback_stats));
-       memcpy(&gb_dev->latency_gb, &reset, sizeof(struct gb_loopback_stats));
        memcpy(&gb_dev->throughput, &reset, sizeof(struct gb_loopback_stats));
        memcpy(&gb_dev->requests_per_second, &reset,
               sizeof(struct gb_loopback_stats));
@@ -679,7 +659,6 @@ error:
 static void gb_loopback_calculate_stats(struct gb_loopback *gb)
 {
        u32 lat;
-       u64 tmp;
 
        /* Express latency in terms of microseconds */
        lat = gb_loopback_nsec_to_usec_latency(gb->elapsed_nsecs);
@@ -694,12 +673,6 @@ static void gb_loopback_calculate_stats(struct gb_loopback *gb)
        /* Log throughput and requests using latency as benchmark */
        gb_loopback_throughput_update(gb, lat);
        gb_loopback_requests_update(gb, lat);
-
-       /* Calculate the greybus related latency number in nanoseconds */
-       tmp = gb->elapsed_nsecs - gb->elapsed_nsecs_gb;
-       lat = tmp;
-       gb_loopback_update_stats(&gb_dev.latency_gb, lat);
-       gb_loopback_update_stats(&gb->latency_gb, lat);
 }
 
 static int gb_loopback_fn(void *data)