css.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * driver for channel subsystem
  4. *
  5. * Copyright IBM Corp. 2002, 2010
  6. *
  7. * Author(s): Arnd Bergmann (arndb@de.ibm.com)
  8. * Cornelia Huck (cornelia.huck@de.ibm.com)
  9. */
  10. #define KMSG_COMPONENT "cio"
  11. #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
  12. #include <linux/export.h>
  13. #include <linux/init.h>
  14. #include <linux/device.h>
  15. #include <linux/slab.h>
  16. #include <linux/errno.h>
  17. #include <linux/list.h>
  18. #include <linux/reboot.h>
  19. #include <linux/suspend.h>
  20. #include <linux/proc_fs.h>
  21. #include <asm/isc.h>
  22. #include <asm/crw.h>
  23. #include "css.h"
  24. #include "cio.h"
  25. #include "blacklist.h"
  26. #include "cio_debug.h"
  27. #include "ioasm.h"
  28. #include "chsc.h"
  29. #include "device.h"
  30. #include "idset.h"
  31. #include "chp.h"
  32. int css_init_done = 0;
  33. int max_ssid;
  34. #define MAX_CSS_IDX 0
  35. struct channel_subsystem *channel_subsystems[MAX_CSS_IDX + 1];
  36. static struct bus_type css_bus_type;
  37. int
  38. for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *data)
  39. {
  40. struct subchannel_id schid;
  41. int ret;
  42. init_subchannel_id(&schid);
  43. do {
  44. do {
  45. ret = fn(schid, data);
  46. if (ret)
  47. break;
  48. } while (schid.sch_no++ < __MAX_SUBCHANNEL);
  49. schid.sch_no = 0;
  50. } while (schid.ssid++ < max_ssid);
  51. return ret;
  52. }
  53. struct cb_data {
  54. void *data;
  55. struct idset *set;
  56. int (*fn_known_sch)(struct subchannel *, void *);
  57. int (*fn_unknown_sch)(struct subchannel_id, void *);
  58. };
  59. static int call_fn_known_sch(struct device *dev, void *data)
  60. {
  61. struct subchannel *sch = to_subchannel(dev);
  62. struct cb_data *cb = data;
  63. int rc = 0;
  64. if (cb->set)
  65. idset_sch_del(cb->set, sch->schid);
  66. if (cb->fn_known_sch)
  67. rc = cb->fn_known_sch(sch, cb->data);
  68. return rc;
  69. }
  70. static int call_fn_unknown_sch(struct subchannel_id schid, void *data)
  71. {
  72. struct cb_data *cb = data;
  73. int rc = 0;
  74. if (idset_sch_contains(cb->set, schid))
  75. rc = cb->fn_unknown_sch(schid, cb->data);
  76. return rc;
  77. }
  78. static int call_fn_all_sch(struct subchannel_id schid, void *data)
  79. {
  80. struct cb_data *cb = data;
  81. struct subchannel *sch;
  82. int rc = 0;
  83. sch = get_subchannel_by_schid(schid);
  84. if (sch) {
  85. if (cb->fn_known_sch)
  86. rc = cb->fn_known_sch(sch, cb->data);
  87. put_device(&sch->dev);
  88. } else {
  89. if (cb->fn_unknown_sch)
  90. rc = cb->fn_unknown_sch(schid, cb->data);
  91. }
  92. return rc;
  93. }
  94. int for_each_subchannel_staged(int (*fn_known)(struct subchannel *, void *),
  95. int (*fn_unknown)(struct subchannel_id,
  96. void *), void *data)
  97. {
  98. struct cb_data cb;
  99. int rc;
  100. cb.data = data;
  101. cb.fn_known_sch = fn_known;
  102. cb.fn_unknown_sch = fn_unknown;
  103. if (fn_known && !fn_unknown) {
  104. /* Skip idset allocation in case of known-only loop. */
  105. cb.set = NULL;
  106. return bus_for_each_dev(&css_bus_type, NULL, &cb,
  107. call_fn_known_sch);
  108. }
  109. cb.set = idset_sch_new();
  110. if (!cb.set)
  111. /* fall back to brute force scanning in case of oom */
  112. return for_each_subchannel(call_fn_all_sch, &cb);
  113. idset_fill(cb.set);
  114. /* Process registered subchannels. */
  115. rc = bus_for_each_dev(&css_bus_type, NULL, &cb, call_fn_known_sch);
  116. if (rc)
  117. goto out;
  118. /* Process unregistered subchannels. */
  119. if (fn_unknown)
  120. rc = for_each_subchannel(call_fn_unknown_sch, &cb);
  121. out:
  122. idset_free(cb.set);
  123. return rc;
  124. }
  125. static void css_sch_todo(struct work_struct *work);
  126. static int css_sch_create_locks(struct subchannel *sch)
  127. {
  128. sch->lock = kmalloc(sizeof(*sch->lock), GFP_KERNEL);
  129. if (!sch->lock)
  130. return -ENOMEM;
  131. spin_lock_init(sch->lock);
  132. mutex_init(&sch->reg_mutex);
  133. return 0;
  134. }
  135. static void css_subchannel_release(struct device *dev)
  136. {
  137. struct subchannel *sch = to_subchannel(dev);
  138. sch->config.intparm = 0;
  139. cio_commit_config(sch);
  140. kfree(sch->lock);
  141. kfree(sch);
  142. }
  143. static int css_validate_subchannel(struct subchannel_id schid,
  144. struct schib *schib)
  145. {
  146. int err;
  147. switch (schib->pmcw.st) {
  148. case SUBCHANNEL_TYPE_IO:
  149. case SUBCHANNEL_TYPE_MSG:
  150. if (!css_sch_is_valid(schib))
  151. err = -ENODEV;
  152. else if (is_blacklisted(schid.ssid, schib->pmcw.dev)) {
  153. CIO_MSG_EVENT(6, "Blacklisted device detected "
  154. "at devno %04X, subchannel set %x\n",
  155. schib->pmcw.dev, schid.ssid);
  156. err = -ENODEV;
  157. } else
  158. err = 0;
  159. break;
  160. default:
  161. err = 0;
  162. }
  163. if (err)
  164. goto out;
  165. CIO_MSG_EVENT(4, "Subchannel 0.%x.%04x reports subchannel type %04X\n",
  166. schid.ssid, schid.sch_no, schib->pmcw.st);
  167. out:
  168. return err;
  169. }
  170. struct subchannel *css_alloc_subchannel(struct subchannel_id schid,
  171. struct schib *schib)
  172. {
  173. struct subchannel *sch;
  174. int ret;
  175. ret = css_validate_subchannel(schid, schib);
  176. if (ret < 0)
  177. return ERR_PTR(ret);
  178. sch = kzalloc(sizeof(*sch), GFP_KERNEL | GFP_DMA);
  179. if (!sch)
  180. return ERR_PTR(-ENOMEM);
  181. sch->schid = schid;
  182. sch->schib = *schib;
  183. sch->st = schib->pmcw.st;
  184. ret = css_sch_create_locks(sch);
  185. if (ret)
  186. goto err;
  187. INIT_WORK(&sch->todo_work, css_sch_todo);
  188. sch->dev.release = &css_subchannel_release;
  189. device_initialize(&sch->dev);
  190. return sch;
  191. err:
  192. kfree(sch);
  193. return ERR_PTR(ret);
  194. }
  195. static int css_sch_device_register(struct subchannel *sch)
  196. {
  197. int ret;
  198. mutex_lock(&sch->reg_mutex);
  199. dev_set_name(&sch->dev, "0.%x.%04x", sch->schid.ssid,
  200. sch->schid.sch_no);
  201. ret = device_add(&sch->dev);
  202. mutex_unlock(&sch->reg_mutex);
  203. return ret;
  204. }
  205. /**
  206. * css_sch_device_unregister - unregister a subchannel
  207. * @sch: subchannel to be unregistered
  208. */
  209. void css_sch_device_unregister(struct subchannel *sch)
  210. {
  211. mutex_lock(&sch->reg_mutex);
  212. if (device_is_registered(&sch->dev))
  213. device_unregister(&sch->dev);
  214. mutex_unlock(&sch->reg_mutex);
  215. }
  216. EXPORT_SYMBOL_GPL(css_sch_device_unregister);
  217. static void ssd_from_pmcw(struct chsc_ssd_info *ssd, struct pmcw *pmcw)
  218. {
  219. int i;
  220. int mask;
  221. memset(ssd, 0, sizeof(struct chsc_ssd_info));
  222. ssd->path_mask = pmcw->pim;
  223. for (i = 0; i < 8; i++) {
  224. mask = 0x80 >> i;
  225. if (pmcw->pim & mask) {
  226. chp_id_init(&ssd->chpid[i]);
  227. ssd->chpid[i].id = pmcw->chpid[i];
  228. }
  229. }
  230. }
  231. static void ssd_register_chpids(struct chsc_ssd_info *ssd)
  232. {
  233. int i;
  234. int mask;
  235. for (i = 0; i < 8; i++) {
  236. mask = 0x80 >> i;
  237. if (ssd->path_mask & mask)
  238. chp_new(ssd->chpid[i]);
  239. }
  240. }
  241. void css_update_ssd_info(struct subchannel *sch)
  242. {
  243. int ret;
  244. ret = chsc_get_ssd_info(sch->schid, &sch->ssd_info);
  245. if (ret)
  246. ssd_from_pmcw(&sch->ssd_info, &sch->schib.pmcw);
  247. ssd_register_chpids(&sch->ssd_info);
  248. }
  249. static ssize_t type_show(struct device *dev, struct device_attribute *attr,
  250. char *buf)
  251. {
  252. struct subchannel *sch = to_subchannel(dev);
  253. return sprintf(buf, "%01x\n", sch->st);
  254. }
  255. static DEVICE_ATTR_RO(type);
  256. static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
  257. char *buf)
  258. {
  259. struct subchannel *sch = to_subchannel(dev);
  260. return sprintf(buf, "css:t%01X\n", sch->st);
  261. }
  262. static DEVICE_ATTR_RO(modalias);
  263. static struct attribute *subch_attrs[] = {
  264. &dev_attr_type.attr,
  265. &dev_attr_modalias.attr,
  266. NULL,
  267. };
  268. static struct attribute_group subch_attr_group = {
  269. .attrs = subch_attrs,
  270. };
  271. static const struct attribute_group *default_subch_attr_groups[] = {
  272. &subch_attr_group,
  273. NULL,
  274. };
  275. static ssize_t chpids_show(struct device *dev,
  276. struct device_attribute *attr,
  277. char *buf)
  278. {
  279. struct subchannel *sch = to_subchannel(dev);
  280. struct chsc_ssd_info *ssd = &sch->ssd_info;
  281. ssize_t ret = 0;
  282. int mask;
  283. int chp;
  284. for (chp = 0; chp < 8; chp++) {
  285. mask = 0x80 >> chp;
  286. if (ssd->path_mask & mask)
  287. ret += sprintf(buf + ret, "%02x ", ssd->chpid[chp].id);
  288. else
  289. ret += sprintf(buf + ret, "00 ");
  290. }
  291. ret += sprintf(buf + ret, "\n");
  292. return ret;
  293. }
  294. static DEVICE_ATTR_RO(chpids);
  295. static ssize_t pimpampom_show(struct device *dev,
  296. struct device_attribute *attr,
  297. char *buf)
  298. {
  299. struct subchannel *sch = to_subchannel(dev);
  300. struct pmcw *pmcw = &sch->schib.pmcw;
  301. return sprintf(buf, "%02x %02x %02x\n",
  302. pmcw->pim, pmcw->pam, pmcw->pom);
  303. }
  304. static DEVICE_ATTR_RO(pimpampom);
  305. static struct attribute *io_subchannel_type_attrs[] = {
  306. &dev_attr_chpids.attr,
  307. &dev_attr_pimpampom.attr,
  308. NULL,
  309. };
  310. ATTRIBUTE_GROUPS(io_subchannel_type);
  311. static const struct device_type io_subchannel_type = {
  312. .groups = io_subchannel_type_groups,
  313. };
  314. int css_register_subchannel(struct subchannel *sch)
  315. {
  316. int ret;
  317. /* Initialize the subchannel structure */
  318. sch->dev.parent = &channel_subsystems[0]->device;
  319. sch->dev.bus = &css_bus_type;
  320. sch->dev.groups = default_subch_attr_groups;
  321. if (sch->st == SUBCHANNEL_TYPE_IO)
  322. sch->dev.type = &io_subchannel_type;
  323. /*
  324. * We don't want to generate uevents for I/O subchannels that don't
  325. * have a working ccw device behind them since they will be
  326. * unregistered before they can be used anyway, so we delay the add
  327. * uevent until after device recognition was successful.
  328. * Note that we suppress the uevent for all subchannel types;
  329. * the subchannel driver can decide itself when it wants to inform
  330. * userspace of its existence.
  331. */
  332. dev_set_uevent_suppress(&sch->dev, 1);
  333. css_update_ssd_info(sch);
  334. /* make it known to the system */
  335. ret = css_sch_device_register(sch);
  336. if (ret) {
  337. CIO_MSG_EVENT(0, "Could not register sch 0.%x.%04x: %d\n",
  338. sch->schid.ssid, sch->schid.sch_no, ret);
  339. return ret;
  340. }
  341. if (!sch->driver) {
  342. /*
  343. * No driver matched. Generate the uevent now so that
  344. * a fitting driver module may be loaded based on the
  345. * modalias.
  346. */
  347. dev_set_uevent_suppress(&sch->dev, 0);
  348. kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
  349. }
  350. return ret;
  351. }
  352. static int css_probe_device(struct subchannel_id schid, struct schib *schib)
  353. {
  354. struct subchannel *sch;
  355. int ret;
  356. sch = css_alloc_subchannel(schid, schib);
  357. if (IS_ERR(sch))
  358. return PTR_ERR(sch);
  359. ret = css_register_subchannel(sch);
  360. if (ret)
  361. put_device(&sch->dev);
  362. return ret;
  363. }
  364. static int
  365. check_subchannel(struct device * dev, void * data)
  366. {
  367. struct subchannel *sch;
  368. struct subchannel_id *schid = data;
  369. sch = to_subchannel(dev);
  370. return schid_equal(&sch->schid, schid);
  371. }
  372. struct subchannel *
  373. get_subchannel_by_schid(struct subchannel_id schid)
  374. {
  375. struct device *dev;
  376. dev = bus_find_device(&css_bus_type, NULL,
  377. &schid, check_subchannel);
  378. return dev ? to_subchannel(dev) : NULL;
  379. }
  380. /**
  381. * css_sch_is_valid() - check if a subchannel is valid
  382. * @schib: subchannel information block for the subchannel
  383. */
  384. int css_sch_is_valid(struct schib *schib)
  385. {
  386. if ((schib->pmcw.st == SUBCHANNEL_TYPE_IO) && !schib->pmcw.dnv)
  387. return 0;
  388. if ((schib->pmcw.st == SUBCHANNEL_TYPE_MSG) && !schib->pmcw.w)
  389. return 0;
  390. return 1;
  391. }
  392. EXPORT_SYMBOL_GPL(css_sch_is_valid);
  393. static int css_evaluate_new_subchannel(struct subchannel_id schid, int slow)
  394. {
  395. struct schib schib;
  396. int ccode;
  397. if (!slow) {
  398. /* Will be done on the slow path. */
  399. return -EAGAIN;
  400. }
  401. /*
  402. * The first subchannel that is not-operational (ccode==3)
  403. * indicates that there aren't any more devices available.
  404. * If stsch gets an exception, it means the current subchannel set
  405. * is not valid.
  406. */
  407. ccode = stsch(schid, &schib);
  408. if (ccode)
  409. return (ccode == 3) ? -ENXIO : ccode;
  410. return css_probe_device(schid, &schib);
  411. }
  412. static int css_evaluate_known_subchannel(struct subchannel *sch, int slow)
  413. {
  414. int ret = 0;
  415. if (sch->driver) {
  416. if (sch->driver->sch_event)
  417. ret = sch->driver->sch_event(sch, slow);
  418. else
  419. dev_dbg(&sch->dev,
  420. "Got subchannel machine check but "
  421. "no sch_event handler provided.\n");
  422. }
  423. if (ret != 0 && ret != -EAGAIN) {
  424. CIO_MSG_EVENT(2, "eval: sch 0.%x.%04x, rc=%d\n",
  425. sch->schid.ssid, sch->schid.sch_no, ret);
  426. }
  427. return ret;
  428. }
  429. static void css_evaluate_subchannel(struct subchannel_id schid, int slow)
  430. {
  431. struct subchannel *sch;
  432. int ret;
  433. sch = get_subchannel_by_schid(schid);
  434. if (sch) {
  435. ret = css_evaluate_known_subchannel(sch, slow);
  436. put_device(&sch->dev);
  437. } else
  438. ret = css_evaluate_new_subchannel(schid, slow);
  439. if (ret == -EAGAIN)
  440. css_schedule_eval(schid);
  441. }
  442. /**
  443. * css_sched_sch_todo - schedule a subchannel operation
  444. * @sch: subchannel
  445. * @todo: todo
  446. *
  447. * Schedule the operation identified by @todo to be performed on the slow path
  448. * workqueue. Do nothing if another operation with higher priority is already
  449. * scheduled. Needs to be called with subchannel lock held.
  450. */
  451. void css_sched_sch_todo(struct subchannel *sch, enum sch_todo todo)
  452. {
  453. CIO_MSG_EVENT(4, "sch_todo: sched sch=0.%x.%04x todo=%d\n",
  454. sch->schid.ssid, sch->schid.sch_no, todo);
  455. if (sch->todo >= todo)
  456. return;
  457. /* Get workqueue ref. */
  458. if (!get_device(&sch->dev))
  459. return;
  460. sch->todo = todo;
  461. if (!queue_work(cio_work_q, &sch->todo_work)) {
  462. /* Already queued, release workqueue ref. */
  463. put_device(&sch->dev);
  464. }
  465. }
  466. EXPORT_SYMBOL_GPL(css_sched_sch_todo);
  467. static void css_sch_todo(struct work_struct *work)
  468. {
  469. struct subchannel *sch;
  470. enum sch_todo todo;
  471. int ret;
  472. sch = container_of(work, struct subchannel, todo_work);
  473. /* Find out todo. */
  474. spin_lock_irq(sch->lock);
  475. todo = sch->todo;
  476. CIO_MSG_EVENT(4, "sch_todo: sch=0.%x.%04x, todo=%d\n", sch->schid.ssid,
  477. sch->schid.sch_no, todo);
  478. sch->todo = SCH_TODO_NOTHING;
  479. spin_unlock_irq(sch->lock);
  480. /* Perform todo. */
  481. switch (todo) {
  482. case SCH_TODO_NOTHING:
  483. break;
  484. case SCH_TODO_EVAL:
  485. ret = css_evaluate_known_subchannel(sch, 1);
  486. if (ret == -EAGAIN) {
  487. spin_lock_irq(sch->lock);
  488. css_sched_sch_todo(sch, todo);
  489. spin_unlock_irq(sch->lock);
  490. }
  491. break;
  492. case SCH_TODO_UNREG:
  493. css_sch_device_unregister(sch);
  494. break;
  495. }
  496. /* Release workqueue ref. */
  497. put_device(&sch->dev);
  498. }
  499. static struct idset *slow_subchannel_set;
  500. static spinlock_t slow_subchannel_lock;
  501. static wait_queue_head_t css_eval_wq;
  502. static atomic_t css_eval_scheduled;
  503. static int __init slow_subchannel_init(void)
  504. {
  505. spin_lock_init(&slow_subchannel_lock);
  506. atomic_set(&css_eval_scheduled, 0);
  507. init_waitqueue_head(&css_eval_wq);
  508. slow_subchannel_set = idset_sch_new();
  509. if (!slow_subchannel_set) {
  510. CIO_MSG_EVENT(0, "could not allocate slow subchannel set\n");
  511. return -ENOMEM;
  512. }
  513. return 0;
  514. }
  515. static int slow_eval_known_fn(struct subchannel *sch, void *data)
  516. {
  517. int eval;
  518. int rc;
  519. spin_lock_irq(&slow_subchannel_lock);
  520. eval = idset_sch_contains(slow_subchannel_set, sch->schid);
  521. idset_sch_del(slow_subchannel_set, sch->schid);
  522. spin_unlock_irq(&slow_subchannel_lock);
  523. if (eval) {
  524. rc = css_evaluate_known_subchannel(sch, 1);
  525. if (rc == -EAGAIN)
  526. css_schedule_eval(sch->schid);
  527. }
  528. return 0;
  529. }
  530. static int slow_eval_unknown_fn(struct subchannel_id schid, void *data)
  531. {
  532. int eval;
  533. int rc = 0;
  534. spin_lock_irq(&slow_subchannel_lock);
  535. eval = idset_sch_contains(slow_subchannel_set, schid);
  536. idset_sch_del(slow_subchannel_set, schid);
  537. spin_unlock_irq(&slow_subchannel_lock);
  538. if (eval) {
  539. rc = css_evaluate_new_subchannel(schid, 1);
  540. switch (rc) {
  541. case -EAGAIN:
  542. css_schedule_eval(schid);
  543. rc = 0;
  544. break;
  545. case -ENXIO:
  546. case -ENOMEM:
  547. case -EIO:
  548. /* These should abort looping */
  549. spin_lock_irq(&slow_subchannel_lock);
  550. idset_sch_del_subseq(slow_subchannel_set, schid);
  551. spin_unlock_irq(&slow_subchannel_lock);
  552. break;
  553. default:
  554. rc = 0;
  555. }
  556. /* Allow scheduling here since the containing loop might
  557. * take a while. */
  558. cond_resched();
  559. }
  560. return rc;
  561. }
  562. static void css_slow_path_func(struct work_struct *unused)
  563. {
  564. unsigned long flags;
  565. CIO_TRACE_EVENT(4, "slowpath");
  566. for_each_subchannel_staged(slow_eval_known_fn, slow_eval_unknown_fn,
  567. NULL);
  568. spin_lock_irqsave(&slow_subchannel_lock, flags);
  569. if (idset_is_empty(slow_subchannel_set)) {
  570. atomic_set(&css_eval_scheduled, 0);
  571. wake_up(&css_eval_wq);
  572. }
  573. spin_unlock_irqrestore(&slow_subchannel_lock, flags);
  574. }
  575. static DECLARE_DELAYED_WORK(slow_path_work, css_slow_path_func);
  576. struct workqueue_struct *cio_work_q;
  577. void css_schedule_eval(struct subchannel_id schid)
  578. {
  579. unsigned long flags;
  580. spin_lock_irqsave(&slow_subchannel_lock, flags);
  581. idset_sch_add(slow_subchannel_set, schid);
  582. atomic_set(&css_eval_scheduled, 1);
  583. queue_delayed_work(cio_work_q, &slow_path_work, 0);
  584. spin_unlock_irqrestore(&slow_subchannel_lock, flags);
  585. }
  586. void css_schedule_eval_all(void)
  587. {
  588. unsigned long flags;
  589. spin_lock_irqsave(&slow_subchannel_lock, flags);
  590. idset_fill(slow_subchannel_set);
  591. atomic_set(&css_eval_scheduled, 1);
  592. queue_delayed_work(cio_work_q, &slow_path_work, 0);
  593. spin_unlock_irqrestore(&slow_subchannel_lock, flags);
  594. }
  595. static int __unset_registered(struct device *dev, void *data)
  596. {
  597. struct idset *set = data;
  598. struct subchannel *sch = to_subchannel(dev);
  599. idset_sch_del(set, sch->schid);
  600. return 0;
  601. }
  602. void css_schedule_eval_all_unreg(unsigned long delay)
  603. {
  604. unsigned long flags;
  605. struct idset *unreg_set;
  606. /* Find unregistered subchannels. */
  607. unreg_set = idset_sch_new();
  608. if (!unreg_set) {
  609. /* Fallback. */
  610. css_schedule_eval_all();
  611. return;
  612. }
  613. idset_fill(unreg_set);
  614. bus_for_each_dev(&css_bus_type, NULL, unreg_set, __unset_registered);
  615. /* Apply to slow_subchannel_set. */
  616. spin_lock_irqsave(&slow_subchannel_lock, flags);
  617. idset_add_set(slow_subchannel_set, unreg_set);
  618. atomic_set(&css_eval_scheduled, 1);
  619. queue_delayed_work(cio_work_q, &slow_path_work, delay);
  620. spin_unlock_irqrestore(&slow_subchannel_lock, flags);
  621. idset_free(unreg_set);
  622. }
  623. void css_wait_for_slow_path(void)
  624. {
  625. flush_workqueue(cio_work_q);
  626. }
  627. /* Schedule reprobing of all unregistered subchannels. */
  628. void css_schedule_reprobe(void)
  629. {
  630. /* Schedule with a delay to allow merging of subsequent calls. */
  631. css_schedule_eval_all_unreg(1 * HZ);
  632. }
  633. EXPORT_SYMBOL_GPL(css_schedule_reprobe);
  634. /*
  635. * Called from the machine check handler for subchannel report words.
  636. */
  637. static void css_process_crw(struct crw *crw0, struct crw *crw1, int overflow)
  638. {
  639. struct subchannel_id mchk_schid;
  640. struct subchannel *sch;
  641. if (overflow) {
  642. css_schedule_eval_all();
  643. return;
  644. }
  645. CIO_CRW_EVENT(2, "CRW0 reports slct=%d, oflw=%d, "
  646. "chn=%d, rsc=%X, anc=%d, erc=%X, rsid=%X\n",
  647. crw0->slct, crw0->oflw, crw0->chn, crw0->rsc, crw0->anc,
  648. crw0->erc, crw0->rsid);
  649. if (crw1)
  650. CIO_CRW_EVENT(2, "CRW1 reports slct=%d, oflw=%d, "
  651. "chn=%d, rsc=%X, anc=%d, erc=%X, rsid=%X\n",
  652. crw1->slct, crw1->oflw, crw1->chn, crw1->rsc,
  653. crw1->anc, crw1->erc, crw1->rsid);
  654. init_subchannel_id(&mchk_schid);
  655. mchk_schid.sch_no = crw0->rsid;
  656. if (crw1)
  657. mchk_schid.ssid = (crw1->rsid >> 4) & 3;
  658. if (crw0->erc == CRW_ERC_PMOD) {
  659. sch = get_subchannel_by_schid(mchk_schid);
  660. if (sch) {
  661. css_update_ssd_info(sch);
  662. put_device(&sch->dev);
  663. }
  664. }
  665. /*
  666. * Since we are always presented with IPI in the CRW, we have to
  667. * use stsch() to find out if the subchannel in question has come
  668. * or gone.
  669. */
  670. css_evaluate_subchannel(mchk_schid, 0);
  671. }
  672. static void __init
  673. css_generate_pgid(struct channel_subsystem *css, u32 tod_high)
  674. {
  675. struct cpuid cpu_id;
  676. if (css_general_characteristics.mcss) {
  677. css->global_pgid.pgid_high.ext_cssid.version = 0x80;
  678. css->global_pgid.pgid_high.ext_cssid.cssid =
  679. (css->cssid < 0) ? 0 : css->cssid;
  680. } else {
  681. css->global_pgid.pgid_high.cpu_addr = stap();
  682. }
  683. get_cpu_id(&cpu_id);
  684. css->global_pgid.cpu_id = cpu_id.ident;
  685. css->global_pgid.cpu_model = cpu_id.machine;
  686. css->global_pgid.tod_high = tod_high;
  687. }
  688. static void channel_subsystem_release(struct device *dev)
  689. {
  690. struct channel_subsystem *css = to_css(dev);
  691. mutex_destroy(&css->mutex);
  692. kfree(css);
  693. }
  694. static ssize_t real_cssid_show(struct device *dev, struct device_attribute *a,
  695. char *buf)
  696. {
  697. struct channel_subsystem *css = to_css(dev);
  698. if (css->cssid < 0)
  699. return -EINVAL;
  700. return sprintf(buf, "%x\n", css->cssid);
  701. }
  702. static DEVICE_ATTR_RO(real_cssid);
  703. static ssize_t cm_enable_show(struct device *dev, struct device_attribute *a,
  704. char *buf)
  705. {
  706. struct channel_subsystem *css = to_css(dev);
  707. int ret;
  708. mutex_lock(&css->mutex);
  709. ret = sprintf(buf, "%x\n", css->cm_enabled);
  710. mutex_unlock(&css->mutex);
  711. return ret;
  712. }
  713. static ssize_t cm_enable_store(struct device *dev, struct device_attribute *a,
  714. const char *buf, size_t count)
  715. {
  716. struct channel_subsystem *css = to_css(dev);
  717. unsigned long val;
  718. int ret;
  719. ret = kstrtoul(buf, 16, &val);
  720. if (ret)
  721. return ret;
  722. mutex_lock(&css->mutex);
  723. switch (val) {
  724. case 0:
  725. ret = css->cm_enabled ? chsc_secm(css, 0) : 0;
  726. break;
  727. case 1:
  728. ret = css->cm_enabled ? 0 : chsc_secm(css, 1);
  729. break;
  730. default:
  731. ret = -EINVAL;
  732. }
  733. mutex_unlock(&css->mutex);
  734. return ret < 0 ? ret : count;
  735. }
  736. static DEVICE_ATTR_RW(cm_enable);
  737. static umode_t cm_enable_mode(struct kobject *kobj, struct attribute *attr,
  738. int index)
  739. {
  740. return css_chsc_characteristics.secm ? attr->mode : 0;
  741. }
  742. static struct attribute *cssdev_attrs[] = {
  743. &dev_attr_real_cssid.attr,
  744. NULL,
  745. };
  746. static struct attribute_group cssdev_attr_group = {
  747. .attrs = cssdev_attrs,
  748. };
  749. static struct attribute *cssdev_cm_attrs[] = {
  750. &dev_attr_cm_enable.attr,
  751. NULL,
  752. };
  753. static struct attribute_group cssdev_cm_attr_group = {
  754. .attrs = cssdev_cm_attrs,
  755. .is_visible = cm_enable_mode,
  756. };
  757. static const struct attribute_group *cssdev_attr_groups[] = {
  758. &cssdev_attr_group,
  759. &cssdev_cm_attr_group,
  760. NULL,
  761. };
  762. static int __init setup_css(int nr)
  763. {
  764. struct channel_subsystem *css;
  765. int ret;
  766. css = kzalloc(sizeof(*css), GFP_KERNEL);
  767. if (!css)
  768. return -ENOMEM;
  769. channel_subsystems[nr] = css;
  770. dev_set_name(&css->device, "css%x", nr);
  771. css->device.groups = cssdev_attr_groups;
  772. css->device.release = channel_subsystem_release;
  773. mutex_init(&css->mutex);
  774. css->cssid = chsc_get_cssid(nr);
  775. css_generate_pgid(css, (u32) (get_tod_clock() >> 32));
  776. ret = device_register(&css->device);
  777. if (ret) {
  778. put_device(&css->device);
  779. goto out_err;
  780. }
  781. css->pseudo_subchannel = kzalloc(sizeof(*css->pseudo_subchannel),
  782. GFP_KERNEL);
  783. if (!css->pseudo_subchannel) {
  784. device_unregister(&css->device);
  785. ret = -ENOMEM;
  786. goto out_err;
  787. }
  788. css->pseudo_subchannel->dev.parent = &css->device;
  789. css->pseudo_subchannel->dev.release = css_subchannel_release;
  790. mutex_init(&css->pseudo_subchannel->reg_mutex);
  791. ret = css_sch_create_locks(css->pseudo_subchannel);
  792. if (ret) {
  793. kfree(css->pseudo_subchannel);
  794. device_unregister(&css->device);
  795. goto out_err;
  796. }
  797. dev_set_name(&css->pseudo_subchannel->dev, "defunct");
  798. ret = device_register(&css->pseudo_subchannel->dev);
  799. if (ret) {
  800. put_device(&css->pseudo_subchannel->dev);
  801. device_unregister(&css->device);
  802. goto out_err;
  803. }
  804. return ret;
  805. out_err:
  806. channel_subsystems[nr] = NULL;
  807. return ret;
  808. }
  809. static int css_reboot_event(struct notifier_block *this,
  810. unsigned long event,
  811. void *ptr)
  812. {
  813. struct channel_subsystem *css;
  814. int ret;
  815. ret = NOTIFY_DONE;
  816. for_each_css(css) {
  817. mutex_lock(&css->mutex);
  818. if (css->cm_enabled)
  819. if (chsc_secm(css, 0))
  820. ret = NOTIFY_BAD;
  821. mutex_unlock(&css->mutex);
  822. }
  823. return ret;
  824. }
  825. static struct notifier_block css_reboot_notifier = {
  826. .notifier_call = css_reboot_event,
  827. };
  828. /*
  829. * Since the css devices are neither on a bus nor have a class
  830. * nor have a special device type, we cannot stop/restart channel
  831. * path measurements via the normal suspend/resume callbacks, but have
  832. * to use notifiers.
  833. */
  834. static int css_power_event(struct notifier_block *this, unsigned long event,
  835. void *ptr)
  836. {
  837. struct channel_subsystem *css;
  838. int ret;
  839. switch (event) {
  840. case PM_HIBERNATION_PREPARE:
  841. case PM_SUSPEND_PREPARE:
  842. ret = NOTIFY_DONE;
  843. for_each_css(css) {
  844. mutex_lock(&css->mutex);
  845. if (!css->cm_enabled) {
  846. mutex_unlock(&css->mutex);
  847. continue;
  848. }
  849. ret = __chsc_do_secm(css, 0);
  850. ret = notifier_from_errno(ret);
  851. mutex_unlock(&css->mutex);
  852. }
  853. break;
  854. case PM_POST_HIBERNATION:
  855. case PM_POST_SUSPEND:
  856. ret = NOTIFY_DONE;
  857. for_each_css(css) {
  858. mutex_lock(&css->mutex);
  859. if (!css->cm_enabled) {
  860. mutex_unlock(&css->mutex);
  861. continue;
  862. }
  863. ret = __chsc_do_secm(css, 1);
  864. ret = notifier_from_errno(ret);
  865. mutex_unlock(&css->mutex);
  866. }
  867. /* search for subchannels, which appeared during hibernation */
  868. css_schedule_reprobe();
  869. break;
  870. default:
  871. ret = NOTIFY_DONE;
  872. }
  873. return ret;
  874. }
  875. static struct notifier_block css_power_notifier = {
  876. .notifier_call = css_power_event,
  877. };
  878. /*
  879. * Now that the driver core is running, we can setup our channel subsystem.
  880. * The struct subchannel's are created during probing.
  881. */
  882. static int __init css_bus_init(void)
  883. {
  884. int ret, i;
  885. ret = chsc_init();
  886. if (ret)
  887. return ret;
  888. chsc_determine_css_characteristics();
  889. /* Try to enable MSS. */
  890. ret = chsc_enable_facility(CHSC_SDA_OC_MSS);
  891. if (ret)
  892. max_ssid = 0;
  893. else /* Success. */
  894. max_ssid = __MAX_SSID;
  895. ret = slow_subchannel_init();
  896. if (ret)
  897. goto out;
  898. ret = crw_register_handler(CRW_RSC_SCH, css_process_crw);
  899. if (ret)
  900. goto out;
  901. if ((ret = bus_register(&css_bus_type)))
  902. goto out;
  903. /* Setup css structure. */
  904. for (i = 0; i <= MAX_CSS_IDX; i++) {
  905. ret = setup_css(i);
  906. if (ret)
  907. goto out_unregister;
  908. }
  909. ret = register_reboot_notifier(&css_reboot_notifier);
  910. if (ret)
  911. goto out_unregister;
  912. ret = register_pm_notifier(&css_power_notifier);
  913. if (ret) {
  914. unregister_reboot_notifier(&css_reboot_notifier);
  915. goto out_unregister;
  916. }
  917. css_init_done = 1;
  918. /* Enable default isc for I/O subchannels. */
  919. isc_register(IO_SCH_ISC);
  920. return 0;
  921. out_unregister:
  922. while (i-- > 0) {
  923. struct channel_subsystem *css = channel_subsystems[i];
  924. device_unregister(&css->pseudo_subchannel->dev);
  925. device_unregister(&css->device);
  926. }
  927. bus_unregister(&css_bus_type);
  928. out:
  929. crw_unregister_handler(CRW_RSC_SCH);
  930. idset_free(slow_subchannel_set);
  931. chsc_init_cleanup();
  932. pr_alert("The CSS device driver initialization failed with "
  933. "errno=%d\n", ret);
  934. return ret;
  935. }
  936. static void __init css_bus_cleanup(void)
  937. {
  938. struct channel_subsystem *css;
  939. for_each_css(css) {
  940. device_unregister(&css->pseudo_subchannel->dev);
  941. device_unregister(&css->device);
  942. }
  943. bus_unregister(&css_bus_type);
  944. crw_unregister_handler(CRW_RSC_SCH);
  945. idset_free(slow_subchannel_set);
  946. chsc_init_cleanup();
  947. isc_unregister(IO_SCH_ISC);
  948. }
  949. static int __init channel_subsystem_init(void)
  950. {
  951. int ret;
  952. ret = css_bus_init();
  953. if (ret)
  954. return ret;
  955. cio_work_q = create_singlethread_workqueue("cio");
  956. if (!cio_work_q) {
  957. ret = -ENOMEM;
  958. goto out_bus;
  959. }
  960. ret = io_subchannel_init();
  961. if (ret)
  962. goto out_wq;
  963. /* Register subchannels which are already in use. */
  964. cio_register_early_subchannels();
  965. /* Start initial subchannel evaluation. */
  966. css_schedule_eval_all();
  967. return ret;
  968. out_wq:
  969. destroy_workqueue(cio_work_q);
  970. out_bus:
  971. css_bus_cleanup();
  972. return ret;
  973. }
  974. subsys_initcall(channel_subsystem_init);
  975. static int css_settle(struct device_driver *drv, void *unused)
  976. {
  977. struct css_driver *cssdrv = to_cssdriver(drv);
  978. if (cssdrv->settle)
  979. return cssdrv->settle();
  980. return 0;
  981. }
  982. int css_complete_work(void)
  983. {
  984. int ret;
  985. /* Wait for the evaluation of subchannels to finish. */
  986. ret = wait_event_interruptible(css_eval_wq,
  987. atomic_read(&css_eval_scheduled) == 0);
  988. if (ret)
  989. return -EINTR;
  990. flush_workqueue(cio_work_q);
  991. /* Wait for the subchannel type specific initialization to finish */
  992. return bus_for_each_drv(&css_bus_type, NULL, NULL, css_settle);
  993. }
  994. /*
  995. * Wait for the initialization of devices to finish, to make sure we are
  996. * done with our setup if the search for the root device starts.
  997. */
  998. static int __init channel_subsystem_init_sync(void)
  999. {
  1000. css_complete_work();
  1001. return 0;
  1002. }
  1003. subsys_initcall_sync(channel_subsystem_init_sync);
  1004. void channel_subsystem_reinit(void)
  1005. {
  1006. struct channel_path *chp;
  1007. struct chp_id chpid;
  1008. chsc_enable_facility(CHSC_SDA_OC_MSS);
  1009. chp_id_for_each(&chpid) {
  1010. chp = chpid_to_chp(chpid);
  1011. if (chp)
  1012. chp_update_desc(chp);
  1013. }
  1014. cmf_reactivate();
  1015. }
  1016. #ifdef CONFIG_PROC_FS
  1017. static ssize_t cio_settle_write(struct file *file, const char __user *buf,
  1018. size_t count, loff_t *ppos)
  1019. {
  1020. int ret;
  1021. /* Handle pending CRW's. */
  1022. crw_wait_for_channel_report();
  1023. ret = css_complete_work();
  1024. return ret ? ret : count;
  1025. }
  1026. static const struct file_operations cio_settle_proc_fops = {
  1027. .open = nonseekable_open,
  1028. .write = cio_settle_write,
  1029. .llseek = no_llseek,
  1030. };
  1031. static int __init cio_settle_init(void)
  1032. {
  1033. struct proc_dir_entry *entry;
  1034. entry = proc_create("cio_settle", S_IWUSR, NULL,
  1035. &cio_settle_proc_fops);
  1036. if (!entry)
  1037. return -ENOMEM;
  1038. return 0;
  1039. }
  1040. device_initcall(cio_settle_init);
  1041. #endif /*CONFIG_PROC_FS*/
  1042. int sch_is_pseudo_sch(struct subchannel *sch)
  1043. {
  1044. return sch == to_css(sch->dev.parent)->pseudo_subchannel;
  1045. }
  1046. static int css_bus_match(struct device *dev, struct device_driver *drv)
  1047. {
  1048. struct subchannel *sch = to_subchannel(dev);
  1049. struct css_driver *driver = to_cssdriver(drv);
  1050. struct css_device_id *id;
  1051. for (id = driver->subchannel_type; id->match_flags; id++) {
  1052. if (sch->st == id->type)
  1053. return 1;
  1054. }
  1055. return 0;
  1056. }
  1057. static int css_probe(struct device *dev)
  1058. {
  1059. struct subchannel *sch;
  1060. int ret;
  1061. sch = to_subchannel(dev);
  1062. sch->driver = to_cssdriver(dev->driver);
  1063. ret = sch->driver->probe ? sch->driver->probe(sch) : 0;
  1064. if (ret)
  1065. sch->driver = NULL;
  1066. return ret;
  1067. }
  1068. static int css_remove(struct device *dev)
  1069. {
  1070. struct subchannel *sch;
  1071. int ret;
  1072. sch = to_subchannel(dev);
  1073. ret = sch->driver->remove ? sch->driver->remove(sch) : 0;
  1074. sch->driver = NULL;
  1075. return ret;
  1076. }
  1077. static void css_shutdown(struct device *dev)
  1078. {
  1079. struct subchannel *sch;
  1080. sch = to_subchannel(dev);
  1081. if (sch->driver && sch->driver->shutdown)
  1082. sch->driver->shutdown(sch);
  1083. }
  1084. static int css_uevent(struct device *dev, struct kobj_uevent_env *env)
  1085. {
  1086. struct subchannel *sch = to_subchannel(dev);
  1087. int ret;
  1088. ret = add_uevent_var(env, "ST=%01X", sch->st);
  1089. if (ret)
  1090. return ret;
  1091. ret = add_uevent_var(env, "MODALIAS=css:t%01X", sch->st);
  1092. return ret;
  1093. }
  1094. static int css_pm_prepare(struct device *dev)
  1095. {
  1096. struct subchannel *sch = to_subchannel(dev);
  1097. struct css_driver *drv;
  1098. if (mutex_is_locked(&sch->reg_mutex))
  1099. return -EAGAIN;
  1100. if (!sch->dev.driver)
  1101. return 0;
  1102. drv = to_cssdriver(sch->dev.driver);
  1103. /* Notify drivers that they may not register children. */
  1104. return drv->prepare ? drv->prepare(sch) : 0;
  1105. }
  1106. static void css_pm_complete(struct device *dev)
  1107. {
  1108. struct subchannel *sch = to_subchannel(dev);
  1109. struct css_driver *drv;
  1110. if (!sch->dev.driver)
  1111. return;
  1112. drv = to_cssdriver(sch->dev.driver);
  1113. if (drv->complete)
  1114. drv->complete(sch);
  1115. }
  1116. static int css_pm_freeze(struct device *dev)
  1117. {
  1118. struct subchannel *sch = to_subchannel(dev);
  1119. struct css_driver *drv;
  1120. if (!sch->dev.driver)
  1121. return 0;
  1122. drv = to_cssdriver(sch->dev.driver);
  1123. return drv->freeze ? drv->freeze(sch) : 0;
  1124. }
  1125. static int css_pm_thaw(struct device *dev)
  1126. {
  1127. struct subchannel *sch = to_subchannel(dev);
  1128. struct css_driver *drv;
  1129. if (!sch->dev.driver)
  1130. return 0;
  1131. drv = to_cssdriver(sch->dev.driver);
  1132. return drv->thaw ? drv->thaw(sch) : 0;
  1133. }
  1134. static int css_pm_restore(struct device *dev)
  1135. {
  1136. struct subchannel *sch = to_subchannel(dev);
  1137. struct css_driver *drv;
  1138. css_update_ssd_info(sch);
  1139. if (!sch->dev.driver)
  1140. return 0;
  1141. drv = to_cssdriver(sch->dev.driver);
  1142. return drv->restore ? drv->restore(sch) : 0;
  1143. }
  1144. static const struct dev_pm_ops css_pm_ops = {
  1145. .prepare = css_pm_prepare,
  1146. .complete = css_pm_complete,
  1147. .freeze = css_pm_freeze,
  1148. .thaw = css_pm_thaw,
  1149. .restore = css_pm_restore,
  1150. };
  1151. static struct bus_type css_bus_type = {
  1152. .name = "css",
  1153. .match = css_bus_match,
  1154. .probe = css_probe,
  1155. .remove = css_remove,
  1156. .shutdown = css_shutdown,
  1157. .uevent = css_uevent,
  1158. .pm = &css_pm_ops,
  1159. };
  1160. /**
  1161. * css_driver_register - register a css driver
  1162. * @cdrv: css driver to register
  1163. *
  1164. * This is mainly a wrapper around driver_register that sets name
  1165. * and bus_type in the embedded struct device_driver correctly.
  1166. */
  1167. int css_driver_register(struct css_driver *cdrv)
  1168. {
  1169. cdrv->drv.bus = &css_bus_type;
  1170. return driver_register(&cdrv->drv);
  1171. }
  1172. EXPORT_SYMBOL_GPL(css_driver_register);
  1173. /**
  1174. * css_driver_unregister - unregister a css driver
  1175. * @cdrv: css driver to unregister
  1176. *
  1177. * This is a wrapper around driver_unregister.
  1178. */
  1179. void css_driver_unregister(struct css_driver *cdrv)
  1180. {
  1181. driver_unregister(&cdrv->drv);
  1182. }
  1183. EXPORT_SYMBOL_GPL(css_driver_unregister);