License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-block.git] / arch / s390 / kernel / sysinfo.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
1da177e4 2/*
94f5b09d
HC
3 * Copyright IBM Corp. 2001, 2009
4 * Author(s): Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
5 * Martin Schwidefsky <schwidefsky@de.ibm.com>,
1da177e4
LT
6 */
7
ae5ca67a 8#include <linux/debugfs.h>
1da177e4
LT
9#include <linux/kernel.h>
10#include <linux/mm.h>
11#include <linux/proc_fs.h>
6bcac508 12#include <linux/seq_file.h>
1da177e4 13#include <linux/init.h>
31ee4b2f 14#include <linux/delay.h>
3994a52b 15#include <linux/export.h>
5a0e3ad6 16#include <linux/slab.h>
1da177e4 17#include <asm/ebcdic.h>
ae5ca67a 18#include <asm/debug.h>
aa24f7f0 19#include <asm/sysinfo.h>
6bcac508 20#include <asm/cpcmd.h>
96f4a70d 21#include <asm/topology.h>
9c203239 22#include <asm/fpu/api.h>
31ee4b2f 23
fade4dc4
HC
24int topology_max_mnest;
25
2c79813a 26static inline int __stsi(void *sysinfo, int fc, int sel1, int sel2, int *lvl)
1da177e4 27{
caf757c6
HC
28 register int r0 asm("0") = (fc << 28) | sel1;
29 register int r1 asm("1") = sel2;
30 int rc = 0;
31
32 asm volatile(
33 " stsi 0(%3)\n"
34 "0: jz 2f\n"
35 "1: lhi %1,%4\n"
36 "2:\n"
37 EX_TABLE(0b, 1b)
38 : "+d" (r0), "+d" (rc)
39 : "d" (r1), "a" (sysinfo), "K" (-EOPNOTSUPP)
40 : "cc", "memory");
2c79813a
HC
41 *lvl = ((unsigned int) r0) >> 28;
42 return rc;
43}
44
45/*
46 * stsi - store system information
47 *
48 * Returns the current configuration level if function code 0 was specified.
49 * Otherwise returns 0 on success or a negative value on error.
50 */
51int stsi(void *sysinfo, int fc, int sel1, int sel2)
52{
53 int lvl, rc;
54
55 rc = __stsi(sysinfo, fc, sel1, sel2, &lvl);
caf757c6
HC
56 if (rc)
57 return rc;
2c79813a 58 return fc ? 0 : lvl;
1da177e4 59}
caf757c6 60EXPORT_SYMBOL(stsi);
1da177e4 61
e32eae10
VM
62static bool convert_ext_name(unsigned char encoding, char *name, size_t len)
63{
64 switch (encoding) {
65 case 1: /* EBCDIC */
66 EBCASC(name, len);
67 break;
68 case 2: /* UTF-8 */
69 break;
70 default:
71 return false;
72 }
73 return true;
74}
75
0facaa17 76static void stsi_1_1_1(struct seq_file *m, struct sysinfo_1_1_1 *info)
1da177e4 77{
25502f00
HC
78 int i;
79
caf757c6 80 if (stsi(info, 1, 1, 1))
0facaa17 81 return;
0fee644a
MS
82 EBCASC(info->manufacturer, sizeof(info->manufacturer));
83 EBCASC(info->type, sizeof(info->type));
84 EBCASC(info->model, sizeof(info->model));
85 EBCASC(info->sequence, sizeof(info->sequence));
86 EBCASC(info->plant, sizeof(info->plant));
87 EBCASC(info->model_capacity, sizeof(info->model_capacity));
cbce70e6
MS
88 EBCASC(info->model_perm_cap, sizeof(info->model_perm_cap));
89 EBCASC(info->model_temp_cap, sizeof(info->model_temp_cap));
0facaa17
HC
90 seq_printf(m, "Manufacturer: %-16.16s\n", info->manufacturer);
91 seq_printf(m, "Type: %-4.4s\n", info->type);
92 /*
93 * Sigh: the model field has been renamed with System z9
94 * to model_capacity and a new model field has been added
95 * after the plant field. To avoid confusing older programs
96 * the "Model:" prints "model_capacity model" or just
97 * "model_capacity" if the model string is empty .
98 */
99 seq_printf(m, "Model: %-16.16s", info->model_capacity);
0fee644a 100 if (info->model[0] != '\0')
0facaa17
HC
101 seq_printf(m, " %-16.16s", info->model);
102 seq_putc(m, '\n');
103 seq_printf(m, "Sequence Code: %-16.16s\n", info->sequence);
104 seq_printf(m, "Plant: %-4.4s\n", info->plant);
105 seq_printf(m, "Model Capacity: %-16.16s %08u\n",
25502f00
HC
106 info->model_capacity, info->model_cap_rating);
107 if (info->model_perm_cap_rating)
0facaa17
HC
108 seq_printf(m, "Model Perm. Capacity: %-16.16s %08u\n",
109 info->model_perm_cap,
25502f00
HC
110 info->model_perm_cap_rating);
111 if (info->model_temp_cap_rating)
0facaa17
HC
112 seq_printf(m, "Model Temp. Capacity: %-16.16s %08u\n",
113 info->model_temp_cap,
25502f00
HC
114 info->model_temp_cap_rating);
115 if (info->ncr)
116 seq_printf(m, "Nominal Cap. Rating: %08u\n", info->ncr);
117 if (info->npr)
118 seq_printf(m, "Nominal Perm. Rating: %08u\n", info->npr);
119 if (info->ntr)
120 seq_printf(m, "Nominal Temp. Rating: %08u\n", info->ntr);
7aca2eda 121 if (info->cai) {
0facaa17
HC
122 seq_printf(m, "Capacity Adj. Ind.: %d\n", info->cai);
123 seq_printf(m, "Capacity Ch. Reason: %d\n", info->ccr);
25502f00
HC
124 seq_printf(m, "Capacity Transient: %d\n", info->t);
125 }
126 if (info->p) {
127 for (i = 1; i <= ARRAY_SIZE(info->typepct); i++) {
128 seq_printf(m, "Type %d Percentage: %d\n",
129 i, info->typepct[i - 1]);
130 }
7aca2eda 131 }
1da177e4
LT
132}
133
0facaa17 134static void stsi_15_1_x(struct seq_file *m, struct sysinfo_15_1_x *info)
96f4a70d 135{
e527aec4 136 int i;
96f4a70d 137
0facaa17 138 seq_putc(m, '\n');
96f4a70d 139 if (!MACHINE_HAS_TOPOLOGY)
0facaa17 140 return;
caf757c6
HC
141 if (stsi(info, 15, 1, topology_max_mnest))
142 return;
0facaa17 143 seq_printf(m, "CPU Topology HW: ");
96f4a70d 144 for (i = 0; i < TOPOLOGY_NR_MAG; i++)
0facaa17
HC
145 seq_printf(m, " %d", info->mag[i]);
146 seq_putc(m, '\n');
9236b4dd 147#ifdef CONFIG_SCHED_TOPOLOGY
96f4a70d 148 store_topology(info);
0facaa17 149 seq_printf(m, "CPU Topology SW: ");
96f4a70d 150 for (i = 0; i < TOPOLOGY_NR_MAG; i++)
0facaa17
HC
151 seq_printf(m, " %d", info->mag[i]);
152 seq_putc(m, '\n');
8d11e021 153#endif
96f4a70d
HC
154}
155
0facaa17 156static void stsi_1_2_2(struct seq_file *m, struct sysinfo_1_2_2 *info)
1da177e4 157{
0fee644a
MS
158 struct sysinfo_1_2_2_extension *ext;
159 int i;
160
caf757c6 161 if (stsi(info, 1, 2, 2))
0facaa17 162 return;
0fee644a
MS
163 ext = (struct sysinfo_1_2_2_extension *)
164 ((unsigned long) info + info->acc_offset);
0facaa17
HC
165 seq_printf(m, "CPUs Total: %d\n", info->cpus_total);
166 seq_printf(m, "CPUs Configured: %d\n", info->cpus_configured);
167 seq_printf(m, "CPUs Standby: %d\n", info->cpus_standby);
168 seq_printf(m, "CPUs Reserved: %d\n", info->cpus_reserved);
7022ec49
HC
169 if (info->mt_installed) {
170 seq_printf(m, "CPUs G-MTID: %d\n", info->mt_gtid);
171 seq_printf(m, "CPUs S-MTID: %d\n", info->mt_stid);
172 }
0facaa17
HC
173 /*
174 * Sigh 2. According to the specification the alternate
175 * capability field is a 32 bit floating point number
176 * if the higher order 8 bits are not zero. Printing
177 * a floating point number in the kernel is a no-no,
178 * always print the number as 32 bit unsigned integer.
179 * The user-space needs to know about the strange
180 * encoding of the alternate cpu capability.
181 */
182 seq_printf(m, "Capability: %u", info->capability);
183 if (info->format == 1)
184 seq_printf(m, " %u", ext->alt_capability);
185 seq_putc(m, '\n');
25502f00
HC
186 if (info->nominal_cap)
187 seq_printf(m, "Nominal Capability: %d\n", info->nominal_cap);
188 if (info->secondary_cap)
189 seq_printf(m, "Secondary Capability: %d\n", info->secondary_cap);
0facaa17
HC
190 for (i = 2; i <= info->cpus_total; i++) {
191 seq_printf(m, "Adjustment %02d-way: %u",
192 i, info->adjustment[i-2]);
193 if (info->format == 1)
194 seq_printf(m, " %u", ext->alt_adjustment[i-2]);
195 seq_putc(m, '\n');
0fee644a 196 }
1da177e4
LT
197}
198
0facaa17 199static void stsi_2_2_2(struct seq_file *m, struct sysinfo_2_2_2 *info)
1da177e4 200{
caf757c6 201 if (stsi(info, 2, 2, 2))
0facaa17 202 return;
94f5b09d 203 EBCASC(info->name, sizeof(info->name));
0facaa17
HC
204 seq_putc(m, '\n');
205 seq_printf(m, "LPAR Number: %d\n", info->lpar_number);
206 seq_printf(m, "LPAR Characteristics: ");
0fee644a 207 if (info->characteristics & LPAR_CHAR_DEDICATED)
0facaa17 208 seq_printf(m, "Dedicated ");
0fee644a 209 if (info->characteristics & LPAR_CHAR_SHARED)
0facaa17 210 seq_printf(m, "Shared ");
0fee644a 211 if (info->characteristics & LPAR_CHAR_LIMITED)
0facaa17
HC
212 seq_printf(m, "Limited ");
213 seq_putc(m, '\n');
214 seq_printf(m, "LPAR Name: %-8.8s\n", info->name);
215 seq_printf(m, "LPAR Adjustment: %d\n", info->caf);
216 seq_printf(m, "LPAR CPUs Total: %d\n", info->cpus_total);
217 seq_printf(m, "LPAR CPUs Configured: %d\n", info->cpus_configured);
218 seq_printf(m, "LPAR CPUs Standby: %d\n", info->cpus_standby);
219 seq_printf(m, "LPAR CPUs Reserved: %d\n", info->cpus_reserved);
220 seq_printf(m, "LPAR CPUs Dedicated: %d\n", info->cpus_dedicated);
221 seq_printf(m, "LPAR CPUs Shared: %d\n", info->cpus_shared);
7022ec49
HC
222 if (info->mt_installed) {
223 seq_printf(m, "LPAR CPUs G-MTID: %d\n", info->mt_gtid);
224 seq_printf(m, "LPAR CPUs S-MTID: %d\n", info->mt_stid);
225 seq_printf(m, "LPAR CPUs PS-MTID: %d\n", info->mt_psmtid);
10ad34bc 226 }
e32eae10
VM
227 if (convert_ext_name(info->vsne, info->ext_name, sizeof(info->ext_name))) {
228 seq_printf(m, "LPAR Extended Name: %-.256s\n", info->ext_name);
229 seq_printf(m, "LPAR UUID: %pUb\n", &info->uuid);
230 }
1da177e4
LT
231}
232
f3d0bd6c
ET
233static void print_ext_name(struct seq_file *m, int lvl,
234 struct sysinfo_3_2_2 *info)
235{
e32eae10
VM
236 size_t len = sizeof(info->ext_names[lvl]);
237
238 if (!convert_ext_name(info->vm[lvl].evmne, info->ext_names[lvl], len))
f3d0bd6c 239 return;
f3d0bd6c
ET
240 seq_printf(m, "VM%02d Extended Name: %-.256s\n", lvl,
241 info->ext_names[lvl]);
242}
243
244static void print_uuid(struct seq_file *m, int i, struct sysinfo_3_2_2 *info)
245{
e64e17a5 246 if (uuid_is_null(&info->vm[i].uuid))
f3d0bd6c
ET
247 return;
248 seq_printf(m, "VM%02d UUID: %pUb\n", i, &info->vm[i].uuid);
249}
250
0facaa17 251static void stsi_3_2_2(struct seq_file *m, struct sysinfo_3_2_2 *info)
1da177e4 252{
0fee644a
MS
253 int i;
254
caf757c6 255 if (stsi(info, 3, 2, 2))
0facaa17 256 return;
0fee644a 257 for (i = 0; i < info->count; i++) {
94f5b09d
HC
258 EBCASC(info->vm[i].name, sizeof(info->vm[i].name));
259 EBCASC(info->vm[i].cpi, sizeof(info->vm[i].cpi));
0facaa17
HC
260 seq_putc(m, '\n');
261 seq_printf(m, "VM%02d Name: %-8.8s\n", i, info->vm[i].name);
262 seq_printf(m, "VM%02d Control Program: %-16.16s\n", i, info->vm[i].cpi);
263 seq_printf(m, "VM%02d Adjustment: %d\n", i, info->vm[i].caf);
264 seq_printf(m, "VM%02d CPUs Total: %d\n", i, info->vm[i].cpus_total);
265 seq_printf(m, "VM%02d CPUs Configured: %d\n", i, info->vm[i].cpus_configured);
266 seq_printf(m, "VM%02d CPUs Standby: %d\n", i, info->vm[i].cpus_standby);
267 seq_printf(m, "VM%02d CPUs Reserved: %d\n", i, info->vm[i].cpus_reserved);
f3d0bd6c
ET
268 print_ext_name(m, i, info);
269 print_uuid(m, i, info);
1da177e4 270 }
1da177e4
LT
271}
272
0facaa17 273static int sysinfo_show(struct seq_file *m, void *v)
1da177e4 274{
0facaa17
HC
275 void *info = (void *)get_zeroed_page(GFP_KERNEL);
276 int level;
94f5b09d 277
1da177e4
LT
278 if (!info)
279 return 0;
caf757c6 280 level = stsi(NULL, 0, 0, 0);
0fee644a 281 if (level >= 1)
0facaa17 282 stsi_1_1_1(m, info);
0fee644a 283 if (level >= 1)
0facaa17 284 stsi_15_1_x(m, info);
96f4a70d 285 if (level >= 1)
0facaa17 286 stsi_1_2_2(m, info);
0fee644a 287 if (level >= 2)
0facaa17 288 stsi_2_2_2(m, info);
0fee644a 289 if (level >= 3)
0facaa17
HC
290 stsi_3_2_2(m, info);
291 free_page((unsigned long)info);
292 return 0;
293}
1da177e4 294
0facaa17
HC
295static int sysinfo_open(struct inode *inode, struct file *file)
296{
297 return single_open(file, sysinfo_show, NULL);
1da177e4
LT
298}
299
0facaa17
HC
300static const struct file_operations sysinfo_fops = {
301 .open = sysinfo_open,
302 .read = seq_read,
303 .llseek = seq_lseek,
304 .release = single_release,
305};
306
307static int __init sysinfo_create_proc(void)
1da177e4 308{
0facaa17 309 proc_create("sysinfo", 0444, NULL, &sysinfo_fops);
1da177e4
LT
310 return 0;
311}
0facaa17 312device_initcall(sysinfo_create_proc);
1da177e4 313
6bcac508
MS
314/*
315 * Service levels interface.
316 */
317
318static DECLARE_RWSEM(service_level_sem);
319static LIST_HEAD(service_level_list);
320
321int register_service_level(struct service_level *slr)
322{
323 struct service_level *ptr;
324
325 down_write(&service_level_sem);
326 list_for_each_entry(ptr, &service_level_list, list)
327 if (ptr == slr) {
328 up_write(&service_level_sem);
329 return -EEXIST;
330 }
331 list_add_tail(&slr->list, &service_level_list);
332 up_write(&service_level_sem);
333 return 0;
334}
335EXPORT_SYMBOL(register_service_level);
336
337int unregister_service_level(struct service_level *slr)
338{
339 struct service_level *ptr, *next;
340 int rc = -ENOENT;
341
342 down_write(&service_level_sem);
343 list_for_each_entry_safe(ptr, next, &service_level_list, list) {
344 if (ptr != slr)
345 continue;
346 list_del(&ptr->list);
347 rc = 0;
348 break;
349 }
350 up_write(&service_level_sem);
351 return rc;
352}
353EXPORT_SYMBOL(unregister_service_level);
354
355static void *service_level_start(struct seq_file *m, loff_t *pos)
356{
357 down_read(&service_level_sem);
358 return seq_list_start(&service_level_list, *pos);
359}
360
361static void *service_level_next(struct seq_file *m, void *p, loff_t *pos)
362{
363 return seq_list_next(p, &service_level_list, pos);
364}
365
366static void service_level_stop(struct seq_file *m, void *p)
367{
368 up_read(&service_level_sem);
369}
370
371static int service_level_show(struct seq_file *m, void *p)
372{
373 struct service_level *slr;
374
375 slr = list_entry(p, struct service_level, list);
376 slr->seq_print(m, slr);
377 return 0;
378}
379
380static const struct seq_operations service_level_seq_ops = {
381 .start = service_level_start,
382 .next = service_level_next,
383 .stop = service_level_stop,
384 .show = service_level_show
385};
386
387static int service_level_open(struct inode *inode, struct file *file)
388{
389 return seq_open(file, &service_level_seq_ops);
390}
391
392static const struct file_operations service_level_ops = {
393 .open = service_level_open,
394 .read = seq_read,
395 .llseek = seq_lseek,
396 .release = seq_release
397};
398
399static void service_level_vm_print(struct seq_file *m,
400 struct service_level *slr)
401{
402 char *query_buffer, *str;
403
404 query_buffer = kmalloc(1024, GFP_KERNEL | GFP_DMA);
405 if (!query_buffer)
406 return;
407 cpcmd("QUERY CPLEVEL", query_buffer, 1024, NULL);
408 str = strchr(query_buffer, '\n');
409 if (str)
410 *str = 0;
411 seq_printf(m, "VM: %s\n", query_buffer);
412 kfree(query_buffer);
413}
414
415static struct service_level service_level_vm = {
416 .seq_print = service_level_vm_print
417};
418
419static __init int create_proc_service_level(void)
420{
421 proc_create("service_levels", 0, NULL, &service_level_ops);
422 if (MACHINE_IS_VM)
423 register_service_level(&service_level_vm);
424 return 0;
425}
6bcac508
MS
426subsys_initcall(create_proc_service_level);
427
31ee4b2f
MS
428/*
429 * CPU capability might have changed. Therefore recalculate loops_per_jiffy.
430 */
431void s390_adjust_jiffies(void)
432{
433 struct sysinfo_1_2_2 *info;
9c203239
HC
434 unsigned long capability;
435 struct kernel_fpu fpu;
31ee4b2f
MS
436
437 info = (void *) get_zeroed_page(GFP_KERNEL);
438 if (!info)
439 return;
440
caf757c6 441 if (stsi(info, 1, 2, 2) == 0) {
31ee4b2f
MS
442 /*
443 * Major sigh. The cpu capability encoding is "special".
444 * If the first 9 bits of info->capability are 0 then it
445 * is a 32 bit unsigned integer in the range 0 .. 2^23.
446 * If the first 9 bits are != 0 then it is a 32 bit float.
447 * In addition a lower value indicates a proportionally
448 * higher cpu capacity. Bogomips are the other way round.
449 * To get to a halfway suitable number we divide 1e7
450 * by the cpu capability number. Yes, that means a floating
9c203239 451 * point division ..
31ee4b2f 452 */
9c203239
HC
453 kernel_fpu_begin(&fpu, KERNEL_FPR);
454 asm volatile(
455 " sfpc %3\n"
456 " l %0,%1\n"
457 " tmlh %0,0xff80\n"
458 " jnz 0f\n"
459 " cefbr %%f2,%0\n"
460 " j 1f\n"
461 "0: le %%f2,%1\n"
462 "1: cefbr %%f0,%2\n"
463 " debr %%f0,%%f2\n"
464 " cgebr %0,5,%%f0\n"
465 : "=&d" (capability)
466 : "Q" (info->capability), "d" (10000000), "d" (0)
467 : "cc"
468 );
7f79695c 469 kernel_fpu_end(&fpu, KERNEL_FPR);
31ee4b2f
MS
470 } else
471 /*
472 * Really old machine without stsi block for basic
473 * cpu information. Report 42.0 bogomips.
474 */
475 capability = 42;
476 loops_per_jiffy = capability * (500000/HZ);
477 free_page((unsigned long) info);
478}
479
480/*
481 * calibrate the delay loop
482 */
e2741f17 483void calibrate_delay(void)
31ee4b2f
MS
484{
485 s390_adjust_jiffies();
486 /* Print the good old Bogomips line .. */
487 printk(KERN_DEBUG "Calibrating delay loop (skipped)... "
488 "%lu.%02lu BogoMIPS preset\n", loops_per_jiffy/(500000/HZ),
489 (loops_per_jiffy/(5000/HZ)) % 100);
490}
ae5ca67a
HC
491
492#ifdef CONFIG_DEBUG_FS
493
494#define STSI_FILE(fc, s1, s2) \
495static int stsi_open_##fc##_##s1##_##s2(struct inode *inode, struct file *file)\
496{ \
497 file->private_data = (void *) get_zeroed_page(GFP_KERNEL); \
498 if (!file->private_data) \
499 return -ENOMEM; \
500 if (stsi(file->private_data, fc, s1, s2)) { \
501 free_page((unsigned long)file->private_data); \
502 file->private_data = NULL; \
503 return -EACCES; \
504 } \
505 return nonseekable_open(inode, file); \
506} \
507 \
508static const struct file_operations stsi_##fc##_##s1##_##s2##_fs_ops = { \
509 .open = stsi_open_##fc##_##s1##_##s2, \
510 .release = stsi_release, \
511 .read = stsi_read, \
512 .llseek = no_llseek, \
513};
514
515static int stsi_release(struct inode *inode, struct file *file)
516{
517 free_page((unsigned long)file->private_data);
518 return 0;
519}
520
521static ssize_t stsi_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
522{
523 return simple_read_from_buffer(buf, size, ppos, file->private_data, PAGE_SIZE);
524}
525
cdd3bd9d
HC
526STSI_FILE( 1, 1, 1);
527STSI_FILE( 1, 2, 1);
528STSI_FILE( 1, 2, 2);
529STSI_FILE( 2, 2, 1);
530STSI_FILE( 2, 2, 2);
531STSI_FILE( 3, 2, 2);
ae5ca67a
HC
532STSI_FILE(15, 1, 2);
533STSI_FILE(15, 1, 3);
534STSI_FILE(15, 1, 4);
535STSI_FILE(15, 1, 5);
536STSI_FILE(15, 1, 6);
537
538struct stsi_file {
539 const struct file_operations *fops;
540 char *name;
541};
542
543static struct stsi_file stsi_file[] __initdata = {
cdd3bd9d
HC
544 {.fops = &stsi_1_1_1_fs_ops, .name = "1_1_1"},
545 {.fops = &stsi_1_2_1_fs_ops, .name = "1_2_1"},
546 {.fops = &stsi_1_2_2_fs_ops, .name = "1_2_2"},
547 {.fops = &stsi_2_2_1_fs_ops, .name = "2_2_1"},
548 {.fops = &stsi_2_2_2_fs_ops, .name = "2_2_2"},
549 {.fops = &stsi_3_2_2_fs_ops, .name = "3_2_2"},
ae5ca67a
HC
550 {.fops = &stsi_15_1_2_fs_ops, .name = "15_1_2"},
551 {.fops = &stsi_15_1_3_fs_ops, .name = "15_1_3"},
552 {.fops = &stsi_15_1_4_fs_ops, .name = "15_1_4"},
553 {.fops = &stsi_15_1_5_fs_ops, .name = "15_1_5"},
554 {.fops = &stsi_15_1_6_fs_ops, .name = "15_1_6"},
555};
556
cdd3bd9d
HC
557static u8 stsi_0_0_0;
558
ae5ca67a
HC
559static __init int stsi_init_debugfs(void)
560{
561 struct dentry *stsi_root;
562 struct stsi_file *sf;
cdd3bd9d 563 int lvl, i;
ae5ca67a
HC
564
565 stsi_root = debugfs_create_dir("stsi", arch_debugfs_dir);
566 if (IS_ERR_OR_NULL(stsi_root))
567 return 0;
cdd3bd9d
HC
568 lvl = stsi(NULL, 0, 0, 0);
569 if (lvl > 0)
570 stsi_0_0_0 = lvl;
571 debugfs_create_u8("0_0_0", 0400, stsi_root, &stsi_0_0_0);
ae5ca67a
HC
572 for (i = 0; i < ARRAY_SIZE(stsi_file); i++) {
573 sf = &stsi_file[i];
574 debugfs_create_file(sf->name, 0400, stsi_root, NULL, sf->fops);
575 }
576 if (IS_ENABLED(CONFIG_SCHED_TOPOLOGY) && MACHINE_HAS_TOPOLOGY) {
577 char link_to[10];
578
579 sprintf(link_to, "15_1_%d", topology_mnest_limit());
580 debugfs_create_symlink("topology", stsi_root, link_to);
581 }
582 return 0;
583}
584device_initcall(stsi_init_debugfs);
585
586#endif /* CONFIG_DEBUG_FS */