sclp_cmd.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  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. rc = -EIO;
  285. break;
  286. }
  287. out:
  288. free_page((unsigned long) sccb);
  289. return rc;
  290. }
  291. static int sclp_assign_storage(u16 rn)
  292. {
  293. return do_assign_storage(0x000d0001, rn);
  294. }
  295. static int sclp_unassign_storage(u16 rn)
  296. {
  297. return do_assign_storage(0x000c0001, rn);
  298. }
  299. struct attach_storage_sccb {
  300. struct sccb_header header;
  301. u16 :16;
  302. u16 assigned;
  303. u32 :32;
  304. u32 entries[0];
  305. } __packed;
  306. static int sclp_attach_storage(u8 id)
  307. {
  308. struct attach_storage_sccb *sccb;
  309. int rc;
  310. int i;
  311. sccb = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
  312. if (!sccb)
  313. return -ENOMEM;
  314. sccb->header.length = PAGE_SIZE;
  315. rc = do_sync_request(0x00080001 | id << 8, sccb);
  316. if (rc)
  317. goto out;
  318. switch (sccb->header.response_code) {
  319. case 0x0020:
  320. set_bit(id, sclp_storage_ids);
  321. for (i = 0; i < sccb->assigned; i++)
  322. sclp_unassign_storage(sccb->entries[i] >> 16);
  323. break;
  324. default:
  325. rc = -EIO;
  326. break;
  327. }
  328. out:
  329. free_page((unsigned long) sccb);
  330. return rc;
  331. }
  332. static int sclp_mem_change_state(unsigned long start, unsigned long size,
  333. int online)
  334. {
  335. struct memory_increment *incr;
  336. unsigned long long istart;
  337. int rc = 0;
  338. list_for_each_entry(incr, &sclp_mem_list, list) {
  339. istart = rn2addr(incr->rn);
  340. if (start + size - 1 < istart)
  341. break;
  342. if (start > istart + rzm - 1)
  343. continue;
  344. if (online) {
  345. if (incr->usecount++)
  346. continue;
  347. /*
  348. * Don't break the loop if one assign fails. Loop may
  349. * be walked again on CANCEL and we can't save
  350. * information if state changed before or not.
  351. * So continue and increase usecount for all increments.
  352. */
  353. rc |= sclp_assign_storage(incr->rn);
  354. } else {
  355. if (--incr->usecount)
  356. continue;
  357. sclp_unassign_storage(incr->rn);
  358. }
  359. }
  360. return rc ? -EIO : 0;
  361. }
  362. static int sclp_mem_notifier(struct notifier_block *nb,
  363. unsigned long action, void *data)
  364. {
  365. unsigned long start, size;
  366. struct memory_notify *arg;
  367. unsigned char id;
  368. int rc = 0;
  369. arg = data;
  370. start = arg->start_pfn << PAGE_SHIFT;
  371. size = arg->nr_pages << PAGE_SHIFT;
  372. mutex_lock(&sclp_mem_mutex);
  373. for (id = 0; id <= sclp_max_storage_id; id++)
  374. if (!test_bit(id, sclp_storage_ids))
  375. sclp_attach_storage(id);
  376. switch (action) {
  377. case MEM_ONLINE:
  378. case MEM_GOING_OFFLINE:
  379. case MEM_CANCEL_OFFLINE:
  380. break;
  381. case MEM_GOING_ONLINE:
  382. rc = sclp_mem_change_state(start, size, 1);
  383. break;
  384. case MEM_CANCEL_ONLINE:
  385. sclp_mem_change_state(start, size, 0);
  386. break;
  387. case MEM_OFFLINE:
  388. sclp_mem_change_state(start, size, 0);
  389. break;
  390. default:
  391. rc = -EINVAL;
  392. break;
  393. }
  394. mutex_unlock(&sclp_mem_mutex);
  395. return rc ? NOTIFY_BAD : NOTIFY_OK;
  396. }
  397. static struct notifier_block sclp_mem_nb = {
  398. .notifier_call = sclp_mem_notifier,
  399. };
  400. static void __init add_memory_merged(u16 rn)
  401. {
  402. static u16 first_rn, num;
  403. unsigned long long start, size;
  404. if (rn && first_rn && (first_rn + num == rn)) {
  405. num++;
  406. return;
  407. }
  408. if (!first_rn)
  409. goto skip_add;
  410. start = rn2addr(first_rn);
  411. size = (unsigned long long ) num * rzm;
  412. if (start >= VMEM_MAX_PHYS)
  413. goto skip_add;
  414. if (start + size > VMEM_MAX_PHYS)
  415. size = VMEM_MAX_PHYS - start;
  416. add_memory(0, start, size);
  417. skip_add:
  418. first_rn = rn;
  419. num = 1;
  420. }
  421. static void __init sclp_add_standby_memory(void)
  422. {
  423. struct memory_increment *incr;
  424. list_for_each_entry(incr, &sclp_mem_list, list)
  425. if (incr->standby)
  426. add_memory_merged(incr->rn);
  427. add_memory_merged(0);
  428. }
  429. static void __init insert_increment(u16 rn, int standby, int assigned)
  430. {
  431. struct memory_increment *incr, *new_incr;
  432. struct list_head *prev;
  433. u16 last_rn;
  434. new_incr = kzalloc(sizeof(*new_incr), GFP_KERNEL);
  435. if (!new_incr)
  436. return;
  437. new_incr->rn = rn;
  438. new_incr->standby = standby;
  439. last_rn = 0;
  440. prev = &sclp_mem_list;
  441. list_for_each_entry(incr, &sclp_mem_list, list) {
  442. if (assigned && incr->rn > rn)
  443. break;
  444. if (!assigned && incr->rn - last_rn > 1)
  445. break;
  446. last_rn = incr->rn;
  447. prev = &incr->list;
  448. }
  449. if (!assigned)
  450. new_incr->rn = last_rn + 1;
  451. if (new_incr->rn > rnmax) {
  452. kfree(new_incr);
  453. return;
  454. }
  455. list_add(&new_incr->list, prev);
  456. }
  457. struct read_storage_sccb {
  458. struct sccb_header header;
  459. u16 max_id;
  460. u16 assigned;
  461. u16 standby;
  462. u16 :16;
  463. u32 entries[0];
  464. } __packed;
  465. static int __init sclp_detect_standby_memory(void)
  466. {
  467. struct read_storage_sccb *sccb;
  468. int i, id, assigned, rc;
  469. if (!early_read_info_sccb_valid)
  470. return 0;
  471. if ((sclp_facilities & 0xe00000000000ULL) != 0xe00000000000ULL)
  472. return 0;
  473. rc = -ENOMEM;
  474. sccb = (void *) __get_free_page(GFP_KERNEL | GFP_DMA);
  475. if (!sccb)
  476. goto out;
  477. assigned = 0;
  478. for (id = 0; id <= sclp_max_storage_id; id++) {
  479. memset(sccb, 0, PAGE_SIZE);
  480. sccb->header.length = PAGE_SIZE;
  481. rc = do_sync_request(0x00040001 | id << 8, sccb);
  482. if (rc)
  483. goto out;
  484. switch (sccb->header.response_code) {
  485. case 0x0010:
  486. set_bit(id, sclp_storage_ids);
  487. for (i = 0; i < sccb->assigned; i++) {
  488. if (!sccb->entries[i])
  489. continue;
  490. assigned++;
  491. insert_increment(sccb->entries[i] >> 16, 0, 1);
  492. }
  493. break;
  494. case 0x0310:
  495. break;
  496. case 0x0410:
  497. for (i = 0; i < sccb->assigned; i++) {
  498. if (!sccb->entries[i])
  499. continue;
  500. assigned++;
  501. insert_increment(sccb->entries[i] >> 16, 1, 1);
  502. }
  503. break;
  504. default:
  505. rc = -EIO;
  506. break;
  507. }
  508. if (!rc)
  509. sclp_max_storage_id = sccb->max_id;
  510. }
  511. if (rc || list_empty(&sclp_mem_list))
  512. goto out;
  513. for (i = 1; i <= rnmax - assigned; i++)
  514. insert_increment(0, 1, 0);
  515. rc = register_memory_notifier(&sclp_mem_nb);
  516. if (rc)
  517. goto out;
  518. sclp_add_standby_memory();
  519. out:
  520. free_page((unsigned long) sccb);
  521. return rc;
  522. }
  523. __initcall(sclp_detect_standby_memory);
  524. #endif /* CONFIG_MEMORY_HOTPLUG */
  525. /*
  526. * Channel path configuration related functions.
  527. */
  528. #define SCLP_CMDW_CONFIGURE_CHPATH 0x000f0001
  529. #define SCLP_CMDW_DECONFIGURE_CHPATH 0x000e0001
  530. #define SCLP_CMDW_READ_CHPATH_INFORMATION 0x00030001
  531. struct chp_cfg_sccb {
  532. struct sccb_header header;
  533. u8 ccm;
  534. u8 reserved[6];
  535. u8 cssid;
  536. } __attribute__((packed));
  537. static int do_chp_configure(sclp_cmdw_t cmd)
  538. {
  539. struct chp_cfg_sccb *sccb;
  540. int rc;
  541. if (!SCLP_HAS_CHP_RECONFIG)
  542. return -EOPNOTSUPP;
  543. /* Prepare sccb. */
  544. sccb = (struct chp_cfg_sccb *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
  545. if (!sccb)
  546. return -ENOMEM;
  547. sccb->header.length = sizeof(*sccb);
  548. rc = do_sync_request(cmd, sccb);
  549. if (rc)
  550. goto out;
  551. switch (sccb->header.response_code) {
  552. case 0x0020:
  553. case 0x0120:
  554. case 0x0440:
  555. case 0x0450:
  556. break;
  557. default:
  558. printk(KERN_WARNING TAG "configure channel-path failed "
  559. "(cmd=0x%08x, response=0x%04x)\n", cmd,
  560. sccb->header.response_code);
  561. rc = -EIO;
  562. break;
  563. }
  564. out:
  565. free_page((unsigned long) sccb);
  566. return rc;
  567. }
  568. /**
  569. * sclp_chp_configure - perform configure channel-path sclp command
  570. * @chpid: channel-path ID
  571. *
  572. * Perform configure channel-path command sclp command for specified chpid.
  573. * Return 0 after command successfully finished, non-zero otherwise.
  574. */
  575. int sclp_chp_configure(struct chp_id chpid)
  576. {
  577. return do_chp_configure(SCLP_CMDW_CONFIGURE_CHPATH | chpid.id << 8);
  578. }
  579. /**
  580. * sclp_chp_deconfigure - perform deconfigure channel-path sclp command
  581. * @chpid: channel-path ID
  582. *
  583. * Perform deconfigure channel-path command sclp command for specified chpid
  584. * and wait for completion. On success return 0. Return non-zero otherwise.
  585. */
  586. int sclp_chp_deconfigure(struct chp_id chpid)
  587. {
  588. return do_chp_configure(SCLP_CMDW_DECONFIGURE_CHPATH | chpid.id << 8);
  589. }
  590. struct chp_info_sccb {
  591. struct sccb_header header;
  592. u8 recognized[SCLP_CHP_INFO_MASK_SIZE];
  593. u8 standby[SCLP_CHP_INFO_MASK_SIZE];
  594. u8 configured[SCLP_CHP_INFO_MASK_SIZE];
  595. u8 ccm;
  596. u8 reserved[6];
  597. u8 cssid;
  598. } __attribute__((packed));
  599. /**
  600. * sclp_chp_read_info - perform read channel-path information sclp command
  601. * @info: resulting channel-path information data
  602. *
  603. * Perform read channel-path information sclp command and wait for completion.
  604. * On success, store channel-path information in @info and return 0. Return
  605. * non-zero otherwise.
  606. */
  607. int sclp_chp_read_info(struct sclp_chp_info *info)
  608. {
  609. struct chp_info_sccb *sccb;
  610. int rc;
  611. if (!SCLP_HAS_CHP_INFO)
  612. return -EOPNOTSUPP;
  613. /* Prepare sccb. */
  614. sccb = (struct chp_info_sccb *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
  615. if (!sccb)
  616. return -ENOMEM;
  617. sccb->header.length = sizeof(*sccb);
  618. rc = do_sync_request(SCLP_CMDW_READ_CHPATH_INFORMATION, sccb);
  619. if (rc)
  620. goto out;
  621. if (sccb->header.response_code != 0x0010) {
  622. printk(KERN_WARNING TAG "read channel-path info failed "
  623. "(response=0x%04x)\n", sccb->header.response_code);
  624. rc = -EIO;
  625. goto out;
  626. }
  627. memcpy(info->recognized, sccb->recognized, SCLP_CHP_INFO_MASK_SIZE);
  628. memcpy(info->standby, sccb->standby, SCLP_CHP_INFO_MASK_SIZE);
  629. memcpy(info->configured, sccb->configured, SCLP_CHP_INFO_MASK_SIZE);
  630. out:
  631. free_page((unsigned long) sccb);
  632. return rc;
  633. }