tape_core.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312
  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 = (struct tape_device *)
  395. kmalloc(sizeof(struct tape_device), GFP_KERNEL);
  396. if (device == NULL) {
  397. DBF_EXCEPTION(2, "ti:no mem\n");
  398. PRINT_INFO ("can't allocate memory for "
  399. "tape info structure\n");
  400. return ERR_PTR(-ENOMEM);
  401. }
  402. memset(device, 0, sizeof(struct tape_device));
  403. device->modeset_byte = (char *) kmalloc(1, GFP_KERNEL | GFP_DMA);
  404. if (device->modeset_byte == NULL) {
  405. DBF_EXCEPTION(2, "ti:no mem\n");
  406. PRINT_INFO("can't allocate memory for modeset byte\n");
  407. kfree(device);
  408. return ERR_PTR(-ENOMEM);
  409. }
  410. INIT_LIST_HEAD(&device->req_queue);
  411. INIT_LIST_HEAD(&device->node);
  412. init_waitqueue_head(&device->state_change_wq);
  413. device->tape_state = TS_INIT;
  414. device->medium_state = MS_UNKNOWN;
  415. *device->modeset_byte = 0;
  416. device->first_minor = -1;
  417. atomic_set(&device->ref_count, 1);
  418. INIT_WORK(&device->tape_dnr, tape_delayed_next_request, device);
  419. return device;
  420. }
  421. /*
  422. * Get a reference to an existing device structure. This will automatically
  423. * increment the reference count.
  424. */
  425. struct tape_device *
  426. tape_get_device_reference(struct tape_device *device)
  427. {
  428. DBF_EVENT(4, "tape_get_device_reference(%p) = %i\n", device,
  429. atomic_inc_return(&device->ref_count));
  430. return device;
  431. }
  432. /*
  433. * Decrease the reference counter of a devices structure. If the
  434. * reference counter reaches zero free the device structure.
  435. * The function returns a NULL pointer to be used by the caller
  436. * for clearing reference pointers.
  437. */
  438. struct tape_device *
  439. tape_put_device(struct tape_device *device)
  440. {
  441. int remain;
  442. remain = atomic_dec_return(&device->ref_count);
  443. if (remain > 0) {
  444. DBF_EVENT(4, "tape_put_device(%p) -> %i\n", device, remain);
  445. } else {
  446. if (remain < 0) {
  447. DBF_EVENT(4, "put device without reference\n");
  448. PRINT_ERR("put device without reference\n");
  449. } else {
  450. DBF_EVENT(4, "tape_free_device(%p)\n", device);
  451. kfree(device->modeset_byte);
  452. kfree(device);
  453. }
  454. }
  455. return NULL;
  456. }
  457. /*
  458. * Find tape device by a device index.
  459. */
  460. struct tape_device *
  461. tape_get_device(int devindex)
  462. {
  463. struct tape_device *device, *tmp;
  464. device = ERR_PTR(-ENODEV);
  465. read_lock(&tape_device_lock);
  466. list_for_each_entry(tmp, &tape_device_list, node) {
  467. if (tmp->first_minor / TAPE_MINORS_PER_DEV == devindex) {
  468. device = tape_get_device_reference(tmp);
  469. break;
  470. }
  471. }
  472. read_unlock(&tape_device_lock);
  473. return device;
  474. }
  475. /*
  476. * Driverfs tape probe function.
  477. */
  478. int
  479. tape_generic_probe(struct ccw_device *cdev)
  480. {
  481. struct tape_device *device;
  482. device = tape_alloc_device();
  483. if (IS_ERR(device))
  484. return -ENODEV;
  485. PRINT_INFO("tape device %s found\n", cdev->dev.bus_id);
  486. cdev->dev.driver_data = device;
  487. device->cdev = cdev;
  488. device->cdev_id = busid_to_int(cdev->dev.bus_id);
  489. cdev->handler = __tape_do_irq;
  490. ccw_device_set_options(cdev, CCWDEV_DO_PATHGROUP);
  491. sysfs_create_group(&cdev->dev.kobj, &tape_attr_group);
  492. return 0;
  493. }
  494. static inline void
  495. __tape_discard_requests(struct tape_device *device)
  496. {
  497. struct tape_request * request;
  498. struct list_head * l, *n;
  499. list_for_each_safe(l, n, &device->req_queue) {
  500. request = list_entry(l, struct tape_request, list);
  501. if (request->status == TAPE_REQUEST_IN_IO)
  502. request->status = TAPE_REQUEST_DONE;
  503. list_del(&request->list);
  504. /* Decrease ref_count for removed request. */
  505. request->device = tape_put_device(device);
  506. request->rc = -EIO;
  507. if (request->callback != NULL)
  508. request->callback(request, request->callback_data);
  509. }
  510. }
  511. /*
  512. * Driverfs tape remove function.
  513. *
  514. * This function is called whenever the common I/O layer detects the device
  515. * gone. This can happen at any time and we cannot refuse.
  516. */
  517. void
  518. tape_generic_remove(struct ccw_device *cdev)
  519. {
  520. struct tape_device * device;
  521. device = cdev->dev.driver_data;
  522. if (!device) {
  523. PRINT_ERR("No device pointer in tape_generic_remove!\n");
  524. return;
  525. }
  526. DBF_LH(3, "(%08x): tape_generic_remove(%p)\n", device->cdev_id, cdev);
  527. spin_lock_irq(get_ccwdev_lock(device->cdev));
  528. switch (device->tape_state) {
  529. case TS_INIT:
  530. tape_state_set(device, TS_NOT_OPER);
  531. case TS_NOT_OPER:
  532. /*
  533. * Nothing to do.
  534. */
  535. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  536. break;
  537. case TS_UNUSED:
  538. /*
  539. * Need only to release the device.
  540. */
  541. tape_state_set(device, TS_NOT_OPER);
  542. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  543. tape_cleanup_device(device);
  544. break;
  545. default:
  546. /*
  547. * There may be requests on the queue. We will not get
  548. * an interrupt for a request that was running. So we
  549. * just post them all as I/O errors.
  550. */
  551. DBF_EVENT(3, "(%08x): Drive in use vanished!\n",
  552. device->cdev_id);
  553. PRINT_WARN("(%s): Drive in use vanished - "
  554. "expect trouble!\n",
  555. device->cdev->dev.bus_id);
  556. PRINT_WARN("State was %i\n", device->tape_state);
  557. tape_state_set(device, TS_NOT_OPER);
  558. __tape_discard_requests(device);
  559. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  560. tape_cleanup_device(device);
  561. }
  562. if (cdev->dev.driver_data != NULL) {
  563. sysfs_remove_group(&cdev->dev.kobj, &tape_attr_group);
  564. cdev->dev.driver_data = tape_put_device(cdev->dev.driver_data);
  565. }
  566. }
  567. /*
  568. * Allocate a new tape ccw request
  569. */
  570. struct tape_request *
  571. tape_alloc_request(int cplength, int datasize)
  572. {
  573. struct tape_request *request;
  574. if (datasize > PAGE_SIZE || (cplength*sizeof(struct ccw1)) > PAGE_SIZE)
  575. BUG();
  576. DBF_LH(6, "tape_alloc_request(%d, %d)\n", cplength, datasize);
  577. request = (struct tape_request *) kmalloc(sizeof(struct tape_request),
  578. GFP_KERNEL);
  579. if (request == NULL) {
  580. DBF_EXCEPTION(1, "cqra nomem\n");
  581. return ERR_PTR(-ENOMEM);
  582. }
  583. memset(request, 0, sizeof(struct tape_request));
  584. /* allocate channel program */
  585. if (cplength > 0) {
  586. request->cpaddr = kmalloc(cplength*sizeof(struct ccw1),
  587. GFP_ATOMIC | GFP_DMA);
  588. if (request->cpaddr == NULL) {
  589. DBF_EXCEPTION(1, "cqra nomem\n");
  590. kfree(request);
  591. return ERR_PTR(-ENOMEM);
  592. }
  593. memset(request->cpaddr, 0, cplength*sizeof(struct ccw1));
  594. }
  595. /* alloc small kernel buffer */
  596. if (datasize > 0) {
  597. request->cpdata = kmalloc(datasize, GFP_KERNEL | GFP_DMA);
  598. if (request->cpdata == NULL) {
  599. DBF_EXCEPTION(1, "cqra nomem\n");
  600. kfree(request->cpaddr);
  601. kfree(request);
  602. return ERR_PTR(-ENOMEM);
  603. }
  604. memset(request->cpdata, 0, datasize);
  605. }
  606. DBF_LH(6, "New request %p(%p/%p)\n", request, request->cpaddr,
  607. request->cpdata);
  608. return request;
  609. }
  610. /*
  611. * Free tape ccw request
  612. */
  613. void
  614. tape_free_request (struct tape_request * request)
  615. {
  616. DBF_LH(6, "Free request %p\n", request);
  617. if (request->device != NULL) {
  618. request->device = tape_put_device(request->device);
  619. }
  620. kfree(request->cpdata);
  621. kfree(request->cpaddr);
  622. kfree(request);
  623. }
  624. static inline int
  625. __tape_start_io(struct tape_device *device, struct tape_request *request)
  626. {
  627. int rc;
  628. #ifdef CONFIG_S390_TAPE_BLOCK
  629. if (request->op == TO_BLOCK)
  630. device->discipline->check_locate(device, request);
  631. #endif
  632. rc = ccw_device_start(
  633. device->cdev,
  634. request->cpaddr,
  635. (unsigned long) request,
  636. 0x00,
  637. request->options
  638. );
  639. if (rc == 0) {
  640. request->status = TAPE_REQUEST_IN_IO;
  641. } else if (rc == -EBUSY) {
  642. /* The common I/O subsystem is currently busy. Retry later. */
  643. request->status = TAPE_REQUEST_QUEUED;
  644. schedule_work(&device->tape_dnr);
  645. rc = 0;
  646. } else {
  647. /* Start failed. Remove request and indicate failure. */
  648. DBF_EVENT(1, "tape: start request failed with RC = %i\n", rc);
  649. }
  650. return rc;
  651. }
  652. static inline void
  653. __tape_start_next_request(struct tape_device *device)
  654. {
  655. struct list_head *l, *n;
  656. struct tape_request *request;
  657. int rc;
  658. DBF_LH(6, "__tape_start_next_request(%p)\n", device);
  659. /*
  660. * Try to start each request on request queue until one is
  661. * started successful.
  662. */
  663. list_for_each_safe(l, n, &device->req_queue) {
  664. request = list_entry(l, struct tape_request, list);
  665. /*
  666. * Avoid race condition if bottom-half was triggered more than
  667. * once.
  668. */
  669. if (request->status == TAPE_REQUEST_IN_IO)
  670. return;
  671. /*
  672. * Request has already been stopped. We have to wait until
  673. * the request is removed from the queue in the interrupt
  674. * handling.
  675. */
  676. if (request->status == TAPE_REQUEST_DONE)
  677. return;
  678. /*
  679. * We wanted to cancel the request but the common I/O layer
  680. * was busy at that time. This can only happen if this
  681. * function is called by delayed_next_request.
  682. * Otherwise we start the next request on the queue.
  683. */
  684. if (request->status == TAPE_REQUEST_CANCEL) {
  685. rc = __tape_cancel_io(device, request);
  686. } else {
  687. rc = __tape_start_io(device, request);
  688. }
  689. if (rc == 0)
  690. return;
  691. /* Set ending status. */
  692. request->rc = rc;
  693. request->status = TAPE_REQUEST_DONE;
  694. /* Remove from request queue. */
  695. list_del(&request->list);
  696. /* Do callback. */
  697. if (request->callback != NULL)
  698. request->callback(request, request->callback_data);
  699. }
  700. }
  701. static void
  702. tape_delayed_next_request(void *data)
  703. {
  704. struct tape_device * device;
  705. device = (struct tape_device *) data;
  706. DBF_LH(6, "tape_delayed_next_request(%p)\n", device);
  707. spin_lock_irq(get_ccwdev_lock(device->cdev));
  708. __tape_start_next_request(device);
  709. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  710. }
  711. static inline void
  712. __tape_end_request(
  713. struct tape_device * device,
  714. struct tape_request * request,
  715. int rc)
  716. {
  717. DBF_LH(6, "__tape_end_request(%p, %p, %i)\n", device, request, rc);
  718. if (request) {
  719. request->rc = rc;
  720. request->status = TAPE_REQUEST_DONE;
  721. /* Remove from request queue. */
  722. list_del(&request->list);
  723. /* Do callback. */
  724. if (request->callback != NULL)
  725. request->callback(request, request->callback_data);
  726. }
  727. /* Start next request. */
  728. if (!list_empty(&device->req_queue))
  729. __tape_start_next_request(device);
  730. }
  731. /*
  732. * Write sense data to console/dbf
  733. */
  734. void
  735. tape_dump_sense(struct tape_device* device, struct tape_request *request,
  736. struct irb *irb)
  737. {
  738. unsigned int *sptr;
  739. PRINT_INFO("-------------------------------------------------\n");
  740. PRINT_INFO("DSTAT : %02x CSTAT: %02x CPA: %04x\n",
  741. irb->scsw.dstat, irb->scsw.cstat, irb->scsw.cpa);
  742. PRINT_INFO("DEVICE: %s\n", device->cdev->dev.bus_id);
  743. if (request != NULL)
  744. PRINT_INFO("OP : %s\n", tape_op_verbose[request->op]);
  745. sptr = (unsigned int *) irb->ecw;
  746. PRINT_INFO("Sense data: %08X %08X %08X %08X \n",
  747. sptr[0], sptr[1], sptr[2], sptr[3]);
  748. PRINT_INFO("Sense data: %08X %08X %08X %08X \n",
  749. sptr[4], sptr[5], sptr[6], sptr[7]);
  750. PRINT_INFO("--------------------------------------------------\n");
  751. }
  752. /*
  753. * Write sense data to dbf
  754. */
  755. void
  756. tape_dump_sense_dbf(struct tape_device *device, struct tape_request *request,
  757. struct irb *irb)
  758. {
  759. unsigned int *sptr;
  760. const char* op;
  761. if (request != NULL)
  762. op = tape_op_verbose[request->op];
  763. else
  764. op = "---";
  765. DBF_EVENT(3, "DSTAT : %02x CSTAT: %02x\n",
  766. irb->scsw.dstat,irb->scsw.cstat);
  767. DBF_EVENT(3, "DEVICE: %08x OP\t: %s\n", device->cdev_id, op);
  768. sptr = (unsigned int *) irb->ecw;
  769. DBF_EVENT(3, "%08x %08x\n", sptr[0], sptr[1]);
  770. DBF_EVENT(3, "%08x %08x\n", sptr[2], sptr[3]);
  771. DBF_EVENT(3, "%08x %08x\n", sptr[4], sptr[5]);
  772. DBF_EVENT(3, "%08x %08x\n", sptr[6], sptr[7]);
  773. }
  774. /*
  775. * I/O helper function. Adds the request to the request queue
  776. * and starts it if the tape is idle. Has to be called with
  777. * the device lock held.
  778. */
  779. static inline int
  780. __tape_start_request(struct tape_device *device, struct tape_request *request)
  781. {
  782. int rc;
  783. switch (request->op) {
  784. case TO_MSEN:
  785. case TO_ASSIGN:
  786. case TO_UNASSIGN:
  787. case TO_READ_ATTMSG:
  788. if (device->tape_state == TS_INIT)
  789. break;
  790. if (device->tape_state == TS_UNUSED)
  791. break;
  792. default:
  793. if (device->tape_state == TS_BLKUSE)
  794. break;
  795. if (device->tape_state != TS_IN_USE)
  796. return -ENODEV;
  797. }
  798. /* Increase use count of device for the added request. */
  799. request->device = tape_get_device_reference(device);
  800. if (list_empty(&device->req_queue)) {
  801. /* No other requests are on the queue. Start this one. */
  802. rc = __tape_start_io(device, request);
  803. if (rc)
  804. return rc;
  805. DBF_LH(5, "Request %p added for execution.\n", request);
  806. list_add(&request->list, &device->req_queue);
  807. } else {
  808. DBF_LH(5, "Request %p add to queue.\n", request);
  809. request->status = TAPE_REQUEST_QUEUED;
  810. list_add_tail(&request->list, &device->req_queue);
  811. }
  812. return 0;
  813. }
  814. /*
  815. * Add the request to the request queue, try to start it if the
  816. * tape is idle. Return without waiting for end of i/o.
  817. */
  818. int
  819. tape_do_io_async(struct tape_device *device, struct tape_request *request)
  820. {
  821. int rc;
  822. DBF_LH(6, "tape_do_io_async(%p, %p)\n", device, request);
  823. spin_lock_irq(get_ccwdev_lock(device->cdev));
  824. /* Add request to request queue and try to start it. */
  825. rc = __tape_start_request(device, request);
  826. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  827. return rc;
  828. }
  829. /*
  830. * tape_do_io/__tape_wake_up
  831. * Add the request to the request queue, try to start it if the
  832. * tape is idle and wait uninterruptible for its completion.
  833. */
  834. static void
  835. __tape_wake_up(struct tape_request *request, void *data)
  836. {
  837. request->callback = NULL;
  838. wake_up((wait_queue_head_t *) data);
  839. }
  840. int
  841. tape_do_io(struct tape_device *device, struct tape_request *request)
  842. {
  843. wait_queue_head_t wq;
  844. int rc;
  845. init_waitqueue_head(&wq);
  846. spin_lock_irq(get_ccwdev_lock(device->cdev));
  847. /* Setup callback */
  848. request->callback = __tape_wake_up;
  849. request->callback_data = &wq;
  850. /* Add request to request queue and try to start it. */
  851. rc = __tape_start_request(device, request);
  852. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  853. if (rc)
  854. return rc;
  855. /* Request added to the queue. Wait for its completion. */
  856. wait_event(wq, (request->callback == NULL));
  857. /* Get rc from request */
  858. return request->rc;
  859. }
  860. /*
  861. * tape_do_io_interruptible/__tape_wake_up_interruptible
  862. * Add the request to the request queue, try to start it if the
  863. * tape is idle and wait uninterruptible for its completion.
  864. */
  865. static void
  866. __tape_wake_up_interruptible(struct tape_request *request, void *data)
  867. {
  868. request->callback = NULL;
  869. wake_up_interruptible((wait_queue_head_t *) data);
  870. }
  871. int
  872. tape_do_io_interruptible(struct tape_device *device,
  873. struct tape_request *request)
  874. {
  875. wait_queue_head_t wq;
  876. int rc;
  877. init_waitqueue_head(&wq);
  878. spin_lock_irq(get_ccwdev_lock(device->cdev));
  879. /* Setup callback */
  880. request->callback = __tape_wake_up_interruptible;
  881. request->callback_data = &wq;
  882. rc = __tape_start_request(device, request);
  883. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  884. if (rc)
  885. return rc;
  886. /* Request added to the queue. Wait for its completion. */
  887. rc = wait_event_interruptible(wq, (request->callback == NULL));
  888. if (rc != -ERESTARTSYS)
  889. /* Request finished normally. */
  890. return request->rc;
  891. /* Interrupted by a signal. We have to stop the current request. */
  892. spin_lock_irq(get_ccwdev_lock(device->cdev));
  893. rc = __tape_cancel_io(device, request);
  894. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  895. if (rc == 0) {
  896. /* Wait for the interrupt that acknowledges the halt. */
  897. do {
  898. rc = wait_event_interruptible(
  899. wq,
  900. (request->callback == NULL)
  901. );
  902. } while (rc == -ERESTARTSYS);
  903. DBF_EVENT(3, "IO stopped on %08x\n", device->cdev_id);
  904. rc = -ERESTARTSYS;
  905. }
  906. return rc;
  907. }
  908. /*
  909. * Stop running ccw.
  910. */
  911. int
  912. tape_cancel_io(struct tape_device *device, struct tape_request *request)
  913. {
  914. int rc;
  915. spin_lock_irq(get_ccwdev_lock(device->cdev));
  916. rc = __tape_cancel_io(device, request);
  917. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  918. return rc;
  919. }
  920. /*
  921. * Tape interrupt routine, called from the ccw_device layer
  922. */
  923. static void
  924. __tape_do_irq (struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
  925. {
  926. struct tape_device *device;
  927. struct tape_request *request;
  928. int rc;
  929. device = (struct tape_device *) cdev->dev.driver_data;
  930. if (device == NULL) {
  931. PRINT_ERR("could not get device structure for %s "
  932. "in interrupt\n", cdev->dev.bus_id);
  933. return;
  934. }
  935. request = (struct tape_request *) intparm;
  936. DBF_LH(6, "__tape_do_irq(device=%p, request=%p)\n", device, request);
  937. /* On special conditions irb is an error pointer */
  938. if (IS_ERR(irb)) {
  939. /* FIXME: What to do with the request? */
  940. switch (PTR_ERR(irb)) {
  941. case -ETIMEDOUT:
  942. PRINT_WARN("(%s): Request timed out\n",
  943. cdev->dev.bus_id);
  944. case -EIO:
  945. __tape_end_request(device, request, -EIO);
  946. break;
  947. default:
  948. PRINT_ERR("(%s): Unexpected i/o error %li\n",
  949. cdev->dev.bus_id,
  950. PTR_ERR(irb));
  951. }
  952. return;
  953. }
  954. /*
  955. * If the condition code is not zero and the start function bit is
  956. * still set, this is an deferred error and the last start I/O did
  957. * not succeed. At this point the condition that caused the deferred
  958. * error might still apply. So we just schedule the request to be
  959. * started later.
  960. */
  961. if (irb->scsw.cc != 0 && (irb->scsw.fctl & SCSW_FCTL_START_FUNC) &&
  962. (request->status == TAPE_REQUEST_IN_IO)) {
  963. DBF_EVENT(3,"(%08x): deferred cc=%i, fctl=%i. restarting\n",
  964. device->cdev_id, irb->scsw.cc, irb->scsw.fctl);
  965. request->status = TAPE_REQUEST_QUEUED;
  966. schedule_delayed_work(&device->tape_dnr, HZ);
  967. return;
  968. }
  969. /* May be an unsolicited irq */
  970. if(request != NULL)
  971. request->rescnt = irb->scsw.count;
  972. if (irb->scsw.dstat != 0x0c) {
  973. /* Set the 'ONLINE' flag depending on sense byte 1 */
  974. if(*(((__u8 *) irb->ecw) + 1) & SENSE_DRIVE_ONLINE)
  975. device->tape_generic_status |= GMT_ONLINE(~0);
  976. else
  977. device->tape_generic_status &= ~GMT_ONLINE(~0);
  978. /*
  979. * Any request that does not come back with channel end
  980. * and device end is unusual. Log the sense data.
  981. */
  982. DBF_EVENT(3,"-- Tape Interrupthandler --\n");
  983. tape_dump_sense_dbf(device, request, irb);
  984. } else {
  985. /* Upon normal completion the device _is_ online */
  986. device->tape_generic_status |= GMT_ONLINE(~0);
  987. }
  988. if (device->tape_state == TS_NOT_OPER) {
  989. DBF_EVENT(6, "tape:device is not operational\n");
  990. return;
  991. }
  992. /*
  993. * Request that were canceled still come back with an interrupt.
  994. * To detect these request the state will be set to TAPE_REQUEST_DONE.
  995. */
  996. if(request != NULL && request->status == TAPE_REQUEST_DONE) {
  997. __tape_end_request(device, request, -EIO);
  998. return;
  999. }
  1000. rc = device->discipline->irq(device, request, irb);
  1001. /*
  1002. * rc < 0 : request finished unsuccessfully.
  1003. * rc == TAPE_IO_SUCCESS: request finished successfully.
  1004. * rc == TAPE_IO_PENDING: request is still running. Ignore rc.
  1005. * rc == TAPE_IO_RETRY: request finished but needs another go.
  1006. * rc == TAPE_IO_STOP: request needs to get terminated.
  1007. */
  1008. switch (rc) {
  1009. case TAPE_IO_SUCCESS:
  1010. /* Upon normal completion the device _is_ online */
  1011. device->tape_generic_status |= GMT_ONLINE(~0);
  1012. __tape_end_request(device, request, rc);
  1013. break;
  1014. case TAPE_IO_PENDING:
  1015. break;
  1016. case TAPE_IO_RETRY:
  1017. rc = __tape_start_io(device, request);
  1018. if (rc)
  1019. __tape_end_request(device, request, rc);
  1020. break;
  1021. case TAPE_IO_STOP:
  1022. rc = __tape_cancel_io(device, request);
  1023. if (rc)
  1024. __tape_end_request(device, request, rc);
  1025. break;
  1026. default:
  1027. if (rc > 0) {
  1028. DBF_EVENT(6, "xunknownrc\n");
  1029. PRINT_ERR("Invalid return code from discipline "
  1030. "interrupt function.\n");
  1031. __tape_end_request(device, request, -EIO);
  1032. } else {
  1033. __tape_end_request(device, request, rc);
  1034. }
  1035. break;
  1036. }
  1037. }
  1038. /*
  1039. * Tape device open function used by tape_char & tape_block frontends.
  1040. */
  1041. int
  1042. tape_open(struct tape_device *device)
  1043. {
  1044. int rc;
  1045. spin_lock(get_ccwdev_lock(device->cdev));
  1046. if (device->tape_state == TS_NOT_OPER) {
  1047. DBF_EVENT(6, "TAPE:nodev\n");
  1048. rc = -ENODEV;
  1049. } else if (device->tape_state == TS_IN_USE) {
  1050. DBF_EVENT(6, "TAPE:dbusy\n");
  1051. rc = -EBUSY;
  1052. } else if (device->tape_state == TS_BLKUSE) {
  1053. DBF_EVENT(6, "TAPE:dbusy\n");
  1054. rc = -EBUSY;
  1055. } else if (device->discipline != NULL &&
  1056. !try_module_get(device->discipline->owner)) {
  1057. DBF_EVENT(6, "TAPE:nodisc\n");
  1058. rc = -ENODEV;
  1059. } else {
  1060. tape_state_set(device, TS_IN_USE);
  1061. rc = 0;
  1062. }
  1063. spin_unlock(get_ccwdev_lock(device->cdev));
  1064. return rc;
  1065. }
  1066. /*
  1067. * Tape device release function used by tape_char & tape_block frontends.
  1068. */
  1069. int
  1070. tape_release(struct tape_device *device)
  1071. {
  1072. spin_lock(get_ccwdev_lock(device->cdev));
  1073. if (device->tape_state == TS_IN_USE)
  1074. tape_state_set(device, TS_UNUSED);
  1075. module_put(device->discipline->owner);
  1076. spin_unlock(get_ccwdev_lock(device->cdev));
  1077. return 0;
  1078. }
  1079. /*
  1080. * Execute a magnetic tape command a number of times.
  1081. */
  1082. int
  1083. tape_mtop(struct tape_device *device, int mt_op, int mt_count)
  1084. {
  1085. tape_mtop_fn fn;
  1086. int rc;
  1087. DBF_EVENT(6, "TAPE:mtio\n");
  1088. DBF_EVENT(6, "TAPE:ioop: %x\n", mt_op);
  1089. DBF_EVENT(6, "TAPE:arg: %x\n", mt_count);
  1090. if (mt_op < 0 || mt_op >= TAPE_NR_MTOPS)
  1091. return -EINVAL;
  1092. fn = device->discipline->mtop_array[mt_op];
  1093. if (fn == NULL)
  1094. return -EINVAL;
  1095. /* We assume that the backends can handle count up to 500. */
  1096. if (mt_op == MTBSR || mt_op == MTFSR || mt_op == MTFSF ||
  1097. mt_op == MTBSF || mt_op == MTFSFM || mt_op == MTBSFM) {
  1098. rc = 0;
  1099. for (; mt_count > 500; mt_count -= 500)
  1100. if ((rc = fn(device, 500)) != 0)
  1101. break;
  1102. if (rc == 0)
  1103. rc = fn(device, mt_count);
  1104. } else
  1105. rc = fn(device, mt_count);
  1106. return rc;
  1107. }
  1108. /*
  1109. * Tape init function.
  1110. */
  1111. static int
  1112. tape_init (void)
  1113. {
  1114. TAPE_DBF_AREA = debug_register ( "tape", 2, 2, 4*sizeof(long));
  1115. debug_register_view(TAPE_DBF_AREA, &debug_sprintf_view);
  1116. #ifdef DBF_LIKE_HELL
  1117. debug_set_level(TAPE_DBF_AREA, 6);
  1118. #endif
  1119. DBF_EVENT(3, "tape init\n");
  1120. tape_proc_init();
  1121. tapechar_init ();
  1122. tapeblock_init ();
  1123. return 0;
  1124. }
  1125. /*
  1126. * Tape exit function.
  1127. */
  1128. static void
  1129. tape_exit(void)
  1130. {
  1131. DBF_EVENT(6, "tape exit\n");
  1132. /* Get rid of the frontends */
  1133. tapechar_exit();
  1134. tapeblock_exit();
  1135. tape_proc_cleanup();
  1136. debug_unregister (TAPE_DBF_AREA);
  1137. }
  1138. MODULE_AUTHOR("(C) 2001 IBM Deutschland Entwicklung GmbH by Carsten Otte and "
  1139. "Michael Holzheu (cotte@de.ibm.com,holzheu@de.ibm.com)");
  1140. MODULE_DESCRIPTION("Linux on zSeries channel attached tape device driver");
  1141. MODULE_LICENSE("GPL");
  1142. module_init(tape_init);
  1143. module_exit(tape_exit);
  1144. EXPORT_SYMBOL(tape_generic_remove);
  1145. EXPORT_SYMBOL(tape_generic_probe);
  1146. EXPORT_SYMBOL(tape_generic_online);
  1147. EXPORT_SYMBOL(tape_generic_offline);
  1148. EXPORT_SYMBOL(tape_put_device);
  1149. EXPORT_SYMBOL(tape_get_device_reference);
  1150. EXPORT_SYMBOL(tape_state_verbose);
  1151. EXPORT_SYMBOL(tape_op_verbose);
  1152. EXPORT_SYMBOL(tape_state_set);
  1153. EXPORT_SYMBOL(tape_med_state_set);
  1154. EXPORT_SYMBOL(tape_alloc_request);
  1155. EXPORT_SYMBOL(tape_free_request);
  1156. EXPORT_SYMBOL(tape_dump_sense);
  1157. EXPORT_SYMBOL(tape_dump_sense_dbf);
  1158. EXPORT_SYMBOL(tape_do_io);
  1159. EXPORT_SYMBOL(tape_do_io_async);
  1160. EXPORT_SYMBOL(tape_do_io_interruptible);
  1161. EXPORT_SYMBOL(tape_cancel_io);
  1162. EXPORT_SYMBOL(tape_mtop);