tape_core.c 34 KB

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