tape_core.c 34 KB

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