sclp_cmd.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. /*
  2. * drivers/s390/char/sclp_cmd.c
  3. *
  4. * Copyright IBM Corp. 2007
  5. * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>,
  6. * Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
  7. */
  8. #define KMSG_COMPONENT "sclp_cmd"
  9. #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
  10. #include <linux/completion.h>
  11. #include <linux/init.h>
  12. #include <linux/errno.h>
  13. #include <linux/slab.h>
  14. #include <linux/string.h>
  15. #include <linux/mm.h>
  16. #include <linux/mmzone.h>
  17. #include <linux/memory.h>
  18. #include <asm/chpid.h>
  19. #include <asm/sclp.h>
  20. #include <asm/setup.h>
  21. #include "sclp.h"
  22. #define SCLP_CMDW_READ_SCP_INFO 0x00020001
  23. #define SCLP_CMDW_READ_SCP_INFO_FORCED 0x00120001
  24. struct read_info_sccb {
  25. struct sccb_header header; /* 0-7 */
  26. u16 rnmax; /* 8-9 */
  27. u8 rnsize; /* 10 */
  28. u8 _reserved0[24 - 11]; /* 11-15 */
  29. u8 loadparm[8]; /* 24-31 */
  30. u8 _reserved1[48 - 32]; /* 32-47 */
  31. u64 facilities; /* 48-55 */
  32. u8 _reserved2[84 - 56]; /* 56-83 */
  33. u8 fac84; /* 84 */
  34. u8 _reserved3[91 - 85]; /* 85-90 */
  35. u8 flags; /* 91 */
  36. u8 _reserved4[100 - 92]; /* 92-99 */
  37. u32 rnsize2; /* 100-103 */
  38. u64 rnmax2; /* 104-111 */
  39. u8 _reserved5[4096 - 112]; /* 112-4095 */
  40. } __attribute__((packed, aligned(PAGE_SIZE)));
  41. static struct read_info_sccb __initdata early_read_info_sccb;
  42. static int __initdata early_read_info_sccb_valid;
  43. u64 sclp_facilities;
  44. static u8 sclp_fac84;
  45. static unsigned long long rzm;
  46. static unsigned long long rnmax;
  47. static int __init sclp_cmd_sync_early(sclp_cmdw_t cmd, void *sccb)
  48. {
  49. int rc;
  50. __ctl_set_bit(0, 9);
  51. rc = sclp_service_call(cmd, sccb);
  52. if (rc)
  53. goto out;
  54. __load_psw_mask(PSW_BASE_BITS | PSW_MASK_EXT |
  55. PSW_MASK_WAIT | PSW_DEFAULT_KEY);
  56. local_irq_disable();
  57. out:
  58. /* Contents of the sccb might have changed. */
  59. barrier();
  60. __ctl_clear_bit(0, 9);
  61. return rc;
  62. }
  63. static void __init sclp_read_info_early(void)
  64. {
  65. int rc;
  66. int i;
  67. struct read_info_sccb *sccb;
  68. sclp_cmdw_t commands[] = {SCLP_CMDW_READ_SCP_INFO_FORCED,
  69. SCLP_CMDW_READ_SCP_INFO};
  70. sccb = &early_read_info_sccb;
  71. for (i = 0; i < ARRAY_SIZE(commands); i++) {
  72. do {
  73. memset(sccb, 0, sizeof(*sccb));
  74. sccb->header.length = sizeof(*sccb);
  75. sccb->header.control_mask[2] = 0x80;
  76. rc = sclp_cmd_sync_early(commands[i], sccb);
  77. } while (rc == -EBUSY);
  78. if (rc)
  79. break;
  80. if (sccb->header.response_code == 0x10) {
  81. early_read_info_sccb_valid = 1;
  82. break;
  83. }
  84. if (sccb->header.response_code != 0x1f0)
  85. break;
  86. }
  87. }
  88. void __init sclp_facilities_detect(void)
  89. {
  90. struct read_info_sccb *sccb;
  91. sclp_read_info_early();
  92. if (!early_read_info_sccb_valid)
  93. return;
  94. sccb = &early_read_info_sccb;
  95. sclp_facilities = sccb->facilities;
  96. sclp_fac84 = sccb->fac84;
  97. rnmax = sccb->rnmax ? sccb->rnmax : sccb->rnmax2;
  98. rzm = sccb->rnsize ? sccb->rnsize : sccb->rnsize2;
  99. rzm <<= 20;
  100. }
  101. unsigned long long sclp_get_rnmax(void)
  102. {
  103. return rnmax;
  104. }
  105. unsigned long long sclp_get_rzm(void)
  106. {
  107. return rzm;
  108. }
  109. /*
  110. * This function will be called after sclp_facilities_detect(), which gets
  111. * called from early.c code. Therefore the sccb should have valid contents.
  112. */
  113. void __init sclp_get_ipl_info(struct sclp_ipl_info *info)
  114. {
  115. struct read_info_sccb *sccb;
  116. if (!early_read_info_sccb_valid)
  117. return;
  118. sccb = &early_read_info_sccb;
  119. info->is_valid = 1;
  120. if (sccb->flags & 0x2)
  121. info->has_dump = 1;
  122. memcpy(&info->loadparm, &sccb->loadparm, LOADPARM_LEN);
  123. }
  124. static void sclp_sync_callback(struct sclp_req *req, void *data)
  125. {
  126. struct completion *completion = data;
  127. complete(completion);
  128. }
  129. static int do_sync_request(sclp_cmdw_t cmd, void *sccb)
  130. {
  131. struct completion completion;
  132. struct sclp_req *request;
  133. int rc;
  134. request = kzalloc(sizeof(*request), GFP_KERNEL);
  135. if (!request)
  136. return -ENOMEM;
  137. request->command = cmd;
  138. request->sccb = sccb;
  139. request->status = SCLP_REQ_FILLED;
  140. request->callback = sclp_sync_callback;
  141. request->callback_data = &completion;
  142. init_completion(&completion);
  143. /* Perform sclp request. */
  144. rc = sclp_add_request(request);
  145. if (rc)
  146. goto out;
  147. wait_for_completion(&completion);
  148. /* Check response. */
  149. if (request->status != SCLP_REQ_DONE) {
  150. pr_warning("sync request failed (cmd=0x%08x, "
  151. "status=0x%02x)\n", cmd, request->status);
  152. rc = -EIO;
  153. }
  154. out:
  155. kfree(request);
  156. return rc;
  157. }
  158. /*
  159. * CPU configuration related functions.
  160. */
  161. #define SCLP_CMDW_READ_CPU_INFO 0x00010001
  162. #define SCLP_CMDW_CONFIGURE_CPU 0x00110001
  163. #define SCLP_CMDW_DECONFIGURE_CPU 0x00100001
  164. struct read_cpu_info_sccb {
  165. struct sccb_header header;
  166. u16 nr_configured;
  167. u16 offset_configured;
  168. u16 nr_standby;
  169. u16 offset_standby;
  170. u8 reserved[4096 - 16];
  171. } __attribute__((packed, aligned(PAGE_SIZE)));
  172. static void sclp_fill_cpu_info(struct sclp_cpu_info *info,
  173. struct read_cpu_info_sccb *sccb)
  174. {
  175. char *page = (char *) sccb;
  176. memset(info, 0, sizeof(*info));
  177. info->configured = sccb->nr_configured;
  178. info->standby = sccb->nr_standby;
  179. info->combined = sccb->nr_configured + sccb->nr_standby;
  180. info->has_cpu_type = sclp_fac84 & 0x1;
  181. memcpy(&info->cpu, page + sccb->offset_configured,
  182. info->combined * sizeof(struct sclp_cpu_entry));
  183. }
  184. int sclp_get_cpu_info(struct sclp_cpu_info *info)
  185. {
  186. int rc;
  187. struct read_cpu_info_sccb *sccb;
  188. if (!SCLP_HAS_CPU_INFO)
  189. return -EOPNOTSUPP;
  190. sccb = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
  191. if (!sccb)
  192. return -ENOMEM;
  193. sccb->header.length = sizeof(*sccb);
  194. rc = do_sync_request(SCLP_CMDW_READ_CPU_INFO, sccb);
  195. if (rc)
  196. goto out;
  197. if (sccb->header.response_code != 0x0010) {
  198. pr_warning("readcpuinfo failed (response=0x%04x)\n",
  199. sccb->header.response_code);
  200. rc = -EIO;
  201. goto out;
  202. }
  203. sclp_fill_cpu_info(info, sccb);
  204. out:
  205. free_page((unsigned long) sccb);
  206. return rc;
  207. }
  208. struct cpu_configure_sccb {
  209. struct sccb_header header;
  210. } __attribute__((packed, aligned(8)));
  211. static int do_cpu_configure(sclp_cmdw_t cmd)
  212. {
  213. struct cpu_configure_sccb *sccb;
  214. int rc;
  215. if (!SCLP_HAS_CPU_RECONFIG)
  216. return -EOPNOTSUPP;
  217. /*
  218. * This is not going to cross a page boundary since we force
  219. * kmalloc to have a minimum alignment of 8 bytes on s390.
  220. */
  221. sccb = kzalloc(sizeof(*sccb), GFP_KERNEL | GFP_DMA);
  222. if (!sccb)
  223. return -ENOMEM;
  224. sccb->header.length = sizeof(*sccb);
  225. rc = do_sync_request(cmd, sccb);
  226. if (rc)
  227. goto out;
  228. switch (sccb->header.response_code) {
  229. case 0x0020:
  230. case 0x0120:
  231. break;
  232. default:
  233. pr_warning("configure cpu failed (cmd=0x%08x, "
  234. "response=0x%04x)\n", cmd,
  235. sccb->header.response_code);
  236. rc = -EIO;
  237. break;
  238. }
  239. out:
  240. kfree(sccb);
  241. return rc;
  242. }
  243. int sclp_cpu_configure(u8 cpu)
  244. {
  245. return do_cpu_configure(SCLP_CMDW_CONFIGURE_CPU | cpu << 8);
  246. }
  247. int sclp_cpu_deconfigure(u8 cpu)
  248. {
  249. return do_cpu_configure(SCLP_CMDW_DECONFIGURE_CPU | cpu << 8);
  250. }
  251. #ifdef CONFIG_MEMORY_HOTPLUG
  252. static DEFINE_MUTEX(sclp_mem_mutex);
  253. static LIST_HEAD(sclp_mem_list);
  254. static u8 sclp_max_storage_id;
  255. static unsigned long sclp_storage_ids[256 / BITS_PER_LONG];
  256. struct memory_increment {
  257. struct list_head list;
  258. u16 rn;
  259. int standby;
  260. int usecount;
  261. };
  262. struct assign_storage_sccb {
  263. struct sccb_header header;
  264. u16 rn;
  265. } __packed;
  266. static unsigned long long rn2addr(u16 rn)
  267. {
  268. return (unsigned long long) (rn - 1) * rzm;
  269. }
  270. static int do_assign_storage(sclp_cmdw_t cmd, u16 rn)
  271. {
  272. struct assign_storage_sccb *sccb;
  273. int rc;
  274. sccb = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
  275. if (!sccb)
  276. return -ENOMEM;
  277. sccb->header.length = PAGE_SIZE;
  278. sccb->rn = rn;
  279. rc = do_sync_request(cmd, sccb);
  280. if (rc)
  281. goto out;
  282. switch (sccb->header.response_code) {
  283. case 0x0020:
  284. case 0x0120:
  285. break;
  286. default:
  287. pr_warning("assign storage failed (cmd=0x%08x, "
  288. "response=0x%04x, rn=0x%04x)\n", cmd,
  289. sccb->header.response_code, rn);
  290. rc = -EIO;
  291. break;
  292. }
  293. out:
  294. free_page((unsigned long) sccb);
  295. return rc;
  296. }
  297. static int sclp_assign_storage(u16 rn)
  298. {
  299. return do_assign_storage(0x000d0001, rn);
  300. }
  301. static int sclp_unassign_storage(u16 rn)
  302. {
  303. return do_assign_storage(0x000c0001, rn);
  304. }
  305. struct attach_storage_sccb {
  306. struct sccb_header header;
  307. u16 :16;
  308. u16 assigned;
  309. u32 :32;
  310. u32 entries[0];
  311. } __packed;
  312. static int sclp_attach_storage(u8 id)
  313. {
  314. struct attach_storage_sccb *sccb;
  315. int rc;
  316. int i;
  317. sccb = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
  318. if (!sccb)
  319. return -ENOMEM;
  320. sccb->header.length = PAGE_SIZE;
  321. rc = do_sync_request(0x00080001 | id << 8, sccb);
  322. if (rc)
  323. goto out;
  324. switch (sccb->header.response_code) {
  325. case 0x0020:
  326. set_bit(id, sclp_storage_ids);
  327. for (i = 0; i < sccb->assigned; i++)
  328. sclp_unassign_storage(sccb->entries[i] >> 16);
  329. break;
  330. default:
  331. rc = -EIO;
  332. break;
  333. }
  334. out:
  335. free_page((unsigned long) sccb);
  336. return rc;
  337. }
  338. static int sclp_mem_change_state(unsigned long start, unsigned long size,
  339. int online)
  340. {
  341. struct memory_increment *incr;
  342. unsigned long long istart;
  343. int rc = 0;
  344. list_for_each_entry(incr, &sclp_mem_list, list) {
  345. istart = rn2addr(incr->rn);
  346. if (start + size - 1 < istart)
  347. break;
  348. if (start > istart + rzm - 1)
  349. continue;
  350. if (online) {
  351. if (incr->usecount++)
  352. continue;
  353. /*
  354. * Don't break the loop if one assign fails. Loop may
  355. * be walked again on CANCEL and we can't save
  356. * information if state changed before or not.
  357. * So continue and increase usecount for all increments.
  358. */
  359. rc |= sclp_assign_storage(incr->rn);
  360. } else {
  361. if (--incr->usecount)
  362. continue;
  363. sclp_unassign_storage(incr->rn);
  364. }
  365. }
  366. return rc ? -EIO : 0;
  367. }
  368. static int sclp_mem_notifier(struct notifier_block *nb,
  369. unsigned long action, void *data)
  370. {
  371. unsigned long start, size;
  372. struct memory_notify *arg;
  373. unsigned char id;
  374. int rc = 0;
  375. arg = data;
  376. start = arg->start_pfn << PAGE_SHIFT;
  377. size = arg->nr_pages << PAGE_SHIFT;
  378. mutex_lock(&sclp_mem_mutex);
  379. for (id = 0; id <= sclp_max_storage_id; id++)
  380. if (!test_bit(id, sclp_storage_ids))
  381. sclp_attach_storage(id);
  382. switch (action) {
  383. case MEM_ONLINE:
  384. case MEM_GOING_OFFLINE:
  385. case MEM_CANCEL_OFFLINE:
  386. break;
  387. case MEM_GOING_ONLINE:
  388. rc = sclp_mem_change_state(start, size, 1);
  389. break;
  390. case MEM_CANCEL_ONLINE:
  391. sclp_mem_change_state(start, size, 0);
  392. break;
  393. case MEM_OFFLINE:
  394. sclp_mem_change_state(start, size, 0);
  395. break;
  396. default:
  397. rc = -EINVAL;
  398. break;
  399. }
  400. mutex_unlock(&sclp_mem_mutex);
  401. return rc ? NOTIFY_BAD : NOTIFY_OK;
  402. }
  403. static struct notifier_block sclp_mem_nb = {
  404. .notifier_call = sclp_mem_notifier,
  405. };
  406. static void __init add_memory_merged(u16 rn)
  407. {
  408. static u16 first_rn, num;
  409. unsigned long long start, size;
  410. if (rn && first_rn && (first_rn + num == rn)) {
  411. num++;
  412. return;
  413. }
  414. if (!first_rn)
  415. goto skip_add;
  416. start = rn2addr(first_rn);
  417. size = (unsigned long long ) num * rzm;
  418. if (start >= VMEM_MAX_PHYS)
  419. goto skip_add;
  420. if (start + size > VMEM_MAX_PHYS)
  421. size = VMEM_MAX_PHYS - start;
  422. if (memory_end_set && (start >= memory_end))
  423. goto skip_add;
  424. if (memory_end_set && (start + size > memory_end))
  425. size = memory_end - start;
  426. add_memory(0, start, size);
  427. skip_add:
  428. first_rn = rn;
  429. num = 1;
  430. }
  431. static void __init sclp_add_standby_memory(void)
  432. {
  433. struct memory_increment *incr;
  434. list_for_each_entry(incr, &sclp_mem_list, list)
  435. if (incr->standby)
  436. add_memory_merged(incr->rn);
  437. add_memory_merged(0);
  438. }
  439. static void __init insert_increment(u16 rn, int standby, int assigned)
  440. {
  441. struct memory_increment *incr, *new_incr;
  442. struct list_head *prev;
  443. u16 last_rn;
  444. new_incr = kzalloc(sizeof(*new_incr), GFP_KERNEL);
  445. if (!new_incr)
  446. return;
  447. new_incr->rn = rn;
  448. new_incr->standby = standby;
  449. last_rn = 0;
  450. prev = &sclp_mem_list;
  451. list_for_each_entry(incr, &sclp_mem_list, list) {
  452. if (assigned && incr->rn > rn)
  453. break;
  454. if (!assigned && incr->rn - last_rn > 1)
  455. break;
  456. last_rn = incr->rn;
  457. prev = &incr->list;
  458. }
  459. if (!assigned)
  460. new_incr->rn = last_rn + 1;
  461. if (new_incr->rn > rnmax) {
  462. kfree(new_incr);
  463. return;
  464. }
  465. list_add(&new_incr->list, prev);
  466. }
  467. struct read_storage_sccb {
  468. struct sccb_header header;
  469. u16 max_id;
  470. u16 assigned;
  471. u16 standby;
  472. u16 :16;
  473. u32 entries[0];
  474. } __packed;
  475. static int __init sclp_detect_standby_memory(void)
  476. {
  477. struct read_storage_sccb *sccb;
  478. int i, id, assigned, rc;
  479. if (!early_read_info_sccb_valid)
  480. return 0;
  481. if ((sclp_facilities & 0xe00000000000ULL) != 0xe00000000000ULL)
  482. return 0;
  483. rc = -ENOMEM;
  484. sccb = (void *) __get_free_page(GFP_KERNEL | GFP_DMA);
  485. if (!sccb)
  486. goto out;
  487. assigned = 0;
  488. for (id = 0; id <= sclp_max_storage_id; id++) {
  489. memset(sccb, 0, PAGE_SIZE);
  490. sccb->header.length = PAGE_SIZE;
  491. rc = do_sync_request(0x00040001 | id << 8, sccb);
  492. if (rc)
  493. goto out;
  494. switch (sccb->header.response_code) {
  495. case 0x0010:
  496. set_bit(id, sclp_storage_ids);
  497. for (i = 0; i < sccb->assigned; i++) {
  498. if (!sccb->entries[i])
  499. continue;
  500. assigned++;
  501. insert_increment(sccb->entries[i] >> 16, 0, 1);
  502. }
  503. break;
  504. case 0x0310:
  505. break;
  506. case 0x0410:
  507. for (i = 0; i < sccb->assigned; i++) {
  508. if (!sccb->entries[i])
  509. continue;
  510. assigned++;
  511. insert_increment(sccb->entries[i] >> 16, 1, 1);
  512. }
  513. break;
  514. default:
  515. rc = -EIO;
  516. break;
  517. }
  518. if (!rc)
  519. sclp_max_storage_id = sccb->max_id;
  520. }
  521. if (rc || list_empty(&sclp_mem_list))
  522. goto out;
  523. for (i = 1; i <= rnmax - assigned; i++)
  524. insert_increment(0, 1, 0);
  525. rc = register_memory_notifier(&sclp_mem_nb);
  526. if (rc)
  527. goto out;
  528. sclp_add_standby_memory();
  529. out:
  530. free_page((unsigned long) sccb);
  531. return rc;
  532. }
  533. __initcall(sclp_detect_standby_memory);
  534. #endif /* CONFIG_MEMORY_HOTPLUG */
  535. /*
  536. * Channel path configuration related functions.
  537. */
  538. #define SCLP_CMDW_CONFIGURE_CHPATH 0x000f0001
  539. #define SCLP_CMDW_DECONFIGURE_CHPATH 0x000e0001
  540. #define SCLP_CMDW_READ_CHPATH_INFORMATION 0x00030001
  541. struct chp_cfg_sccb {
  542. struct sccb_header header;
  543. u8 ccm;
  544. u8 reserved[6];
  545. u8 cssid;
  546. } __attribute__((packed));
  547. static int do_chp_configure(sclp_cmdw_t cmd)
  548. {
  549. struct chp_cfg_sccb *sccb;
  550. int rc;
  551. if (!SCLP_HAS_CHP_RECONFIG)
  552. return -EOPNOTSUPP;
  553. /* Prepare sccb. */
  554. sccb = (struct chp_cfg_sccb *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
  555. if (!sccb)
  556. return -ENOMEM;
  557. sccb->header.length = sizeof(*sccb);
  558. rc = do_sync_request(cmd, sccb);
  559. if (rc)
  560. goto out;
  561. switch (sccb->header.response_code) {
  562. case 0x0020:
  563. case 0x0120:
  564. case 0x0440:
  565. case 0x0450:
  566. break;
  567. default:
  568. pr_warning("configure channel-path failed "
  569. "(cmd=0x%08x, response=0x%04x)\n", cmd,
  570. sccb->header.response_code);
  571. rc = -EIO;
  572. break;
  573. }
  574. out:
  575. free_page((unsigned long) sccb);
  576. return rc;
  577. }
  578. /**
  579. * sclp_chp_configure - perform configure channel-path sclp command
  580. * @chpid: channel-path ID
  581. *
  582. * Perform configure channel-path command sclp command for specified chpid.
  583. * Return 0 after command successfully finished, non-zero otherwise.
  584. */
  585. int sclp_chp_configure(struct chp_id chpid)
  586. {
  587. return do_chp_configure(SCLP_CMDW_CONFIGURE_CHPATH | chpid.id << 8);
  588. }
  589. /**
  590. * sclp_chp_deconfigure - perform deconfigure channel-path sclp command
  591. * @chpid: channel-path ID
  592. *
  593. * Perform deconfigure channel-path command sclp command for specified chpid
  594. * and wait for completion. On success return 0. Return non-zero otherwise.
  595. */
  596. int sclp_chp_deconfigure(struct chp_id chpid)
  597. {
  598. return do_chp_configure(SCLP_CMDW_DECONFIGURE_CHPATH | chpid.id << 8);
  599. }
  600. struct chp_info_sccb {
  601. struct sccb_header header;
  602. u8 recognized[SCLP_CHP_INFO_MASK_SIZE];
  603. u8 standby[SCLP_CHP_INFO_MASK_SIZE];
  604. u8 configured[SCLP_CHP_INFO_MASK_SIZE];
  605. u8 ccm;
  606. u8 reserved[6];
  607. u8 cssid;
  608. } __attribute__((packed));
  609. /**
  610. * sclp_chp_read_info - perform read channel-path information sclp command
  611. * @info: resulting channel-path information data
  612. *
  613. * Perform read channel-path information sclp command and wait for completion.
  614. * On success, store channel-path information in @info and return 0. Return
  615. * non-zero otherwise.
  616. */
  617. int sclp_chp_read_info(struct sclp_chp_info *info)
  618. {
  619. struct chp_info_sccb *sccb;
  620. int rc;
  621. if (!SCLP_HAS_CHP_INFO)
  622. return -EOPNOTSUPP;
  623. /* Prepare sccb. */
  624. sccb = (struct chp_info_sccb *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
  625. if (!sccb)
  626. return -ENOMEM;
  627. sccb->header.length = sizeof(*sccb);
  628. rc = do_sync_request(SCLP_CMDW_READ_CHPATH_INFORMATION, sccb);
  629. if (rc)
  630. goto out;
  631. if (sccb->header.response_code != 0x0010) {
  632. pr_warning("read channel-path info failed "
  633. "(response=0x%04x)\n", sccb->header.response_code);
  634. rc = -EIO;
  635. goto out;
  636. }
  637. memcpy(info->recognized, sccb->recognized, SCLP_CHP_INFO_MASK_SIZE);
  638. memcpy(info->standby, sccb->standby, SCLP_CHP_INFO_MASK_SIZE);
  639. memcpy(info->configured, sccb->configured, SCLP_CHP_INFO_MASK_SIZE);
  640. out:
  641. free_page((unsigned long) sccb);
  642. return rc;
  643. }