| .. | .. |
|---|
| 25 | 25 | #include <linux/workqueue.h> |
|---|
| 26 | 26 | #include <linux/atomic.h> |
|---|
| 27 | 27 | #include <linux/pm_runtime.h> |
|---|
| 28 | | - |
|---|
| 28 | +#include <linux/greybus.h> |
|---|
| 29 | 29 | #include <asm/div64.h> |
|---|
| 30 | | - |
|---|
| 31 | | -#include "greybus.h" |
|---|
| 32 | | -#include "connection.h" |
|---|
| 33 | 30 | |
|---|
| 34 | 31 | #define NSEC_PER_DAY 86400000000000ULL |
|---|
| 35 | 32 | |
|---|
| .. | .. |
|---|
| 47 | 44 | |
|---|
| 48 | 45 | /* We need to take a lock in atomic context */ |
|---|
| 49 | 46 | spinlock_t lock; |
|---|
| 50 | | - struct list_head list; |
|---|
| 51 | | - struct list_head list_op_async; |
|---|
| 52 | 47 | wait_queue_head_t wq; |
|---|
| 53 | 48 | }; |
|---|
| 54 | 49 | |
|---|
| .. | .. |
|---|
| 68 | 63 | struct kfifo kfifo_lat; |
|---|
| 69 | 64 | struct mutex mutex; |
|---|
| 70 | 65 | struct task_struct *task; |
|---|
| 71 | | - struct list_head entry; |
|---|
| 72 | 66 | struct device *dev; |
|---|
| 73 | 67 | wait_queue_head_t wq; |
|---|
| 74 | 68 | wait_queue_head_t wq_completion; |
|---|
| .. | .. |
|---|
| 97 | 91 | u32 timeout_min; |
|---|
| 98 | 92 | u32 timeout_max; |
|---|
| 99 | 93 | u32 outstanding_operations_max; |
|---|
| 100 | | - u32 lbid; |
|---|
| 101 | 94 | u64 elapsed_nsecs; |
|---|
| 102 | 95 | u32 apbridge_latency_ts; |
|---|
| 103 | 96 | u32 gbphy_latency_ts; |
|---|
| .. | .. |
|---|
| 142 | 135 | char *buf) \ |
|---|
| 143 | 136 | { \ |
|---|
| 144 | 137 | struct gb_loopback *gb = dev_get_drvdata(dev); \ |
|---|
| 145 | | - /* Report 0 for min and max if no transfer successed */ \ |
|---|
| 138 | + /* Report 0 for min and max if no transfer succeeded */ \ |
|---|
| 146 | 139 | if (!gb->requests_completed) \ |
|---|
| 147 | 140 | return sprintf(buf, "0\n"); \ |
|---|
| 148 | | - return sprintf(buf, "%"#type"\n", gb->name.field); \ |
|---|
| 141 | + return sprintf(buf, "%" #type "\n", gb->name.field); \ |
|---|
| 149 | 142 | } \ |
|---|
| 150 | 143 | static DEVICE_ATTR_RO(name##_##field) |
|---|
| 151 | 144 | |
|---|
| .. | .. |
|---|
| 180 | 173 | char *buf) \ |
|---|
| 181 | 174 | { \ |
|---|
| 182 | 175 | struct gb_loopback *gb = dev_get_drvdata(dev); \ |
|---|
| 183 | | - return sprintf(buf, "%"#type"\n", gb->field); \ |
|---|
| 176 | + return sprintf(buf, "%" #type "\n", gb->field); \ |
|---|
| 184 | 177 | } \ |
|---|
| 185 | 178 | static ssize_t field##_store(struct device *dev, \ |
|---|
| 186 | 179 | struct device_attribute *attr, \ |
|---|
| .. | .. |
|---|
| 216 | 209 | char *buf) \ |
|---|
| 217 | 210 | { \ |
|---|
| 218 | 211 | struct gb_loopback *gb = dev_get_drvdata(dev); \ |
|---|
| 219 | | - return sprintf(buf, "%"#type"\n", gb->field); \ |
|---|
| 212 | + return sprintf(buf, "%" #type "\n", gb->field); \ |
|---|
| 220 | 213 | } \ |
|---|
| 221 | 214 | static ssize_t field##_store(struct device *dev, \ |
|---|
| 222 | 215 | struct device_attribute *attr, \ |
|---|
| .. | .. |
|---|
| 886 | 879 | gb->type = 0; |
|---|
| 887 | 880 | gb->send_count = 0; |
|---|
| 888 | 881 | sysfs_notify(&gb->dev->kobj, NULL, |
|---|
| 889 | | - "iteration_count"); |
|---|
| 882 | + "iteration_count"); |
|---|
| 890 | 883 | dev_dbg(&bundle->dev, "load test complete\n"); |
|---|
| 891 | 884 | } else { |
|---|
| 892 | 885 | dev_dbg(&bundle->dev, |
|---|
| .. | .. |
|---|
| 974 | 967 | return gb_loopback_dbgfs_latency_show_common(s, &gb->kfifo_lat, |
|---|
| 975 | 968 | &gb->mutex); |
|---|
| 976 | 969 | } |
|---|
| 977 | | - |
|---|
| 978 | | -static int gb_loopback_latency_open(struct inode *inode, struct file *file) |
|---|
| 979 | | -{ |
|---|
| 980 | | - return single_open(file, gb_loopback_dbgfs_latency_show, |
|---|
| 981 | | - inode->i_private); |
|---|
| 982 | | -} |
|---|
| 983 | | - |
|---|
| 984 | | -static const struct file_operations gb_loopback_debugfs_latency_ops = { |
|---|
| 985 | | - .open = gb_loopback_latency_open, |
|---|
| 986 | | - .read = seq_read, |
|---|
| 987 | | - .llseek = seq_lseek, |
|---|
| 988 | | - .release = single_release, |
|---|
| 989 | | -}; |
|---|
| 990 | | - |
|---|
| 991 | | -static int gb_loopback_bus_id_compare(void *priv, struct list_head *lha, |
|---|
| 992 | | - struct list_head *lhb) |
|---|
| 993 | | -{ |
|---|
| 994 | | - struct gb_loopback *a = list_entry(lha, struct gb_loopback, entry); |
|---|
| 995 | | - struct gb_loopback *b = list_entry(lhb, struct gb_loopback, entry); |
|---|
| 996 | | - struct gb_connection *ca = a->connection; |
|---|
| 997 | | - struct gb_connection *cb = b->connection; |
|---|
| 998 | | - |
|---|
| 999 | | - if (ca->bundle->intf->interface_id < cb->bundle->intf->interface_id) |
|---|
| 1000 | | - return -1; |
|---|
| 1001 | | - if (cb->bundle->intf->interface_id < ca->bundle->intf->interface_id) |
|---|
| 1002 | | - return 1; |
|---|
| 1003 | | - if (ca->bundle->id < cb->bundle->id) |
|---|
| 1004 | | - return -1; |
|---|
| 1005 | | - if (cb->bundle->id < ca->bundle->id) |
|---|
| 1006 | | - return 1; |
|---|
| 1007 | | - if (ca->intf_cport_id < cb->intf_cport_id) |
|---|
| 1008 | | - return -1; |
|---|
| 1009 | | - else if (cb->intf_cport_id < ca->intf_cport_id) |
|---|
| 1010 | | - return 1; |
|---|
| 1011 | | - |
|---|
| 1012 | | - return 0; |
|---|
| 1013 | | -} |
|---|
| 1014 | | - |
|---|
| 1015 | | -static void gb_loopback_insert_id(struct gb_loopback *gb) |
|---|
| 1016 | | -{ |
|---|
| 1017 | | - struct gb_loopback *gb_list; |
|---|
| 1018 | | - u32 new_lbid = 0; |
|---|
| 1019 | | - |
|---|
| 1020 | | - /* perform an insertion sort */ |
|---|
| 1021 | | - list_add_tail(&gb->entry, &gb_dev.list); |
|---|
| 1022 | | - list_sort(NULL, &gb_dev.list, gb_loopback_bus_id_compare); |
|---|
| 1023 | | - list_for_each_entry(gb_list, &gb_dev.list, entry) { |
|---|
| 1024 | | - gb_list->lbid = 1 << new_lbid; |
|---|
| 1025 | | - new_lbid++; |
|---|
| 1026 | | - } |
|---|
| 1027 | | -} |
|---|
| 970 | +DEFINE_SHOW_ATTRIBUTE(gb_loopback_dbgfs_latency); |
|---|
| 1028 | 971 | |
|---|
| 1029 | 972 | #define DEBUGFS_NAMELEN 32 |
|---|
| 1030 | 973 | |
|---|
| .. | .. |
|---|
| 1084 | 1027 | snprintf(name, sizeof(name), "raw_latency_%s", |
|---|
| 1085 | 1028 | dev_name(&connection->bundle->dev)); |
|---|
| 1086 | 1029 | gb->file = debugfs_create_file(name, S_IFREG | 0444, gb_dev.root, gb, |
|---|
| 1087 | | - &gb_loopback_debugfs_latency_ops); |
|---|
| 1030 | + &gb_loopback_dbgfs_latency_fops); |
|---|
| 1088 | 1031 | |
|---|
| 1089 | 1032 | gb->id = ida_simple_get(&loopback_ida, 0, 0, GFP_KERNEL); |
|---|
| 1090 | 1033 | if (gb->id < 0) { |
|---|
| .. | .. |
|---|
| 1108 | 1051 | |
|---|
| 1109 | 1052 | /* Allocate kfifo */ |
|---|
| 1110 | 1053 | if (kfifo_alloc(&gb->kfifo_lat, kfifo_depth * sizeof(u32), |
|---|
| 1111 | | - GFP_KERNEL)) { |
|---|
| 1054 | + GFP_KERNEL)) { |
|---|
| 1112 | 1055 | retval = -ENOMEM; |
|---|
| 1113 | 1056 | goto out_conn; |
|---|
| 1114 | 1057 | } |
|---|
| .. | .. |
|---|
| 1121 | 1064 | } |
|---|
| 1122 | 1065 | |
|---|
| 1123 | 1066 | spin_lock_irqsave(&gb_dev.lock, flags); |
|---|
| 1124 | | - gb_loopback_insert_id(gb); |
|---|
| 1125 | 1067 | gb_dev.count++; |
|---|
| 1126 | 1068 | spin_unlock_irqrestore(&gb_dev.lock, flags); |
|---|
| 1127 | 1069 | |
|---|
| .. | .. |
|---|
| 1177 | 1119 | |
|---|
| 1178 | 1120 | spin_lock_irqsave(&gb_dev.lock, flags); |
|---|
| 1179 | 1121 | gb_dev.count--; |
|---|
| 1180 | | - list_del(&gb->entry); |
|---|
| 1181 | 1122 | spin_unlock_irqrestore(&gb_dev.lock, flags); |
|---|
| 1182 | 1123 | |
|---|
| 1183 | 1124 | device_unregister(gb->dev); |
|---|
| .. | .. |
|---|
| 1204 | 1145 | { |
|---|
| 1205 | 1146 | int retval; |
|---|
| 1206 | 1147 | |
|---|
| 1207 | | - INIT_LIST_HEAD(&gb_dev.list); |
|---|
| 1208 | | - INIT_LIST_HEAD(&gb_dev.list_op_async); |
|---|
| 1209 | 1148 | spin_lock_init(&gb_dev.lock); |
|---|
| 1210 | 1149 | gb_dev.root = debugfs_create_dir("gb_loopback", NULL); |
|---|
| 1211 | 1150 | |
|---|