sclp_cmd.c 16 KB

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