sclp_cmd.c 16 KB

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