chp.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. /*
  2. * drivers/s390/cio/chp.c
  3. *
  4. * Copyright IBM Corp. 1999,2007
  5. * Author(s): Cornelia Huck (cornelia.huck@de.ibm.com)
  6. * Arnd Bergmann (arndb@de.ibm.com)
  7. * Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
  8. */
  9. #include <linux/bug.h>
  10. #include <linux/workqueue.h>
  11. #include <linux/spinlock.h>
  12. #include <linux/init.h>
  13. #include <linux/jiffies.h>
  14. #include <linux/wait.h>
  15. #include <linux/mutex.h>
  16. #include <linux/errno.h>
  17. #include <asm/chpid.h>
  18. #include <asm/sclp.h>
  19. #include "../s390mach.h"
  20. #include "cio.h"
  21. #include "css.h"
  22. #include "ioasm.h"
  23. #include "cio_debug.h"
  24. #include "chp.h"
  25. #define to_channelpath(device) container_of(device, struct channel_path, dev)
  26. #define CHP_INFO_UPDATE_INTERVAL 1*HZ
  27. enum cfg_task_t {
  28. cfg_none,
  29. cfg_configure,
  30. cfg_deconfigure
  31. };
  32. /* Map for pending configure tasks. */
  33. static enum cfg_task_t chp_cfg_task[__MAX_CSSID + 1][__MAX_CHPID + 1];
  34. static DEFINE_MUTEX(cfg_lock);
  35. static int cfg_busy;
  36. /* Map for channel-path status. */
  37. static struct sclp_chp_info chp_info;
  38. static DEFINE_MUTEX(info_lock);
  39. /* Time after which channel-path status may be outdated. */
  40. static unsigned long chp_info_expires;
  41. /* Workqueue to perform pending configure tasks. */
  42. static struct workqueue_struct *chp_wq;
  43. static struct work_struct cfg_work;
  44. /* Wait queue for configure completion events. */
  45. static wait_queue_head_t cfg_wait_queue;
  46. /* Return channel_path struct for given chpid. */
  47. static inline struct channel_path *chpid_to_chp(struct chp_id chpid)
  48. {
  49. return channel_subsystems[chpid.cssid]->chps[chpid.id];
  50. }
  51. /* Set vary state for given chpid. */
  52. static void set_chp_logically_online(struct chp_id chpid, int onoff)
  53. {
  54. chpid_to_chp(chpid)->state = onoff;
  55. }
  56. /* On succes return 0 if channel-path is varied offline, 1 if it is varied
  57. * online. Return -ENODEV if channel-path is not registered. */
  58. int chp_get_status(struct chp_id chpid)
  59. {
  60. return (chpid_to_chp(chpid) ? chpid_to_chp(chpid)->state : -ENODEV);
  61. }
  62. /**
  63. * chp_get_sch_opm - return opm for subchannel
  64. * @sch: subchannel
  65. *
  66. * Calculate and return the operational path mask (opm) based on the chpids
  67. * used by the subchannel and the status of the associated channel-paths.
  68. */
  69. u8 chp_get_sch_opm(struct subchannel *sch)
  70. {
  71. struct chp_id chpid;
  72. int opm;
  73. int i;
  74. opm = 0;
  75. chp_id_init(&chpid);
  76. for (i = 0; i < 8; i++) {
  77. opm <<= 1;
  78. chpid.id = sch->schib.pmcw.chpid[i];
  79. if (chp_get_status(chpid) != 0)
  80. opm |= 1;
  81. }
  82. return opm;
  83. }
  84. EXPORT_SYMBOL_GPL(chp_get_sch_opm);
  85. /**
  86. * chp_is_registered - check if a channel-path is registered
  87. * @chpid: channel-path ID
  88. *
  89. * Return non-zero if a channel-path with the given chpid is registered,
  90. * zero otherwise.
  91. */
  92. int chp_is_registered(struct chp_id chpid)
  93. {
  94. return chpid_to_chp(chpid) != NULL;
  95. }
  96. /*
  97. * Function: s390_vary_chpid
  98. * Varies the specified chpid online or offline
  99. */
  100. static int s390_vary_chpid(struct chp_id chpid, int on)
  101. {
  102. char dbf_text[15];
  103. int status;
  104. sprintf(dbf_text, on?"varyon%x.%02x":"varyoff%x.%02x", chpid.cssid,
  105. chpid.id);
  106. CIO_TRACE_EVENT(2, dbf_text);
  107. status = chp_get_status(chpid);
  108. if (!on && !status) {
  109. printk(KERN_ERR "cio: chpid %x.%02x is already offline\n",
  110. chpid.cssid, chpid.id);
  111. return -EINVAL;
  112. }
  113. set_chp_logically_online(chpid, on);
  114. chsc_chp_vary(chpid, on);
  115. return 0;
  116. }
  117. /*
  118. * Channel measurement related functions
  119. */
  120. static ssize_t chp_measurement_chars_read(struct kobject *kobj,
  121. struct bin_attribute *bin_attr,
  122. char *buf, loff_t off, size_t count)
  123. {
  124. struct channel_path *chp;
  125. struct device *device;
  126. device = container_of(kobj, struct device, kobj);
  127. chp = to_channelpath(device);
  128. if (!chp->cmg_chars)
  129. return 0;
  130. return memory_read_from_buffer(buf, count, &off,
  131. chp->cmg_chars, sizeof(struct cmg_chars));
  132. }
  133. static struct bin_attribute chp_measurement_chars_attr = {
  134. .attr = {
  135. .name = "measurement_chars",
  136. .mode = S_IRUSR,
  137. },
  138. .size = sizeof(struct cmg_chars),
  139. .read = chp_measurement_chars_read,
  140. };
  141. static void chp_measurement_copy_block(struct cmg_entry *buf,
  142. struct channel_subsystem *css,
  143. struct chp_id chpid)
  144. {
  145. void *area;
  146. struct cmg_entry *entry, reference_buf;
  147. int idx;
  148. if (chpid.id < 128) {
  149. area = css->cub_addr1;
  150. idx = chpid.id;
  151. } else {
  152. area = css->cub_addr2;
  153. idx = chpid.id - 128;
  154. }
  155. entry = area + (idx * sizeof(struct cmg_entry));
  156. do {
  157. memcpy(buf, entry, sizeof(*entry));
  158. memcpy(&reference_buf, entry, sizeof(*entry));
  159. } while (reference_buf.values[0] != buf->values[0]);
  160. }
  161. static ssize_t chp_measurement_read(struct kobject *kobj,
  162. struct bin_attribute *bin_attr,
  163. char *buf, loff_t off, size_t count)
  164. {
  165. struct channel_path *chp;
  166. struct channel_subsystem *css;
  167. struct device *device;
  168. unsigned int size;
  169. device = container_of(kobj, struct device, kobj);
  170. chp = to_channelpath(device);
  171. css = to_css(chp->dev.parent);
  172. size = sizeof(struct cmg_entry);
  173. /* Only allow single reads. */
  174. if (off || count < size)
  175. return 0;
  176. chp_measurement_copy_block((struct cmg_entry *)buf, css, chp->chpid);
  177. count = size;
  178. return count;
  179. }
  180. static struct bin_attribute chp_measurement_attr = {
  181. .attr = {
  182. .name = "measurement",
  183. .mode = S_IRUSR,
  184. },
  185. .size = sizeof(struct cmg_entry),
  186. .read = chp_measurement_read,
  187. };
  188. void chp_remove_cmg_attr(struct channel_path *chp)
  189. {
  190. device_remove_bin_file(&chp->dev, &chp_measurement_chars_attr);
  191. device_remove_bin_file(&chp->dev, &chp_measurement_attr);
  192. }
  193. int chp_add_cmg_attr(struct channel_path *chp)
  194. {
  195. int ret;
  196. ret = device_create_bin_file(&chp->dev, &chp_measurement_chars_attr);
  197. if (ret)
  198. return ret;
  199. ret = device_create_bin_file(&chp->dev, &chp_measurement_attr);
  200. if (ret)
  201. device_remove_bin_file(&chp->dev, &chp_measurement_chars_attr);
  202. return ret;
  203. }
  204. /*
  205. * Files for the channel path entries.
  206. */
  207. static ssize_t chp_status_show(struct device *dev,
  208. struct device_attribute *attr, char *buf)
  209. {
  210. struct channel_path *chp = to_channelpath(dev);
  211. if (!chp)
  212. return 0;
  213. return (chp_get_status(chp->chpid) ? sprintf(buf, "online\n") :
  214. sprintf(buf, "offline\n"));
  215. }
  216. static ssize_t chp_status_write(struct device *dev,
  217. struct device_attribute *attr,
  218. const char *buf, size_t count)
  219. {
  220. struct channel_path *cp = to_channelpath(dev);
  221. char cmd[10];
  222. int num_args;
  223. int error;
  224. num_args = sscanf(buf, "%5s", cmd);
  225. if (!num_args)
  226. return count;
  227. if (!strnicmp(cmd, "on", 2) || !strcmp(cmd, "1"))
  228. error = s390_vary_chpid(cp->chpid, 1);
  229. else if (!strnicmp(cmd, "off", 3) || !strcmp(cmd, "0"))
  230. error = s390_vary_chpid(cp->chpid, 0);
  231. else
  232. error = -EINVAL;
  233. return error < 0 ? error : count;
  234. }
  235. static DEVICE_ATTR(status, 0644, chp_status_show, chp_status_write);
  236. static ssize_t chp_configure_show(struct device *dev,
  237. struct device_attribute *attr, char *buf)
  238. {
  239. struct channel_path *cp;
  240. int status;
  241. cp = to_channelpath(dev);
  242. status = chp_info_get_status(cp->chpid);
  243. if (status < 0)
  244. return status;
  245. return snprintf(buf, PAGE_SIZE, "%d\n", status);
  246. }
  247. static int cfg_wait_idle(void);
  248. static ssize_t chp_configure_write(struct device *dev,
  249. struct device_attribute *attr,
  250. const char *buf, size_t count)
  251. {
  252. struct channel_path *cp;
  253. int val;
  254. char delim;
  255. if (sscanf(buf, "%d %c", &val, &delim) != 1)
  256. return -EINVAL;
  257. if (val != 0 && val != 1)
  258. return -EINVAL;
  259. cp = to_channelpath(dev);
  260. chp_cfg_schedule(cp->chpid, val);
  261. cfg_wait_idle();
  262. return count;
  263. }
  264. static DEVICE_ATTR(configure, 0644, chp_configure_show, chp_configure_write);
  265. static ssize_t chp_type_show(struct device *dev, struct device_attribute *attr,
  266. char *buf)
  267. {
  268. struct channel_path *chp = to_channelpath(dev);
  269. if (!chp)
  270. return 0;
  271. return sprintf(buf, "%x\n", chp->desc.desc);
  272. }
  273. static DEVICE_ATTR(type, 0444, chp_type_show, NULL);
  274. static ssize_t chp_cmg_show(struct device *dev, struct device_attribute *attr,
  275. char *buf)
  276. {
  277. struct channel_path *chp = to_channelpath(dev);
  278. if (!chp)
  279. return 0;
  280. if (chp->cmg == -1) /* channel measurements not available */
  281. return sprintf(buf, "unknown\n");
  282. return sprintf(buf, "%x\n", chp->cmg);
  283. }
  284. static DEVICE_ATTR(cmg, 0444, chp_cmg_show, NULL);
  285. static ssize_t chp_shared_show(struct device *dev,
  286. struct device_attribute *attr, char *buf)
  287. {
  288. struct channel_path *chp = to_channelpath(dev);
  289. if (!chp)
  290. return 0;
  291. if (chp->shared == -1) /* channel measurements not available */
  292. return sprintf(buf, "unknown\n");
  293. return sprintf(buf, "%x\n", chp->shared);
  294. }
  295. static DEVICE_ATTR(shared, 0444, chp_shared_show, NULL);
  296. static struct attribute *chp_attrs[] = {
  297. &dev_attr_status.attr,
  298. &dev_attr_configure.attr,
  299. &dev_attr_type.attr,
  300. &dev_attr_cmg.attr,
  301. &dev_attr_shared.attr,
  302. NULL,
  303. };
  304. static struct attribute_group chp_attr_group = {
  305. .attrs = chp_attrs,
  306. };
  307. static void chp_release(struct device *dev)
  308. {
  309. struct channel_path *cp;
  310. cp = to_channelpath(dev);
  311. kfree(cp);
  312. }
  313. /**
  314. * chp_new - register a new channel-path
  315. * @chpid - channel-path ID
  316. *
  317. * Create and register data structure representing new channel-path. Return
  318. * zero on success, non-zero otherwise.
  319. */
  320. int chp_new(struct chp_id chpid)
  321. {
  322. struct channel_path *chp;
  323. int ret;
  324. if (chp_is_registered(chpid))
  325. return 0;
  326. chp = kzalloc(sizeof(struct channel_path), GFP_KERNEL);
  327. if (!chp)
  328. return -ENOMEM;
  329. /* fill in status, etc. */
  330. chp->chpid = chpid;
  331. chp->state = 1;
  332. chp->dev.parent = &channel_subsystems[chpid.cssid]->device;
  333. chp->dev.release = chp_release;
  334. snprintf(chp->dev.bus_id, BUS_ID_SIZE, "chp%x.%02x", chpid.cssid,
  335. chpid.id);
  336. /* Obtain channel path description and fill it in. */
  337. ret = chsc_determine_base_channel_path_desc(chpid, &chp->desc);
  338. if (ret)
  339. goto out_free;
  340. if ((chp->desc.flags & 0x80) == 0) {
  341. ret = -ENODEV;
  342. goto out_free;
  343. }
  344. /* Get channel-measurement characteristics. */
  345. if (css_chsc_characteristics.scmc && css_chsc_characteristics.secm) {
  346. ret = chsc_get_channel_measurement_chars(chp);
  347. if (ret)
  348. goto out_free;
  349. } else {
  350. chp->cmg = -1;
  351. }
  352. /* make it known to the system */
  353. ret = device_register(&chp->dev);
  354. if (ret) {
  355. CIO_MSG_EVENT(0, "Could not register chp%x.%02x: %d\n",
  356. chpid.cssid, chpid.id, ret);
  357. goto out_free;
  358. }
  359. ret = sysfs_create_group(&chp->dev.kobj, &chp_attr_group);
  360. if (ret) {
  361. device_unregister(&chp->dev);
  362. goto out_free;
  363. }
  364. mutex_lock(&channel_subsystems[chpid.cssid]->mutex);
  365. if (channel_subsystems[chpid.cssid]->cm_enabled) {
  366. ret = chp_add_cmg_attr(chp);
  367. if (ret) {
  368. sysfs_remove_group(&chp->dev.kobj, &chp_attr_group);
  369. device_unregister(&chp->dev);
  370. mutex_unlock(&channel_subsystems[chpid.cssid]->mutex);
  371. goto out_free;
  372. }
  373. }
  374. channel_subsystems[chpid.cssid]->chps[chpid.id] = chp;
  375. mutex_unlock(&channel_subsystems[chpid.cssid]->mutex);
  376. return ret;
  377. out_free:
  378. kfree(chp);
  379. return ret;
  380. }
  381. /**
  382. * chp_get_chp_desc - return newly allocated channel-path description
  383. * @chpid: channel-path ID
  384. *
  385. * On success return a newly allocated copy of the channel-path description
  386. * data associated with the given channel-path ID. Return %NULL on error.
  387. */
  388. void *chp_get_chp_desc(struct chp_id chpid)
  389. {
  390. struct channel_path *chp;
  391. struct channel_path_desc *desc;
  392. chp = chpid_to_chp(chpid);
  393. if (!chp)
  394. return NULL;
  395. desc = kmalloc(sizeof(struct channel_path_desc), GFP_KERNEL);
  396. if (!desc)
  397. return NULL;
  398. memcpy(desc, &chp->desc, sizeof(struct channel_path_desc));
  399. return desc;
  400. }
  401. /**
  402. * chp_process_crw - process channel-path status change
  403. * @crw0: channel report-word to handler
  404. * @crw1: second channel-report word (always NULL)
  405. * @overflow: crw overflow indication
  406. *
  407. * Handle channel-report-words indicating that the status of a channel-path
  408. * has changed.
  409. */
  410. static void chp_process_crw(struct crw *crw0, struct crw *crw1,
  411. int overflow)
  412. {
  413. struct chp_id chpid;
  414. if (overflow) {
  415. css_schedule_eval_all();
  416. return;
  417. }
  418. CIO_CRW_EVENT(2, "CRW reports slct=%d, oflw=%d, "
  419. "chn=%d, rsc=%X, anc=%d, erc=%X, rsid=%X\n",
  420. crw0->slct, crw0->oflw, crw0->chn, crw0->rsc, crw0->anc,
  421. crw0->erc, crw0->rsid);
  422. /*
  423. * Check for solicited machine checks. These are
  424. * created by reset channel path and need not be
  425. * handled here.
  426. */
  427. if (crw0->slct) {
  428. CIO_CRW_EVENT(2, "solicited machine check for "
  429. "channel path %02X\n", crw0->rsid);
  430. return;
  431. }
  432. chp_id_init(&chpid);
  433. chpid.id = crw0->rsid;
  434. switch (crw0->erc) {
  435. case CRW_ERC_IPARM: /* Path has come. */
  436. if (!chp_is_registered(chpid))
  437. chp_new(chpid);
  438. chsc_chp_online(chpid);
  439. break;
  440. case CRW_ERC_PERRI: /* Path has gone. */
  441. case CRW_ERC_PERRN:
  442. chsc_chp_offline(chpid);
  443. break;
  444. default:
  445. CIO_CRW_EVENT(2, "Don't know how to handle erc=%x\n",
  446. crw0->erc);
  447. }
  448. }
  449. int chp_ssd_get_mask(struct chsc_ssd_info *ssd, struct chp_link *link)
  450. {
  451. int i;
  452. int mask;
  453. for (i = 0; i < 8; i++) {
  454. mask = 0x80 >> i;
  455. if (!(ssd->path_mask & mask))
  456. continue;
  457. if (!chp_id_is_equal(&ssd->chpid[i], &link->chpid))
  458. continue;
  459. if ((ssd->fla_valid_mask & mask) &&
  460. ((ssd->fla[i] & link->fla_mask) != link->fla))
  461. continue;
  462. return mask;
  463. }
  464. return 0;
  465. }
  466. EXPORT_SYMBOL_GPL(chp_ssd_get_mask);
  467. static inline int info_bit_num(struct chp_id id)
  468. {
  469. return id.id + id.cssid * (__MAX_CHPID + 1);
  470. }
  471. /* Force chp_info refresh on next call to info_validate(). */
  472. static void info_expire(void)
  473. {
  474. mutex_lock(&info_lock);
  475. chp_info_expires = jiffies - 1;
  476. mutex_unlock(&info_lock);
  477. }
  478. /* Ensure that chp_info is up-to-date. */
  479. static int info_update(void)
  480. {
  481. int rc;
  482. mutex_lock(&info_lock);
  483. rc = 0;
  484. if (time_after(jiffies, chp_info_expires)) {
  485. /* Data is too old, update. */
  486. rc = sclp_chp_read_info(&chp_info);
  487. chp_info_expires = jiffies + CHP_INFO_UPDATE_INTERVAL ;
  488. }
  489. mutex_unlock(&info_lock);
  490. return rc;
  491. }
  492. /**
  493. * chp_info_get_status - retrieve configure status of a channel-path
  494. * @chpid: channel-path ID
  495. *
  496. * On success, return 0 for standby, 1 for configured, 2 for reserved,
  497. * 3 for not recognized. Return negative error code on error.
  498. */
  499. int chp_info_get_status(struct chp_id chpid)
  500. {
  501. int rc;
  502. int bit;
  503. rc = info_update();
  504. if (rc)
  505. return rc;
  506. bit = info_bit_num(chpid);
  507. mutex_lock(&info_lock);
  508. if (!chp_test_bit(chp_info.recognized, bit))
  509. rc = CHP_STATUS_NOT_RECOGNIZED;
  510. else if (chp_test_bit(chp_info.configured, bit))
  511. rc = CHP_STATUS_CONFIGURED;
  512. else if (chp_test_bit(chp_info.standby, bit))
  513. rc = CHP_STATUS_STANDBY;
  514. else
  515. rc = CHP_STATUS_RESERVED;
  516. mutex_unlock(&info_lock);
  517. return rc;
  518. }
  519. /* Return configure task for chpid. */
  520. static enum cfg_task_t cfg_get_task(struct chp_id chpid)
  521. {
  522. return chp_cfg_task[chpid.cssid][chpid.id];
  523. }
  524. /* Set configure task for chpid. */
  525. static void cfg_set_task(struct chp_id chpid, enum cfg_task_t cfg)
  526. {
  527. chp_cfg_task[chpid.cssid][chpid.id] = cfg;
  528. }
  529. /* Perform one configure/deconfigure request. Reschedule work function until
  530. * last request. */
  531. static void cfg_func(struct work_struct *work)
  532. {
  533. struct chp_id chpid;
  534. enum cfg_task_t t;
  535. int rc;
  536. mutex_lock(&cfg_lock);
  537. t = cfg_none;
  538. chp_id_for_each(&chpid) {
  539. t = cfg_get_task(chpid);
  540. if (t != cfg_none) {
  541. cfg_set_task(chpid, cfg_none);
  542. break;
  543. }
  544. }
  545. mutex_unlock(&cfg_lock);
  546. switch (t) {
  547. case cfg_configure:
  548. rc = sclp_chp_configure(chpid);
  549. if (rc)
  550. CIO_MSG_EVENT(2, "chp: sclp_chp_configure(%x.%02x)="
  551. "%d\n", chpid.cssid, chpid.id, rc);
  552. else {
  553. info_expire();
  554. chsc_chp_online(chpid);
  555. }
  556. break;
  557. case cfg_deconfigure:
  558. rc = sclp_chp_deconfigure(chpid);
  559. if (rc)
  560. CIO_MSG_EVENT(2, "chp: sclp_chp_deconfigure(%x.%02x)="
  561. "%d\n", chpid.cssid, chpid.id, rc);
  562. else {
  563. info_expire();
  564. chsc_chp_offline(chpid);
  565. }
  566. break;
  567. case cfg_none:
  568. /* Get updated information after last change. */
  569. info_update();
  570. mutex_lock(&cfg_lock);
  571. cfg_busy = 0;
  572. mutex_unlock(&cfg_lock);
  573. wake_up_interruptible(&cfg_wait_queue);
  574. return;
  575. }
  576. queue_work(chp_wq, &cfg_work);
  577. }
  578. /**
  579. * chp_cfg_schedule - schedule chpid configuration request
  580. * @chpid - channel-path ID
  581. * @configure - Non-zero for configure, zero for deconfigure
  582. *
  583. * Schedule a channel-path configuration/deconfiguration request.
  584. */
  585. void chp_cfg_schedule(struct chp_id chpid, int configure)
  586. {
  587. CIO_MSG_EVENT(2, "chp_cfg_sched%x.%02x=%d\n", chpid.cssid, chpid.id,
  588. configure);
  589. mutex_lock(&cfg_lock);
  590. cfg_set_task(chpid, configure ? cfg_configure : cfg_deconfigure);
  591. cfg_busy = 1;
  592. mutex_unlock(&cfg_lock);
  593. queue_work(chp_wq, &cfg_work);
  594. }
  595. /**
  596. * chp_cfg_cancel_deconfigure - cancel chpid deconfiguration request
  597. * @chpid - channel-path ID
  598. *
  599. * Cancel an active channel-path deconfiguration request if it has not yet
  600. * been performed.
  601. */
  602. void chp_cfg_cancel_deconfigure(struct chp_id chpid)
  603. {
  604. CIO_MSG_EVENT(2, "chp_cfg_cancel:%x.%02x\n", chpid.cssid, chpid.id);
  605. mutex_lock(&cfg_lock);
  606. if (cfg_get_task(chpid) == cfg_deconfigure)
  607. cfg_set_task(chpid, cfg_none);
  608. mutex_unlock(&cfg_lock);
  609. }
  610. static int cfg_wait_idle(void)
  611. {
  612. if (wait_event_interruptible(cfg_wait_queue, !cfg_busy))
  613. return -ERESTARTSYS;
  614. return 0;
  615. }
  616. static int __init chp_init(void)
  617. {
  618. struct chp_id chpid;
  619. int ret;
  620. ret = s390_register_crw_handler(CRW_RSC_CPATH, chp_process_crw);
  621. if (ret)
  622. return ret;
  623. chp_wq = create_singlethread_workqueue("cio_chp");
  624. if (!chp_wq) {
  625. s390_unregister_crw_handler(CRW_RSC_CPATH);
  626. return -ENOMEM;
  627. }
  628. INIT_WORK(&cfg_work, cfg_func);
  629. init_waitqueue_head(&cfg_wait_queue);
  630. if (info_update())
  631. return 0;
  632. /* Register available channel-paths. */
  633. chp_id_for_each(&chpid) {
  634. if (chp_info_get_status(chpid) != CHP_STATUS_NOT_RECOGNIZED)
  635. chp_new(chpid);
  636. }
  637. return 0;
  638. }
  639. subsys_initcall(chp_init);