hosts.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. /*
  2. * hosts.c Copyright (C) 1992 Drew Eckhardt
  3. * Copyright (C) 1993, 1994, 1995 Eric Youngdale
  4. * Copyright (C) 2002-2003 Christoph Hellwig
  5. *
  6. * mid to lowlevel SCSI driver interface
  7. * Initial versions: Drew Eckhardt
  8. * Subsequent revisions: Eric Youngdale
  9. *
  10. * <drew@colorado.edu>
  11. *
  12. * Jiffies wrap fixes (host->resetting), 3 Dec 1998 Andrea Arcangeli
  13. * Added QLOGIC QLA1280 SCSI controller kernel host support.
  14. * August 4, 1999 Fred Lewis, Intel DuPont
  15. *
  16. * Updated to reflect the new initialization scheme for the higher
  17. * level of scsi drivers (sd/sr/st)
  18. * September 17, 2000 Torben Mathiasen <tmm@image.dk>
  19. *
  20. * Restructured scsi_host lists and associated functions.
  21. * September 04, 2002 Mike Anderson (andmike@us.ibm.com)
  22. */
  23. #include <linux/module.h>
  24. #include <linux/blkdev.h>
  25. #include <linux/kernel.h>
  26. #include <linux/slab.h>
  27. #include <linux/kthread.h>
  28. #include <linux/string.h>
  29. #include <linux/mm.h>
  30. #include <linux/init.h>
  31. #include <linux/completion.h>
  32. #include <linux/transport_class.h>
  33. #include <linux/platform_device.h>
  34. #include <linux/pm_runtime.h>
  35. #include <linux/idr.h>
  36. #include <scsi/scsi_device.h>
  37. #include <scsi/scsi_host.h>
  38. #include <scsi/scsi_transport.h>
  39. #include "scsi_priv.h"
  40. #include "scsi_logging.h"
  41. static DEFINE_IDA(host_index_ida);
  42. static void scsi_host_cls_release(struct device *dev)
  43. {
  44. put_device(&class_to_shost(dev)->shost_gendev);
  45. }
  46. static struct class shost_class = {
  47. .name = "scsi_host",
  48. .dev_release = scsi_host_cls_release,
  49. };
  50. /**
  51. * scsi_host_set_state - Take the given host through the host state model.
  52. * @shost: scsi host to change the state of.
  53. * @state: state to change to.
  54. *
  55. * Returns zero if unsuccessful or an error if the requested
  56. * transition is illegal.
  57. **/
  58. int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state)
  59. {
  60. enum scsi_host_state oldstate = shost->shost_state;
  61. if (state == oldstate)
  62. return 0;
  63. switch (state) {
  64. case SHOST_CREATED:
  65. /* There are no legal states that come back to
  66. * created. This is the manually initialised start
  67. * state */
  68. goto illegal;
  69. case SHOST_RUNNING:
  70. switch (oldstate) {
  71. case SHOST_CREATED:
  72. case SHOST_RECOVERY:
  73. break;
  74. default:
  75. goto illegal;
  76. }
  77. break;
  78. case SHOST_RECOVERY:
  79. switch (oldstate) {
  80. case SHOST_RUNNING:
  81. break;
  82. default:
  83. goto illegal;
  84. }
  85. break;
  86. case SHOST_CANCEL:
  87. switch (oldstate) {
  88. case SHOST_CREATED:
  89. case SHOST_RUNNING:
  90. case SHOST_CANCEL_RECOVERY:
  91. break;
  92. default:
  93. goto illegal;
  94. }
  95. break;
  96. case SHOST_DEL:
  97. switch (oldstate) {
  98. case SHOST_CANCEL:
  99. case SHOST_DEL_RECOVERY:
  100. break;
  101. default:
  102. goto illegal;
  103. }
  104. break;
  105. case SHOST_CANCEL_RECOVERY:
  106. switch (oldstate) {
  107. case SHOST_CANCEL:
  108. case SHOST_RECOVERY:
  109. break;
  110. default:
  111. goto illegal;
  112. }
  113. break;
  114. case SHOST_DEL_RECOVERY:
  115. switch (oldstate) {
  116. case SHOST_CANCEL_RECOVERY:
  117. break;
  118. default:
  119. goto illegal;
  120. }
  121. break;
  122. }
  123. shost->shost_state = state;
  124. return 0;
  125. illegal:
  126. SCSI_LOG_ERROR_RECOVERY(1,
  127. shost_printk(KERN_ERR, shost,
  128. "Illegal host state transition"
  129. "%s->%s\n",
  130. scsi_host_state_name(oldstate),
  131. scsi_host_state_name(state)));
  132. return -EINVAL;
  133. }
  134. EXPORT_SYMBOL(scsi_host_set_state);
  135. /**
  136. * scsi_remove_host - remove a scsi host
  137. * @shost: a pointer to a scsi host to remove
  138. **/
  139. void scsi_remove_host(struct Scsi_Host *shost)
  140. {
  141. unsigned long flags;
  142. mutex_lock(&shost->scan_mutex);
  143. spin_lock_irqsave(shost->host_lock, flags);
  144. if (scsi_host_set_state(shost, SHOST_CANCEL))
  145. if (scsi_host_set_state(shost, SHOST_CANCEL_RECOVERY)) {
  146. spin_unlock_irqrestore(shost->host_lock, flags);
  147. mutex_unlock(&shost->scan_mutex);
  148. return;
  149. }
  150. spin_unlock_irqrestore(shost->host_lock, flags);
  151. scsi_autopm_get_host(shost);
  152. flush_workqueue(shost->tmf_work_q);
  153. scsi_forget_host(shost);
  154. mutex_unlock(&shost->scan_mutex);
  155. scsi_proc_host_rm(shost);
  156. spin_lock_irqsave(shost->host_lock, flags);
  157. if (scsi_host_set_state(shost, SHOST_DEL))
  158. BUG_ON(scsi_host_set_state(shost, SHOST_DEL_RECOVERY));
  159. spin_unlock_irqrestore(shost->host_lock, flags);
  160. transport_unregister_device(&shost->shost_gendev);
  161. device_unregister(&shost->shost_dev);
  162. device_del(&shost->shost_gendev);
  163. }
  164. EXPORT_SYMBOL(scsi_remove_host);
  165. /**
  166. * scsi_add_host_with_dma - add a scsi host with dma device
  167. * @shost: scsi host pointer to add
  168. * @dev: a struct device of type scsi class
  169. * @dma_dev: dma device for the host
  170. *
  171. * Note: You rarely need to worry about this unless you're in a
  172. * virtualised host environments, so use the simpler scsi_add_host()
  173. * function instead.
  174. *
  175. * Return value:
  176. * 0 on success / != 0 for error
  177. **/
  178. int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,
  179. struct device *dma_dev)
  180. {
  181. struct scsi_host_template *sht = shost->hostt;
  182. int error = -EINVAL;
  183. shost_printk(KERN_INFO, shost, "%s\n",
  184. sht->info ? sht->info(shost) : sht->name);
  185. if (!shost->can_queue) {
  186. shost_printk(KERN_ERR, shost,
  187. "can_queue = 0 no longer supported\n");
  188. goto fail;
  189. }
  190. shost->cmd_per_lun = min_t(short, shost->cmd_per_lun,
  191. shost->can_queue);
  192. error = scsi_init_sense_cache(shost);
  193. if (error)
  194. goto fail;
  195. if (shost_use_blk_mq(shost)) {
  196. error = scsi_mq_setup_tags(shost);
  197. if (error)
  198. goto fail;
  199. } else {
  200. shost->bqt = blk_init_tags(shost->can_queue,
  201. shost->hostt->tag_alloc_policy);
  202. if (!shost->bqt) {
  203. error = -ENOMEM;
  204. goto fail;
  205. }
  206. }
  207. if (!shost->shost_gendev.parent)
  208. shost->shost_gendev.parent = dev ? dev : &platform_bus;
  209. if (!dma_dev)
  210. dma_dev = shost->shost_gendev.parent;
  211. shost->dma_dev = dma_dev;
  212. /*
  213. * Increase usage count temporarily here so that calling
  214. * scsi_autopm_put_host() will trigger runtime idle if there is
  215. * nothing else preventing suspending the device.
  216. */
  217. pm_runtime_get_noresume(&shost->shost_gendev);
  218. pm_runtime_set_active(&shost->shost_gendev);
  219. pm_runtime_enable(&shost->shost_gendev);
  220. device_enable_async_suspend(&shost->shost_gendev);
  221. error = device_add(&shost->shost_gendev);
  222. if (error)
  223. goto out_disable_runtime_pm;
  224. scsi_host_set_state(shost, SHOST_RUNNING);
  225. get_device(shost->shost_gendev.parent);
  226. device_enable_async_suspend(&shost->shost_dev);
  227. get_device(&shost->shost_gendev);
  228. error = device_add(&shost->shost_dev);
  229. if (error)
  230. goto out_del_gendev;
  231. if (shost->transportt->host_size) {
  232. shost->shost_data = kzalloc(shost->transportt->host_size,
  233. GFP_KERNEL);
  234. if (shost->shost_data == NULL) {
  235. error = -ENOMEM;
  236. goto out_del_dev;
  237. }
  238. }
  239. if (shost->transportt->create_work_queue) {
  240. snprintf(shost->work_q_name, sizeof(shost->work_q_name),
  241. "scsi_wq_%d", shost->host_no);
  242. shost->work_q = create_singlethread_workqueue(
  243. shost->work_q_name);
  244. if (!shost->work_q) {
  245. error = -EINVAL;
  246. goto out_free_shost_data;
  247. }
  248. }
  249. error = scsi_sysfs_add_host(shost);
  250. if (error)
  251. goto out_destroy_host;
  252. scsi_proc_host_add(shost);
  253. scsi_autopm_put_host(shost);
  254. return error;
  255. out_destroy_host:
  256. if (shost->work_q)
  257. destroy_workqueue(shost->work_q);
  258. out_free_shost_data:
  259. kfree(shost->shost_data);
  260. out_del_dev:
  261. device_del(&shost->shost_dev);
  262. out_del_gendev:
  263. /*
  264. * Host state is SHOST_RUNNING so we have to explicitly release
  265. * ->shost_dev.
  266. */
  267. put_device(&shost->shost_dev);
  268. device_del(&shost->shost_gendev);
  269. out_disable_runtime_pm:
  270. device_disable_async_suspend(&shost->shost_gendev);
  271. pm_runtime_disable(&shost->shost_gendev);
  272. pm_runtime_set_suspended(&shost->shost_gendev);
  273. pm_runtime_put_noidle(&shost->shost_gendev);
  274. if (shost_use_blk_mq(shost))
  275. scsi_mq_destroy_tags(shost);
  276. fail:
  277. return error;
  278. }
  279. EXPORT_SYMBOL(scsi_add_host_with_dma);
  280. static void scsi_host_dev_release(struct device *dev)
  281. {
  282. struct Scsi_Host *shost = dev_to_shost(dev);
  283. struct device *parent = dev->parent;
  284. scsi_proc_hostdir_rm(shost->hostt);
  285. /* Wait for functions invoked through call_rcu(&shost->rcu, ...) */
  286. rcu_barrier();
  287. if (shost->tmf_work_q)
  288. destroy_workqueue(shost->tmf_work_q);
  289. if (shost->ehandler)
  290. kthread_stop(shost->ehandler);
  291. if (shost->work_q)
  292. destroy_workqueue(shost->work_q);
  293. if (shost->shost_state == SHOST_CREATED) {
  294. /*
  295. * Free the shost_dev device name here if scsi_host_alloc()
  296. * and scsi_host_put() have been called but neither
  297. * scsi_host_add() nor scsi_host_remove() has been called.
  298. * This avoids that the memory allocated for the shost_dev
  299. * name is leaked.
  300. */
  301. kfree(dev_name(&shost->shost_dev));
  302. }
  303. if (shost_use_blk_mq(shost)) {
  304. if (shost->tag_set.tags)
  305. scsi_mq_destroy_tags(shost);
  306. } else {
  307. if (shost->bqt)
  308. blk_free_tags(shost->bqt);
  309. }
  310. kfree(shost->shost_data);
  311. ida_simple_remove(&host_index_ida, shost->host_no);
  312. if (shost->shost_state != SHOST_CREATED)
  313. put_device(parent);
  314. kfree(shost);
  315. }
  316. static int shost_eh_deadline = -1;
  317. module_param_named(eh_deadline, shost_eh_deadline, int, S_IRUGO|S_IWUSR);
  318. MODULE_PARM_DESC(eh_deadline,
  319. "SCSI EH timeout in seconds (should be between 0 and 2^31-1)");
  320. static struct device_type scsi_host_type = {
  321. .name = "scsi_host",
  322. .release = scsi_host_dev_release,
  323. };
  324. /**
  325. * scsi_host_alloc - register a scsi host adapter instance.
  326. * @sht: pointer to scsi host template
  327. * @privsize: extra bytes to allocate for driver
  328. *
  329. * Note:
  330. * Allocate a new Scsi_Host and perform basic initialization.
  331. * The host is not published to the scsi midlayer until scsi_add_host
  332. * is called.
  333. *
  334. * Return value:
  335. * Pointer to a new Scsi_Host
  336. **/
  337. struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
  338. {
  339. struct Scsi_Host *shost;
  340. gfp_t gfp_mask = GFP_KERNEL;
  341. int index;
  342. if (sht->unchecked_isa_dma && privsize)
  343. gfp_mask |= __GFP_DMA;
  344. shost = kzalloc(sizeof(struct Scsi_Host) + privsize, gfp_mask);
  345. if (!shost)
  346. return NULL;
  347. shost->host_lock = &shost->default_lock;
  348. spin_lock_init(shost->host_lock);
  349. shost->shost_state = SHOST_CREATED;
  350. INIT_LIST_HEAD(&shost->__devices);
  351. INIT_LIST_HEAD(&shost->__targets);
  352. INIT_LIST_HEAD(&shost->eh_cmd_q);
  353. INIT_LIST_HEAD(&shost->starved_list);
  354. init_waitqueue_head(&shost->host_wait);
  355. mutex_init(&shost->scan_mutex);
  356. index = ida_simple_get(&host_index_ida, 0, 0, GFP_KERNEL);
  357. if (index < 0) {
  358. kfree(shost);
  359. return NULL;
  360. }
  361. shost->host_no = index;
  362. shost->dma_channel = 0xff;
  363. /* These three are default values which can be overridden */
  364. shost->max_channel = 0;
  365. shost->max_id = 8;
  366. shost->max_lun = 8;
  367. /* Give each shost a default transportt */
  368. shost->transportt = &blank_transport_template;
  369. /*
  370. * All drivers right now should be able to handle 12 byte
  371. * commands. Every so often there are requests for 16 byte
  372. * commands, but individual low-level drivers need to certify that
  373. * they actually do something sensible with such commands.
  374. */
  375. shost->max_cmd_len = 12;
  376. shost->hostt = sht;
  377. shost->this_id = sht->this_id;
  378. shost->can_queue = sht->can_queue;
  379. shost->sg_tablesize = sht->sg_tablesize;
  380. shost->sg_prot_tablesize = sht->sg_prot_tablesize;
  381. shost->cmd_per_lun = sht->cmd_per_lun;
  382. shost->unchecked_isa_dma = sht->unchecked_isa_dma;
  383. shost->use_clustering = sht->use_clustering;
  384. shost->no_write_same = sht->no_write_same;
  385. if (shost_eh_deadline == -1 || !sht->eh_host_reset_handler)
  386. shost->eh_deadline = -1;
  387. else if ((ulong) shost_eh_deadline * HZ > INT_MAX) {
  388. shost_printk(KERN_WARNING, shost,
  389. "eh_deadline %u too large, setting to %u\n",
  390. shost_eh_deadline, INT_MAX / HZ);
  391. shost->eh_deadline = INT_MAX;
  392. } else
  393. shost->eh_deadline = shost_eh_deadline * HZ;
  394. if (sht->supported_mode == MODE_UNKNOWN)
  395. /* means we didn't set it ... default to INITIATOR */
  396. shost->active_mode = MODE_INITIATOR;
  397. else
  398. shost->active_mode = sht->supported_mode;
  399. if (sht->max_host_blocked)
  400. shost->max_host_blocked = sht->max_host_blocked;
  401. else
  402. shost->max_host_blocked = SCSI_DEFAULT_HOST_BLOCKED;
  403. /*
  404. * If the driver imposes no hard sector transfer limit, start at
  405. * machine infinity initially.
  406. */
  407. if (sht->max_sectors)
  408. shost->max_sectors = sht->max_sectors;
  409. else
  410. shost->max_sectors = SCSI_DEFAULT_MAX_SECTORS;
  411. /*
  412. * assume a 4GB boundary, if not set
  413. */
  414. if (sht->dma_boundary)
  415. shost->dma_boundary = sht->dma_boundary;
  416. else
  417. shost->dma_boundary = 0xffffffff;
  418. shost->use_blk_mq = scsi_use_blk_mq;
  419. shost->use_blk_mq = scsi_use_blk_mq || shost->hostt->force_blk_mq;
  420. device_initialize(&shost->shost_gendev);
  421. dev_set_name(&shost->shost_gendev, "host%d", shost->host_no);
  422. shost->shost_gendev.bus = &scsi_bus_type;
  423. shost->shost_gendev.type = &scsi_host_type;
  424. device_initialize(&shost->shost_dev);
  425. shost->shost_dev.parent = &shost->shost_gendev;
  426. shost->shost_dev.class = &shost_class;
  427. dev_set_name(&shost->shost_dev, "host%d", shost->host_no);
  428. shost->shost_dev.groups = scsi_sysfs_shost_attr_groups;
  429. shost->ehandler = kthread_run(scsi_error_handler, shost,
  430. "scsi_eh_%d", shost->host_no);
  431. if (IS_ERR(shost->ehandler)) {
  432. shost_printk(KERN_WARNING, shost,
  433. "error handler thread failed to spawn, error = %ld\n",
  434. PTR_ERR(shost->ehandler));
  435. shost->ehandler = NULL;
  436. goto fail;
  437. }
  438. shost->tmf_work_q = alloc_workqueue("scsi_tmf_%d",
  439. WQ_UNBOUND | WQ_MEM_RECLAIM,
  440. 1, shost->host_no);
  441. if (!shost->tmf_work_q) {
  442. shost_printk(KERN_WARNING, shost,
  443. "failed to create tmf workq\n");
  444. goto fail;
  445. }
  446. scsi_proc_hostdir_add(shost->hostt);
  447. return shost;
  448. fail:
  449. /*
  450. * Host state is still SHOST_CREATED and that is enough to release
  451. * ->shost_gendev. scsi_host_dev_release() will free
  452. * dev_name(&shost->shost_dev).
  453. */
  454. put_device(&shost->shost_gendev);
  455. return NULL;
  456. }
  457. EXPORT_SYMBOL(scsi_host_alloc);
  458. struct Scsi_Host *scsi_register(struct scsi_host_template *sht, int privsize)
  459. {
  460. struct Scsi_Host *shost = scsi_host_alloc(sht, privsize);
  461. if (!sht->detect) {
  462. printk(KERN_WARNING "scsi_register() called on new-style "
  463. "template for driver %s\n", sht->name);
  464. dump_stack();
  465. }
  466. if (shost)
  467. list_add_tail(&shost->sht_legacy_list, &sht->legacy_hosts);
  468. return shost;
  469. }
  470. EXPORT_SYMBOL(scsi_register);
  471. void scsi_unregister(struct Scsi_Host *shost)
  472. {
  473. list_del(&shost->sht_legacy_list);
  474. scsi_host_put(shost);
  475. }
  476. EXPORT_SYMBOL(scsi_unregister);
  477. static int __scsi_host_match(struct device *dev, const void *data)
  478. {
  479. struct Scsi_Host *p;
  480. const unsigned short *hostnum = data;
  481. p = class_to_shost(dev);
  482. return p->host_no == *hostnum;
  483. }
  484. /**
  485. * scsi_host_lookup - get a reference to a Scsi_Host by host no
  486. * @hostnum: host number to locate
  487. *
  488. * Return value:
  489. * A pointer to located Scsi_Host or NULL.
  490. *
  491. * The caller must do a scsi_host_put() to drop the reference
  492. * that scsi_host_get() took. The put_device() below dropped
  493. * the reference from class_find_device().
  494. **/
  495. struct Scsi_Host *scsi_host_lookup(unsigned short hostnum)
  496. {
  497. struct device *cdev;
  498. struct Scsi_Host *shost = NULL;
  499. cdev = class_find_device(&shost_class, NULL, &hostnum,
  500. __scsi_host_match);
  501. if (cdev) {
  502. shost = scsi_host_get(class_to_shost(cdev));
  503. put_device(cdev);
  504. }
  505. return shost;
  506. }
  507. EXPORT_SYMBOL(scsi_host_lookup);
  508. /**
  509. * scsi_host_get - inc a Scsi_Host ref count
  510. * @shost: Pointer to Scsi_Host to inc.
  511. **/
  512. struct Scsi_Host *scsi_host_get(struct Scsi_Host *shost)
  513. {
  514. if ((shost->shost_state == SHOST_DEL) ||
  515. !get_device(&shost->shost_gendev))
  516. return NULL;
  517. return shost;
  518. }
  519. EXPORT_SYMBOL(scsi_host_get);
  520. /**
  521. * scsi_host_put - dec a Scsi_Host ref count
  522. * @shost: Pointer to Scsi_Host to dec.
  523. **/
  524. void scsi_host_put(struct Scsi_Host *shost)
  525. {
  526. put_device(&shost->shost_gendev);
  527. }
  528. EXPORT_SYMBOL(scsi_host_put);
  529. int scsi_init_hosts(void)
  530. {
  531. return class_register(&shost_class);
  532. }
  533. void scsi_exit_hosts(void)
  534. {
  535. class_unregister(&shost_class);
  536. ida_destroy(&host_index_ida);
  537. }
  538. int scsi_is_host_device(const struct device *dev)
  539. {
  540. return dev->type == &scsi_host_type;
  541. }
  542. EXPORT_SYMBOL(scsi_is_host_device);
  543. /**
  544. * scsi_queue_work - Queue work to the Scsi_Host workqueue.
  545. * @shost: Pointer to Scsi_Host.
  546. * @work: Work to queue for execution.
  547. *
  548. * Return value:
  549. * 1 - work queued for execution
  550. * 0 - work is already queued
  551. * -EINVAL - work queue doesn't exist
  552. **/
  553. int scsi_queue_work(struct Scsi_Host *shost, struct work_struct *work)
  554. {
  555. if (unlikely(!shost->work_q)) {
  556. shost_printk(KERN_ERR, shost,
  557. "ERROR: Scsi host '%s' attempted to queue scsi-work, "
  558. "when no workqueue created.\n", shost->hostt->name);
  559. dump_stack();
  560. return -EINVAL;
  561. }
  562. return queue_work(shost->work_q, work);
  563. }
  564. EXPORT_SYMBOL_GPL(scsi_queue_work);
  565. /**
  566. * scsi_flush_work - Flush a Scsi_Host's workqueue.
  567. * @shost: Pointer to Scsi_Host.
  568. **/
  569. void scsi_flush_work(struct Scsi_Host *shost)
  570. {
  571. if (!shost->work_q) {
  572. shost_printk(KERN_ERR, shost,
  573. "ERROR: Scsi host '%s' attempted to flush scsi-work, "
  574. "when no workqueue created.\n", shost->hostt->name);
  575. dump_stack();
  576. return;
  577. }
  578. flush_workqueue(shost->work_q);
  579. }
  580. EXPORT_SYMBOL_GPL(scsi_flush_work);