css.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. /*
  2. * drivers/s390/cio/css.c
  3. * driver for channel subsystem
  4. *
  5. * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
  6. * IBM Corporation
  7. * Author(s): Arnd Bergmann (arndb@de.ibm.com)
  8. * Cornelia Huck (cornelia.huck@de.ibm.com)
  9. */
  10. #include <linux/module.h>
  11. #include <linux/init.h>
  12. #include <linux/device.h>
  13. #include <linux/slab.h>
  14. #include <linux/errno.h>
  15. #include <linux/list.h>
  16. #include "css.h"
  17. #include "cio.h"
  18. #include "cio_debug.h"
  19. #include "ioasm.h"
  20. #include "chsc.h"
  21. #include "device.h"
  22. int need_rescan = 0;
  23. int css_init_done = 0;
  24. static int need_reprobe = 0;
  25. static int max_ssid = 0;
  26. struct channel_subsystem *css[__MAX_CSSID + 1];
  27. int css_characteristics_avail = 0;
  28. inline int
  29. for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *data)
  30. {
  31. struct subchannel_id schid;
  32. int ret;
  33. init_subchannel_id(&schid);
  34. ret = -ENODEV;
  35. do {
  36. do {
  37. ret = fn(schid, data);
  38. if (ret)
  39. break;
  40. } while (schid.sch_no++ < __MAX_SUBCHANNEL);
  41. schid.sch_no = 0;
  42. } while (schid.ssid++ < max_ssid);
  43. return ret;
  44. }
  45. static struct subchannel *
  46. css_alloc_subchannel(struct subchannel_id schid)
  47. {
  48. struct subchannel *sch;
  49. int ret;
  50. sch = kmalloc (sizeof (*sch), GFP_KERNEL | GFP_DMA);
  51. if (sch == NULL)
  52. return ERR_PTR(-ENOMEM);
  53. ret = cio_validate_subchannel (sch, schid);
  54. if (ret < 0) {
  55. kfree(sch);
  56. return ERR_PTR(ret);
  57. }
  58. if (sch->st != SUBCHANNEL_TYPE_IO) {
  59. /* For now we ignore all non-io subchannels. */
  60. kfree(sch);
  61. return ERR_PTR(-EINVAL);
  62. }
  63. /*
  64. * Set intparm to subchannel address.
  65. * This is fine even on 64bit since the subchannel is always located
  66. * under 2G.
  67. */
  68. sch->schib.pmcw.intparm = (__u32)(unsigned long)sch;
  69. ret = cio_modify(sch);
  70. if (ret) {
  71. kfree(sch);
  72. return ERR_PTR(ret);
  73. }
  74. return sch;
  75. }
  76. static void
  77. css_free_subchannel(struct subchannel *sch)
  78. {
  79. if (sch) {
  80. /* Reset intparm to zeroes. */
  81. sch->schib.pmcw.intparm = 0;
  82. cio_modify(sch);
  83. kfree(sch);
  84. }
  85. }
  86. static void
  87. css_subchannel_release(struct device *dev)
  88. {
  89. struct subchannel *sch;
  90. sch = to_subchannel(dev);
  91. if (!cio_is_console(sch->schid))
  92. kfree(sch);
  93. }
  94. extern int css_get_ssd_info(struct subchannel *sch);
  95. int css_sch_device_register(struct subchannel *sch)
  96. {
  97. int ret;
  98. mutex_lock(&sch->reg_mutex);
  99. ret = device_register(&sch->dev);
  100. mutex_unlock(&sch->reg_mutex);
  101. return ret;
  102. }
  103. void css_sch_device_unregister(struct subchannel *sch)
  104. {
  105. mutex_lock(&sch->reg_mutex);
  106. device_unregister(&sch->dev);
  107. mutex_unlock(&sch->reg_mutex);
  108. }
  109. static int
  110. css_register_subchannel(struct subchannel *sch)
  111. {
  112. int ret;
  113. /* Initialize the subchannel structure */
  114. sch->dev.parent = &css[0]->device;
  115. sch->dev.bus = &css_bus_type;
  116. sch->dev.release = &css_subchannel_release;
  117. /* make it known to the system */
  118. ret = css_sch_device_register(sch);
  119. if (ret)
  120. printk (KERN_WARNING "%s: could not register %s\n",
  121. __func__, sch->dev.bus_id);
  122. else
  123. css_get_ssd_info(sch);
  124. return ret;
  125. }
  126. int
  127. css_probe_device(struct subchannel_id schid)
  128. {
  129. int ret;
  130. struct subchannel *sch;
  131. sch = css_alloc_subchannel(schid);
  132. if (IS_ERR(sch))
  133. return PTR_ERR(sch);
  134. ret = css_register_subchannel(sch);
  135. if (ret)
  136. css_free_subchannel(sch);
  137. return ret;
  138. }
  139. static int
  140. check_subchannel(struct device * dev, void * data)
  141. {
  142. struct subchannel *sch;
  143. struct subchannel_id *schid = data;
  144. sch = to_subchannel(dev);
  145. return schid_equal(&sch->schid, schid);
  146. }
  147. struct subchannel *
  148. get_subchannel_by_schid(struct subchannel_id schid)
  149. {
  150. struct device *dev;
  151. dev = bus_find_device(&css_bus_type, NULL,
  152. &schid, check_subchannel);
  153. return dev ? to_subchannel(dev) : NULL;
  154. }
  155. static inline int css_get_subchannel_status(struct subchannel *sch)
  156. {
  157. struct schib schib;
  158. if (stsch(sch->schid, &schib) || !schib.pmcw.dnv)
  159. return CIO_GONE;
  160. if (sch->schib.pmcw.dnv && (schib.pmcw.dev != sch->schib.pmcw.dev))
  161. return CIO_REVALIDATE;
  162. if (!sch->lpm)
  163. return CIO_NO_PATH;
  164. return CIO_OPER;
  165. }
  166. static int css_evaluate_known_subchannel(struct subchannel *sch, int slow)
  167. {
  168. int event, ret, disc;
  169. unsigned long flags;
  170. enum { NONE, UNREGISTER, UNREGISTER_PROBE, REPROBE } action;
  171. spin_lock_irqsave(&sch->lock, flags);
  172. disc = device_is_disconnected(sch);
  173. if (disc && slow) {
  174. /* Disconnected devices are evaluated directly only.*/
  175. spin_unlock_irqrestore(&sch->lock, flags);
  176. return 0;
  177. }
  178. /* No interrupt after machine check - kill pending timers. */
  179. device_kill_pending_timer(sch);
  180. if (!disc && !slow) {
  181. /* Non-disconnected devices are evaluated on the slow path. */
  182. spin_unlock_irqrestore(&sch->lock, flags);
  183. return -EAGAIN;
  184. }
  185. event = css_get_subchannel_status(sch);
  186. CIO_MSG_EVENT(4, "Evaluating schid 0.%x.%04x, event %d, %s, %s path.\n",
  187. sch->schid.ssid, sch->schid.sch_no, event,
  188. disc ? "disconnected" : "normal",
  189. slow ? "slow" : "fast");
  190. /* Analyze subchannel status. */
  191. action = NONE;
  192. switch (event) {
  193. case CIO_NO_PATH:
  194. if (disc) {
  195. /* Check if paths have become available. */
  196. action = REPROBE;
  197. break;
  198. }
  199. /* fall through */
  200. case CIO_GONE:
  201. /* Prevent unwanted effects when opening lock. */
  202. cio_disable_subchannel(sch);
  203. device_set_disconnected(sch);
  204. /* Ask driver what to do with device. */
  205. action = UNREGISTER;
  206. if (sch->driver && sch->driver->notify) {
  207. spin_unlock_irqrestore(&sch->lock, flags);
  208. ret = sch->driver->notify(&sch->dev, event);
  209. spin_lock_irqsave(&sch->lock, flags);
  210. if (ret)
  211. action = NONE;
  212. }
  213. break;
  214. case CIO_REVALIDATE:
  215. /* Device will be removed, so no notify necessary. */
  216. if (disc)
  217. /* Reprobe because immediate unregister might block. */
  218. action = REPROBE;
  219. else
  220. action = UNREGISTER_PROBE;
  221. break;
  222. case CIO_OPER:
  223. if (disc)
  224. /* Get device operational again. */
  225. action = REPROBE;
  226. break;
  227. }
  228. /* Perform action. */
  229. ret = 0;
  230. switch (action) {
  231. case UNREGISTER:
  232. case UNREGISTER_PROBE:
  233. /* Unregister device (will use subchannel lock). */
  234. spin_unlock_irqrestore(&sch->lock, flags);
  235. css_sch_device_unregister(sch);
  236. spin_lock_irqsave(&sch->lock, flags);
  237. /* Reset intparm to zeroes. */
  238. sch->schib.pmcw.intparm = 0;
  239. cio_modify(sch);
  240. /* Probe if necessary. */
  241. if (action == UNREGISTER_PROBE)
  242. ret = css_probe_device(sch->schid);
  243. break;
  244. case REPROBE:
  245. device_trigger_reprobe(sch);
  246. break;
  247. default:
  248. break;
  249. }
  250. spin_unlock_irqrestore(&sch->lock, flags);
  251. return ret;
  252. }
  253. static int css_evaluate_new_subchannel(struct subchannel_id schid, int slow)
  254. {
  255. struct schib schib;
  256. if (!slow) {
  257. /* Will be done on the slow path. */
  258. return -EAGAIN;
  259. }
  260. if (stsch(schid, &schib) || !schib.pmcw.dnv) {
  261. /* Unusable - ignore. */
  262. return 0;
  263. }
  264. CIO_MSG_EVENT(4, "Evaluating schid 0.%x.%04x, event %d, unknown, "
  265. "slow path.\n", schid.ssid, schid.sch_no, CIO_OPER);
  266. return css_probe_device(schid);
  267. }
  268. static int css_evaluate_subchannel(struct subchannel_id schid, int slow)
  269. {
  270. struct subchannel *sch;
  271. int ret;
  272. sch = get_subchannel_by_schid(schid);
  273. if (sch) {
  274. ret = css_evaluate_known_subchannel(sch, slow);
  275. put_device(&sch->dev);
  276. } else
  277. ret = css_evaluate_new_subchannel(schid, slow);
  278. return ret;
  279. }
  280. static int
  281. css_rescan_devices(struct subchannel_id schid, void *data)
  282. {
  283. return css_evaluate_subchannel(schid, 1);
  284. }
  285. struct slow_subchannel {
  286. struct list_head slow_list;
  287. struct subchannel_id schid;
  288. };
  289. static LIST_HEAD(slow_subchannels_head);
  290. static DEFINE_SPINLOCK(slow_subchannel_lock);
  291. static void
  292. css_trigger_slow_path(void)
  293. {
  294. CIO_TRACE_EVENT(4, "slowpath");
  295. if (need_rescan) {
  296. need_rescan = 0;
  297. for_each_subchannel(css_rescan_devices, NULL);
  298. return;
  299. }
  300. spin_lock_irq(&slow_subchannel_lock);
  301. while (!list_empty(&slow_subchannels_head)) {
  302. struct slow_subchannel *slow_sch =
  303. list_entry(slow_subchannels_head.next,
  304. struct slow_subchannel, slow_list);
  305. list_del_init(slow_subchannels_head.next);
  306. spin_unlock_irq(&slow_subchannel_lock);
  307. css_evaluate_subchannel(slow_sch->schid, 1);
  308. spin_lock_irq(&slow_subchannel_lock);
  309. kfree(slow_sch);
  310. }
  311. spin_unlock_irq(&slow_subchannel_lock);
  312. }
  313. typedef void (*workfunc)(void *);
  314. DECLARE_WORK(slow_path_work, (workfunc)css_trigger_slow_path, NULL);
  315. struct workqueue_struct *slow_path_wq;
  316. /* Reprobe subchannel if unregistered. */
  317. static int reprobe_subchannel(struct subchannel_id schid, void *data)
  318. {
  319. struct subchannel *sch;
  320. int ret;
  321. CIO_DEBUG(KERN_INFO, 6, "cio: reprobe 0.%x.%04x\n",
  322. schid.ssid, schid.sch_no);
  323. if (need_reprobe)
  324. return -EAGAIN;
  325. sch = get_subchannel_by_schid(schid);
  326. if (sch) {
  327. /* Already known. */
  328. put_device(&sch->dev);
  329. return 0;
  330. }
  331. ret = css_probe_device(schid);
  332. switch (ret) {
  333. case 0:
  334. break;
  335. case -ENXIO:
  336. case -ENOMEM:
  337. /* These should abort looping */
  338. break;
  339. default:
  340. ret = 0;
  341. }
  342. return ret;
  343. }
  344. /* Work function used to reprobe all unregistered subchannels. */
  345. static void reprobe_all(void *data)
  346. {
  347. int ret;
  348. CIO_MSG_EVENT(2, "reprobe start\n");
  349. need_reprobe = 0;
  350. /* Make sure initial subchannel scan is done. */
  351. wait_event(ccw_device_init_wq,
  352. atomic_read(&ccw_device_init_count) == 0);
  353. ret = for_each_subchannel(reprobe_subchannel, NULL);
  354. CIO_MSG_EVENT(2, "reprobe done (rc=%d, need_reprobe=%d)\n", ret,
  355. need_reprobe);
  356. }
  357. DECLARE_WORK(css_reprobe_work, reprobe_all, NULL);
  358. /* Schedule reprobing of all unregistered subchannels. */
  359. void css_schedule_reprobe(void)
  360. {
  361. need_reprobe = 1;
  362. queue_work(ccw_device_work, &css_reprobe_work);
  363. }
  364. EXPORT_SYMBOL_GPL(css_schedule_reprobe);
  365. /*
  366. * Rescan for new devices. FIXME: This is slow.
  367. * This function is called when we have lost CRWs due to overflows and we have
  368. * to do subchannel housekeeping.
  369. */
  370. void
  371. css_reiterate_subchannels(void)
  372. {
  373. css_clear_subchannel_slow_list();
  374. need_rescan = 1;
  375. }
  376. /*
  377. * Called from the machine check handler for subchannel report words.
  378. */
  379. int
  380. css_process_crw(int rsid1, int rsid2)
  381. {
  382. int ret;
  383. struct subchannel_id mchk_schid;
  384. CIO_CRW_EVENT(2, "source is subchannel %04X, subsystem id %x\n",
  385. rsid1, rsid2);
  386. if (need_rescan)
  387. /* We need to iterate all subchannels anyway. */
  388. return -EAGAIN;
  389. init_subchannel_id(&mchk_schid);
  390. mchk_schid.sch_no = rsid1;
  391. if (rsid2 != 0)
  392. mchk_schid.ssid = (rsid2 >> 8) & 3;
  393. /*
  394. * Since we are always presented with IPI in the CRW, we have to
  395. * use stsch() to find out if the subchannel in question has come
  396. * or gone.
  397. */
  398. ret = css_evaluate_subchannel(mchk_schid, 0);
  399. if (ret == -EAGAIN) {
  400. if (css_enqueue_subchannel_slow(mchk_schid)) {
  401. css_clear_subchannel_slow_list();
  402. need_rescan = 1;
  403. }
  404. }
  405. return ret;
  406. }
  407. static int __init
  408. __init_channel_subsystem(struct subchannel_id schid, void *data)
  409. {
  410. struct subchannel *sch;
  411. int ret;
  412. if (cio_is_console(schid))
  413. sch = cio_get_console_subchannel();
  414. else {
  415. sch = css_alloc_subchannel(schid);
  416. if (IS_ERR(sch))
  417. ret = PTR_ERR(sch);
  418. else
  419. ret = 0;
  420. switch (ret) {
  421. case 0:
  422. break;
  423. case -ENOMEM:
  424. panic("Out of memory in init_channel_subsystem\n");
  425. /* -ENXIO: no more subchannels. */
  426. case -ENXIO:
  427. return ret;
  428. /* -EIO: this subchannel set not supported. */
  429. case -EIO:
  430. return ret;
  431. default:
  432. return 0;
  433. }
  434. }
  435. /*
  436. * We register ALL valid subchannels in ioinfo, even those
  437. * that have been present before init_channel_subsystem.
  438. * These subchannels can't have been registered yet (kmalloc
  439. * not working) so we do it now. This is true e.g. for the
  440. * console subchannel.
  441. */
  442. css_register_subchannel(sch);
  443. return 0;
  444. }
  445. static void __init
  446. css_generate_pgid(struct channel_subsystem *css, u32 tod_high)
  447. {
  448. if (css_characteristics_avail && css_general_characteristics.mcss) {
  449. css->global_pgid.pgid_high.ext_cssid.version = 0x80;
  450. css->global_pgid.pgid_high.ext_cssid.cssid = css->cssid;
  451. } else {
  452. #ifdef CONFIG_SMP
  453. css->global_pgid.pgid_high.cpu_addr = hard_smp_processor_id();
  454. #else
  455. css->global_pgid.pgid_high.cpu_addr = 0;
  456. #endif
  457. }
  458. css->global_pgid.cpu_id = ((cpuid_t *) __LC_CPUID)->ident;
  459. css->global_pgid.cpu_model = ((cpuid_t *) __LC_CPUID)->machine;
  460. css->global_pgid.tod_high = tod_high;
  461. }
  462. static void
  463. channel_subsystem_release(struct device *dev)
  464. {
  465. struct channel_subsystem *css;
  466. css = to_css(dev);
  467. mutex_destroy(&css->mutex);
  468. kfree(css);
  469. }
  470. static ssize_t
  471. css_cm_enable_show(struct device *dev, struct device_attribute *attr,
  472. char *buf)
  473. {
  474. struct channel_subsystem *css = to_css(dev);
  475. if (!css)
  476. return 0;
  477. return sprintf(buf, "%x\n", css->cm_enabled);
  478. }
  479. static ssize_t
  480. css_cm_enable_store(struct device *dev, struct device_attribute *attr,
  481. const char *buf, size_t count)
  482. {
  483. struct channel_subsystem *css = to_css(dev);
  484. int ret;
  485. switch (buf[0]) {
  486. case '0':
  487. ret = css->cm_enabled ? chsc_secm(css, 0) : 0;
  488. break;
  489. case '1':
  490. ret = css->cm_enabled ? 0 : chsc_secm(css, 1);
  491. break;
  492. default:
  493. ret = -EINVAL;
  494. }
  495. return ret < 0 ? ret : count;
  496. }
  497. static DEVICE_ATTR(cm_enable, 0644, css_cm_enable_show, css_cm_enable_store);
  498. static inline void __init
  499. setup_css(int nr)
  500. {
  501. u32 tod_high;
  502. memset(css[nr], 0, sizeof(struct channel_subsystem));
  503. mutex_init(&css[nr]->mutex);
  504. css[nr]->valid = 1;
  505. css[nr]->cssid = nr;
  506. sprintf(css[nr]->device.bus_id, "css%x", nr);
  507. css[nr]->device.release = channel_subsystem_release;
  508. tod_high = (u32) (get_clock() >> 32);
  509. css_generate_pgid(css[nr], tod_high);
  510. }
  511. /*
  512. * Now that the driver core is running, we can setup our channel subsystem.
  513. * The struct subchannel's are created during probing (except for the
  514. * static console subchannel).
  515. */
  516. static int __init
  517. init_channel_subsystem (void)
  518. {
  519. int ret, i;
  520. if (chsc_determine_css_characteristics() == 0)
  521. css_characteristics_avail = 1;
  522. if ((ret = bus_register(&css_bus_type)))
  523. goto out;
  524. /* Try to enable MSS. */
  525. ret = chsc_enable_facility(CHSC_SDA_OC_MSS);
  526. switch (ret) {
  527. case 0: /* Success. */
  528. max_ssid = __MAX_SSID;
  529. break;
  530. case -ENOMEM:
  531. goto out_bus;
  532. default:
  533. max_ssid = 0;
  534. }
  535. /* Setup css structure. */
  536. for (i = 0; i <= __MAX_CSSID; i++) {
  537. css[i] = kmalloc(sizeof(struct channel_subsystem), GFP_KERNEL);
  538. if (!css[i]) {
  539. ret = -ENOMEM;
  540. goto out_unregister;
  541. }
  542. setup_css(i);
  543. ret = device_register(&css[i]->device);
  544. if (ret)
  545. goto out_free;
  546. if (css_characteristics_avail &&
  547. css_chsc_characteristics.secm) {
  548. ret = device_create_file(&css[i]->device,
  549. &dev_attr_cm_enable);
  550. if (ret)
  551. goto out_device;
  552. }
  553. }
  554. css_init_done = 1;
  555. ctl_set_bit(6, 28);
  556. for_each_subchannel(__init_channel_subsystem, NULL);
  557. return 0;
  558. out_device:
  559. device_unregister(&css[i]->device);
  560. out_free:
  561. kfree(css[i]);
  562. out_unregister:
  563. while (i > 0) {
  564. i--;
  565. if (css_characteristics_avail && css_chsc_characteristics.secm)
  566. device_remove_file(&css[i]->device,
  567. &dev_attr_cm_enable);
  568. device_unregister(&css[i]->device);
  569. }
  570. out_bus:
  571. bus_unregister(&css_bus_type);
  572. out:
  573. return ret;
  574. }
  575. /*
  576. * find a driver for a subchannel. They identify by the subchannel
  577. * type with the exception that the console subchannel driver has its own
  578. * subchannel type although the device is an i/o subchannel
  579. */
  580. static int
  581. css_bus_match (struct device *dev, struct device_driver *drv)
  582. {
  583. struct subchannel *sch = container_of (dev, struct subchannel, dev);
  584. struct css_driver *driver = container_of (drv, struct css_driver, drv);
  585. if (sch->st == driver->subchannel_type)
  586. return 1;
  587. return 0;
  588. }
  589. static int
  590. css_probe (struct device *dev)
  591. {
  592. struct subchannel *sch;
  593. sch = to_subchannel(dev);
  594. sch->driver = container_of (dev->driver, struct css_driver, drv);
  595. return (sch->driver->probe ? sch->driver->probe(sch) : 0);
  596. }
  597. static int
  598. css_remove (struct device *dev)
  599. {
  600. struct subchannel *sch;
  601. sch = to_subchannel(dev);
  602. return (sch->driver->remove ? sch->driver->remove(sch) : 0);
  603. }
  604. static void
  605. css_shutdown (struct device *dev)
  606. {
  607. struct subchannel *sch;
  608. sch = to_subchannel(dev);
  609. if (sch->driver->shutdown)
  610. sch->driver->shutdown(sch);
  611. }
  612. struct bus_type css_bus_type = {
  613. .name = "css",
  614. .match = css_bus_match,
  615. .probe = css_probe,
  616. .remove = css_remove,
  617. .shutdown = css_shutdown,
  618. };
  619. subsys_initcall(init_channel_subsystem);
  620. int
  621. css_enqueue_subchannel_slow(struct subchannel_id schid)
  622. {
  623. struct slow_subchannel *new_slow_sch;
  624. unsigned long flags;
  625. new_slow_sch = kzalloc(sizeof(struct slow_subchannel), GFP_ATOMIC);
  626. if (!new_slow_sch)
  627. return -ENOMEM;
  628. new_slow_sch->schid = schid;
  629. spin_lock_irqsave(&slow_subchannel_lock, flags);
  630. list_add_tail(&new_slow_sch->slow_list, &slow_subchannels_head);
  631. spin_unlock_irqrestore(&slow_subchannel_lock, flags);
  632. return 0;
  633. }
  634. void
  635. css_clear_subchannel_slow_list(void)
  636. {
  637. unsigned long flags;
  638. spin_lock_irqsave(&slow_subchannel_lock, flags);
  639. while (!list_empty(&slow_subchannels_head)) {
  640. struct slow_subchannel *slow_sch =
  641. list_entry(slow_subchannels_head.next,
  642. struct slow_subchannel, slow_list);
  643. list_del_init(slow_subchannels_head.next);
  644. kfree(slow_sch);
  645. }
  646. spin_unlock_irqrestore(&slow_subchannel_lock, flags);
  647. }
  648. int
  649. css_slow_subchannels_exist(void)
  650. {
  651. return (!list_empty(&slow_subchannels_head));
  652. }
  653. MODULE_LICENSE("GPL");
  654. EXPORT_SYMBOL(css_bus_type);
  655. EXPORT_SYMBOL_GPL(css_characteristics_avail);