.. | .. |
---|
379 | 379 | struct hfi1_devdata *dd = dd_from_dev(ibd); |
---|
380 | 380 | |
---|
381 | 381 | ++*pos; |
---|
382 | | - if (!dd->rcd || *pos >= dd->n_krcv_queues) |
---|
| 382 | + if (!dd->rcd || *pos >= dd->num_rcv_contexts) |
---|
383 | 383 | return NULL; |
---|
384 | 384 | return pos; |
---|
385 | 385 | } |
---|
.. | .. |
---|
406 | 406 | DEBUGFS_SEQ_FILE_OPS(rcds); |
---|
407 | 407 | DEBUGFS_SEQ_FILE_OPEN(rcds) |
---|
408 | 408 | DEBUGFS_FILE_OPS(rcds); |
---|
| 409 | + |
---|
| 410 | +static void *_pios_seq_start(struct seq_file *s, loff_t *pos) |
---|
| 411 | +{ |
---|
| 412 | + struct hfi1_ibdev *ibd; |
---|
| 413 | + struct hfi1_devdata *dd; |
---|
| 414 | + |
---|
| 415 | + ibd = (struct hfi1_ibdev *)s->private; |
---|
| 416 | + dd = dd_from_dev(ibd); |
---|
| 417 | + if (!dd->send_contexts || *pos >= dd->num_send_contexts) |
---|
| 418 | + return NULL; |
---|
| 419 | + return pos; |
---|
| 420 | +} |
---|
| 421 | + |
---|
| 422 | +static void *_pios_seq_next(struct seq_file *s, void *v, loff_t *pos) |
---|
| 423 | +{ |
---|
| 424 | + struct hfi1_ibdev *ibd = (struct hfi1_ibdev *)s->private; |
---|
| 425 | + struct hfi1_devdata *dd = dd_from_dev(ibd); |
---|
| 426 | + |
---|
| 427 | + ++*pos; |
---|
| 428 | + if (!dd->send_contexts || *pos >= dd->num_send_contexts) |
---|
| 429 | + return NULL; |
---|
| 430 | + return pos; |
---|
| 431 | +} |
---|
| 432 | + |
---|
| 433 | +static void _pios_seq_stop(struct seq_file *s, void *v) |
---|
| 434 | +{ |
---|
| 435 | +} |
---|
| 436 | + |
---|
| 437 | +static int _pios_seq_show(struct seq_file *s, void *v) |
---|
| 438 | +{ |
---|
| 439 | + struct hfi1_ibdev *ibd = (struct hfi1_ibdev *)s->private; |
---|
| 440 | + struct hfi1_devdata *dd = dd_from_dev(ibd); |
---|
| 441 | + struct send_context_info *sci; |
---|
| 442 | + loff_t *spos = v; |
---|
| 443 | + loff_t i = *spos; |
---|
| 444 | + unsigned long flags; |
---|
| 445 | + |
---|
| 446 | + spin_lock_irqsave(&dd->sc_lock, flags); |
---|
| 447 | + sci = &dd->send_contexts[i]; |
---|
| 448 | + if (sci && sci->type != SC_USER && sci->allocated && sci->sc) |
---|
| 449 | + seqfile_dump_sci(s, i, sci); |
---|
| 450 | + spin_unlock_irqrestore(&dd->sc_lock, flags); |
---|
| 451 | + return 0; |
---|
| 452 | +} |
---|
| 453 | + |
---|
| 454 | +DEBUGFS_SEQ_FILE_OPS(pios); |
---|
| 455 | +DEBUGFS_SEQ_FILE_OPEN(pios) |
---|
| 456 | +DEBUGFS_FILE_OPS(pios); |
---|
409 | 457 | |
---|
410 | 458 | /* read the per-device counters */ |
---|
411 | 459 | static ssize_t dev_counters_read(struct file *file, char __user *buf, |
---|
.. | .. |
---|
937 | 985 | static int __i2c_debugfs_open(struct inode *in, struct file *fp, u32 target) |
---|
938 | 986 | { |
---|
939 | 987 | struct hfi1_pportdata *ppd; |
---|
940 | | - int ret; |
---|
941 | | - |
---|
942 | | - if (!try_module_get(THIS_MODULE)) |
---|
943 | | - return -ENODEV; |
---|
944 | 988 | |
---|
945 | 989 | ppd = private2ppd(fp); |
---|
946 | 990 | |
---|
947 | | - ret = acquire_chip_resource(ppd->dd, i2c_target(target), 0); |
---|
948 | | - if (ret) /* failed - release the module */ |
---|
949 | | - module_put(THIS_MODULE); |
---|
950 | | - |
---|
951 | | - return ret; |
---|
| 991 | + return acquire_chip_resource(ppd->dd, i2c_target(target), 0); |
---|
952 | 992 | } |
---|
953 | 993 | |
---|
954 | 994 | static int i2c1_debugfs_open(struct inode *in, struct file *fp) |
---|
.. | .. |
---|
968 | 1008 | ppd = private2ppd(fp); |
---|
969 | 1009 | |
---|
970 | 1010 | release_chip_resource(ppd->dd, i2c_target(target)); |
---|
971 | | - module_put(THIS_MODULE); |
---|
972 | 1011 | |
---|
973 | 1012 | return 0; |
---|
974 | 1013 | } |
---|
.. | .. |
---|
986 | 1025 | static int __qsfp_debugfs_open(struct inode *in, struct file *fp, u32 target) |
---|
987 | 1026 | { |
---|
988 | 1027 | struct hfi1_pportdata *ppd; |
---|
989 | | - int ret; |
---|
990 | | - |
---|
991 | | - if (!try_module_get(THIS_MODULE)) |
---|
992 | | - return -ENODEV; |
---|
993 | 1028 | |
---|
994 | 1029 | ppd = private2ppd(fp); |
---|
995 | 1030 | |
---|
996 | | - ret = acquire_chip_resource(ppd->dd, i2c_target(target), 0); |
---|
997 | | - if (ret) /* failed - release the module */ |
---|
998 | | - module_put(THIS_MODULE); |
---|
999 | | - |
---|
1000 | | - return ret; |
---|
| 1031 | + return acquire_chip_resource(ppd->dd, i2c_target(target), 0); |
---|
1001 | 1032 | } |
---|
1002 | 1033 | |
---|
1003 | 1034 | static int qsfp1_debugfs_open(struct inode *in, struct file *fp) |
---|
.. | .. |
---|
1017 | 1048 | ppd = private2ppd(fp); |
---|
1018 | 1049 | |
---|
1019 | 1050 | release_chip_resource(ppd->dd, i2c_target(target)); |
---|
1020 | | - module_put(THIS_MODULE); |
---|
1021 | 1051 | |
---|
1022 | 1052 | return 0; |
---|
1023 | 1053 | } |
---|
.. | .. |
---|
1032 | 1062 | return __qsfp_debugfs_release(in, fp, 1); |
---|
1033 | 1063 | } |
---|
1034 | 1064 | |
---|
| 1065 | +#define EXPROM_WRITE_ENABLE BIT_ULL(14) |
---|
| 1066 | + |
---|
| 1067 | +static bool exprom_wp_disabled; |
---|
| 1068 | + |
---|
| 1069 | +static int exprom_wp_set(struct hfi1_devdata *dd, bool disable) |
---|
| 1070 | +{ |
---|
| 1071 | + u64 gpio_val = 0; |
---|
| 1072 | + |
---|
| 1073 | + if (disable) { |
---|
| 1074 | + gpio_val = EXPROM_WRITE_ENABLE; |
---|
| 1075 | + exprom_wp_disabled = true; |
---|
| 1076 | + dd_dev_info(dd, "Disable Expansion ROM Write Protection\n"); |
---|
| 1077 | + } else { |
---|
| 1078 | + exprom_wp_disabled = false; |
---|
| 1079 | + dd_dev_info(dd, "Enable Expansion ROM Write Protection\n"); |
---|
| 1080 | + } |
---|
| 1081 | + |
---|
| 1082 | + write_csr(dd, ASIC_GPIO_OUT, gpio_val); |
---|
| 1083 | + write_csr(dd, ASIC_GPIO_OE, gpio_val); |
---|
| 1084 | + |
---|
| 1085 | + return 0; |
---|
| 1086 | +} |
---|
| 1087 | + |
---|
| 1088 | +static ssize_t exprom_wp_debugfs_read(struct file *file, char __user *buf, |
---|
| 1089 | + size_t count, loff_t *ppos) |
---|
| 1090 | +{ |
---|
| 1091 | + return 0; |
---|
| 1092 | +} |
---|
| 1093 | + |
---|
| 1094 | +static ssize_t exprom_wp_debugfs_write(struct file *file, |
---|
| 1095 | + const char __user *buf, size_t count, |
---|
| 1096 | + loff_t *ppos) |
---|
| 1097 | +{ |
---|
| 1098 | + struct hfi1_pportdata *ppd = private2ppd(file); |
---|
| 1099 | + char cdata; |
---|
| 1100 | + |
---|
| 1101 | + if (count != 1) |
---|
| 1102 | + return -EINVAL; |
---|
| 1103 | + if (get_user(cdata, buf)) |
---|
| 1104 | + return -EFAULT; |
---|
| 1105 | + if (cdata == '0') |
---|
| 1106 | + exprom_wp_set(ppd->dd, false); |
---|
| 1107 | + else if (cdata == '1') |
---|
| 1108 | + exprom_wp_set(ppd->dd, true); |
---|
| 1109 | + else |
---|
| 1110 | + return -EINVAL; |
---|
| 1111 | + |
---|
| 1112 | + return 1; |
---|
| 1113 | +} |
---|
| 1114 | + |
---|
| 1115 | +static unsigned long exprom_in_use; |
---|
| 1116 | + |
---|
| 1117 | +static int exprom_wp_debugfs_open(struct inode *in, struct file *fp) |
---|
| 1118 | +{ |
---|
| 1119 | + if (test_and_set_bit(0, &exprom_in_use)) |
---|
| 1120 | + return -EBUSY; |
---|
| 1121 | + |
---|
| 1122 | + return 0; |
---|
| 1123 | +} |
---|
| 1124 | + |
---|
| 1125 | +static int exprom_wp_debugfs_release(struct inode *in, struct file *fp) |
---|
| 1126 | +{ |
---|
| 1127 | + struct hfi1_pportdata *ppd = private2ppd(fp); |
---|
| 1128 | + |
---|
| 1129 | + if (exprom_wp_disabled) |
---|
| 1130 | + exprom_wp_set(ppd->dd, false); |
---|
| 1131 | + clear_bit(0, &exprom_in_use); |
---|
| 1132 | + |
---|
| 1133 | + return 0; |
---|
| 1134 | +} |
---|
| 1135 | + |
---|
1035 | 1136 | #define DEBUGFS_OPS(nm, readroutine, writeroutine) \ |
---|
1036 | 1137 | { \ |
---|
1037 | 1138 | .name = nm, \ |
---|
1038 | 1139 | .ops = { \ |
---|
| 1140 | + .owner = THIS_MODULE, \ |
---|
1039 | 1141 | .read = readroutine, \ |
---|
1040 | 1142 | .write = writeroutine, \ |
---|
1041 | 1143 | .llseek = generic_file_llseek, \ |
---|
.. | .. |
---|
1046 | 1148 | { \ |
---|
1047 | 1149 | .name = nm, \ |
---|
1048 | 1150 | .ops = { \ |
---|
| 1151 | + .owner = THIS_MODULE, \ |
---|
1049 | 1152 | .read = readf, \ |
---|
1050 | 1153 | .write = writef, \ |
---|
1051 | 1154 | .llseek = generic_file_llseek, \ |
---|
.. | .. |
---|
1071 | 1174 | qsfp1_debugfs_open, qsfp1_debugfs_release), |
---|
1072 | 1175 | DEBUGFS_XOPS("qsfp2", qsfp2_debugfs_read, qsfp2_debugfs_write, |
---|
1073 | 1176 | qsfp2_debugfs_open, qsfp2_debugfs_release), |
---|
| 1177 | + DEBUGFS_XOPS("exprom_wp", exprom_wp_debugfs_read, |
---|
| 1178 | + exprom_wp_debugfs_write, exprom_wp_debugfs_open, |
---|
| 1179 | + exprom_wp_debugfs_release), |
---|
1074 | 1180 | DEBUGFS_OPS("asic_flags", asic_flags_read, asic_flags_write), |
---|
1075 | 1181 | DEBUGFS_OPS("dc8051_memory", dc8051_memory_read, NULL), |
---|
1076 | 1182 | DEBUGFS_OPS("lcb", debugfs_lcb_read, debugfs_lcb_write), |
---|
.. | .. |
---|
1119 | 1225 | char link[10]; |
---|
1120 | 1226 | struct hfi1_devdata *dd = dd_from_dev(ibd); |
---|
1121 | 1227 | struct hfi1_pportdata *ppd; |
---|
| 1228 | + struct dentry *root; |
---|
1122 | 1229 | int unit = dd->unit; |
---|
1123 | 1230 | int i, j; |
---|
1124 | 1231 | |
---|
.. | .. |
---|
1126 | 1233 | return; |
---|
1127 | 1234 | snprintf(name, sizeof(name), "%s_%d", class_name(), unit); |
---|
1128 | 1235 | snprintf(link, sizeof(link), "%d", unit); |
---|
1129 | | - ibd->hfi1_ibdev_dbg = debugfs_create_dir(name, hfi1_dbg_root); |
---|
1130 | | - if (!ibd->hfi1_ibdev_dbg) { |
---|
1131 | | - pr_warn("create of %s failed\n", name); |
---|
1132 | | - return; |
---|
1133 | | - } |
---|
| 1236 | + root = debugfs_create_dir(name, hfi1_dbg_root); |
---|
| 1237 | + ibd->hfi1_ibdev_dbg = root; |
---|
| 1238 | + |
---|
1134 | 1239 | ibd->hfi1_ibdev_link = |
---|
1135 | 1240 | debugfs_create_symlink(link, hfi1_dbg_root, name); |
---|
1136 | | - if (!ibd->hfi1_ibdev_link) { |
---|
1137 | | - pr_warn("create of %s symlink failed\n", name); |
---|
1138 | | - return; |
---|
1139 | | - } |
---|
1140 | | - DEBUGFS_SEQ_FILE_CREATE(opcode_stats, ibd->hfi1_ibdev_dbg, ibd); |
---|
1141 | | - DEBUGFS_SEQ_FILE_CREATE(tx_opcode_stats, ibd->hfi1_ibdev_dbg, ibd); |
---|
1142 | | - DEBUGFS_SEQ_FILE_CREATE(ctx_stats, ibd->hfi1_ibdev_dbg, ibd); |
---|
1143 | | - DEBUGFS_SEQ_FILE_CREATE(qp_stats, ibd->hfi1_ibdev_dbg, ibd); |
---|
1144 | | - DEBUGFS_SEQ_FILE_CREATE(sdes, ibd->hfi1_ibdev_dbg, ibd); |
---|
1145 | | - DEBUGFS_SEQ_FILE_CREATE(rcds, ibd->hfi1_ibdev_dbg, ibd); |
---|
1146 | | - DEBUGFS_SEQ_FILE_CREATE(sdma_cpu_list, ibd->hfi1_ibdev_dbg, ibd); |
---|
| 1241 | + |
---|
| 1242 | + debugfs_create_file("opcode_stats", 0444, root, ibd, |
---|
| 1243 | + &_opcode_stats_file_ops); |
---|
| 1244 | + debugfs_create_file("tx_opcode_stats", 0444, root, ibd, |
---|
| 1245 | + &_tx_opcode_stats_file_ops); |
---|
| 1246 | + debugfs_create_file("ctx_stats", 0444, root, ibd, &_ctx_stats_file_ops); |
---|
| 1247 | + debugfs_create_file("qp_stats", 0444, root, ibd, &_qp_stats_file_ops); |
---|
| 1248 | + debugfs_create_file("sdes", 0444, root, ibd, &_sdes_file_ops); |
---|
| 1249 | + debugfs_create_file("rcds", 0444, root, ibd, &_rcds_file_ops); |
---|
| 1250 | + debugfs_create_file("pios", 0444, root, ibd, &_pios_file_ops); |
---|
| 1251 | + debugfs_create_file("sdma_cpu_list", 0444, root, ibd, |
---|
| 1252 | + &_sdma_cpu_list_file_ops); |
---|
| 1253 | + |
---|
1147 | 1254 | /* dev counter files */ |
---|
1148 | 1255 | for (i = 0; i < ARRAY_SIZE(cntr_ops); i++) |
---|
1149 | | - DEBUGFS_FILE_CREATE(cntr_ops[i].name, |
---|
1150 | | - ibd->hfi1_ibdev_dbg, |
---|
1151 | | - dd, |
---|
1152 | | - &cntr_ops[i].ops, S_IRUGO); |
---|
| 1256 | + debugfs_create_file(cntr_ops[i].name, 0444, root, dd, |
---|
| 1257 | + &cntr_ops[i].ops); |
---|
| 1258 | + |
---|
1153 | 1259 | /* per port files */ |
---|
1154 | 1260 | for (ppd = dd->pport, j = 0; j < dd->num_pports; j++, ppd++) |
---|
1155 | 1261 | for (i = 0; i < ARRAY_SIZE(port_cntr_ops); i++) { |
---|
.. | .. |
---|
1157 | 1263 | sizeof(name), |
---|
1158 | 1264 | port_cntr_ops[i].name, |
---|
1159 | 1265 | j + 1); |
---|
1160 | | - DEBUGFS_FILE_CREATE(name, |
---|
1161 | | - ibd->hfi1_ibdev_dbg, |
---|
1162 | | - ppd, |
---|
1163 | | - &port_cntr_ops[i].ops, |
---|
| 1266 | + debugfs_create_file(name, |
---|
1164 | 1267 | !port_cntr_ops[i].ops.write ? |
---|
1165 | | - S_IRUGO : S_IRUGO | S_IWUSR); |
---|
| 1268 | + S_IRUGO : |
---|
| 1269 | + S_IRUGO | S_IWUSR, |
---|
| 1270 | + root, ppd, &port_cntr_ops[i].ops); |
---|
1166 | 1271 | } |
---|
1167 | 1272 | |
---|
1168 | 1273 | hfi1_fault_init_debugfs(ibd); |
---|
.. | .. |
---|
1255 | 1360 | |
---|
1256 | 1361 | static u64 hfi1_sps_ints(void) |
---|
1257 | 1362 | { |
---|
1258 | | - unsigned long flags; |
---|
| 1363 | + unsigned long index, flags; |
---|
1259 | 1364 | struct hfi1_devdata *dd; |
---|
1260 | 1365 | u64 sps_ints = 0; |
---|
1261 | 1366 | |
---|
1262 | | - spin_lock_irqsave(&hfi1_devs_lock, flags); |
---|
1263 | | - list_for_each_entry(dd, &hfi1_dev_list, list) { |
---|
| 1367 | + xa_lock_irqsave(&hfi1_dev_table, flags); |
---|
| 1368 | + xa_for_each(&hfi1_dev_table, index, dd) { |
---|
1264 | 1369 | sps_ints += get_all_cpu_total(dd->int_counter); |
---|
1265 | 1370 | } |
---|
1266 | | - spin_unlock_irqrestore(&hfi1_devs_lock, flags); |
---|
| 1371 | + xa_unlock_irqrestore(&hfi1_dev_table, flags); |
---|
1267 | 1372 | return sps_ints; |
---|
1268 | 1373 | } |
---|
1269 | 1374 | |
---|
.. | .. |
---|
1292 | 1397 | void hfi1_dbg_init(void) |
---|
1293 | 1398 | { |
---|
1294 | 1399 | hfi1_dbg_root = debugfs_create_dir(DRIVER_NAME, NULL); |
---|
1295 | | - if (!hfi1_dbg_root) |
---|
1296 | | - pr_warn("init of debugfs failed\n"); |
---|
1297 | | - DEBUGFS_SEQ_FILE_CREATE(driver_stats_names, hfi1_dbg_root, NULL); |
---|
1298 | | - DEBUGFS_SEQ_FILE_CREATE(driver_stats, hfi1_dbg_root, NULL); |
---|
| 1400 | + debugfs_create_file("driver_stats_names", 0444, hfi1_dbg_root, NULL, |
---|
| 1401 | + &_driver_stats_names_file_ops); |
---|
| 1402 | + debugfs_create_file("driver_stats", 0444, hfi1_dbg_root, NULL, |
---|
| 1403 | + &_driver_stats_file_ops); |
---|
1299 | 1404 | } |
---|
1300 | 1405 | |
---|
1301 | 1406 | void hfi1_dbg_exit(void) |
---|