Commit d090446a authored by Bryan O'Donoghue's avatar Bryan O'Donoghue Committed by Greg Kroah-Hartman

greybus: loopback: drop dependency on internal timestamps

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: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 608f6619
...@@ -67,29 +67,6 @@ void greybus_data_rcvd(struct greybus_host_device *hd, u16 cport_id, ...@@ -67,29 +67,6 @@ void greybus_data_rcvd(struct greybus_host_device *hd, u16 cport_id,
} }
EXPORT_SYMBOL_GPL(greybus_data_rcvd); 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, static ssize_t state_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
...@@ -138,7 +115,6 @@ static void gb_connection_release(struct device *dev) ...@@ -138,7 +115,6 @@ static void gb_connection_release(struct device *dev)
struct gb_connection *connection = to_gb_connection(dev); struct gb_connection *connection = to_gb_connection(dev);
destroy_workqueue(connection->wq); destroy_workqueue(connection->wq);
kfifo_free(&connection->ts_kfifo);
kfree(connection); kfree(connection);
} }
...@@ -234,10 +210,6 @@ gb_connection_create_range(struct greybus_host_device *hd, ...@@ -234,10 +210,6 @@ gb_connection_create_range(struct greybus_host_device *hd,
if (!connection->wq) if (!connection->wq)
goto err_free_connection; 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.parent = parent;
connection->dev.bus = &greybus_bus_type; connection->dev.bus = &greybus_bus_type;
connection->dev.type = &greybus_connection_type; connection->dev.type = &greybus_connection_type;
...@@ -274,8 +246,6 @@ gb_connection_create_range(struct greybus_host_device *hd, ...@@ -274,8 +246,6 @@ gb_connection_create_range(struct greybus_host_device *hd,
return connection; return connection;
err_destroy_wq:
destroy_workqueue(connection->wq);
err_free_connection: err_free_connection:
kfree(connection); kfree(connection);
err_remove_ida: err_remove_ida:
......
...@@ -43,7 +43,6 @@ struct gb_connection { ...@@ -43,7 +43,6 @@ struct gb_connection {
struct list_head operations; struct list_head operations;
struct workqueue_struct *wq; struct workqueue_struct *wq;
struct kfifo ts_kfifo;
atomic_t op_cycle; atomic_t op_cycle;
...@@ -64,9 +63,6 @@ void gb_hd_connections_exit(struct greybus_host_device *hd); ...@@ -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, void greybus_data_rcvd(struct greybus_host_device *hd, u16 cport_id,
u8 *data, size_t length); 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); int gb_connection_bind_protocol(struct gb_connection *connection);
......
...@@ -215,7 +215,6 @@ static int message_send(struct greybus_host_device *hd, u16 cport_id, ...@@ -215,7 +215,6 @@ static int message_send(struct greybus_host_device *hd, u16 cport_id,
message->buffer, buffer_size, message->buffer, buffer_size,
cport_out_callback, message); cport_out_callback, message);
urb->transfer_flags |= URB_ZERO_PACKET; urb->transfer_flags |= URB_ZERO_PACKET;
gb_connection_push_timestamp(message->operation->connection);
retval = usb_submit_urb(urb, gfp_mask); retval = usb_submit_urb(urb, gfp_mask);
if (retval) { if (retval) {
pr_err("error %d submitting URB\n", retval); pr_err("error %d submitting URB\n", retval);
......
...@@ -319,7 +319,6 @@ static int message_send(struct greybus_host_device *hd, u16 cport_id, ...@@ -319,7 +319,6 @@ static int message_send(struct greybus_host_device *hd, u16 cport_id,
message->buffer, buffer_size, message->buffer, buffer_size,
cport_out_callback, message); cport_out_callback, message);
urb->transfer_flags |= URB_ZERO_PACKET; urb->transfer_flags |= URB_ZERO_PACKET;
gb_connection_push_timestamp(message->operation->connection);
retval = usb_submit_urb(urb, gfp_mask); retval = usb_submit_urb(urb, gfp_mask);
if (retval) { if (retval) {
pr_err("error %d submitting URB\n", retval); pr_err("error %d submitting URB\n", retval);
......
...@@ -57,7 +57,6 @@ struct gb_loopback_device { ...@@ -57,7 +57,6 @@ struct gb_loopback_device {
/* Overall stats */ /* Overall stats */
struct gb_loopback_stats latency; struct gb_loopback_stats latency;
struct gb_loopback_stats latency_gb;
struct gb_loopback_stats throughput; struct gb_loopback_stats throughput;
struct gb_loopback_stats requests_per_second; struct gb_loopback_stats requests_per_second;
}; };
...@@ -76,14 +75,12 @@ struct gb_loopback { ...@@ -76,14 +75,12 @@ struct gb_loopback {
/* Per connection stats */ /* Per connection stats */
struct gb_loopback_stats latency; struct gb_loopback_stats latency;
struct gb_loopback_stats latency_gb;
struct gb_loopback_stats throughput; struct gb_loopback_stats throughput;
struct gb_loopback_stats requests_per_second; struct gb_loopback_stats requests_per_second;
u32 lbid; u32 lbid;
u32 iteration_count; u32 iteration_count;
u64 elapsed_nsecs; u64 elapsed_nsecs;
u64 elapsed_nsecs_gb;
u32 error; u32 error;
}; };
...@@ -266,9 +263,6 @@ static void gb_loopback_check_attr(struct gb_loopback_device *gb_dev, ...@@ -266,9 +263,6 @@ static void gb_loopback_check_attr(struct gb_loopback_device *gb_dev,
/* Time to send and receive one message */ /* Time to send and receive one message */
gb_loopback_stats_attrs(latency, dev, false); gb_loopback_stats_attrs(latency, dev, false);
gb_loopback_stats_attrs(latency, con, true); 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 */ /* 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, dev, false);
gb_loopback_stats_attrs(requests_per_second, con, true); gb_loopback_stats_attrs(requests_per_second, con, true);
...@@ -303,9 +297,6 @@ static struct attribute *loopback_dev_attrs[] = { ...@@ -303,9 +297,6 @@ static struct attribute *loopback_dev_attrs[] = {
&dev_attr_latency_min_dev.attr, &dev_attr_latency_min_dev.attr,
&dev_attr_latency_max_dev.attr, &dev_attr_latency_max_dev.attr,
&dev_attr_latency_avg_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_min_dev.attr,
&dev_attr_requests_per_second_max_dev.attr, &dev_attr_requests_per_second_max_dev.attr,
&dev_attr_requests_per_second_avg_dev.attr, &dev_attr_requests_per_second_avg_dev.attr,
...@@ -327,9 +318,6 @@ static struct attribute *loopback_con_attrs[] = { ...@@ -327,9 +318,6 @@ static struct attribute *loopback_con_attrs[] = {
&dev_attr_latency_min_con.attr, &dev_attr_latency_min_con.attr,
&dev_attr_latency_max_con.attr, &dev_attr_latency_max_con.attr,
&dev_attr_latency_avg_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_min_con.attr,
&dev_attr_requests_per_second_max_con.attr, &dev_attr_requests_per_second_max_con.attr,
&dev_attr_requests_per_second_avg_con.attr, &dev_attr_requests_per_second_avg_con.attr,
...@@ -423,11 +411,6 @@ static int gb_loopback_operation_sync(struct gb_loopback *gb, int type, ...@@ -423,11 +411,6 @@ static int gb_loopback_operation_sync(struct gb_loopback *gb, int type,
gb_loopback_push_latency_ts(gb, &ts, &te); gb_loopback_push_latency_ts(gb, &ts, &te);
gb->elapsed_nsecs = gb_loopback_calc_latency(&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; return ret;
} }
...@@ -554,8 +537,6 @@ static void gb_loopback_reset_stats(struct gb_loopback_device *gb_dev) ...@@ -554,8 +537,6 @@ static void gb_loopback_reset_stats(struct gb_loopback_device *gb_dev)
mutex_lock(&gb->mutex); mutex_lock(&gb->mutex);
memcpy(&gb->latency, &reset, memcpy(&gb->latency, &reset,
sizeof(struct gb_loopback_stats)); sizeof(struct gb_loopback_stats));
memcpy(&gb->latency_gb, &reset,
sizeof(struct gb_loopback_stats));
memcpy(&gb->throughput, &reset, memcpy(&gb->throughput, &reset,
sizeof(struct gb_loopback_stats)); sizeof(struct gb_loopback_stats));
memcpy(&gb->requests_per_second, &reset, memcpy(&gb->requests_per_second, &reset,
...@@ -567,7 +548,6 @@ static void gb_loopback_reset_stats(struct gb_loopback_device *gb_dev) ...@@ -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->start, 0, sizeof(struct timeval));
memset(&gb_dev->end, 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, &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->throughput, &reset, sizeof(struct gb_loopback_stats));
memcpy(&gb_dev->requests_per_second, &reset, memcpy(&gb_dev->requests_per_second, &reset,
sizeof(struct gb_loopback_stats)); sizeof(struct gb_loopback_stats));
...@@ -679,7 +659,6 @@ static int gb_loopback_calculate_aggregate_stats(void) ...@@ -679,7 +659,6 @@ static int gb_loopback_calculate_aggregate_stats(void)
static void gb_loopback_calculate_stats(struct gb_loopback *gb) static void gb_loopback_calculate_stats(struct gb_loopback *gb)
{ {
u32 lat; u32 lat;
u64 tmp;
/* Express latency in terms of microseconds */ /* Express latency in terms of microseconds */
lat = gb_loopback_nsec_to_usec_latency(gb->elapsed_nsecs); lat = gb_loopback_nsec_to_usec_latency(gb->elapsed_nsecs);
...@@ -694,12 +673,6 @@ static void gb_loopback_calculate_stats(struct gb_loopback *gb) ...@@ -694,12 +673,6 @@ static void gb_loopback_calculate_stats(struct gb_loopback *gb)
/* Log throughput and requests using latency as benchmark */ /* Log throughput and requests using latency as benchmark */
gb_loopback_throughput_update(gb, lat); gb_loopback_throughput_update(gb, lat);
gb_loopback_requests_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) static int gb_loopback_fn(void *data)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment