tape_core.c 32 KB

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