tape_core.c 34 KB

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