hosts.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  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. if (shost_use_blk_mq(shost)) {
  191. error = scsi_mq_setup_tags(shost);
  192. if (error)
  193. goto fail;
  194. } else {
  195. shost->bqt = blk_init_tags(shost->can_queue,
  196. shost->hostt->tag_alloc_policy);
  197. if (!shost->bqt) {
  198. error = -ENOMEM;
  199. goto fail;
  200. }
  201. }
  202. /*
  203. * Note that we allocate the freelist even for the MQ case for now,
  204. * as we need a command set aside for scsi_reset_provider. Having
  205. * the full host freelist and one command available for that is a
  206. * little heavy-handed, but avoids introducing a special allocator
  207. * just for this. Eventually the structure of scsi_reset_provider
  208. * will need a major overhaul.
  209. */
  210. error = scsi_setup_command_freelist(shost);
  211. if (error)
  212. goto out_destroy_tags;
  213. if (!shost->shost_gendev.parent)
  214. shost->shost_gendev.parent = dev ? dev : &platform_bus;
  215. if (!dma_dev)
  216. dma_dev = shost->shost_gendev.parent;
  217. shost->dma_dev = dma_dev;
  218. /*
  219. * Increase usage count temporarily here so that calling
  220. * scsi_autopm_put_host() will trigger runtime idle if there is
  221. * nothing else preventing suspending the device.
  222. */
  223. pm_runtime_get_noresume(&shost->shost_gendev);
  224. pm_runtime_set_active(&shost->shost_gendev);
  225. pm_runtime_enable(&shost->shost_gendev);
  226. device_enable_async_suspend(&shost->shost_gendev);
  227. error = device_add(&shost->shost_gendev);
  228. if (error)
  229. goto out_destroy_freelist;
  230. scsi_host_set_state(shost, SHOST_RUNNING);
  231. get_device(shost->shost_gendev.parent);
  232. device_enable_async_suspend(&shost->shost_dev);
  233. error = device_add(&shost->shost_dev);
  234. if (error)
  235. goto out_del_gendev;
  236. get_device(&shost->shost_gendev);
  237. if (shost->transportt->host_size) {
  238. shost->shost_data = kzalloc(shost->transportt->host_size,
  239. GFP_KERNEL);
  240. if (shost->shost_data == NULL) {
  241. error = -ENOMEM;
  242. goto out_del_dev;
  243. }
  244. }
  245. if (shost->transportt->create_work_queue) {
  246. snprintf(shost->work_q_name, sizeof(shost->work_q_name),
  247. "scsi_wq_%d", shost->host_no);
  248. shost->work_q = create_singlethread_workqueue(
  249. shost->work_q_name);
  250. if (!shost->work_q) {
  251. error = -EINVAL;
  252. goto out_free_shost_data;
  253. }
  254. }
  255. error = scsi_sysfs_add_host(shost);
  256. if (error)
  257. goto out_destroy_host;
  258. scsi_proc_host_add(shost);
  259. scsi_autopm_put_host(shost);
  260. return error;
  261. out_destroy_host:
  262. if (shost->work_q)
  263. destroy_workqueue(shost->work_q);
  264. out_free_shost_data:
  265. kfree(shost->shost_data);
  266. out_del_dev:
  267. device_del(&shost->shost_dev);
  268. out_del_gendev:
  269. device_del(&shost->shost_gendev);
  270. out_destroy_freelist:
  271. device_disable_async_suspend(&shost->shost_gendev);
  272. pm_runtime_disable(&shost->shost_gendev);
  273. pm_runtime_set_suspended(&shost->shost_gendev);
  274. pm_runtime_put_noidle(&shost->shost_gendev);
  275. scsi_destroy_command_freelist(shost);
  276. out_destroy_tags:
  277. if (shost_use_blk_mq(shost))
  278. scsi_mq_destroy_tags(shost);
  279. fail:
  280. return error;
  281. }
  282. EXPORT_SYMBOL(scsi_add_host_with_dma);
  283. static void scsi_host_dev_release(struct device *dev)
  284. {
  285. struct Scsi_Host *shost = dev_to_shost(dev);
  286. struct device *parent = dev->parent;
  287. struct request_queue *q;
  288. void *queuedata;
  289. scsi_proc_hostdir_rm(shost->hostt);
  290. if (shost->tmf_work_q)
  291. destroy_workqueue(shost->tmf_work_q);
  292. if (shost->ehandler)
  293. kthread_stop(shost->ehandler);
  294. if (shost->work_q)
  295. destroy_workqueue(shost->work_q);
  296. q = shost->uspace_req_q;
  297. if (q) {
  298. queuedata = q->queuedata;
  299. blk_cleanup_queue(q);
  300. kfree(queuedata);
  301. }
  302. if (shost->shost_state == SHOST_CREATED) {
  303. /*
  304. * Free the shost_dev device name here if scsi_host_alloc()
  305. * and scsi_host_put() have been called but neither
  306. * scsi_host_add() nor scsi_host_remove() has been called.
  307. * This avoids that the memory allocated for the shost_dev
  308. * name is leaked.
  309. */
  310. kfree(dev_name(&shost->shost_dev));
  311. }
  312. scsi_destroy_command_freelist(shost);
  313. if (shost_use_blk_mq(shost)) {
  314. if (shost->tag_set.tags)
  315. scsi_mq_destroy_tags(shost);
  316. } else {
  317. if (shost->bqt)
  318. blk_free_tags(shost->bqt);
  319. }
  320. kfree(shost->shost_data);
  321. ida_simple_remove(&host_index_ida, shost->host_no);
  322. if (parent)
  323. put_device(parent);
  324. kfree(shost);
  325. }
  326. static int shost_eh_deadline = -1;
  327. module_param_named(eh_deadline, shost_eh_deadline, int, S_IRUGO|S_IWUSR);
  328. MODULE_PARM_DESC(eh_deadline,
  329. "SCSI EH timeout in seconds (should be between 0 and 2^31-1)");
  330. static struct device_type scsi_host_type = {
  331. .name = "scsi_host",
  332. .release = scsi_host_dev_release,
  333. };
  334. /**
  335. * scsi_host_alloc - register a scsi host adapter instance.
  336. * @sht: pointer to scsi host template
  337. * @privsize: extra bytes to allocate for driver
  338. *
  339. * Note:
  340. * Allocate a new Scsi_Host and perform basic initialization.
  341. * The host is not published to the scsi midlayer until scsi_add_host
  342. * is called.
  343. *
  344. * Return value:
  345. * Pointer to a new Scsi_Host
  346. **/
  347. struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
  348. {
  349. struct Scsi_Host *shost;
  350. gfp_t gfp_mask = GFP_KERNEL;
  351. int index;
  352. if (sht->unchecked_isa_dma && privsize)
  353. gfp_mask |= __GFP_DMA;
  354. shost = kzalloc(sizeof(struct Scsi_Host) + privsize, gfp_mask);
  355. if (!shost)
  356. return NULL;
  357. shost->host_lock = &shost->default_lock;
  358. spin_lock_init(shost->host_lock);
  359. shost->shost_state = SHOST_CREATED;
  360. INIT_LIST_HEAD(&shost->__devices);
  361. INIT_LIST_HEAD(&shost->__targets);
  362. INIT_LIST_HEAD(&shost->eh_cmd_q);
  363. INIT_LIST_HEAD(&shost->starved_list);
  364. init_waitqueue_head(&shost->host_wait);
  365. mutex_init(&shost->scan_mutex);
  366. index = ida_simple_get(&host_index_ida, 0, 0, GFP_KERNEL);
  367. if (index < 0)
  368. goto fail_kfree;
  369. shost->host_no = index;
  370. shost->dma_channel = 0xff;
  371. /* These three are default values which can be overridden */
  372. shost->max_channel = 0;
  373. shost->max_id = 8;
  374. shost->max_lun = 8;
  375. /* Give each shost a default transportt */
  376. shost->transportt = &blank_transport_template;
  377. /*
  378. * All drivers right now should be able to handle 12 byte
  379. * commands. Every so often there are requests for 16 byte
  380. * commands, but individual low-level drivers need to certify that
  381. * they actually do something sensible with such commands.
  382. */
  383. shost->max_cmd_len = 12;
  384. shost->hostt = sht;
  385. shost->this_id = sht->this_id;
  386. shost->can_queue = sht->can_queue;
  387. shost->sg_tablesize = sht->sg_tablesize;
  388. shost->sg_prot_tablesize = sht->sg_prot_tablesize;
  389. shost->cmd_per_lun = sht->cmd_per_lun;
  390. shost->unchecked_isa_dma = sht->unchecked_isa_dma;
  391. shost->use_clustering = sht->use_clustering;
  392. shost->no_write_same = sht->no_write_same;
  393. if (shost_eh_deadline == -1 || !sht->eh_host_reset_handler)
  394. shost->eh_deadline = -1;
  395. else if ((ulong) shost_eh_deadline * HZ > INT_MAX) {
  396. shost_printk(KERN_WARNING, shost,
  397. "eh_deadline %u too large, setting to %u\n",
  398. shost_eh_deadline, INT_MAX / HZ);
  399. shost->eh_deadline = INT_MAX;
  400. } else
  401. shost->eh_deadline = shost_eh_deadline * HZ;
  402. if (sht->supported_mode == MODE_UNKNOWN)
  403. /* means we didn't set it ... default to INITIATOR */
  404. shost->active_mode = MODE_INITIATOR;
  405. else
  406. shost->active_mode = sht->supported_mode;
  407. if (sht->max_host_blocked)
  408. shost->max_host_blocked = sht->max_host_blocked;
  409. else
  410. shost->max_host_blocked = SCSI_DEFAULT_HOST_BLOCKED;
  411. /*
  412. * If the driver imposes no hard sector transfer limit, start at
  413. * machine infinity initially.
  414. */
  415. if (sht->max_sectors)
  416. shost->max_sectors = sht->max_sectors;
  417. else
  418. shost->max_sectors = SCSI_DEFAULT_MAX_SECTORS;
  419. /*
  420. * assume a 4GB boundary, if not set
  421. */
  422. if (sht->dma_boundary)
  423. shost->dma_boundary = sht->dma_boundary;
  424. else
  425. shost->dma_boundary = 0xffffffff;
  426. shost->use_blk_mq = scsi_use_blk_mq;
  427. device_initialize(&shost->shost_gendev);
  428. dev_set_name(&shost->shost_gendev, "host%d", shost->host_no);
  429. shost->shost_gendev.bus = &scsi_bus_type;
  430. shost->shost_gendev.type = &scsi_host_type;
  431. device_initialize(&shost->shost_dev);
  432. shost->shost_dev.parent = &shost->shost_gendev;
  433. shost->shost_dev.class = &shost_class;
  434. dev_set_name(&shost->shost_dev, "host%d", shost->host_no);
  435. shost->shost_dev.groups = scsi_sysfs_shost_attr_groups;
  436. shost->ehandler = kthread_run(scsi_error_handler, shost,
  437. "scsi_eh_%d", shost->host_no);
  438. if (IS_ERR(shost->ehandler)) {
  439. shost_printk(KERN_WARNING, shost,
  440. "error handler thread failed to spawn, error = %ld\n",
  441. PTR_ERR(shost->ehandler));
  442. goto fail_index_remove;
  443. }
  444. shost->tmf_work_q = alloc_workqueue("scsi_tmf_%d",
  445. WQ_UNBOUND | WQ_MEM_RECLAIM,
  446. 1, shost->host_no);
  447. if (!shost->tmf_work_q) {
  448. shost_printk(KERN_WARNING, shost,
  449. "failed to create tmf workq\n");
  450. goto fail_kthread;
  451. }
  452. scsi_proc_hostdir_add(shost->hostt);
  453. return shost;
  454. fail_kthread:
  455. kthread_stop(shost->ehandler);
  456. fail_index_remove:
  457. ida_simple_remove(&host_index_ida, shost->host_no);
  458. fail_kfree:
  459. kfree(shost);
  460. return NULL;
  461. }
  462. EXPORT_SYMBOL(scsi_host_alloc);
  463. struct Scsi_Host *scsi_register(struct scsi_host_template *sht, int privsize)
  464. {
  465. struct Scsi_Host *shost = scsi_host_alloc(sht, privsize);
  466. if (!sht->detect) {
  467. printk(KERN_WARNING "scsi_register() called on new-style "
  468. "template for driver %s\n", sht->name);
  469. dump_stack();
  470. }
  471. if (shost)
  472. list_add_tail(&shost->sht_legacy_list, &sht->legacy_hosts);
  473. return shost;
  474. }
  475. EXPORT_SYMBOL(scsi_register);
  476. void scsi_unregister(struct Scsi_Host *shost)
  477. {
  478. list_del(&shost->sht_legacy_list);
  479. scsi_host_put(shost);
  480. }
  481. EXPORT_SYMBOL(scsi_unregister);
  482. static int __scsi_host_match(struct device *dev, const void *data)
  483. {
  484. struct Scsi_Host *p;
  485. const unsigned short *hostnum = data;
  486. p = class_to_shost(dev);
  487. return p->host_no == *hostnum;
  488. }
  489. /**
  490. * scsi_host_lookup - get a reference to a Scsi_Host by host no
  491. * @hostnum: host number to locate
  492. *
  493. * Return value:
  494. * A pointer to located Scsi_Host or NULL.
  495. *
  496. * The caller must do a scsi_host_put() to drop the reference
  497. * that scsi_host_get() took. The put_device() below dropped
  498. * the reference from class_find_device().
  499. **/
  500. struct Scsi_Host *scsi_host_lookup(unsigned short hostnum)
  501. {
  502. struct device *cdev;
  503. struct Scsi_Host *shost = NULL;
  504. cdev = class_find_device(&shost_class, NULL, &hostnum,
  505. __scsi_host_match);
  506. if (cdev) {
  507. shost = scsi_host_get(class_to_shost(cdev));
  508. put_device(cdev);
  509. }
  510. return shost;
  511. }
  512. EXPORT_SYMBOL(scsi_host_lookup);
  513. /**
  514. * scsi_host_get - inc a Scsi_Host ref count
  515. * @shost: Pointer to Scsi_Host to inc.
  516. **/
  517. struct Scsi_Host *scsi_host_get(struct Scsi_Host *shost)
  518. {
  519. if ((shost->shost_state == SHOST_DEL) ||
  520. !get_device(&shost->shost_gendev))
  521. return NULL;
  522. return shost;
  523. }
  524. EXPORT_SYMBOL(scsi_host_get);
  525. /**
  526. * scsi_host_put - dec a Scsi_Host ref count
  527. * @shost: Pointer to Scsi_Host to dec.
  528. **/
  529. void scsi_host_put(struct Scsi_Host *shost)
  530. {
  531. put_device(&shost->shost_gendev);
  532. }
  533. EXPORT_SYMBOL(scsi_host_put);
  534. int scsi_init_hosts(void)
  535. {
  536. return class_register(&shost_class);
  537. }
  538. void scsi_exit_hosts(void)
  539. {
  540. class_unregister(&shost_class);
  541. ida_destroy(&host_index_ida);
  542. }
  543. int scsi_is_host_device(const struct device *dev)
  544. {
  545. return dev->type == &scsi_host_type;
  546. }
  547. EXPORT_SYMBOL(scsi_is_host_device);
  548. /**
  549. * scsi_queue_work - Queue work to the Scsi_Host workqueue.
  550. * @shost: Pointer to Scsi_Host.
  551. * @work: Work to queue for execution.
  552. *
  553. * Return value:
  554. * 1 - work queued for execution
  555. * 0 - work is already queued
  556. * -EINVAL - work queue doesn't exist
  557. **/
  558. int scsi_queue_work(struct Scsi_Host *shost, struct work_struct *work)
  559. {
  560. if (unlikely(!shost->work_q)) {
  561. shost_printk(KERN_ERR, shost,
  562. "ERROR: Scsi host '%s' attempted to queue scsi-work, "
  563. "when no workqueue created.\n", shost->hostt->name);
  564. dump_stack();
  565. return -EINVAL;
  566. }
  567. return queue_work(shost->work_q, work);
  568. }
  569. EXPORT_SYMBOL_GPL(scsi_queue_work);
  570. /**
  571. * scsi_flush_work - Flush a Scsi_Host's workqueue.
  572. * @shost: Pointer to Scsi_Host.
  573. **/
  574. void scsi_flush_work(struct Scsi_Host *shost)
  575. {
  576. if (!shost->work_q) {
  577. shost_printk(KERN_ERR, shost,
  578. "ERROR: Scsi host '%s' attempted to flush scsi-work, "
  579. "when no workqueue created.\n", shost->hostt->name);
  580. dump_stack();
  581. return;
  582. }
  583. flush_workqueue(shost->work_q);
  584. }
  585. EXPORT_SYMBOL_GPL(scsi_flush_work);