hypfs_diag.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. /*
  2. * Hypervisor filesystem for Linux on s390. Diag 204 and 224
  3. * implementation.
  4. *
  5. * Copyright IBM Corp. 2006, 2008
  6. * Author(s): Michael Holzheu <holzheu@de.ibm.com>
  7. */
  8. #define KMSG_COMPONENT "hypfs"
  9. #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
  10. #include <linux/types.h>
  11. #include <linux/errno.h>
  12. #include <linux/slab.h>
  13. #include <linux/string.h>
  14. #include <linux/vmalloc.h>
  15. #include <linux/mm.h>
  16. #include <asm/diag.h>
  17. #include <asm/ebcdic.h>
  18. #include "hypfs.h"
  19. #define TMP_SIZE 64 /* size of temporary buffers */
  20. #define DBFS_D204_HDR_VERSION 0
  21. static char *diag224_cpu_names; /* diag 224 name table */
  22. static enum diag204_sc diag204_store_sc; /* used subcode for store */
  23. static enum diag204_format diag204_info_type; /* used diag 204 data format */
  24. static void *diag204_buf; /* 4K aligned buffer for diag204 data */
  25. static void *diag204_buf_vmalloc; /* vmalloc pointer for diag204 data */
  26. static int diag204_buf_pages; /* number of pages for diag204 data */
  27. static struct dentry *dbfs_d204_file;
  28. /*
  29. * DIAG 204 member access functions.
  30. *
  31. * Since we have two different diag 204 data formats for old and new s390
  32. * machines, we do not access the structs directly, but use getter functions for
  33. * each struct member instead. This should make the code more readable.
  34. */
  35. /* Time information block */
  36. static inline int info_blk_hdr__size(enum diag204_format type)
  37. {
  38. if (type == DIAG204_INFO_SIMPLE)
  39. return sizeof(struct diag204_info_blk_hdr);
  40. else /* DIAG204_INFO_EXT */
  41. return sizeof(struct diag204_x_info_blk_hdr);
  42. }
  43. static inline __u8 info_blk_hdr__npar(enum diag204_format type, void *hdr)
  44. {
  45. if (type == DIAG204_INFO_SIMPLE)
  46. return ((struct diag204_info_blk_hdr *)hdr)->npar;
  47. else /* DIAG204_INFO_EXT */
  48. return ((struct diag204_x_info_blk_hdr *)hdr)->npar;
  49. }
  50. static inline __u8 info_blk_hdr__flags(enum diag204_format type, void *hdr)
  51. {
  52. if (type == DIAG204_INFO_SIMPLE)
  53. return ((struct diag204_info_blk_hdr *)hdr)->flags;
  54. else /* DIAG204_INFO_EXT */
  55. return ((struct diag204_x_info_blk_hdr *)hdr)->flags;
  56. }
  57. static inline __u16 info_blk_hdr__pcpus(enum diag204_format type, void *hdr)
  58. {
  59. if (type == DIAG204_INFO_SIMPLE)
  60. return ((struct diag204_info_blk_hdr *)hdr)->phys_cpus;
  61. else /* DIAG204_INFO_EXT */
  62. return ((struct diag204_x_info_blk_hdr *)hdr)->phys_cpus;
  63. }
  64. /* Partition header */
  65. static inline int part_hdr__size(enum diag204_format type)
  66. {
  67. if (type == DIAG204_INFO_SIMPLE)
  68. return sizeof(struct diag204_part_hdr);
  69. else /* DIAG204_INFO_EXT */
  70. return sizeof(struct diag204_x_part_hdr);
  71. }
  72. static inline __u8 part_hdr__rcpus(enum diag204_format type, void *hdr)
  73. {
  74. if (type == DIAG204_INFO_SIMPLE)
  75. return ((struct diag204_part_hdr *)hdr)->cpus;
  76. else /* DIAG204_INFO_EXT */
  77. return ((struct diag204_x_part_hdr *)hdr)->rcpus;
  78. }
  79. static inline void part_hdr__part_name(enum diag204_format type, void *hdr,
  80. char *name)
  81. {
  82. if (type == DIAG204_INFO_SIMPLE)
  83. memcpy(name, ((struct diag204_part_hdr *)hdr)->part_name,
  84. DIAG204_LPAR_NAME_LEN);
  85. else /* DIAG204_INFO_EXT */
  86. memcpy(name, ((struct diag204_x_part_hdr *)hdr)->part_name,
  87. DIAG204_LPAR_NAME_LEN);
  88. EBCASC(name, DIAG204_LPAR_NAME_LEN);
  89. name[DIAG204_LPAR_NAME_LEN] = 0;
  90. strim(name);
  91. }
  92. /* CPU info block */
  93. static inline int cpu_info__size(enum diag204_format type)
  94. {
  95. if (type == DIAG204_INFO_SIMPLE)
  96. return sizeof(struct diag204_cpu_info);
  97. else /* DIAG204_INFO_EXT */
  98. return sizeof(struct diag204_x_cpu_info);
  99. }
  100. static inline __u8 cpu_info__ctidx(enum diag204_format type, void *hdr)
  101. {
  102. if (type == DIAG204_INFO_SIMPLE)
  103. return ((struct diag204_cpu_info *)hdr)->ctidx;
  104. else /* DIAG204_INFO_EXT */
  105. return ((struct diag204_x_cpu_info *)hdr)->ctidx;
  106. }
  107. static inline __u16 cpu_info__cpu_addr(enum diag204_format type, void *hdr)
  108. {
  109. if (type == DIAG204_INFO_SIMPLE)
  110. return ((struct diag204_cpu_info *)hdr)->cpu_addr;
  111. else /* DIAG204_INFO_EXT */
  112. return ((struct diag204_x_cpu_info *)hdr)->cpu_addr;
  113. }
  114. static inline __u64 cpu_info__acc_time(enum diag204_format type, void *hdr)
  115. {
  116. if (type == DIAG204_INFO_SIMPLE)
  117. return ((struct diag204_cpu_info *)hdr)->acc_time;
  118. else /* DIAG204_INFO_EXT */
  119. return ((struct diag204_x_cpu_info *)hdr)->acc_time;
  120. }
  121. static inline __u64 cpu_info__lp_time(enum diag204_format type, void *hdr)
  122. {
  123. if (type == DIAG204_INFO_SIMPLE)
  124. return ((struct diag204_cpu_info *)hdr)->lp_time;
  125. else /* DIAG204_INFO_EXT */
  126. return ((struct diag204_x_cpu_info *)hdr)->lp_time;
  127. }
  128. static inline __u64 cpu_info__online_time(enum diag204_format type, void *hdr)
  129. {
  130. if (type == DIAG204_INFO_SIMPLE)
  131. return 0; /* online_time not available in simple info */
  132. else /* DIAG204_INFO_EXT */
  133. return ((struct diag204_x_cpu_info *)hdr)->online_time;
  134. }
  135. /* Physical header */
  136. static inline int phys_hdr__size(enum diag204_format type)
  137. {
  138. if (type == DIAG204_INFO_SIMPLE)
  139. return sizeof(struct diag204_phys_hdr);
  140. else /* DIAG204_INFO_EXT */
  141. return sizeof(struct diag204_x_phys_hdr);
  142. }
  143. static inline __u8 phys_hdr__cpus(enum diag204_format type, void *hdr)
  144. {
  145. if (type == DIAG204_INFO_SIMPLE)
  146. return ((struct diag204_phys_hdr *)hdr)->cpus;
  147. else /* DIAG204_INFO_EXT */
  148. return ((struct diag204_x_phys_hdr *)hdr)->cpus;
  149. }
  150. /* Physical CPU info block */
  151. static inline int phys_cpu__size(enum diag204_format type)
  152. {
  153. if (type == DIAG204_INFO_SIMPLE)
  154. return sizeof(struct diag204_phys_cpu);
  155. else /* DIAG204_INFO_EXT */
  156. return sizeof(struct diag204_x_phys_cpu);
  157. }
  158. static inline __u16 phys_cpu__cpu_addr(enum diag204_format type, void *hdr)
  159. {
  160. if (type == DIAG204_INFO_SIMPLE)
  161. return ((struct diag204_phys_cpu *)hdr)->cpu_addr;
  162. else /* DIAG204_INFO_EXT */
  163. return ((struct diag204_x_phys_cpu *)hdr)->cpu_addr;
  164. }
  165. static inline __u64 phys_cpu__mgm_time(enum diag204_format type, void *hdr)
  166. {
  167. if (type == DIAG204_INFO_SIMPLE)
  168. return ((struct diag204_phys_cpu *)hdr)->mgm_time;
  169. else /* DIAG204_INFO_EXT */
  170. return ((struct diag204_x_phys_cpu *)hdr)->mgm_time;
  171. }
  172. static inline __u64 phys_cpu__ctidx(enum diag204_format type, void *hdr)
  173. {
  174. if (type == DIAG204_INFO_SIMPLE)
  175. return ((struct diag204_phys_cpu *)hdr)->ctidx;
  176. else /* DIAG204_INFO_EXT */
  177. return ((struct diag204_x_phys_cpu *)hdr)->ctidx;
  178. }
  179. /* Diagnose 204 functions */
  180. /*
  181. * For the old diag subcode 4 with simple data format we have to use real
  182. * memory. If we use subcode 6 or 7 with extended data format, we can (and
  183. * should) use vmalloc, since we need a lot of memory in that case. Currently
  184. * up to 93 pages!
  185. */
  186. static void diag204_free_buffer(void)
  187. {
  188. if (!diag204_buf)
  189. return;
  190. if (diag204_buf_vmalloc) {
  191. vfree(diag204_buf_vmalloc);
  192. diag204_buf_vmalloc = NULL;
  193. } else {
  194. free_pages((unsigned long) diag204_buf, 0);
  195. }
  196. diag204_buf = NULL;
  197. }
  198. static void *page_align_ptr(void *ptr)
  199. {
  200. return (void *) PAGE_ALIGN((unsigned long) ptr);
  201. }
  202. static void *diag204_alloc_vbuf(int pages)
  203. {
  204. /* The buffer has to be page aligned! */
  205. diag204_buf_vmalloc = vmalloc(PAGE_SIZE * (pages + 1));
  206. if (!diag204_buf_vmalloc)
  207. return ERR_PTR(-ENOMEM);
  208. diag204_buf = page_align_ptr(diag204_buf_vmalloc);
  209. diag204_buf_pages = pages;
  210. return diag204_buf;
  211. }
  212. static void *diag204_alloc_rbuf(void)
  213. {
  214. diag204_buf = (void*)__get_free_pages(GFP_KERNEL,0);
  215. if (!diag204_buf)
  216. return ERR_PTR(-ENOMEM);
  217. diag204_buf_pages = 1;
  218. return diag204_buf;
  219. }
  220. static void *diag204_get_buffer(enum diag204_format fmt, int *pages)
  221. {
  222. if (diag204_buf) {
  223. *pages = diag204_buf_pages;
  224. return diag204_buf;
  225. }
  226. if (fmt == DIAG204_INFO_SIMPLE) {
  227. *pages = 1;
  228. return diag204_alloc_rbuf();
  229. } else {/* DIAG204_INFO_EXT */
  230. *pages = diag204((unsigned long)DIAG204_SUBC_RSI |
  231. (unsigned long)DIAG204_INFO_EXT, 0, NULL);
  232. if (*pages <= 0)
  233. return ERR_PTR(-ENOSYS);
  234. else
  235. return diag204_alloc_vbuf(*pages);
  236. }
  237. }
  238. /*
  239. * diag204_probe() has to find out, which type of diagnose 204 implementation
  240. * we have on our machine. Currently there are three possible scanarios:
  241. * - subcode 4 + simple data format (only one page)
  242. * - subcode 4-6 + extended data format
  243. * - subcode 4-7 + extended data format
  244. *
  245. * Subcode 5 is used to retrieve the size of the data, provided by subcodes
  246. * 6 and 7. Subcode 7 basically has the same function as subcode 6. In addition
  247. * to subcode 6 it provides also information about secondary cpus.
  248. * In order to get as much information as possible, we first try
  249. * subcode 7, then 6 and if both fail, we use subcode 4.
  250. */
  251. static int diag204_probe(void)
  252. {
  253. void *buf;
  254. int pages, rc;
  255. buf = diag204_get_buffer(DIAG204_INFO_EXT, &pages);
  256. if (!IS_ERR(buf)) {
  257. if (diag204((unsigned long)DIAG204_SUBC_STIB7 |
  258. (unsigned long)DIAG204_INFO_EXT, pages, buf) >= 0) {
  259. diag204_store_sc = DIAG204_SUBC_STIB7;
  260. diag204_info_type = DIAG204_INFO_EXT;
  261. goto out;
  262. }
  263. if (diag204((unsigned long)DIAG204_SUBC_STIB6 |
  264. (unsigned long)DIAG204_INFO_EXT, pages, buf) >= 0) {
  265. diag204_store_sc = DIAG204_SUBC_STIB6;
  266. diag204_info_type = DIAG204_INFO_EXT;
  267. goto out;
  268. }
  269. diag204_free_buffer();
  270. }
  271. /* subcodes 6 and 7 failed, now try subcode 4 */
  272. buf = diag204_get_buffer(DIAG204_INFO_SIMPLE, &pages);
  273. if (IS_ERR(buf)) {
  274. rc = PTR_ERR(buf);
  275. goto fail_alloc;
  276. }
  277. if (diag204((unsigned long)DIAG204_SUBC_STIB4 |
  278. (unsigned long)DIAG204_INFO_SIMPLE, pages, buf) >= 0) {
  279. diag204_store_sc = DIAG204_SUBC_STIB4;
  280. diag204_info_type = DIAG204_INFO_SIMPLE;
  281. goto out;
  282. } else {
  283. rc = -ENOSYS;
  284. goto fail_store;
  285. }
  286. out:
  287. rc = 0;
  288. fail_store:
  289. diag204_free_buffer();
  290. fail_alloc:
  291. return rc;
  292. }
  293. static int diag204_do_store(void *buf, int pages)
  294. {
  295. int rc;
  296. rc = diag204((unsigned long) diag204_store_sc |
  297. (unsigned long) diag204_info_type, pages, buf);
  298. return rc < 0 ? -ENOSYS : 0;
  299. }
  300. static void *diag204_store(void)
  301. {
  302. void *buf;
  303. int pages, rc;
  304. buf = diag204_get_buffer(diag204_info_type, &pages);
  305. if (IS_ERR(buf))
  306. goto out;
  307. rc = diag204_do_store(buf, pages);
  308. if (rc)
  309. return ERR_PTR(rc);
  310. out:
  311. return buf;
  312. }
  313. /* Diagnose 224 functions */
  314. static int diag224_get_name_table(void)
  315. {
  316. /* memory must be below 2GB */
  317. diag224_cpu_names = (char *) __get_free_page(GFP_KERNEL | GFP_DMA);
  318. if (!diag224_cpu_names)
  319. return -ENOMEM;
  320. if (diag224(diag224_cpu_names)) {
  321. free_page((unsigned long) diag224_cpu_names);
  322. return -EOPNOTSUPP;
  323. }
  324. EBCASC(diag224_cpu_names + 16, (*diag224_cpu_names + 1) * 16);
  325. return 0;
  326. }
  327. static void diag224_delete_name_table(void)
  328. {
  329. free_page((unsigned long) diag224_cpu_names);
  330. }
  331. static int diag224_idx2name(int index, char *name)
  332. {
  333. memcpy(name, diag224_cpu_names + ((index + 1) * DIAG204_CPU_NAME_LEN),
  334. DIAG204_CPU_NAME_LEN);
  335. name[DIAG204_CPU_NAME_LEN] = 0;
  336. strim(name);
  337. return 0;
  338. }
  339. struct dbfs_d204_hdr {
  340. u64 len; /* Length of d204 buffer without header */
  341. u16 version; /* Version of header */
  342. u8 sc; /* Used subcode */
  343. char reserved[53];
  344. } __attribute__ ((packed));
  345. struct dbfs_d204 {
  346. struct dbfs_d204_hdr hdr; /* 64 byte header */
  347. char buf[]; /* d204 buffer */
  348. } __attribute__ ((packed));
  349. static int dbfs_d204_create(void **data, void **data_free_ptr, size_t *size)
  350. {
  351. struct dbfs_d204 *d204;
  352. int rc, buf_size;
  353. void *base;
  354. buf_size = PAGE_SIZE * (diag204_buf_pages + 1) + sizeof(d204->hdr);
  355. base = vzalloc(buf_size);
  356. if (!base)
  357. return -ENOMEM;
  358. d204 = page_align_ptr(base + sizeof(d204->hdr)) - sizeof(d204->hdr);
  359. rc = diag204_do_store(d204->buf, diag204_buf_pages);
  360. if (rc) {
  361. vfree(base);
  362. return rc;
  363. }
  364. d204->hdr.version = DBFS_D204_HDR_VERSION;
  365. d204->hdr.len = PAGE_SIZE * diag204_buf_pages;
  366. d204->hdr.sc = diag204_store_sc;
  367. *data = d204;
  368. *data_free_ptr = base;
  369. *size = d204->hdr.len + sizeof(struct dbfs_d204_hdr);
  370. return 0;
  371. }
  372. static struct hypfs_dbfs_file dbfs_file_d204 = {
  373. .name = "diag_204",
  374. .data_create = dbfs_d204_create,
  375. .data_free = vfree,
  376. };
  377. __init int hypfs_diag_init(void)
  378. {
  379. int rc;
  380. if (diag204_probe()) {
  381. pr_err("The hardware system does not support hypfs\n");
  382. return -ENODATA;
  383. }
  384. if (diag204_info_type == DIAG204_INFO_EXT) {
  385. rc = hypfs_dbfs_create_file(&dbfs_file_d204);
  386. if (rc)
  387. return rc;
  388. }
  389. if (MACHINE_IS_LPAR) {
  390. rc = diag224_get_name_table();
  391. if (rc) {
  392. pr_err("The hardware system does not provide all "
  393. "functions required by hypfs\n");
  394. debugfs_remove(dbfs_d204_file);
  395. return rc;
  396. }
  397. }
  398. return 0;
  399. }
  400. void hypfs_diag_exit(void)
  401. {
  402. debugfs_remove(dbfs_d204_file);
  403. diag224_delete_name_table();
  404. diag204_free_buffer();
  405. hypfs_dbfs_remove_file(&dbfs_file_d204);
  406. }
  407. /*
  408. * Functions to create the directory structure
  409. * *******************************************
  410. */
  411. static int hypfs_create_cpu_files(struct dentry *cpus_dir, void *cpu_info)
  412. {
  413. struct dentry *cpu_dir;
  414. char buffer[TMP_SIZE];
  415. void *rc;
  416. snprintf(buffer, TMP_SIZE, "%d", cpu_info__cpu_addr(diag204_info_type,
  417. cpu_info));
  418. cpu_dir = hypfs_mkdir(cpus_dir, buffer);
  419. rc = hypfs_create_u64(cpu_dir, "mgmtime",
  420. cpu_info__acc_time(diag204_info_type, cpu_info) -
  421. cpu_info__lp_time(diag204_info_type, cpu_info));
  422. if (IS_ERR(rc))
  423. return PTR_ERR(rc);
  424. rc = hypfs_create_u64(cpu_dir, "cputime",
  425. cpu_info__lp_time(diag204_info_type, cpu_info));
  426. if (IS_ERR(rc))
  427. return PTR_ERR(rc);
  428. if (diag204_info_type == DIAG204_INFO_EXT) {
  429. rc = hypfs_create_u64(cpu_dir, "onlinetime",
  430. cpu_info__online_time(diag204_info_type,
  431. cpu_info));
  432. if (IS_ERR(rc))
  433. return PTR_ERR(rc);
  434. }
  435. diag224_idx2name(cpu_info__ctidx(diag204_info_type, cpu_info), buffer);
  436. rc = hypfs_create_str(cpu_dir, "type", buffer);
  437. return PTR_RET(rc);
  438. }
  439. static void *hypfs_create_lpar_files(struct dentry *systems_dir, void *part_hdr)
  440. {
  441. struct dentry *cpus_dir;
  442. struct dentry *lpar_dir;
  443. char lpar_name[DIAG204_LPAR_NAME_LEN + 1];
  444. void *cpu_info;
  445. int i;
  446. part_hdr__part_name(diag204_info_type, part_hdr, lpar_name);
  447. lpar_name[DIAG204_LPAR_NAME_LEN] = 0;
  448. lpar_dir = hypfs_mkdir(systems_dir, lpar_name);
  449. if (IS_ERR(lpar_dir))
  450. return lpar_dir;
  451. cpus_dir = hypfs_mkdir(lpar_dir, "cpus");
  452. if (IS_ERR(cpus_dir))
  453. return cpus_dir;
  454. cpu_info = part_hdr + part_hdr__size(diag204_info_type);
  455. for (i = 0; i < part_hdr__rcpus(diag204_info_type, part_hdr); i++) {
  456. int rc;
  457. rc = hypfs_create_cpu_files(cpus_dir, cpu_info);
  458. if (rc)
  459. return ERR_PTR(rc);
  460. cpu_info += cpu_info__size(diag204_info_type);
  461. }
  462. return cpu_info;
  463. }
  464. static int hypfs_create_phys_cpu_files(struct dentry *cpus_dir, void *cpu_info)
  465. {
  466. struct dentry *cpu_dir;
  467. char buffer[TMP_SIZE];
  468. void *rc;
  469. snprintf(buffer, TMP_SIZE, "%i", phys_cpu__cpu_addr(diag204_info_type,
  470. cpu_info));
  471. cpu_dir = hypfs_mkdir(cpus_dir, buffer);
  472. if (IS_ERR(cpu_dir))
  473. return PTR_ERR(cpu_dir);
  474. rc = hypfs_create_u64(cpu_dir, "mgmtime",
  475. phys_cpu__mgm_time(diag204_info_type, cpu_info));
  476. if (IS_ERR(rc))
  477. return PTR_ERR(rc);
  478. diag224_idx2name(phys_cpu__ctidx(diag204_info_type, cpu_info), buffer);
  479. rc = hypfs_create_str(cpu_dir, "type", buffer);
  480. return PTR_RET(rc);
  481. }
  482. static void *hypfs_create_phys_files(struct dentry *parent_dir, void *phys_hdr)
  483. {
  484. int i;
  485. void *cpu_info;
  486. struct dentry *cpus_dir;
  487. cpus_dir = hypfs_mkdir(parent_dir, "cpus");
  488. if (IS_ERR(cpus_dir))
  489. return cpus_dir;
  490. cpu_info = phys_hdr + phys_hdr__size(diag204_info_type);
  491. for (i = 0; i < phys_hdr__cpus(diag204_info_type, phys_hdr); i++) {
  492. int rc;
  493. rc = hypfs_create_phys_cpu_files(cpus_dir, cpu_info);
  494. if (rc)
  495. return ERR_PTR(rc);
  496. cpu_info += phys_cpu__size(diag204_info_type);
  497. }
  498. return cpu_info;
  499. }
  500. int hypfs_diag_create_files(struct dentry *root)
  501. {
  502. struct dentry *systems_dir, *hyp_dir;
  503. void *time_hdr, *part_hdr;
  504. int i, rc;
  505. void *buffer, *ptr;
  506. buffer = diag204_store();
  507. if (IS_ERR(buffer))
  508. return PTR_ERR(buffer);
  509. systems_dir = hypfs_mkdir(root, "systems");
  510. if (IS_ERR(systems_dir)) {
  511. rc = PTR_ERR(systems_dir);
  512. goto err_out;
  513. }
  514. time_hdr = (struct x_info_blk_hdr *)buffer;
  515. part_hdr = time_hdr + info_blk_hdr__size(diag204_info_type);
  516. for (i = 0; i < info_blk_hdr__npar(diag204_info_type, time_hdr); i++) {
  517. part_hdr = hypfs_create_lpar_files(systems_dir, part_hdr);
  518. if (IS_ERR(part_hdr)) {
  519. rc = PTR_ERR(part_hdr);
  520. goto err_out;
  521. }
  522. }
  523. if (info_blk_hdr__flags(diag204_info_type, time_hdr) &
  524. DIAG204_LPAR_PHYS_FLG) {
  525. ptr = hypfs_create_phys_files(root, part_hdr);
  526. if (IS_ERR(ptr)) {
  527. rc = PTR_ERR(ptr);
  528. goto err_out;
  529. }
  530. }
  531. hyp_dir = hypfs_mkdir(root, "hyp");
  532. if (IS_ERR(hyp_dir)) {
  533. rc = PTR_ERR(hyp_dir);
  534. goto err_out;
  535. }
  536. ptr = hypfs_create_str(hyp_dir, "type", "LPAR Hypervisor");
  537. if (IS_ERR(ptr)) {
  538. rc = PTR_ERR(ptr);
  539. goto err_out;
  540. }
  541. rc = 0;
  542. err_out:
  543. return rc;
  544. }