Merge git://git.infradead.org/mtd-2.6
[linux-2.6] / arch / s390 / hypfs / hypfs_diag.c
1 /*
2  *  arch/s390/hypfs/hypfs_diag.c
3  *    Hypervisor filesystem for Linux on s390. Diag 204 and 224
4  *    implementation.
5  *
6  *    Copyright (C) IBM Corp. 2006
7  *    Author(s): Michael Holzheu <holzheu@de.ibm.com>
8  */
9
10 #include <linux/types.h>
11 #include <linux/errno.h>
12 #include <linux/string.h>
13 #include <linux/vmalloc.h>
14 #include <asm/ebcdic.h>
15 #include "hypfs.h"
16
17 #define LPAR_NAME_LEN 8         /* lpar name len in diag 204 data */
18 #define CPU_NAME_LEN 16         /* type name len of cpus in diag224 name table */
19 #define TMP_SIZE 64             /* size of temporary buffers */
20
21 /* diag 204 subcodes */
22 enum diag204_sc {
23         SUBC_STIB4 = 4,
24         SUBC_RSI = 5,
25         SUBC_STIB6 = 6,
26         SUBC_STIB7 = 7
27 };
28
29 /* The two available diag 204 data formats */
30 enum diag204_format {
31         INFO_SIMPLE = 0,
32         INFO_EXT = 0x00010000
33 };
34
35 /* bit is set in flags, when physical cpu info is included in diag 204 data */
36 #define LPAR_PHYS_FLG  0x80
37
38 static char *diag224_cpu_names;                 /* diag 224 name table */
39 static enum diag204_sc diag204_store_sc;        /* used subcode for store */
40 static enum diag204_format diag204_info_type;   /* used diag 204 data format */
41
42 static void *diag204_buf;               /* 4K aligned buffer for diag204 data */
43 static void *diag204_buf_vmalloc;       /* vmalloc pointer for diag204 data */
44 static int diag204_buf_pages;           /* number of pages for diag204 data */
45
46 /*
47  * DIAG 204 data structures and member access functions.
48  *
49  * Since we have two different diag 204 data formats for old and new s390
50  * machines, we do not access the structs directly, but use getter functions for
51  * each struct member instead. This should make the code more readable.
52  */
53
54 /* Time information block */
55
56 struct info_blk_hdr {
57         __u8  npar;
58         __u8  flags;
59         __u16 tslice;
60         __u16 phys_cpus;
61         __u16 this_part;
62         __u64 curtod;
63 } __attribute__ ((packed));
64
65 struct x_info_blk_hdr {
66         __u8  npar;
67         __u8  flags;
68         __u16 tslice;
69         __u16 phys_cpus;
70         __u16 this_part;
71         __u64 curtod1;
72         __u64 curtod2;
73         char reserved[40];
74 } __attribute__ ((packed));
75
76 static inline int info_blk_hdr__size(enum diag204_format type)
77 {
78         if (type == INFO_SIMPLE)
79                 return sizeof(struct info_blk_hdr);
80         else /* INFO_EXT */
81                 return sizeof(struct x_info_blk_hdr);
82 }
83
84 static inline __u8 info_blk_hdr__npar(enum diag204_format type, void *hdr)
85 {
86         if (type == INFO_SIMPLE)
87                 return ((struct info_blk_hdr *)hdr)->npar;
88         else /* INFO_EXT */
89                 return ((struct x_info_blk_hdr *)hdr)->npar;
90 }
91
92 static inline __u8 info_blk_hdr__flags(enum diag204_format type, void *hdr)
93 {
94         if (type == INFO_SIMPLE)
95                 return ((struct info_blk_hdr *)hdr)->flags;
96         else /* INFO_EXT */
97                 return ((struct x_info_blk_hdr *)hdr)->flags;
98 }
99
100 static inline __u16 info_blk_hdr__pcpus(enum diag204_format type, void *hdr)
101 {
102         if (type == INFO_SIMPLE)
103                 return ((struct info_blk_hdr *)hdr)->phys_cpus;
104         else /* INFO_EXT */
105                 return ((struct x_info_blk_hdr *)hdr)->phys_cpus;
106 }
107
108 /* Partition header */
109
110 struct part_hdr {
111         __u8 pn;
112         __u8 cpus;
113         char reserved[6];
114         char part_name[LPAR_NAME_LEN];
115 } __attribute__ ((packed));
116
117 struct x_part_hdr {
118         __u8  pn;
119         __u8  cpus;
120         __u8  rcpus;
121         __u8  pflag;
122         __u32 mlu;
123         char  part_name[LPAR_NAME_LEN];
124         char  lpc_name[8];
125         char  os_name[8];
126         __u64 online_cs;
127         __u64 online_es;
128         __u8  upid;
129         char  reserved1[3];
130         __u32 group_mlu;
131         char  group_name[8];
132         char  reserved2[32];
133 } __attribute__ ((packed));
134
135 static inline int part_hdr__size(enum diag204_format type)
136 {
137         if (type == INFO_SIMPLE)
138                 return sizeof(struct part_hdr);
139         else /* INFO_EXT */
140                 return sizeof(struct x_part_hdr);
141 }
142
143 static inline __u8 part_hdr__rcpus(enum diag204_format type, void *hdr)
144 {
145         if (type == INFO_SIMPLE)
146                 return ((struct part_hdr *)hdr)->cpus;
147         else /* INFO_EXT */
148                 return ((struct x_part_hdr *)hdr)->rcpus;
149 }
150
151 static inline void part_hdr__part_name(enum diag204_format type, void *hdr,
152                                        char *name)
153 {
154         if (type == INFO_SIMPLE)
155                 memcpy(name, ((struct part_hdr *)hdr)->part_name,
156                        LPAR_NAME_LEN);
157         else /* INFO_EXT */
158                 memcpy(name, ((struct x_part_hdr *)hdr)->part_name,
159                        LPAR_NAME_LEN);
160         EBCASC(name, LPAR_NAME_LEN);
161         name[LPAR_NAME_LEN] = 0;
162         strstrip(name);
163 }
164
165 struct cpu_info {
166         __u16 cpu_addr;
167         char  reserved1[2];
168         __u8  ctidx;
169         __u8  cflag;
170         __u16 weight;
171         __u64 acc_time;
172         __u64 lp_time;
173 } __attribute__ ((packed));
174
175 struct x_cpu_info {
176         __u16 cpu_addr;
177         char  reserved1[2];
178         __u8  ctidx;
179         __u8  cflag;
180         __u16 weight;
181         __u64 acc_time;
182         __u64 lp_time;
183         __u16 min_weight;
184         __u16 cur_weight;
185         __u16 max_weight;
186         char  reseved2[2];
187         __u64 online_time;
188         __u64 wait_time;
189         __u32 pma_weight;
190         __u32 polar_weight;
191         char  reserved3[40];
192 } __attribute__ ((packed));
193
194 /* CPU info block */
195
196 static inline int cpu_info__size(enum diag204_format type)
197 {
198         if (type == INFO_SIMPLE)
199                 return sizeof(struct cpu_info);
200         else /* INFO_EXT */
201                 return sizeof(struct x_cpu_info);
202 }
203
204 static inline __u8 cpu_info__ctidx(enum diag204_format type, void *hdr)
205 {
206         if (type == INFO_SIMPLE)
207                 return ((struct cpu_info *)hdr)->ctidx;
208         else /* INFO_EXT */
209                 return ((struct x_cpu_info *)hdr)->ctidx;
210 }
211
212 static inline __u16 cpu_info__cpu_addr(enum diag204_format type, void *hdr)
213 {
214         if (type == INFO_SIMPLE)
215                 return ((struct cpu_info *)hdr)->cpu_addr;
216         else /* INFO_EXT */
217                 return ((struct x_cpu_info *)hdr)->cpu_addr;
218 }
219
220 static inline __u64 cpu_info__acc_time(enum diag204_format type, void *hdr)
221 {
222         if (type == INFO_SIMPLE)
223                 return ((struct cpu_info *)hdr)->acc_time;
224         else /* INFO_EXT */
225                 return ((struct x_cpu_info *)hdr)->acc_time;
226 }
227
228 static inline __u64 cpu_info__lp_time(enum diag204_format type, void *hdr)
229 {
230         if (type == INFO_SIMPLE)
231                 return ((struct cpu_info *)hdr)->lp_time;
232         else /* INFO_EXT */
233                 return ((struct x_cpu_info *)hdr)->lp_time;
234 }
235
236 static inline __u64 cpu_info__online_time(enum diag204_format type, void *hdr)
237 {
238         if (type == INFO_SIMPLE)
239                 return 0;       /* online_time not available in simple info */
240         else /* INFO_EXT */
241                 return ((struct x_cpu_info *)hdr)->online_time;
242 }
243
244 /* Physical header */
245
246 struct phys_hdr {
247         char reserved1[1];
248         __u8 cpus;
249         char reserved2[6];
250         char mgm_name[8];
251 } __attribute__ ((packed));
252
253 struct x_phys_hdr {
254         char reserved1[1];
255         __u8 cpus;
256         char reserved2[6];
257         char mgm_name[8];
258         char reserved3[80];
259 } __attribute__ ((packed));
260
261 static inline int phys_hdr__size(enum diag204_format type)
262 {
263         if (type == INFO_SIMPLE)
264                 return sizeof(struct phys_hdr);
265         else /* INFO_EXT */
266                 return sizeof(struct x_phys_hdr);
267 }
268
269 static inline __u8 phys_hdr__cpus(enum diag204_format type, void *hdr)
270 {
271         if (type == INFO_SIMPLE)
272                 return ((struct phys_hdr *)hdr)->cpus;
273         else /* INFO_EXT */
274                 return ((struct x_phys_hdr *)hdr)->cpus;
275 }
276
277 /* Physical CPU info block */
278
279 struct phys_cpu {
280         __u16 cpu_addr;
281         char  reserved1[2];
282         __u8  ctidx;
283         char  reserved2[3];
284         __u64 mgm_time;
285         char  reserved3[8];
286 } __attribute__ ((packed));
287
288 struct x_phys_cpu {
289         __u16 cpu_addr;
290         char  reserved1[2];
291         __u8  ctidx;
292         char  reserved2[3];
293         __u64 mgm_time;
294         char  reserved3[80];
295 } __attribute__ ((packed));
296
297 static inline int phys_cpu__size(enum diag204_format type)
298 {
299         if (type == INFO_SIMPLE)
300                 return sizeof(struct phys_cpu);
301         else /* INFO_EXT */
302                 return sizeof(struct x_phys_cpu);
303 }
304
305 static inline __u16 phys_cpu__cpu_addr(enum diag204_format type, void *hdr)
306 {
307         if (type == INFO_SIMPLE)
308                 return ((struct phys_cpu *)hdr)->cpu_addr;
309         else /* INFO_EXT */
310                 return ((struct x_phys_cpu *)hdr)->cpu_addr;
311 }
312
313 static inline __u64 phys_cpu__mgm_time(enum diag204_format type, void *hdr)
314 {
315         if (type == INFO_SIMPLE)
316                 return ((struct phys_cpu *)hdr)->mgm_time;
317         else /* INFO_EXT */
318                 return ((struct x_phys_cpu *)hdr)->mgm_time;
319 }
320
321 static inline __u64 phys_cpu__ctidx(enum diag204_format type, void *hdr)
322 {
323         if (type == INFO_SIMPLE)
324                 return ((struct phys_cpu *)hdr)->ctidx;
325         else /* INFO_EXT */
326                 return ((struct x_phys_cpu *)hdr)->ctidx;
327 }
328
329 /* Diagnose 204 functions */
330
331 static int diag204(unsigned long subcode, unsigned long size, void *addr)
332 {
333         register unsigned long _subcode asm("0") = subcode;
334         register unsigned long _size asm("1") = size;
335
336         asm volatile ("   diag    %2,%0,0x204\n"
337                       "0: \n" ".section __ex_table,\"a\"\n"
338 #ifndef __s390x__
339                       "    .align 4\n"
340                       "    .long  0b,0b\n"
341 #else
342                       "    .align 8\n"
343                       "    .quad  0b,0b\n"
344 #endif
345                       ".previous":"+d" (_subcode), "+d"(_size)
346                       :"d"(addr)
347                       :"memory");
348         if (_subcode)
349                 return -1;
350         else
351                 return _size;
352 }
353
354 /*
355  * For the old diag subcode 4 with simple data format we have to use real
356  * memory. If we use subcode 6 or 7 with extended data format, we can (and
357  * should) use vmalloc, since we need a lot of memory in that case. Currently
358  * up to 93 pages!
359  */
360
361 static void diag204_free_buffer(void)
362 {
363         if (!diag204_buf)
364                 return;
365         if (diag204_buf_vmalloc) {
366                 vfree(diag204_buf_vmalloc);
367                 diag204_buf_vmalloc = NULL;
368         } else {
369                 free_pages((unsigned long) diag204_buf, 0);
370         }
371         diag204_buf_pages = 0;
372         diag204_buf = NULL;
373 }
374
375 static void *diag204_alloc_vbuf(int pages)
376 {
377         /* The buffer has to be page aligned! */
378         diag204_buf_vmalloc = vmalloc(PAGE_SIZE * (pages + 1));
379         if (!diag204_buf_vmalloc)
380                 return ERR_PTR(-ENOMEM);
381         diag204_buf = (void*)((unsigned long)diag204_buf_vmalloc
382                                 & ~0xfffUL) + 0x1000;
383         diag204_buf_pages = pages;
384         return diag204_buf;
385 }
386
387 static void *diag204_alloc_rbuf(void)
388 {
389         diag204_buf = (void*)__get_free_pages(GFP_KERNEL,0);
390         if (diag204_buf)
391                 return ERR_PTR(-ENOMEM);
392         diag204_buf_pages = 1;
393         return diag204_buf;
394 }
395
396 static void *diag204_get_buffer(enum diag204_format fmt, int *pages)
397 {
398         if (diag204_buf) {
399                 *pages = diag204_buf_pages;
400                 return diag204_buf;
401         }
402         if (fmt == INFO_SIMPLE) {
403                 *pages = 1;
404                 return diag204_alloc_rbuf();
405         } else {/* INFO_EXT */
406                 *pages = diag204(SUBC_RSI | INFO_EXT, 0, NULL);
407                 if (*pages <= 0)
408                         return ERR_PTR(-ENOSYS);
409                 else
410                         return diag204_alloc_vbuf(*pages);
411         }
412 }
413
414 /*
415  * diag204_probe() has to find out, which type of diagnose 204 implementation
416  * we have on our machine. Currently there are three possible scanarios:
417  *   - subcode 4   + simple data format (only one page)
418  *   - subcode 4-6 + extended data format
419  *   - subcode 4-7 + extended data format
420  *
421  * Subcode 5 is used to retrieve the size of the data, provided by subcodes
422  * 6 and 7. Subcode 7 basically has the same function as subcode 6. In addition
423  * to subcode 6 it provides also information about secondary cpus.
424  * In order to get as much information as possible, we first try
425  * subcode 7, then 6 and if both fail, we use subcode 4.
426  */
427
428 static int diag204_probe(void)
429 {
430         void *buf;
431         int pages, rc;
432
433         buf = diag204_get_buffer(INFO_EXT, &pages);
434         if (!IS_ERR(buf)) {
435                 if (diag204((unsigned long)SUBC_STIB7 |
436                             (unsigned long)INFO_EXT, pages, buf) >= 0) {
437                         diag204_store_sc = SUBC_STIB7;
438                         diag204_info_type = INFO_EXT;
439                         goto out;
440                 }
441                 if (diag204((unsigned long)SUBC_STIB6 |
442                             (unsigned long)INFO_EXT, pages, buf) >= 0) {
443                         diag204_store_sc = SUBC_STIB7;
444                         diag204_info_type = INFO_EXT;
445                         goto out;
446                 }
447                 diag204_free_buffer();
448         }
449
450         /* subcodes 6 and 7 failed, now try subcode 4 */
451
452         buf = diag204_get_buffer(INFO_SIMPLE, &pages);
453         if (IS_ERR(buf)) {
454                 rc = PTR_ERR(buf);
455                 goto fail_alloc;
456         }
457         if (diag204((unsigned long)SUBC_STIB4 |
458                     (unsigned long)INFO_SIMPLE, pages, buf) >= 0) {
459                 diag204_store_sc = SUBC_STIB4;
460                 diag204_info_type = INFO_SIMPLE;
461                 goto out;
462         } else {
463                 rc = -ENOSYS;
464                 goto fail_store;
465         }
466 out:
467         rc = 0;
468 fail_store:
469         diag204_free_buffer();
470 fail_alloc:
471         return rc;
472 }
473
474 static void *diag204_store(void)
475 {
476         void *buf;
477         int pages;
478
479         buf = diag204_get_buffer(diag204_info_type, &pages);
480         if (IS_ERR(buf))
481                 goto out;
482         if (diag204((unsigned long)diag204_store_sc |
483                     (unsigned long)diag204_info_type, pages, buf) < 0)
484                 return ERR_PTR(-ENOSYS);
485 out:
486         return buf;
487 }
488
489 /* Diagnose 224 functions */
490
491 static void diag224(void *ptr)
492 {
493         asm volatile("   diag    %0,%1,0x224\n"
494                      : :"d" (0), "d"(ptr) : "memory");
495 }
496
497 static int diag224_get_name_table(void)
498 {
499         /* memory must be below 2GB */
500         diag224_cpu_names = kmalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
501         if (!diag224_cpu_names)
502                 return -ENOMEM;
503         diag224(diag224_cpu_names);
504         EBCASC(diag224_cpu_names + 16, (*diag224_cpu_names + 1) * 16);
505         return 0;
506 }
507
508 static void diag224_delete_name_table(void)
509 {
510         kfree(diag224_cpu_names);
511 }
512
513 static int diag224_idx2name(int index, char *name)
514 {
515         memcpy(name, diag224_cpu_names + ((index + 1) * CPU_NAME_LEN),
516                 CPU_NAME_LEN);
517         name[CPU_NAME_LEN] = 0;
518         strstrip(name);
519         return 0;
520 }
521
522 __init int hypfs_diag_init(void)
523 {
524         int rc;
525
526         if (diag204_probe()) {
527                 printk(KERN_ERR "hypfs: diag 204 not working.");
528                 return -ENODATA;
529         }
530         rc = diag224_get_name_table();
531         if (rc) {
532                 diag224_delete_name_table();
533                 printk(KERN_ERR "hypfs: could not get name table.\n");
534         }
535         return rc;
536 }
537
538 void hypfs_diag_exit(void)
539 {
540         diag224_delete_name_table();
541         diag204_free_buffer();
542 }
543
544 /*
545  * Functions to create the directory structure
546  * *******************************************
547  */
548
549 static int hypfs_create_cpu_files(struct super_block *sb,
550                                   struct dentry *cpus_dir, void *cpu_info)
551 {
552         struct dentry *cpu_dir;
553         char buffer[TMP_SIZE];
554         void *rc;
555
556         snprintf(buffer, TMP_SIZE, "%d", cpu_info__cpu_addr(diag204_info_type,
557                                                             cpu_info));
558         cpu_dir = hypfs_mkdir(sb, cpus_dir, buffer);
559         rc = hypfs_create_u64(sb, cpu_dir, "mgmtime",
560                               cpu_info__acc_time(diag204_info_type, cpu_info) -
561                               cpu_info__lp_time(diag204_info_type, cpu_info));
562         if (IS_ERR(rc))
563                 return PTR_ERR(rc);
564         rc = hypfs_create_u64(sb, cpu_dir, "cputime",
565                               cpu_info__lp_time(diag204_info_type, cpu_info));
566         if (IS_ERR(rc))
567                 return PTR_ERR(rc);
568         if (diag204_info_type == INFO_EXT) {
569                 rc = hypfs_create_u64(sb, cpu_dir, "onlinetime",
570                                       cpu_info__online_time(diag204_info_type,
571                                                             cpu_info));
572                 if (IS_ERR(rc))
573                         return PTR_ERR(rc);
574         }
575         diag224_idx2name(cpu_info__ctidx(diag204_info_type, cpu_info), buffer);
576         rc = hypfs_create_str(sb, cpu_dir, "type", buffer);
577         if (IS_ERR(rc))
578                 return PTR_ERR(rc);
579         return 0;
580 }
581
582 static void *hypfs_create_lpar_files(struct super_block *sb,
583                                      struct dentry *systems_dir, void *part_hdr)
584 {
585         struct dentry *cpus_dir;
586         struct dentry *lpar_dir;
587         char lpar_name[LPAR_NAME_LEN + 1];
588         void *cpu_info;
589         int i;
590
591         part_hdr__part_name(diag204_info_type, part_hdr, lpar_name);
592         lpar_name[LPAR_NAME_LEN] = 0;
593         lpar_dir = hypfs_mkdir(sb, systems_dir, lpar_name);
594         if (IS_ERR(lpar_dir))
595                 return lpar_dir;
596         cpus_dir = hypfs_mkdir(sb, lpar_dir, "cpus");
597         if (IS_ERR(cpus_dir))
598                 return cpus_dir;
599         cpu_info = part_hdr + part_hdr__size(diag204_info_type);
600         for (i = 0; i < part_hdr__rcpus(diag204_info_type, part_hdr); i++) {
601                 int rc;
602                 rc = hypfs_create_cpu_files(sb, cpus_dir, cpu_info);
603                 if (rc)
604                         return ERR_PTR(rc);
605                 cpu_info += cpu_info__size(diag204_info_type);
606         }
607         return cpu_info;
608 }
609
610 static int hypfs_create_phys_cpu_files(struct super_block *sb,
611                                        struct dentry *cpus_dir, void *cpu_info)
612 {
613         struct dentry *cpu_dir;
614         char buffer[TMP_SIZE];
615         void *rc;
616
617         snprintf(buffer, TMP_SIZE, "%i", phys_cpu__cpu_addr(diag204_info_type,
618                                                             cpu_info));
619         cpu_dir = hypfs_mkdir(sb, cpus_dir, buffer);
620         if (IS_ERR(cpu_dir))
621                 return PTR_ERR(cpu_dir);
622         rc = hypfs_create_u64(sb, cpu_dir, "mgmtime",
623                               phys_cpu__mgm_time(diag204_info_type, cpu_info));
624         if (IS_ERR(rc))
625                 return PTR_ERR(rc);
626         diag224_idx2name(phys_cpu__ctidx(diag204_info_type, cpu_info), buffer);
627         rc = hypfs_create_str(sb, cpu_dir, "type", buffer);
628         if (IS_ERR(rc))
629                 return PTR_ERR(rc);
630         return 0;
631 }
632
633 static void *hypfs_create_phys_files(struct super_block *sb,
634                                      struct dentry *parent_dir, void *phys_hdr)
635 {
636         int i;
637         void *cpu_info;
638         struct dentry *cpus_dir;
639
640         cpus_dir = hypfs_mkdir(sb, parent_dir, "cpus");
641         if (IS_ERR(cpus_dir))
642                 return cpus_dir;
643         cpu_info = phys_hdr + phys_hdr__size(diag204_info_type);
644         for (i = 0; i < phys_hdr__cpus(diag204_info_type, phys_hdr); i++) {
645                 int rc;
646                 rc = hypfs_create_phys_cpu_files(sb, cpus_dir, cpu_info);
647                 if (rc)
648                         return ERR_PTR(rc);
649                 cpu_info += phys_cpu__size(diag204_info_type);
650         }
651         return cpu_info;
652 }
653
654 int hypfs_diag_create_files(struct super_block *sb, struct dentry *root)
655 {
656         struct dentry *systems_dir, *hyp_dir;
657         void *time_hdr, *part_hdr;
658         int i, rc;
659         void *buffer, *ptr;
660
661         buffer = diag204_store();
662         if (IS_ERR(buffer))
663                 return PTR_ERR(buffer);
664
665         systems_dir = hypfs_mkdir(sb, root, "systems");
666         if (IS_ERR(systems_dir)) {
667                 rc = PTR_ERR(systems_dir);
668                 goto err_out;
669         }
670         time_hdr = (struct x_info_blk_hdr *)buffer;
671         part_hdr = time_hdr + info_blk_hdr__size(diag204_info_type);
672         for (i = 0; i < info_blk_hdr__npar(diag204_info_type, time_hdr); i++) {
673                 part_hdr = hypfs_create_lpar_files(sb, systems_dir, part_hdr);
674                 if (IS_ERR(part_hdr)) {
675                         rc = PTR_ERR(part_hdr);
676                         goto err_out;
677                 }
678         }
679         if (info_blk_hdr__flags(diag204_info_type, time_hdr) & LPAR_PHYS_FLG) {
680                 ptr = hypfs_create_phys_files(sb, root, part_hdr);
681                 if (IS_ERR(ptr)) {
682                         rc = PTR_ERR(ptr);
683                         goto err_out;
684                 }
685         }
686         hyp_dir = hypfs_mkdir(sb, root, "hyp");
687         if (IS_ERR(hyp_dir)) {
688                 rc = PTR_ERR(hyp_dir);
689                 goto err_out;
690         }
691         ptr = hypfs_create_str(sb, hyp_dir, "type", "LPAR Hypervisor");
692         if (IS_ERR(ptr)) {
693                 rc = PTR_ERR(ptr);
694                 goto err_out;
695         }
696         rc = 0;
697
698 err_out:
699         return rc;
700 }