tape_core.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305
  1. /*
  2. * drivers/s390/char/tape_core.c
  3. * basic function of the tape device driver
  4. *
  5. * S390 and zSeries version
  6. * Copyright (C) 2001,2005 IBM Deutschland Entwicklung GmbH, IBM Corporation
  7. * Author(s): Carsten Otte <cotte@de.ibm.com>
  8. * Michael Holzheu <holzheu@de.ibm.com>
  9. * Tuan Ngo-Anh <ngoanh@de.ibm.com>
  10. * Martin Schwidefsky <schwidefsky@de.ibm.com>
  11. * Stefan Bader <shbader@de.ibm.com>
  12. */
  13. #include <linux/module.h>
  14. #include <linux/init.h> // for kernel parameters
  15. #include <linux/kmod.h> // for requesting modules
  16. #include <linux/spinlock.h> // for locks
  17. #include <linux/vmalloc.h>
  18. #include <linux/list.h>
  19. #include <asm/types.h> // for variable types
  20. #define TAPE_DBF_AREA tape_core_dbf
  21. #include "tape.h"
  22. #include "tape_std.h"
  23. #define PRINTK_HEADER "TAPE_CORE: "
  24. static void __tape_do_irq (struct ccw_device *, unsigned long, struct irb *);
  25. static void tape_delayed_next_request(void * data);
  26. /*
  27. * One list to contain all tape devices of all disciplines, so
  28. * we can assign the devices to minor numbers of the same major
  29. * The list is protected by the rwlock
  30. */
  31. static struct list_head tape_device_list = LIST_HEAD_INIT(tape_device_list);
  32. static DEFINE_RWLOCK(tape_device_lock);
  33. /*
  34. * Pointer to debug area.
  35. */
  36. debug_info_t *TAPE_DBF_AREA = NULL;
  37. EXPORT_SYMBOL(TAPE_DBF_AREA);
  38. /*
  39. * Printable strings for tape enumerations.
  40. */
  41. const char *tape_state_verbose[TS_SIZE] =
  42. {
  43. [TS_UNUSED] = "UNUSED",
  44. [TS_IN_USE] = "IN_USE",
  45. [TS_BLKUSE] = "BLKUSE",
  46. [TS_INIT] = "INIT ",
  47. [TS_NOT_OPER] = "NOT_OP"
  48. };
  49. const char *tape_op_verbose[TO_SIZE] =
  50. {
  51. [TO_BLOCK] = "BLK", [TO_BSB] = "BSB",
  52. [TO_BSF] = "BSF", [TO_DSE] = "DSE",
  53. [TO_FSB] = "FSB", [TO_FSF] = "FSF",
  54. [TO_LBL] = "LBL", [TO_NOP] = "NOP",
  55. [TO_RBA] = "RBA", [TO_RBI] = "RBI",
  56. [TO_RFO] = "RFO", [TO_REW] = "REW",
  57. [TO_RUN] = "RUN", [TO_WRI] = "WRI",
  58. [TO_WTM] = "WTM", [TO_MSEN] = "MSN",
  59. [TO_LOAD] = "LOA", [TO_READ_CONFIG] = "RCF",
  60. [TO_READ_ATTMSG] = "RAT",
  61. [TO_DIS] = "DIS", [TO_ASSIGN] = "ASS",
  62. [TO_UNASSIGN] = "UAS"
  63. };
  64. static inline int
  65. busid_to_int(char *bus_id)
  66. {
  67. int dec;
  68. int d;
  69. char * s;
  70. for(s = bus_id, d = 0; *s != '\0' && *s != '.'; s++)
  71. d = (d * 10) + (*s - '0');
  72. dec = d;
  73. for(s++, d = 0; *s != '\0' && *s != '.'; s++)
  74. d = (d * 10) + (*s - '0');
  75. dec = (dec << 8) + d;
  76. for(s++; *s != '\0'; s++) {
  77. if (*s >= '0' && *s <= '9') {
  78. d = *s - '0';
  79. } else if (*s >= 'a' && *s <= 'f') {
  80. d = *s - 'a' + 10;
  81. } else {
  82. d = *s - 'A' + 10;
  83. }
  84. dec = (dec << 4) + d;
  85. }
  86. return dec;
  87. }
  88. /*
  89. * Some channel attached tape specific attributes.
  90. *
  91. * FIXME: In the future the first_minor and blocksize attribute should be
  92. * replaced by a link to the cdev tree.
  93. */
  94. static ssize_t
  95. tape_medium_state_show(struct device *dev, struct device_attribute *attr, char *buf)
  96. {
  97. struct tape_device *tdev;
  98. tdev = (struct tape_device *) dev->driver_data;
  99. return scnprintf(buf, PAGE_SIZE, "%i\n", tdev->medium_state);
  100. }
  101. static
  102. DEVICE_ATTR(medium_state, 0444, tape_medium_state_show, NULL);
  103. static ssize_t
  104. tape_first_minor_show(struct device *dev, struct device_attribute *attr, char *buf)
  105. {
  106. struct tape_device *tdev;
  107. tdev = (struct tape_device *) dev->driver_data;
  108. return scnprintf(buf, PAGE_SIZE, "%i\n", tdev->first_minor);
  109. }
  110. static
  111. DEVICE_ATTR(first_minor, 0444, tape_first_minor_show, NULL);
  112. static ssize_t
  113. tape_state_show(struct device *dev, struct device_attribute *attr, char *buf)
  114. {
  115. struct tape_device *tdev;
  116. tdev = (struct tape_device *) dev->driver_data;
  117. return scnprintf(buf, PAGE_SIZE, "%s\n", (tdev->first_minor < 0) ?
  118. "OFFLINE" : tape_state_verbose[tdev->tape_state]);
  119. }
  120. static
  121. DEVICE_ATTR(state, 0444, tape_state_show, NULL);
  122. static ssize_t
  123. tape_operation_show(struct device *dev, struct device_attribute *attr, char *buf)
  124. {
  125. struct tape_device *tdev;
  126. ssize_t rc;
  127. tdev = (struct tape_device *) dev->driver_data;
  128. if (tdev->first_minor < 0)
  129. return scnprintf(buf, PAGE_SIZE, "N/A\n");
  130. spin_lock_irq(get_ccwdev_lock(tdev->cdev));
  131. if (list_empty(&tdev->req_queue))
  132. rc = scnprintf(buf, PAGE_SIZE, "---\n");
  133. else {
  134. struct tape_request *req;
  135. req = list_entry(tdev->req_queue.next, struct tape_request,
  136. list);
  137. rc = scnprintf(buf,PAGE_SIZE, "%s\n", tape_op_verbose[req->op]);
  138. }
  139. spin_unlock_irq(get_ccwdev_lock(tdev->cdev));
  140. return rc;
  141. }
  142. static
  143. DEVICE_ATTR(operation, 0444, tape_operation_show, NULL);
  144. static ssize_t
  145. tape_blocksize_show(struct device *dev, struct device_attribute *attr, char *buf)
  146. {
  147. struct tape_device *tdev;
  148. tdev = (struct tape_device *) dev->driver_data;
  149. return scnprintf(buf, PAGE_SIZE, "%i\n", tdev->char_data.block_size);
  150. }
  151. static
  152. DEVICE_ATTR(blocksize, 0444, tape_blocksize_show, NULL);
  153. static struct attribute *tape_attrs[] = {
  154. &dev_attr_medium_state.attr,
  155. &dev_attr_first_minor.attr,
  156. &dev_attr_state.attr,
  157. &dev_attr_operation.attr,
  158. &dev_attr_blocksize.attr,
  159. NULL
  160. };
  161. static struct attribute_group tape_attr_group = {
  162. .attrs = tape_attrs,
  163. };
  164. /*
  165. * Tape state functions
  166. */
  167. void
  168. tape_state_set(struct tape_device *device, enum tape_state newstate)
  169. {
  170. const char *str;
  171. if (device->tape_state == TS_NOT_OPER) {
  172. DBF_EVENT(3, "ts_set err: not oper\n");
  173. return;
  174. }
  175. DBF_EVENT(4, "ts. dev: %x\n", device->first_minor);
  176. DBF_EVENT(4, "old ts:\t\n");
  177. if (device->tape_state < TS_SIZE && device->tape_state >=0 )
  178. str = tape_state_verbose[device->tape_state];
  179. else
  180. str = "UNKNOWN TS";
  181. DBF_EVENT(4, "%s\n", str);
  182. DBF_EVENT(4, "new ts:\t\n");
  183. if (newstate < TS_SIZE && newstate >= 0)
  184. str = tape_state_verbose[newstate];
  185. else
  186. str = "UNKNOWN TS";
  187. DBF_EVENT(4, "%s\n", str);
  188. device->tape_state = newstate;
  189. wake_up(&device->state_change_wq);
  190. }
  191. void
  192. tape_med_state_set(struct tape_device *device, enum tape_medium_state newstate)
  193. {
  194. if (device->medium_state == newstate)
  195. return;
  196. switch(newstate){
  197. case MS_UNLOADED:
  198. device->tape_generic_status |= GMT_DR_OPEN(~0);
  199. PRINT_INFO("(%s): Tape is unloaded\n",
  200. device->cdev->dev.bus_id);
  201. break;
  202. case MS_LOADED:
  203. device->tape_generic_status &= ~GMT_DR_OPEN(~0);
  204. PRINT_INFO("(%s): Tape has been mounted\n",
  205. device->cdev->dev.bus_id);
  206. break;
  207. default:
  208. // print nothing
  209. break;
  210. }
  211. device->medium_state = newstate;
  212. wake_up(&device->state_change_wq);
  213. }
  214. /*
  215. * Stop running ccw. Has to be called with the device lock held.
  216. */
  217. static inline int
  218. __tape_cancel_io(struct tape_device *device, struct tape_request *request)
  219. {
  220. int retries;
  221. int rc;
  222. /* Check if interrupt has already been processed */
  223. if (request->callback == NULL)
  224. return 0;
  225. rc = 0;
  226. for (retries = 0; retries < 5; retries++) {
  227. rc = ccw_device_clear(device->cdev, (long) request);
  228. switch (rc) {
  229. case 0:
  230. request->status = TAPE_REQUEST_DONE;
  231. return 0;
  232. case -EBUSY:
  233. request->status = TAPE_REQUEST_CANCEL;
  234. schedule_work(&device->tape_dnr);
  235. return 0;
  236. case -ENODEV:
  237. DBF_EXCEPTION(2, "device gone, retry\n");
  238. break;
  239. case -EIO:
  240. DBF_EXCEPTION(2, "I/O error, retry\n");
  241. break;
  242. default:
  243. BUG();
  244. }
  245. }
  246. return rc;
  247. }
  248. /*
  249. * Add device into the sorted list, giving it the first
  250. * available minor number.
  251. */
  252. static int
  253. tape_assign_minor(struct tape_device *device)
  254. {
  255. struct tape_device *tmp;
  256. int minor;
  257. minor = 0;
  258. write_lock(&tape_device_lock);
  259. list_for_each_entry(tmp, &tape_device_list, node) {
  260. if (minor < tmp->first_minor)
  261. break;
  262. minor += TAPE_MINORS_PER_DEV;
  263. }
  264. if (minor >= 256) {
  265. write_unlock(&tape_device_lock);
  266. return -ENODEV;
  267. }
  268. device->first_minor = minor;
  269. list_add_tail(&device->node, &tmp->node);
  270. write_unlock(&tape_device_lock);
  271. return 0;
  272. }
  273. /* remove device from the list */
  274. static void
  275. tape_remove_minor(struct tape_device *device)
  276. {
  277. write_lock(&tape_device_lock);
  278. list_del_init(&device->node);
  279. device->first_minor = -1;
  280. write_unlock(&tape_device_lock);
  281. }
  282. /*
  283. * Set a device online.
  284. *
  285. * This function is called by the common I/O layer to move a device from the
  286. * detected but offline into the online state.
  287. * If we return an error (RC < 0) the device remains in the offline state. This
  288. * can happen if the device is assigned somewhere else, for example.
  289. */
  290. int
  291. tape_generic_online(struct tape_device *device,
  292. struct tape_discipline *discipline)
  293. {
  294. int rc;
  295. DBF_LH(6, "tape_enable_device(%p, %p)\n", device, discipline);
  296. if (device->tape_state != TS_INIT) {
  297. DBF_LH(3, "Tapestate not INIT (%d)\n", device->tape_state);
  298. return -EINVAL;
  299. }
  300. /* Let the discipline have a go at the device. */
  301. device->discipline = discipline;
  302. if (!try_module_get(discipline->owner)) {
  303. PRINT_ERR("Cannot get module. Module gone.\n");
  304. return -EINVAL;
  305. }
  306. rc = discipline->setup_device(device);
  307. if (rc)
  308. goto out;
  309. rc = tape_assign_minor(device);
  310. if (rc)
  311. goto out_discipline;
  312. rc = tapechar_setup_device(device);
  313. if (rc)
  314. goto out_minor;
  315. rc = tapeblock_setup_device(device);
  316. if (rc)
  317. goto out_char;
  318. tape_state_set(device, TS_UNUSED);
  319. DBF_LH(3, "(%08x): Drive set online\n", device->cdev_id);
  320. return 0;
  321. out_char:
  322. tapechar_cleanup_device(device);
  323. out_discipline:
  324. device->discipline->cleanup_device(device);
  325. device->discipline = NULL;
  326. out_minor:
  327. tape_remove_minor(device);
  328. out:
  329. module_put(discipline->owner);
  330. return rc;
  331. }
  332. static inline void
  333. tape_cleanup_device(struct tape_device *device)
  334. {
  335. tapeblock_cleanup_device(device);
  336. tapechar_cleanup_device(device);
  337. device->discipline->cleanup_device(device);
  338. module_put(device->discipline->owner);
  339. tape_remove_minor(device);
  340. tape_med_state_set(device, MS_UNKNOWN);
  341. }
  342. /*
  343. * Set device offline.
  344. *
  345. * Called by the common I/O layer if the drive should set offline on user
  346. * request. We may prevent this by returning an error.
  347. * Manual offline is only allowed while the drive is not in use.
  348. */
  349. int
  350. tape_generic_offline(struct tape_device *device)
  351. {
  352. if (!device) {
  353. PRINT_ERR("tape_generic_offline: no such device\n");
  354. return -ENODEV;
  355. }
  356. DBF_LH(3, "(%08x): tape_generic_offline(%p)\n",
  357. device->cdev_id, device);
  358. spin_lock_irq(get_ccwdev_lock(device->cdev));
  359. switch (device->tape_state) {
  360. case TS_INIT:
  361. case TS_NOT_OPER:
  362. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  363. break;
  364. case TS_UNUSED:
  365. tape_state_set(device, TS_INIT);
  366. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  367. tape_cleanup_device(device);
  368. break;
  369. default:
  370. DBF_EVENT(3, "(%08x): Set offline failed "
  371. "- drive in use.\n",
  372. device->cdev_id);
  373. PRINT_WARN("(%s): Set offline failed "
  374. "- drive in use.\n",
  375. device->cdev->dev.bus_id);
  376. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  377. return -EBUSY;
  378. }
  379. DBF_LH(3, "(%08x): Drive set offline.\n", device->cdev_id);
  380. return 0;
  381. }
  382. /*
  383. * Allocate memory for a new device structure.
  384. */
  385. static struct tape_device *
  386. tape_alloc_device(void)
  387. {
  388. struct tape_device *device;
  389. device = kzalloc(sizeof(struct tape_device), GFP_KERNEL);
  390. if (device == NULL) {
  391. DBF_EXCEPTION(2, "ti:no mem\n");
  392. PRINT_INFO ("can't allocate memory for "
  393. "tape info structure\n");
  394. return ERR_PTR(-ENOMEM);
  395. }
  396. device->modeset_byte = kmalloc(1, GFP_KERNEL | GFP_DMA);
  397. if (device->modeset_byte == NULL) {
  398. DBF_EXCEPTION(2, "ti:no mem\n");
  399. PRINT_INFO("can't allocate memory for modeset byte\n");
  400. kfree(device);
  401. return ERR_PTR(-ENOMEM);
  402. }
  403. INIT_LIST_HEAD(&device->req_queue);
  404. INIT_LIST_HEAD(&device->node);
  405. init_waitqueue_head(&device->state_change_wq);
  406. device->tape_state = TS_INIT;
  407. device->medium_state = MS_UNKNOWN;
  408. *device->modeset_byte = 0;
  409. device->first_minor = -1;
  410. atomic_set(&device->ref_count, 1);
  411. INIT_WORK(&device->tape_dnr, tape_delayed_next_request, device);
  412. return device;
  413. }
  414. /*
  415. * Get a reference to an existing device structure. This will automatically
  416. * increment the reference count.
  417. */
  418. struct tape_device *
  419. tape_get_device_reference(struct tape_device *device)
  420. {
  421. DBF_EVENT(4, "tape_get_device_reference(%p) = %i\n", device,
  422. atomic_inc_return(&device->ref_count));
  423. return device;
  424. }
  425. /*
  426. * Decrease the reference counter of a devices structure. If the
  427. * reference counter reaches zero free the device structure.
  428. * The function returns a NULL pointer to be used by the caller
  429. * for clearing reference pointers.
  430. */
  431. struct tape_device *
  432. tape_put_device(struct tape_device *device)
  433. {
  434. int remain;
  435. remain = atomic_dec_return(&device->ref_count);
  436. if (remain > 0) {
  437. DBF_EVENT(4, "tape_put_device(%p) -> %i\n", device, remain);
  438. } else {
  439. if (remain < 0) {
  440. DBF_EVENT(4, "put device without reference\n");
  441. PRINT_ERR("put device without reference\n");
  442. } else {
  443. DBF_EVENT(4, "tape_free_device(%p)\n", device);
  444. kfree(device->modeset_byte);
  445. kfree(device);
  446. }
  447. }
  448. return NULL;
  449. }
  450. /*
  451. * Find tape device by a device index.
  452. */
  453. struct tape_device *
  454. tape_get_device(int devindex)
  455. {
  456. struct tape_device *device, *tmp;
  457. device = ERR_PTR(-ENODEV);
  458. read_lock(&tape_device_lock);
  459. list_for_each_entry(tmp, &tape_device_list, node) {
  460. if (tmp->first_minor / TAPE_MINORS_PER_DEV == devindex) {
  461. device = tape_get_device_reference(tmp);
  462. break;
  463. }
  464. }
  465. read_unlock(&tape_device_lock);
  466. return device;
  467. }
  468. /*
  469. * Driverfs tape probe function.
  470. */
  471. int
  472. tape_generic_probe(struct ccw_device *cdev)
  473. {
  474. struct tape_device *device;
  475. int ret;
  476. device = tape_alloc_device();
  477. if (IS_ERR(device))
  478. return -ENODEV;
  479. ccw_device_set_options(cdev, CCWDEV_DO_PATHGROUP);
  480. ret = sysfs_create_group(&cdev->dev.kobj, &tape_attr_group);
  481. if (ret) {
  482. tape_put_device(device);
  483. PRINT_ERR("probe failed for tape device %s\n", cdev->dev.bus_id);
  484. return ret;
  485. }
  486. cdev->dev.driver_data = device;
  487. cdev->handler = __tape_do_irq;
  488. device->cdev = cdev;
  489. device->cdev_id = busid_to_int(cdev->dev.bus_id);
  490. PRINT_INFO("tape device %s found\n", cdev->dev.bus_id);
  491. return ret;
  492. }
  493. static inline void
  494. __tape_discard_requests(struct tape_device *device)
  495. {
  496. struct tape_request * request;
  497. struct list_head * l, *n;
  498. list_for_each_safe(l, n, &device->req_queue) {
  499. request = list_entry(l, struct tape_request, list);
  500. if (request->status == TAPE_REQUEST_IN_IO)
  501. request->status = TAPE_REQUEST_DONE;
  502. list_del(&request->list);
  503. /* Decrease ref_count for removed request. */
  504. request->device = tape_put_device(device);
  505. request->rc = -EIO;
  506. if (request->callback != NULL)
  507. request->callback(request, request->callback_data);
  508. }
  509. }
  510. /*
  511. * Driverfs tape remove function.
  512. *
  513. * This function is called whenever the common I/O layer detects the device
  514. * gone. This can happen at any time and we cannot refuse.
  515. */
  516. void
  517. tape_generic_remove(struct ccw_device *cdev)
  518. {
  519. struct tape_device * device;
  520. device = cdev->dev.driver_data;
  521. if (!device) {
  522. PRINT_ERR("No device pointer in tape_generic_remove!\n");
  523. return;
  524. }
  525. DBF_LH(3, "(%08x): tape_generic_remove(%p)\n", device->cdev_id, cdev);
  526. spin_lock_irq(get_ccwdev_lock(device->cdev));
  527. switch (device->tape_state) {
  528. case TS_INIT:
  529. tape_state_set(device, TS_NOT_OPER);
  530. case TS_NOT_OPER:
  531. /*
  532. * Nothing to do.
  533. */
  534. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  535. break;
  536. case TS_UNUSED:
  537. /*
  538. * Need only to release the device.
  539. */
  540. tape_state_set(device, TS_NOT_OPER);
  541. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  542. tape_cleanup_device(device);
  543. break;
  544. default:
  545. /*
  546. * There may be requests on the queue. We will not get
  547. * an interrupt for a request that was running. So we
  548. * just post them all as I/O errors.
  549. */
  550. DBF_EVENT(3, "(%08x): Drive in use vanished!\n",
  551. device->cdev_id);
  552. PRINT_WARN("(%s): Drive in use vanished - "
  553. "expect trouble!\n",
  554. device->cdev->dev.bus_id);
  555. PRINT_WARN("State was %i\n", device->tape_state);
  556. tape_state_set(device, TS_NOT_OPER);
  557. __tape_discard_requests(device);
  558. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  559. tape_cleanup_device(device);
  560. }
  561. if (cdev->dev.driver_data != NULL) {
  562. sysfs_remove_group(&cdev->dev.kobj, &tape_attr_group);
  563. cdev->dev.driver_data = tape_put_device(cdev->dev.driver_data);
  564. }
  565. }
  566. /*
  567. * Allocate a new tape ccw request
  568. */
  569. struct tape_request *
  570. tape_alloc_request(int cplength, int datasize)
  571. {
  572. struct tape_request *request;
  573. if (datasize > PAGE_SIZE || (cplength*sizeof(struct ccw1)) > PAGE_SIZE)
  574. BUG();
  575. DBF_LH(6, "tape_alloc_request(%d, %d)\n", cplength, datasize);
  576. request = kzalloc(sizeof(struct tape_request), GFP_KERNEL);
  577. if (request == NULL) {
  578. DBF_EXCEPTION(1, "cqra nomem\n");
  579. return ERR_PTR(-ENOMEM);
  580. }
  581. /* allocate channel program */
  582. if (cplength > 0) {
  583. request->cpaddr = kcalloc(cplength, sizeof(struct ccw1),
  584. GFP_ATOMIC | GFP_DMA);
  585. if (request->cpaddr == NULL) {
  586. DBF_EXCEPTION(1, "cqra nomem\n");
  587. kfree(request);
  588. return ERR_PTR(-ENOMEM);
  589. }
  590. }
  591. /* alloc small kernel buffer */
  592. if (datasize > 0) {
  593. request->cpdata = kzalloc(datasize, GFP_KERNEL | GFP_DMA);
  594. if (request->cpdata == NULL) {
  595. DBF_EXCEPTION(1, "cqra nomem\n");
  596. kfree(request->cpaddr);
  597. kfree(request);
  598. return ERR_PTR(-ENOMEM);
  599. }
  600. }
  601. DBF_LH(6, "New request %p(%p/%p)\n", request, request->cpaddr,
  602. request->cpdata);
  603. return request;
  604. }
  605. /*
  606. * Free tape ccw request
  607. */
  608. void
  609. tape_free_request (struct tape_request * request)
  610. {
  611. DBF_LH(6, "Free request %p\n", request);
  612. if (request->device != NULL) {
  613. request->device = tape_put_device(request->device);
  614. }
  615. kfree(request->cpdata);
  616. kfree(request->cpaddr);
  617. kfree(request);
  618. }
  619. static inline int
  620. __tape_start_io(struct tape_device *device, struct tape_request *request)
  621. {
  622. int rc;
  623. #ifdef CONFIG_S390_TAPE_BLOCK
  624. if (request->op == TO_BLOCK)
  625. device->discipline->check_locate(device, request);
  626. #endif
  627. rc = ccw_device_start(
  628. device->cdev,
  629. request->cpaddr,
  630. (unsigned long) request,
  631. 0x00,
  632. request->options
  633. );
  634. if (rc == 0) {
  635. request->status = TAPE_REQUEST_IN_IO;
  636. } else if (rc == -EBUSY) {
  637. /* The common I/O subsystem is currently busy. Retry later. */
  638. request->status = TAPE_REQUEST_QUEUED;
  639. schedule_work(&device->tape_dnr);
  640. rc = 0;
  641. } else {
  642. /* Start failed. Remove request and indicate failure. */
  643. DBF_EVENT(1, "tape: start request failed with RC = %i\n", rc);
  644. }
  645. return rc;
  646. }
  647. static inline void
  648. __tape_start_next_request(struct tape_device *device)
  649. {
  650. struct list_head *l, *n;
  651. struct tape_request *request;
  652. int rc;
  653. DBF_LH(6, "__tape_start_next_request(%p)\n", device);
  654. /*
  655. * Try to start each request on request queue until one is
  656. * started successful.
  657. */
  658. list_for_each_safe(l, n, &device->req_queue) {
  659. request = list_entry(l, struct tape_request, list);
  660. /*
  661. * Avoid race condition if bottom-half was triggered more than
  662. * once.
  663. */
  664. if (request->status == TAPE_REQUEST_IN_IO)
  665. return;
  666. /*
  667. * Request has already been stopped. We have to wait until
  668. * the request is removed from the queue in the interrupt
  669. * handling.
  670. */
  671. if (request->status == TAPE_REQUEST_DONE)
  672. return;
  673. /*
  674. * We wanted to cancel the request but the common I/O layer
  675. * was busy at that time. This can only happen if this
  676. * function is called by delayed_next_request.
  677. * Otherwise we start the next request on the queue.
  678. */
  679. if (request->status == TAPE_REQUEST_CANCEL) {
  680. rc = __tape_cancel_io(device, request);
  681. } else {
  682. rc = __tape_start_io(device, request);
  683. }
  684. if (rc == 0)
  685. return;
  686. /* Set ending status. */
  687. request->rc = rc;
  688. request->status = TAPE_REQUEST_DONE;
  689. /* Remove from request queue. */
  690. list_del(&request->list);
  691. /* Do callback. */
  692. if (request->callback != NULL)
  693. request->callback(request, request->callback_data);
  694. }
  695. }
  696. static void
  697. tape_delayed_next_request(void *data)
  698. {
  699. struct tape_device * device;
  700. device = (struct tape_device *) data;
  701. DBF_LH(6, "tape_delayed_next_request(%p)\n", device);
  702. spin_lock_irq(get_ccwdev_lock(device->cdev));
  703. __tape_start_next_request(device);
  704. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  705. }
  706. static inline void
  707. __tape_end_request(
  708. struct tape_device * device,
  709. struct tape_request * request,
  710. int rc)
  711. {
  712. DBF_LH(6, "__tape_end_request(%p, %p, %i)\n", device, request, rc);
  713. if (request) {
  714. request->rc = rc;
  715. request->status = TAPE_REQUEST_DONE;
  716. /* Remove from request queue. */
  717. list_del(&request->list);
  718. /* Do callback. */
  719. if (request->callback != NULL)
  720. request->callback(request, request->callback_data);
  721. }
  722. /* Start next request. */
  723. if (!list_empty(&device->req_queue))
  724. __tape_start_next_request(device);
  725. }
  726. /*
  727. * Write sense data to console/dbf
  728. */
  729. void
  730. tape_dump_sense(struct tape_device* device, struct tape_request *request,
  731. struct irb *irb)
  732. {
  733. unsigned int *sptr;
  734. PRINT_INFO("-------------------------------------------------\n");
  735. PRINT_INFO("DSTAT : %02x CSTAT: %02x CPA: %04x\n",
  736. irb->scsw.dstat, irb->scsw.cstat, irb->scsw.cpa);
  737. PRINT_INFO("DEVICE: %s\n", device->cdev->dev.bus_id);
  738. if (request != NULL)
  739. PRINT_INFO("OP : %s\n", tape_op_verbose[request->op]);
  740. sptr = (unsigned int *) irb->ecw;
  741. PRINT_INFO("Sense data: %08X %08X %08X %08X \n",
  742. sptr[0], sptr[1], sptr[2], sptr[3]);
  743. PRINT_INFO("Sense data: %08X %08X %08X %08X \n",
  744. sptr[4], sptr[5], sptr[6], sptr[7]);
  745. PRINT_INFO("--------------------------------------------------\n");
  746. }
  747. /*
  748. * Write sense data to dbf
  749. */
  750. void
  751. tape_dump_sense_dbf(struct tape_device *device, struct tape_request *request,
  752. struct irb *irb)
  753. {
  754. unsigned int *sptr;
  755. const char* op;
  756. if (request != NULL)
  757. op = tape_op_verbose[request->op];
  758. else
  759. op = "---";
  760. DBF_EVENT(3, "DSTAT : %02x CSTAT: %02x\n",
  761. irb->scsw.dstat,irb->scsw.cstat);
  762. DBF_EVENT(3, "DEVICE: %08x OP\t: %s\n", device->cdev_id, op);
  763. sptr = (unsigned int *) irb->ecw;
  764. DBF_EVENT(3, "%08x %08x\n", sptr[0], sptr[1]);
  765. DBF_EVENT(3, "%08x %08x\n", sptr[2], sptr[3]);
  766. DBF_EVENT(3, "%08x %08x\n", sptr[4], sptr[5]);
  767. DBF_EVENT(3, "%08x %08x\n", sptr[6], sptr[7]);
  768. }
  769. /*
  770. * I/O helper function. Adds the request to the request queue
  771. * and starts it if the tape is idle. Has to be called with
  772. * the device lock held.
  773. */
  774. static inline int
  775. __tape_start_request(struct tape_device *device, struct tape_request *request)
  776. {
  777. int rc;
  778. switch (request->op) {
  779. case TO_MSEN:
  780. case TO_ASSIGN:
  781. case TO_UNASSIGN:
  782. case TO_READ_ATTMSG:
  783. if (device->tape_state == TS_INIT)
  784. break;
  785. if (device->tape_state == TS_UNUSED)
  786. break;
  787. default:
  788. if (device->tape_state == TS_BLKUSE)
  789. break;
  790. if (device->tape_state != TS_IN_USE)
  791. return -ENODEV;
  792. }
  793. /* Increase use count of device for the added request. */
  794. request->device = tape_get_device_reference(device);
  795. if (list_empty(&device->req_queue)) {
  796. /* No other requests are on the queue. Start this one. */
  797. rc = __tape_start_io(device, request);
  798. if (rc)
  799. return rc;
  800. DBF_LH(5, "Request %p added for execution.\n", request);
  801. list_add(&request->list, &device->req_queue);
  802. } else {
  803. DBF_LH(5, "Request %p add to queue.\n", request);
  804. request->status = TAPE_REQUEST_QUEUED;
  805. list_add_tail(&request->list, &device->req_queue);
  806. }
  807. return 0;
  808. }
  809. /*
  810. * Add the request to the request queue, try to start it if the
  811. * tape is idle. Return without waiting for end of i/o.
  812. */
  813. int
  814. tape_do_io_async(struct tape_device *device, struct tape_request *request)
  815. {
  816. int rc;
  817. DBF_LH(6, "tape_do_io_async(%p, %p)\n", device, request);
  818. spin_lock_irq(get_ccwdev_lock(device->cdev));
  819. /* Add request to request queue and try to start it. */
  820. rc = __tape_start_request(device, request);
  821. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  822. return rc;
  823. }
  824. /*
  825. * tape_do_io/__tape_wake_up
  826. * Add the request to the request queue, try to start it if the
  827. * tape is idle and wait uninterruptible for its completion.
  828. */
  829. static void
  830. __tape_wake_up(struct tape_request *request, void *data)
  831. {
  832. request->callback = NULL;
  833. wake_up((wait_queue_head_t *) data);
  834. }
  835. int
  836. tape_do_io(struct tape_device *device, struct tape_request *request)
  837. {
  838. wait_queue_head_t wq;
  839. int rc;
  840. init_waitqueue_head(&wq);
  841. spin_lock_irq(get_ccwdev_lock(device->cdev));
  842. /* Setup callback */
  843. request->callback = __tape_wake_up;
  844. request->callback_data = &wq;
  845. /* Add request to request queue and try to start it. */
  846. rc = __tape_start_request(device, request);
  847. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  848. if (rc)
  849. return rc;
  850. /* Request added to the queue. Wait for its completion. */
  851. wait_event(wq, (request->callback == NULL));
  852. /* Get rc from request */
  853. return request->rc;
  854. }
  855. /*
  856. * tape_do_io_interruptible/__tape_wake_up_interruptible
  857. * Add the request to the request queue, try to start it if the
  858. * tape is idle and wait uninterruptible for its completion.
  859. */
  860. static void
  861. __tape_wake_up_interruptible(struct tape_request *request, void *data)
  862. {
  863. request->callback = NULL;
  864. wake_up_interruptible((wait_queue_head_t *) data);
  865. }
  866. int
  867. tape_do_io_interruptible(struct tape_device *device,
  868. struct tape_request *request)
  869. {
  870. wait_queue_head_t wq;
  871. int rc;
  872. init_waitqueue_head(&wq);
  873. spin_lock_irq(get_ccwdev_lock(device->cdev));
  874. /* Setup callback */
  875. request->callback = __tape_wake_up_interruptible;
  876. request->callback_data = &wq;
  877. rc = __tape_start_request(device, request);
  878. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  879. if (rc)
  880. return rc;
  881. /* Request added to the queue. Wait for its completion. */
  882. rc = wait_event_interruptible(wq, (request->callback == NULL));
  883. if (rc != -ERESTARTSYS)
  884. /* Request finished normally. */
  885. return request->rc;
  886. /* Interrupted by a signal. We have to stop the current request. */
  887. spin_lock_irq(get_ccwdev_lock(device->cdev));
  888. rc = __tape_cancel_io(device, request);
  889. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  890. if (rc == 0) {
  891. /* Wait for the interrupt that acknowledges the halt. */
  892. do {
  893. rc = wait_event_interruptible(
  894. wq,
  895. (request->callback == NULL)
  896. );
  897. } while (rc == -ERESTARTSYS);
  898. DBF_EVENT(3, "IO stopped on %08x\n", device->cdev_id);
  899. rc = -ERESTARTSYS;
  900. }
  901. return rc;
  902. }
  903. /*
  904. * Stop running ccw.
  905. */
  906. int
  907. tape_cancel_io(struct tape_device *device, struct tape_request *request)
  908. {
  909. int rc;
  910. spin_lock_irq(get_ccwdev_lock(device->cdev));
  911. rc = __tape_cancel_io(device, request);
  912. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  913. return rc;
  914. }
  915. /*
  916. * Tape interrupt routine, called from the ccw_device layer
  917. */
  918. static void
  919. __tape_do_irq (struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
  920. {
  921. struct tape_device *device;
  922. struct tape_request *request;
  923. int rc;
  924. device = (struct tape_device *) cdev->dev.driver_data;
  925. if (device == NULL) {
  926. PRINT_ERR("could not get device structure for %s "
  927. "in interrupt\n", cdev->dev.bus_id);
  928. return;
  929. }
  930. request = (struct tape_request *) intparm;
  931. DBF_LH(6, "__tape_do_irq(device=%p, request=%p)\n", device, request);
  932. /* On special conditions irb is an error pointer */
  933. if (IS_ERR(irb)) {
  934. /* FIXME: What to do with the request? */
  935. switch (PTR_ERR(irb)) {
  936. case -ETIMEDOUT:
  937. PRINT_WARN("(%s): Request timed out\n",
  938. cdev->dev.bus_id);
  939. case -EIO:
  940. __tape_end_request(device, request, -EIO);
  941. break;
  942. default:
  943. PRINT_ERR("(%s): Unexpected i/o error %li\n",
  944. cdev->dev.bus_id,
  945. PTR_ERR(irb));
  946. }
  947. return;
  948. }
  949. /*
  950. * If the condition code is not zero and the start function bit is
  951. * still set, this is an deferred error and the last start I/O did
  952. * not succeed. At this point the condition that caused the deferred
  953. * error might still apply. So we just schedule the request to be
  954. * started later.
  955. */
  956. if (irb->scsw.cc != 0 && (irb->scsw.fctl & SCSW_FCTL_START_FUNC) &&
  957. (request->status == TAPE_REQUEST_IN_IO)) {
  958. DBF_EVENT(3,"(%08x): deferred cc=%i, fctl=%i. restarting\n",
  959. device->cdev_id, irb->scsw.cc, irb->scsw.fctl);
  960. request->status = TAPE_REQUEST_QUEUED;
  961. schedule_delayed_work(&device->tape_dnr, HZ);
  962. return;
  963. }
  964. /* May be an unsolicited irq */
  965. if(request != NULL)
  966. request->rescnt = irb->scsw.count;
  967. if (irb->scsw.dstat != 0x0c) {
  968. /* Set the 'ONLINE' flag depending on sense byte 1 */
  969. if(*(((__u8 *) irb->ecw) + 1) & SENSE_DRIVE_ONLINE)
  970. device->tape_generic_status |= GMT_ONLINE(~0);
  971. else
  972. device->tape_generic_status &= ~GMT_ONLINE(~0);
  973. /*
  974. * Any request that does not come back with channel end
  975. * and device end is unusual. Log the sense data.
  976. */
  977. DBF_EVENT(3,"-- Tape Interrupthandler --\n");
  978. tape_dump_sense_dbf(device, request, irb);
  979. } else {
  980. /* Upon normal completion the device _is_ online */
  981. device->tape_generic_status |= GMT_ONLINE(~0);
  982. }
  983. if (device->tape_state == TS_NOT_OPER) {
  984. DBF_EVENT(6, "tape:device is not operational\n");
  985. return;
  986. }
  987. /*
  988. * Request that were canceled still come back with an interrupt.
  989. * To detect these request the state will be set to TAPE_REQUEST_DONE.
  990. */
  991. if(request != NULL && request->status == TAPE_REQUEST_DONE) {
  992. __tape_end_request(device, request, -EIO);
  993. return;
  994. }
  995. rc = device->discipline->irq(device, request, irb);
  996. /*
  997. * rc < 0 : request finished unsuccessfully.
  998. * rc == TAPE_IO_SUCCESS: request finished successfully.
  999. * rc == TAPE_IO_PENDING: request is still running. Ignore rc.
  1000. * rc == TAPE_IO_RETRY: request finished but needs another go.
  1001. * rc == TAPE_IO_STOP: request needs to get terminated.
  1002. */
  1003. switch (rc) {
  1004. case TAPE_IO_SUCCESS:
  1005. /* Upon normal completion the device _is_ online */
  1006. device->tape_generic_status |= GMT_ONLINE(~0);
  1007. __tape_end_request(device, request, rc);
  1008. break;
  1009. case TAPE_IO_PENDING:
  1010. break;
  1011. case TAPE_IO_RETRY:
  1012. rc = __tape_start_io(device, request);
  1013. if (rc)
  1014. __tape_end_request(device, request, rc);
  1015. break;
  1016. case TAPE_IO_STOP:
  1017. rc = __tape_cancel_io(device, request);
  1018. if (rc)
  1019. __tape_end_request(device, request, rc);
  1020. break;
  1021. default:
  1022. if (rc > 0) {
  1023. DBF_EVENT(6, "xunknownrc\n");
  1024. PRINT_ERR("Invalid return code from discipline "
  1025. "interrupt function.\n");
  1026. __tape_end_request(device, request, -EIO);
  1027. } else {
  1028. __tape_end_request(device, request, rc);
  1029. }
  1030. break;
  1031. }
  1032. }
  1033. /*
  1034. * Tape device open function used by tape_char & tape_block frontends.
  1035. */
  1036. int
  1037. tape_open(struct tape_device *device)
  1038. {
  1039. int rc;
  1040. spin_lock(get_ccwdev_lock(device->cdev));
  1041. if (device->tape_state == TS_NOT_OPER) {
  1042. DBF_EVENT(6, "TAPE:nodev\n");
  1043. rc = -ENODEV;
  1044. } else if (device->tape_state == TS_IN_USE) {
  1045. DBF_EVENT(6, "TAPE:dbusy\n");
  1046. rc = -EBUSY;
  1047. } else if (device->tape_state == TS_BLKUSE) {
  1048. DBF_EVENT(6, "TAPE:dbusy\n");
  1049. rc = -EBUSY;
  1050. } else if (device->discipline != NULL &&
  1051. !try_module_get(device->discipline->owner)) {
  1052. DBF_EVENT(6, "TAPE:nodisc\n");
  1053. rc = -ENODEV;
  1054. } else {
  1055. tape_state_set(device, TS_IN_USE);
  1056. rc = 0;
  1057. }
  1058. spin_unlock(get_ccwdev_lock(device->cdev));
  1059. return rc;
  1060. }
  1061. /*
  1062. * Tape device release function used by tape_char & tape_block frontends.
  1063. */
  1064. int
  1065. tape_release(struct tape_device *device)
  1066. {
  1067. spin_lock(get_ccwdev_lock(device->cdev));
  1068. if (device->tape_state == TS_IN_USE)
  1069. tape_state_set(device, TS_UNUSED);
  1070. module_put(device->discipline->owner);
  1071. spin_unlock(get_ccwdev_lock(device->cdev));
  1072. return 0;
  1073. }
  1074. /*
  1075. * Execute a magnetic tape command a number of times.
  1076. */
  1077. int
  1078. tape_mtop(struct tape_device *device, int mt_op, int mt_count)
  1079. {
  1080. tape_mtop_fn fn;
  1081. int rc;
  1082. DBF_EVENT(6, "TAPE:mtio\n");
  1083. DBF_EVENT(6, "TAPE:ioop: %x\n", mt_op);
  1084. DBF_EVENT(6, "TAPE:arg: %x\n", mt_count);
  1085. if (mt_op < 0 || mt_op >= TAPE_NR_MTOPS)
  1086. return -EINVAL;
  1087. fn = device->discipline->mtop_array[mt_op];
  1088. if (fn == NULL)
  1089. return -EINVAL;
  1090. /* We assume that the backends can handle count up to 500. */
  1091. if (mt_op == MTBSR || mt_op == MTFSR || mt_op == MTFSF ||
  1092. mt_op == MTBSF || mt_op == MTFSFM || mt_op == MTBSFM) {
  1093. rc = 0;
  1094. for (; mt_count > 500; mt_count -= 500)
  1095. if ((rc = fn(device, 500)) != 0)
  1096. break;
  1097. if (rc == 0)
  1098. rc = fn(device, mt_count);
  1099. } else
  1100. rc = fn(device, mt_count);
  1101. return rc;
  1102. }
  1103. /*
  1104. * Tape init function.
  1105. */
  1106. static int
  1107. tape_init (void)
  1108. {
  1109. TAPE_DBF_AREA = debug_register ( "tape", 2, 2, 4*sizeof(long));
  1110. debug_register_view(TAPE_DBF_AREA, &debug_sprintf_view);
  1111. #ifdef DBF_LIKE_HELL
  1112. debug_set_level(TAPE_DBF_AREA, 6);
  1113. #endif
  1114. DBF_EVENT(3, "tape init\n");
  1115. tape_proc_init();
  1116. tapechar_init ();
  1117. tapeblock_init ();
  1118. return 0;
  1119. }
  1120. /*
  1121. * Tape exit function.
  1122. */
  1123. static void
  1124. tape_exit(void)
  1125. {
  1126. DBF_EVENT(6, "tape exit\n");
  1127. /* Get rid of the frontends */
  1128. tapechar_exit();
  1129. tapeblock_exit();
  1130. tape_proc_cleanup();
  1131. debug_unregister (TAPE_DBF_AREA);
  1132. }
  1133. MODULE_AUTHOR("(C) 2001 IBM Deutschland Entwicklung GmbH by Carsten Otte and "
  1134. "Michael Holzheu (cotte@de.ibm.com,holzheu@de.ibm.com)");
  1135. MODULE_DESCRIPTION("Linux on zSeries channel attached tape device driver");
  1136. MODULE_LICENSE("GPL");
  1137. module_init(tape_init);
  1138. module_exit(tape_exit);
  1139. EXPORT_SYMBOL(tape_generic_remove);
  1140. EXPORT_SYMBOL(tape_generic_probe);
  1141. EXPORT_SYMBOL(tape_generic_online);
  1142. EXPORT_SYMBOL(tape_generic_offline);
  1143. EXPORT_SYMBOL(tape_put_device);
  1144. EXPORT_SYMBOL(tape_get_device_reference);
  1145. EXPORT_SYMBOL(tape_state_verbose);
  1146. EXPORT_SYMBOL(tape_op_verbose);
  1147. EXPORT_SYMBOL(tape_state_set);
  1148. EXPORT_SYMBOL(tape_med_state_set);
  1149. EXPORT_SYMBOL(tape_alloc_request);
  1150. EXPORT_SYMBOL(tape_free_request);
  1151. EXPORT_SYMBOL(tape_dump_sense);
  1152. EXPORT_SYMBOL(tape_dump_sense_dbf);
  1153. EXPORT_SYMBOL(tape_do_io);
  1154. EXPORT_SYMBOL(tape_do_io_async);
  1155. EXPORT_SYMBOL(tape_do_io_interruptible);
  1156. EXPORT_SYMBOL(tape_cancel_io);
  1157. EXPORT_SYMBOL(tape_mtop);