sclp_cmd.c 16 KB

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