tape_core.c 34 KB

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