forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/misc/genwqe/card_debugfs.c
....@@ -1,4 +1,5 @@
1
-/**
1
+// SPDX-License-Identifier: GPL-2.0-only
2
+/*
23 * IBM Accelerator Family 'GenWQE'
34 *
45 * (C) Copyright IBM Corp. 2013
....@@ -7,15 +8,6 @@
78 * Author: Joerg-Stephan Vogt <jsvogt@de.ibm.com>
89 * Author: Michael Jung <mijung@gmx.net>
910 * Author: Michael Ruettger <michael@ibmra.de>
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License (version 2 only)
13
- * as published by the Free Software Foundation.
14
- *
15
- * This program is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- * GNU General Public License for more details.
1911 */
2012
2113 /*
....@@ -32,19 +24,6 @@
3224
3325 #include "card_base.h"
3426 #include "card_ddcb.h"
35
-
36
-#define GENWQE_DEBUGFS_RO(_name, _showfn) \
37
- static int genwqe_debugfs_##_name##_open(struct inode *inode, \
38
- struct file *file) \
39
- { \
40
- return single_open(file, _showfn, inode->i_private); \
41
- } \
42
- static const struct file_operations genwqe_##_name##_fops = { \
43
- .open = genwqe_debugfs_##_name##_open, \
44
- .read = seq_read, \
45
- .llseek = seq_lseek, \
46
- .release = single_release, \
47
- }
4827
4928 static void dbg_uidn_show(struct seq_file *s, struct genwqe_reg *regs,
5029 int entries)
....@@ -87,26 +66,26 @@
8766 return 0;
8867 }
8968
90
-static int genwqe_curr_dbg_uid0_show(struct seq_file *s, void *unused)
69
+static int curr_dbg_uid0_show(struct seq_file *s, void *unused)
9170 {
9271 return curr_dbg_uidn_show(s, unused, 0);
9372 }
9473
95
-GENWQE_DEBUGFS_RO(curr_dbg_uid0, genwqe_curr_dbg_uid0_show);
74
+DEFINE_SHOW_ATTRIBUTE(curr_dbg_uid0);
9675
97
-static int genwqe_curr_dbg_uid1_show(struct seq_file *s, void *unused)
76
+static int curr_dbg_uid1_show(struct seq_file *s, void *unused)
9877 {
9978 return curr_dbg_uidn_show(s, unused, 1);
10079 }
10180
102
-GENWQE_DEBUGFS_RO(curr_dbg_uid1, genwqe_curr_dbg_uid1_show);
81
+DEFINE_SHOW_ATTRIBUTE(curr_dbg_uid1);
10382
104
-static int genwqe_curr_dbg_uid2_show(struct seq_file *s, void *unused)
83
+static int curr_dbg_uid2_show(struct seq_file *s, void *unused)
10584 {
10685 return curr_dbg_uidn_show(s, unused, 2);
10786 }
10887
109
-GENWQE_DEBUGFS_RO(curr_dbg_uid2, genwqe_curr_dbg_uid2_show);
88
+DEFINE_SHOW_ATTRIBUTE(curr_dbg_uid2);
11089
11190 static int prev_dbg_uidn_show(struct seq_file *s, void *unused, int uid)
11291 {
....@@ -116,28 +95,28 @@
11695 return 0;
11796 }
11897
119
-static int genwqe_prev_dbg_uid0_show(struct seq_file *s, void *unused)
98
+static int prev_dbg_uid0_show(struct seq_file *s, void *unused)
12099 {
121100 return prev_dbg_uidn_show(s, unused, 0);
122101 }
123102
124
-GENWQE_DEBUGFS_RO(prev_dbg_uid0, genwqe_prev_dbg_uid0_show);
103
+DEFINE_SHOW_ATTRIBUTE(prev_dbg_uid0);
125104
126
-static int genwqe_prev_dbg_uid1_show(struct seq_file *s, void *unused)
105
+static int prev_dbg_uid1_show(struct seq_file *s, void *unused)
127106 {
128107 return prev_dbg_uidn_show(s, unused, 1);
129108 }
130109
131
-GENWQE_DEBUGFS_RO(prev_dbg_uid1, genwqe_prev_dbg_uid1_show);
110
+DEFINE_SHOW_ATTRIBUTE(prev_dbg_uid1);
132111
133
-static int genwqe_prev_dbg_uid2_show(struct seq_file *s, void *unused)
112
+static int prev_dbg_uid2_show(struct seq_file *s, void *unused)
134113 {
135114 return prev_dbg_uidn_show(s, unused, 2);
136115 }
137116
138
-GENWQE_DEBUGFS_RO(prev_dbg_uid2, genwqe_prev_dbg_uid2_show);
117
+DEFINE_SHOW_ATTRIBUTE(prev_dbg_uid2);
139118
140
-static int genwqe_curr_regs_show(struct seq_file *s, void *unused)
119
+static int curr_regs_show(struct seq_file *s, void *unused)
141120 {
142121 struct genwqe_dev *cd = s->private;
143122 unsigned int i;
....@@ -164,9 +143,9 @@
164143 return 0;
165144 }
166145
167
-GENWQE_DEBUGFS_RO(curr_regs, genwqe_curr_regs_show);
146
+DEFINE_SHOW_ATTRIBUTE(curr_regs);
168147
169
-static int genwqe_prev_regs_show(struct seq_file *s, void *unused)
148
+static int prev_regs_show(struct seq_file *s, void *unused)
170149 {
171150 struct genwqe_dev *cd = s->private;
172151 unsigned int i;
....@@ -188,9 +167,9 @@
188167 return 0;
189168 }
190169
191
-GENWQE_DEBUGFS_RO(prev_regs, genwqe_prev_regs_show);
170
+DEFINE_SHOW_ATTRIBUTE(prev_regs);
192171
193
-static int genwqe_jtimer_show(struct seq_file *s, void *unused)
172
+static int jtimer_show(struct seq_file *s, void *unused)
194173 {
195174 struct genwqe_dev *cd = s->private;
196175 unsigned int vf_num;
....@@ -209,9 +188,9 @@
209188 return 0;
210189 }
211190
212
-GENWQE_DEBUGFS_RO(jtimer, genwqe_jtimer_show);
191
+DEFINE_SHOW_ATTRIBUTE(jtimer);
213192
214
-static int genwqe_queue_working_time_show(struct seq_file *s, void *unused)
193
+static int queue_working_time_show(struct seq_file *s, void *unused)
215194 {
216195 struct genwqe_dev *cd = s->private;
217196 unsigned int vf_num;
....@@ -227,9 +206,9 @@
227206 return 0;
228207 }
229208
230
-GENWQE_DEBUGFS_RO(queue_working_time, genwqe_queue_working_time_show);
209
+DEFINE_SHOW_ATTRIBUTE(queue_working_time);
231210
232
-static int genwqe_ddcb_info_show(struct seq_file *s, void *unused)
211
+static int ddcb_info_show(struct seq_file *s, void *unused)
233212 {
234213 struct genwqe_dev *cd = s->private;
235214 unsigned int i;
....@@ -240,7 +219,7 @@
240219 seq_puts(s, "DDCB QUEUE:\n");
241220 seq_printf(s, " ddcb_max: %d\n"
242221 " ddcb_daddr: %016llx - %016llx\n"
243
- " ddcb_vaddr: %016llx\n"
222
+ " ddcb_vaddr: %p\n"
244223 " ddcbs_in_flight: %u\n"
245224 " ddcbs_max_in_flight: %u\n"
246225 " ddcbs_completed: %u\n"
....@@ -250,7 +229,7 @@
250229 queue->ddcb_max, (long long)queue->ddcb_daddr,
251230 (long long)queue->ddcb_daddr +
252231 (queue->ddcb_max * DDCB_LENGTH),
253
- (long long)queue->ddcb_vaddr, queue->ddcbs_in_flight,
232
+ queue->ddcb_vaddr, queue->ddcbs_in_flight,
254233 queue->ddcbs_max_in_flight, queue->ddcbs_completed,
255234 queue->return_on_busy, queue->wait_on_busy,
256235 cd->irqs_processed);
....@@ -300,9 +279,9 @@
300279 return 0;
301280 }
302281
303
-GENWQE_DEBUGFS_RO(ddcb_info, genwqe_ddcb_info_show);
282
+DEFINE_SHOW_ATTRIBUTE(ddcb_info);
304283
305
-static int genwqe_info_show(struct seq_file *s, void *unused)
284
+static int info_show(struct seq_file *s, void *unused)
306285 {
307286 struct genwqe_dev *cd = s->private;
308287 u64 app_id, slu_id, bitstream = -1;
....@@ -335,13 +314,11 @@
335314 return 0;
336315 }
337316
338
-GENWQE_DEBUGFS_RO(info, genwqe_info_show);
317
+DEFINE_SHOW_ATTRIBUTE(info);
339318
340
-int genwqe_init_debugfs(struct genwqe_dev *cd)
319
+void genwqe_init_debugfs(struct genwqe_dev *cd)
341320 {
342321 struct dentry *root;
343
- struct dentry *file;
344
- int ret;
345322 char card_name[64];
346323 char name[64];
347324 unsigned int i;
....@@ -349,153 +326,50 @@
349326 sprintf(card_name, "%s%d_card", GENWQE_DEVNAME, cd->card_idx);
350327
351328 root = debugfs_create_dir(card_name, cd->debugfs_genwqe);
352
- if (!root) {
353
- ret = -ENOMEM;
354
- goto err0;
355
- }
356329
357330 /* non privileged interfaces are done here */
358
- file = debugfs_create_file("ddcb_info", S_IRUGO, root, cd,
359
- &genwqe_ddcb_info_fops);
360
- if (!file) {
361
- ret = -ENOMEM;
362
- goto err1;
363
- }
364
-
365
- file = debugfs_create_file("info", S_IRUGO, root, cd,
366
- &genwqe_info_fops);
367
- if (!file) {
368
- ret = -ENOMEM;
369
- goto err1;
370
- }
371
-
372
- file = debugfs_create_x64("err_inject", 0666, root, &cd->err_inject);
373
- if (!file) {
374
- ret = -ENOMEM;
375
- goto err1;
376
- }
377
-
378
- file = debugfs_create_u32("ddcb_software_timeout", 0666, root,
379
- &cd->ddcb_software_timeout);
380
- if (!file) {
381
- ret = -ENOMEM;
382
- goto err1;
383
- }
384
-
385
- file = debugfs_create_u32("kill_timeout", 0666, root,
386
- &cd->kill_timeout);
387
- if (!file) {
388
- ret = -ENOMEM;
389
- goto err1;
390
- }
331
+ debugfs_create_file("ddcb_info", S_IRUGO, root, cd, &ddcb_info_fops);
332
+ debugfs_create_file("info", S_IRUGO, root, cd, &info_fops);
333
+ debugfs_create_x64("err_inject", 0666, root, &cd->err_inject);
334
+ debugfs_create_u32("ddcb_software_timeout", 0666, root,
335
+ &cd->ddcb_software_timeout);
336
+ debugfs_create_u32("kill_timeout", 0666, root, &cd->kill_timeout);
391337
392338 /* privileged interfaces follow here */
393339 if (!genwqe_is_privileged(cd)) {
394340 cd->debugfs_root = root;
395
- return 0;
341
+ return;
396342 }
397343
398
- file = debugfs_create_file("curr_regs", S_IRUGO, root, cd,
399
- &genwqe_curr_regs_fops);
400
- if (!file) {
401
- ret = -ENOMEM;
402
- goto err1;
403
- }
404
-
405
- file = debugfs_create_file("curr_dbg_uid0", S_IRUGO, root, cd,
406
- &genwqe_curr_dbg_uid0_fops);
407
- if (!file) {
408
- ret = -ENOMEM;
409
- goto err1;
410
- }
411
-
412
- file = debugfs_create_file("curr_dbg_uid1", S_IRUGO, root, cd,
413
- &genwqe_curr_dbg_uid1_fops);
414
- if (!file) {
415
- ret = -ENOMEM;
416
- goto err1;
417
- }
418
-
419
- file = debugfs_create_file("curr_dbg_uid2", S_IRUGO, root, cd,
420
- &genwqe_curr_dbg_uid2_fops);
421
- if (!file) {
422
- ret = -ENOMEM;
423
- goto err1;
424
- }
425
-
426
- file = debugfs_create_file("prev_regs", S_IRUGO, root, cd,
427
- &genwqe_prev_regs_fops);
428
- if (!file) {
429
- ret = -ENOMEM;
430
- goto err1;
431
- }
432
-
433
- file = debugfs_create_file("prev_dbg_uid0", S_IRUGO, root, cd,
434
- &genwqe_prev_dbg_uid0_fops);
435
- if (!file) {
436
- ret = -ENOMEM;
437
- goto err1;
438
- }
439
-
440
- file = debugfs_create_file("prev_dbg_uid1", S_IRUGO, root, cd,
441
- &genwqe_prev_dbg_uid1_fops);
442
- if (!file) {
443
- ret = -ENOMEM;
444
- goto err1;
445
- }
446
-
447
- file = debugfs_create_file("prev_dbg_uid2", S_IRUGO, root, cd,
448
- &genwqe_prev_dbg_uid2_fops);
449
- if (!file) {
450
- ret = -ENOMEM;
451
- goto err1;
452
- }
344
+ debugfs_create_file("curr_regs", S_IRUGO, root, cd, &curr_regs_fops);
345
+ debugfs_create_file("curr_dbg_uid0", S_IRUGO, root, cd,
346
+ &curr_dbg_uid0_fops);
347
+ debugfs_create_file("curr_dbg_uid1", S_IRUGO, root, cd,
348
+ &curr_dbg_uid1_fops);
349
+ debugfs_create_file("curr_dbg_uid2", S_IRUGO, root, cd,
350
+ &curr_dbg_uid2_fops);
351
+ debugfs_create_file("prev_regs", S_IRUGO, root, cd, &prev_regs_fops);
352
+ debugfs_create_file("prev_dbg_uid0", S_IRUGO, root, cd,
353
+ &prev_dbg_uid0_fops);
354
+ debugfs_create_file("prev_dbg_uid1", S_IRUGO, root, cd,
355
+ &prev_dbg_uid1_fops);
356
+ debugfs_create_file("prev_dbg_uid2", S_IRUGO, root, cd,
357
+ &prev_dbg_uid2_fops);
453358
454359 for (i = 0; i < GENWQE_MAX_VFS; i++) {
455360 sprintf(name, "vf%u_jobtimeout_msec", i);
456
-
457
- file = debugfs_create_u32(name, 0666, root,
458
- &cd->vf_jobtimeout_msec[i]);
459
- if (!file) {
460
- ret = -ENOMEM;
461
- goto err1;
462
- }
361
+ debugfs_create_u32(name, 0666, root,
362
+ &cd->vf_jobtimeout_msec[i]);
463363 }
464364
465
- file = debugfs_create_file("jobtimer", S_IRUGO, root, cd,
466
- &genwqe_jtimer_fops);
467
- if (!file) {
468
- ret = -ENOMEM;
469
- goto err1;
470
- }
471
-
472
- file = debugfs_create_file("queue_working_time", S_IRUGO, root, cd,
473
- &genwqe_queue_working_time_fops);
474
- if (!file) {
475
- ret = -ENOMEM;
476
- goto err1;
477
- }
478
-
479
- file = debugfs_create_u32("skip_recovery", 0666, root,
480
- &cd->skip_recovery);
481
- if (!file) {
482
- ret = -ENOMEM;
483
- goto err1;
484
- }
485
-
486
- file = debugfs_create_u32("use_platform_recovery", 0666, root,
487
- &cd->use_platform_recovery);
488
- if (!file) {
489
- ret = -ENOMEM;
490
- goto err1;
491
- }
365
+ debugfs_create_file("jobtimer", S_IRUGO, root, cd, &jtimer_fops);
366
+ debugfs_create_file("queue_working_time", S_IRUGO, root, cd,
367
+ &queue_working_time_fops);
368
+ debugfs_create_u32("skip_recovery", 0666, root, &cd->skip_recovery);
369
+ debugfs_create_u32("use_platform_recovery", 0666, root,
370
+ &cd->use_platform_recovery);
492371
493372 cd->debugfs_root = root;
494
- return 0;
495
-err1:
496
- debugfs_remove_recursive(root);
497
-err0:
498
- return ret;
499373 }
500374
501375 void genqwe_exit_debugfs(struct genwqe_dev *cd)