tape_3590.c 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763
  1. /*
  2. * drivers/s390/char/tape_3590.c
  3. * tape device discipline for 3590 tapes.
  4. *
  5. * Copyright IBM Corp. 2001,2006
  6. * Author(s): Stefan Bader <shbader@de.ibm.com>
  7. * Michael Holzheu <holzheu@de.ibm.com>
  8. * Martin Schwidefsky <schwidefsky@de.ibm.com>
  9. */
  10. #include <linux/module.h>
  11. #include <linux/init.h>
  12. #include <linux/bio.h>
  13. #include <asm/ebcdic.h>
  14. #define TAPE_DBF_AREA tape_3590_dbf
  15. #include "tape.h"
  16. #include "tape_std.h"
  17. #include "tape_3590.h"
  18. /*
  19. * Pointer to debug area.
  20. */
  21. debug_info_t *TAPE_DBF_AREA = NULL;
  22. EXPORT_SYMBOL(TAPE_DBF_AREA);
  23. /*******************************************************************
  24. * Error Recovery fuctions:
  25. * - Read Opposite: implemented
  26. * - Read Device (buffered) log: BRA
  27. * - Read Library log: BRA
  28. * - Swap Devices: BRA
  29. * - Long Busy: implemented
  30. * - Special Intercept: BRA
  31. * - Read Alternate: implemented
  32. *******************************************************************/
  33. #define PRINTK_HEADER "TAPE_3590: "
  34. static const char *tape_3590_msg[TAPE_3590_MAX_MSG] = {
  35. [0x00] = "",
  36. [0x10] = "Lost Sense",
  37. [0x11] = "Assigned Elsewhere",
  38. [0x12] = "Allegiance Reset",
  39. [0x13] = "Shared Access Violation",
  40. [0x20] = "Command Reject",
  41. [0x21] = "Configuration Error",
  42. [0x22] = "Protection Exception",
  43. [0x23] = "Write Protect",
  44. [0x24] = "Write Length",
  45. [0x25] = "Read-Only Format",
  46. [0x31] = "Beginning of Partition",
  47. [0x33] = "End of Partition",
  48. [0x34] = "End of Data",
  49. [0x35] = "Block not found",
  50. [0x40] = "Device Intervention",
  51. [0x41] = "Loader Intervention",
  52. [0x42] = "Library Intervention",
  53. [0x50] = "Write Error",
  54. [0x51] = "Erase Error",
  55. [0x52] = "Formatting Error",
  56. [0x53] = "Read Error",
  57. [0x54] = "Unsupported Format",
  58. [0x55] = "No Formatting",
  59. [0x56] = "Positioning lost",
  60. [0x57] = "Read Length",
  61. [0x60] = "Unsupported Medium",
  62. [0x61] = "Medium Length Error",
  63. [0x62] = "Medium removed",
  64. [0x64] = "Load Check",
  65. [0x65] = "Unload Check",
  66. [0x70] = "Equipment Check",
  67. [0x71] = "Bus out Check",
  68. [0x72] = "Protocol Error",
  69. [0x73] = "Interface Error",
  70. [0x74] = "Overrun",
  71. [0x75] = "Halt Signal",
  72. [0x90] = "Device fenced",
  73. [0x91] = "Device Path fenced",
  74. [0xa0] = "Volume misplaced",
  75. [0xa1] = "Volume inaccessible",
  76. [0xa2] = "Volume in input",
  77. [0xa3] = "Volume ejected",
  78. [0xa4] = "All categories reserved",
  79. [0xa5] = "Duplicate Volume",
  80. [0xa6] = "Library Manager Offline",
  81. [0xa7] = "Library Output Station full",
  82. [0xa8] = "Vision System non-operational",
  83. [0xa9] = "Library Manager Equipment Check",
  84. [0xaa] = "Library Equipment Check",
  85. [0xab] = "All Library Cells full",
  86. [0xac] = "No Cleaner Volumes in Library",
  87. [0xad] = "I/O Station door open",
  88. [0xae] = "Subsystem environmental alert",
  89. };
  90. static int crypt_supported(struct tape_device *device)
  91. {
  92. return TAPE390_CRYPT_SUPPORTED(TAPE_3590_CRYPT_INFO(device));
  93. }
  94. static int crypt_enabled(struct tape_device *device)
  95. {
  96. return TAPE390_CRYPT_ON(TAPE_3590_CRYPT_INFO(device));
  97. }
  98. static void ext_to_int_kekl(struct tape390_kekl *in,
  99. struct tape3592_kekl *out)
  100. {
  101. int i;
  102. memset(out, 0, sizeof(*out));
  103. if (in->type == TAPE390_KEKL_TYPE_HASH)
  104. out->flags |= 0x40;
  105. if (in->type_on_tape == TAPE390_KEKL_TYPE_HASH)
  106. out->flags |= 0x80;
  107. strncpy(out->label, in->label, 64);
  108. for (i = strlen(in->label); i < sizeof(out->label); i++)
  109. out->label[i] = ' ';
  110. ASCEBC(out->label, sizeof(out->label));
  111. }
  112. static void int_to_ext_kekl(struct tape3592_kekl *in,
  113. struct tape390_kekl *out)
  114. {
  115. memset(out, 0, sizeof(*out));
  116. if(in->flags & 0x40)
  117. out->type = TAPE390_KEKL_TYPE_HASH;
  118. else
  119. out->type = TAPE390_KEKL_TYPE_LABEL;
  120. if(in->flags & 0x80)
  121. out->type_on_tape = TAPE390_KEKL_TYPE_HASH;
  122. else
  123. out->type_on_tape = TAPE390_KEKL_TYPE_LABEL;
  124. memcpy(out->label, in->label, sizeof(in->label));
  125. EBCASC(out->label, sizeof(in->label));
  126. strstrip(out->label);
  127. }
  128. static void int_to_ext_kekl_pair(struct tape3592_kekl_pair *in,
  129. struct tape390_kekl_pair *out)
  130. {
  131. if (in->count == 0) {
  132. out->kekl[0].type = TAPE390_KEKL_TYPE_NONE;
  133. out->kekl[0].type_on_tape = TAPE390_KEKL_TYPE_NONE;
  134. out->kekl[1].type = TAPE390_KEKL_TYPE_NONE;
  135. out->kekl[1].type_on_tape = TAPE390_KEKL_TYPE_NONE;
  136. } else if (in->count == 1) {
  137. int_to_ext_kekl(&in->kekl[0], &out->kekl[0]);
  138. out->kekl[1].type = TAPE390_KEKL_TYPE_NONE;
  139. out->kekl[1].type_on_tape = TAPE390_KEKL_TYPE_NONE;
  140. } else if (in->count == 2) {
  141. int_to_ext_kekl(&in->kekl[0], &out->kekl[0]);
  142. int_to_ext_kekl(&in->kekl[1], &out->kekl[1]);
  143. } else {
  144. printk("Invalid KEKL number: %d\n", in->count);
  145. BUG();
  146. }
  147. }
  148. static int check_ext_kekl(struct tape390_kekl *kekl)
  149. {
  150. if (kekl->type == TAPE390_KEKL_TYPE_NONE)
  151. goto invalid;
  152. if (kekl->type > TAPE390_KEKL_TYPE_HASH)
  153. goto invalid;
  154. if (kekl->type_on_tape == TAPE390_KEKL_TYPE_NONE)
  155. goto invalid;
  156. if (kekl->type_on_tape > TAPE390_KEKL_TYPE_HASH)
  157. goto invalid;
  158. if ((kekl->type == TAPE390_KEKL_TYPE_HASH) &&
  159. (kekl->type_on_tape == TAPE390_KEKL_TYPE_LABEL))
  160. goto invalid;
  161. return 0;
  162. invalid:
  163. return -EINVAL;
  164. }
  165. static int check_ext_kekl_pair(struct tape390_kekl_pair *kekls)
  166. {
  167. if (check_ext_kekl(&kekls->kekl[0]))
  168. goto invalid;
  169. if (check_ext_kekl(&kekls->kekl[1]))
  170. goto invalid;
  171. return 0;
  172. invalid:
  173. return -EINVAL;
  174. }
  175. /*
  176. * Query KEKLs
  177. */
  178. static int tape_3592_kekl_query(struct tape_device *device,
  179. struct tape390_kekl_pair *ext_kekls)
  180. {
  181. struct tape_request *request;
  182. struct tape3592_kekl_query_order *order;
  183. struct tape3592_kekl_query_data *int_kekls;
  184. int rc;
  185. DBF_EVENT(6, "tape3592_kekl_query\n");
  186. int_kekls = kmalloc(sizeof(*int_kekls), GFP_KERNEL|GFP_DMA);
  187. if (!int_kekls)
  188. return -ENOMEM;
  189. request = tape_alloc_request(2, sizeof(*order));
  190. if (IS_ERR(request)) {
  191. rc = PTR_ERR(request);
  192. goto fail_malloc;
  193. }
  194. order = request->cpdata;
  195. memset(order,0,sizeof(*order));
  196. order->code = 0xe2;
  197. order->max_count = 2;
  198. request->op = TO_KEKL_QUERY;
  199. tape_ccw_cc(request->cpaddr, PERF_SUBSYS_FUNC, sizeof(*order), order);
  200. tape_ccw_end(request->cpaddr + 1, READ_SS_DATA, sizeof(*int_kekls),
  201. int_kekls);
  202. rc = tape_do_io(device, request);
  203. if (rc)
  204. goto fail_request;
  205. int_to_ext_kekl_pair(&int_kekls->kekls, ext_kekls);
  206. rc = 0;
  207. fail_request:
  208. tape_free_request(request);
  209. fail_malloc:
  210. kfree(int_kekls);
  211. return rc;
  212. }
  213. /*
  214. * IOCTL: Query KEKLs
  215. */
  216. static int tape_3592_ioctl_kekl_query(struct tape_device *device,
  217. unsigned long arg)
  218. {
  219. int rc;
  220. struct tape390_kekl_pair *ext_kekls;
  221. DBF_EVENT(6, "tape_3592_ioctl_kekl_query\n");
  222. if (!crypt_supported(device))
  223. return -ENOSYS;
  224. if (!crypt_enabled(device))
  225. return -EUNATCH;
  226. ext_kekls = kmalloc(sizeof(*ext_kekls), GFP_KERNEL);
  227. if (!ext_kekls)
  228. return -ENOMEM;
  229. rc = tape_3592_kekl_query(device, ext_kekls);
  230. if (rc != 0)
  231. goto fail;
  232. if (copy_to_user((char __user *) arg, ext_kekls, sizeof(*ext_kekls))) {
  233. rc = -EFAULT;
  234. goto fail;
  235. }
  236. rc = 0;
  237. fail:
  238. kfree(ext_kekls);
  239. return rc;
  240. }
  241. static int tape_3590_mttell(struct tape_device *device, int mt_count);
  242. /*
  243. * Set KEKLs
  244. */
  245. static int tape_3592_kekl_set(struct tape_device *device,
  246. struct tape390_kekl_pair *ext_kekls)
  247. {
  248. struct tape_request *request;
  249. struct tape3592_kekl_set_order *order;
  250. DBF_EVENT(6, "tape3592_kekl_set\n");
  251. if (check_ext_kekl_pair(ext_kekls)) {
  252. DBF_EVENT(6, "invalid kekls\n");
  253. return -EINVAL;
  254. }
  255. if (tape_3590_mttell(device, 0) != 0)
  256. return -EBADSLT;
  257. request = tape_alloc_request(1, sizeof(*order));
  258. if (IS_ERR(request))
  259. return PTR_ERR(request);
  260. order = request->cpdata;
  261. memset(order, 0, sizeof(*order));
  262. order->code = 0xe3;
  263. order->kekls.count = 2;
  264. ext_to_int_kekl(&ext_kekls->kekl[0], &order->kekls.kekl[0]);
  265. ext_to_int_kekl(&ext_kekls->kekl[1], &order->kekls.kekl[1]);
  266. request->op = TO_KEKL_SET;
  267. tape_ccw_end(request->cpaddr, PERF_SUBSYS_FUNC, sizeof(*order), order);
  268. return tape_do_io_free(device, request);
  269. }
  270. /*
  271. * IOCTL: Set KEKLs
  272. */
  273. static int tape_3592_ioctl_kekl_set(struct tape_device *device,
  274. unsigned long arg)
  275. {
  276. int rc;
  277. struct tape390_kekl_pair *ext_kekls;
  278. DBF_EVENT(6, "tape_3592_ioctl_kekl_set\n");
  279. if (!crypt_supported(device))
  280. return -ENOSYS;
  281. if (!crypt_enabled(device))
  282. return -EUNATCH;
  283. ext_kekls = kmalloc(sizeof(*ext_kekls), GFP_KERNEL);
  284. if (!ext_kekls)
  285. return -ENOMEM;
  286. if (copy_from_user(ext_kekls, (char __user *)arg, sizeof(*ext_kekls))) {
  287. rc = -EFAULT;
  288. goto out;
  289. }
  290. rc = tape_3592_kekl_set(device, ext_kekls);
  291. out:
  292. kfree(ext_kekls);
  293. return rc;
  294. }
  295. /*
  296. * Enable encryption
  297. */
  298. static int tape_3592_enable_crypt(struct tape_device *device)
  299. {
  300. struct tape_request *request;
  301. char *data;
  302. DBF_EVENT(6, "tape_3592_enable_crypt\n");
  303. if (!crypt_supported(device))
  304. return -ENOSYS;
  305. request = tape_alloc_request(2, 72);
  306. if (IS_ERR(request))
  307. return PTR_ERR(request);
  308. data = request->cpdata;
  309. memset(data,0,72);
  310. data[0] = 0x05;
  311. data[36 + 0] = 0x03;
  312. data[36 + 1] = 0x03;
  313. data[36 + 4] = 0x40;
  314. data[36 + 6] = 0x01;
  315. data[36 + 14] = 0x2f;
  316. data[36 + 18] = 0xc3;
  317. data[36 + 35] = 0x72;
  318. request->op = TO_CRYPT_ON;
  319. tape_ccw_cc(request->cpaddr, MODE_SET_CB, 36, data);
  320. tape_ccw_end(request->cpaddr + 1, MODE_SET_CB, 36, data + 36);
  321. return tape_do_io_free(device, request);
  322. }
  323. /*
  324. * Disable encryption
  325. */
  326. static int tape_3592_disable_crypt(struct tape_device *device)
  327. {
  328. struct tape_request *request;
  329. char *data;
  330. DBF_EVENT(6, "tape_3592_disable_crypt\n");
  331. if (!crypt_supported(device))
  332. return -ENOSYS;
  333. request = tape_alloc_request(2, 72);
  334. if (IS_ERR(request))
  335. return PTR_ERR(request);
  336. data = request->cpdata;
  337. memset(data,0,72);
  338. data[0] = 0x05;
  339. data[36 + 0] = 0x03;
  340. data[36 + 1] = 0x03;
  341. data[36 + 35] = 0x32;
  342. request->op = TO_CRYPT_OFF;
  343. tape_ccw_cc(request->cpaddr, MODE_SET_CB, 36, data);
  344. tape_ccw_end(request->cpaddr + 1, MODE_SET_CB, 36, data + 36);
  345. return tape_do_io_free(device, request);
  346. }
  347. /*
  348. * IOCTL: Set encryption status
  349. */
  350. static int tape_3592_ioctl_crypt_set(struct tape_device *device,
  351. unsigned long arg)
  352. {
  353. struct tape390_crypt_info info;
  354. DBF_EVENT(6, "tape_3592_ioctl_crypt_set\n");
  355. if (!crypt_supported(device))
  356. return -ENOSYS;
  357. if (copy_from_user(&info, (char __user *)arg, sizeof(info)))
  358. return -EFAULT;
  359. if (info.status & ~TAPE390_CRYPT_ON_MASK)
  360. return -EINVAL;
  361. if (info.status & TAPE390_CRYPT_ON_MASK)
  362. return tape_3592_enable_crypt(device);
  363. else
  364. return tape_3592_disable_crypt(device);
  365. }
  366. static int tape_3590_sense_medium(struct tape_device *device);
  367. /*
  368. * IOCTL: Query enryption status
  369. */
  370. static int tape_3592_ioctl_crypt_query(struct tape_device *device,
  371. unsigned long arg)
  372. {
  373. DBF_EVENT(6, "tape_3592_ioctl_crypt_query\n");
  374. if (!crypt_supported(device))
  375. return -ENOSYS;
  376. tape_3590_sense_medium(device);
  377. if (copy_to_user((char __user *) arg, &TAPE_3590_CRYPT_INFO(device),
  378. sizeof(TAPE_3590_CRYPT_INFO(device))))
  379. return -EFAULT;
  380. else
  381. return 0;
  382. }
  383. /*
  384. * 3590 IOCTL Overload
  385. */
  386. static int
  387. tape_3590_ioctl(struct tape_device *device, unsigned int cmd, unsigned long arg)
  388. {
  389. switch (cmd) {
  390. case TAPE390_DISPLAY: {
  391. struct display_struct disp;
  392. if (copy_from_user(&disp, (char __user *) arg, sizeof(disp)))
  393. return -EFAULT;
  394. return tape_std_display(device, &disp);
  395. }
  396. case TAPE390_KEKL_SET:
  397. return tape_3592_ioctl_kekl_set(device, arg);
  398. case TAPE390_KEKL_QUERY:
  399. return tape_3592_ioctl_kekl_query(device, arg);
  400. case TAPE390_CRYPT_SET:
  401. return tape_3592_ioctl_crypt_set(device, arg);
  402. case TAPE390_CRYPT_QUERY:
  403. return tape_3592_ioctl_crypt_query(device, arg);
  404. default:
  405. return -EINVAL; /* no additional ioctls */
  406. }
  407. }
  408. /*
  409. * SENSE Medium: Get Sense data about medium state
  410. */
  411. static int
  412. tape_3590_sense_medium(struct tape_device *device)
  413. {
  414. struct tape_request *request;
  415. request = tape_alloc_request(1, 128);
  416. if (IS_ERR(request))
  417. return PTR_ERR(request);
  418. request->op = TO_MSEN;
  419. tape_ccw_end(request->cpaddr, MEDIUM_SENSE, 128, request->cpdata);
  420. return tape_do_io_free(device, request);
  421. }
  422. /*
  423. * MTTELL: Tell block. Return the number of block relative to current file.
  424. */
  425. static int
  426. tape_3590_mttell(struct tape_device *device, int mt_count)
  427. {
  428. __u64 block_id;
  429. int rc;
  430. rc = tape_std_read_block_id(device, &block_id);
  431. if (rc)
  432. return rc;
  433. return block_id >> 32;
  434. }
  435. /*
  436. * MTSEEK: seek to the specified block.
  437. */
  438. static int
  439. tape_3590_mtseek(struct tape_device *device, int count)
  440. {
  441. struct tape_request *request;
  442. DBF_EVENT(6, "xsee id: %x\n", count);
  443. request = tape_alloc_request(3, 4);
  444. if (IS_ERR(request))
  445. return PTR_ERR(request);
  446. request->op = TO_LBL;
  447. tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
  448. *(__u32 *) request->cpdata = count;
  449. tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
  450. tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
  451. return tape_do_io_free(device, request);
  452. }
  453. /*
  454. * Read Opposite Error Recovery Function:
  455. * Used, when Read Forward does not work
  456. */
  457. static void
  458. tape_3590_read_opposite(struct tape_device *device,
  459. struct tape_request *request)
  460. {
  461. struct tape_3590_disc_data *data;
  462. /*
  463. * We have allocated 4 ccws in tape_std_read, so we can now
  464. * transform the request to a read backward, followed by a
  465. * forward space block.
  466. */
  467. request->op = TO_RBA;
  468. tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
  469. data = device->discdata;
  470. tape_ccw_cc_idal(request->cpaddr + 1, data->read_back_op,
  471. device->char_data.idal_buf);
  472. tape_ccw_cc(request->cpaddr + 2, FORSPACEBLOCK, 0, NULL);
  473. tape_ccw_end(request->cpaddr + 3, NOP, 0, NULL);
  474. DBF_EVENT(6, "xrop ccwg\n");
  475. }
  476. /*
  477. * Read Attention Msg
  478. * This should be done after an interrupt with attention bit (0x80)
  479. * in device state.
  480. *
  481. * After a "read attention message" request there are two possible
  482. * results:
  483. *
  484. * 1. A unit check is presented, when attention sense is present (e.g. when
  485. * a medium has been unloaded). The attention sense comes then
  486. * together with the unit check. The recovery action is either "retry"
  487. * (in case there is an attention message pending) or "permanent error".
  488. *
  489. * 2. The attention msg is written to the "read subsystem data" buffer.
  490. * In this case we probably should print it to the console.
  491. */
  492. static int
  493. tape_3590_read_attmsg(struct tape_device *device)
  494. {
  495. struct tape_request *request;
  496. char *buf;
  497. request = tape_alloc_request(3, 4096);
  498. if (IS_ERR(request))
  499. return PTR_ERR(request);
  500. request->op = TO_READ_ATTMSG;
  501. buf = request->cpdata;
  502. buf[0] = PREP_RD_SS_DATA;
  503. buf[6] = RD_ATTMSG; /* read att msg */
  504. tape_ccw_cc(request->cpaddr, PERFORM_SS_FUNC, 12, buf);
  505. tape_ccw_cc(request->cpaddr + 1, READ_SS_DATA, 4096 - 12, buf + 12);
  506. tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
  507. return tape_do_io_free(device, request);
  508. }
  509. /*
  510. * These functions are used to schedule follow-up actions from within an
  511. * interrupt context (like unsolicited interrupts).
  512. */
  513. struct work_handler_data {
  514. struct tape_device *device;
  515. enum tape_op op;
  516. struct work_struct work;
  517. };
  518. static void
  519. tape_3590_work_handler(struct work_struct *work)
  520. {
  521. struct work_handler_data *p =
  522. container_of(work, struct work_handler_data, work);
  523. switch (p->op) {
  524. case TO_MSEN:
  525. tape_3590_sense_medium(p->device);
  526. break;
  527. case TO_READ_ATTMSG:
  528. tape_3590_read_attmsg(p->device);
  529. break;
  530. case TO_CRYPT_ON:
  531. tape_3592_enable_crypt(p->device);
  532. break;
  533. case TO_CRYPT_OFF:
  534. tape_3592_disable_crypt(p->device);
  535. break;
  536. default:
  537. DBF_EVENT(3, "T3590: work handler undefined for "
  538. "operation 0x%02x\n", p->op);
  539. }
  540. tape_put_device(p->device);
  541. kfree(p);
  542. }
  543. static int
  544. tape_3590_schedule_work(struct tape_device *device, enum tape_op op)
  545. {
  546. struct work_handler_data *p;
  547. if ((p = kzalloc(sizeof(*p), GFP_ATOMIC)) == NULL)
  548. return -ENOMEM;
  549. INIT_WORK(&p->work, tape_3590_work_handler);
  550. p->device = tape_get_device_reference(device);
  551. p->op = op;
  552. schedule_work(&p->work);
  553. return 0;
  554. }
  555. #ifdef CONFIG_S390_TAPE_BLOCK
  556. /*
  557. * Tape Block READ
  558. */
  559. static struct tape_request *
  560. tape_3590_bread(struct tape_device *device, struct request *req)
  561. {
  562. struct tape_request *request;
  563. struct ccw1 *ccw;
  564. int count = 0, start_block, i;
  565. unsigned off;
  566. char *dst;
  567. struct bio_vec *bv;
  568. struct bio *bio;
  569. DBF_EVENT(6, "xBREDid:");
  570. start_block = req->sector >> TAPEBLOCK_HSEC_S2B;
  571. DBF_EVENT(6, "start_block = %i\n", start_block);
  572. rq_for_each_bio(bio, req) {
  573. bio_for_each_segment(bv, bio, i) {
  574. count += bv->bv_len >> (TAPEBLOCK_HSEC_S2B + 9);
  575. }
  576. }
  577. request = tape_alloc_request(2 + count + 1, 4);
  578. if (IS_ERR(request))
  579. return request;
  580. request->op = TO_BLOCK;
  581. *(__u32 *) request->cpdata = start_block;
  582. ccw = request->cpaddr;
  583. ccw = tape_ccw_cc(ccw, MODE_SET_DB, 1, device->modeset_byte);
  584. /*
  585. * We always setup a nop after the mode set ccw. This slot is
  586. * used in tape_std_check_locate to insert a locate ccw if the
  587. * current tape position doesn't match the start block to be read.
  588. */
  589. ccw = tape_ccw_cc(ccw, NOP, 0, NULL);
  590. rq_for_each_bio(bio, req) {
  591. bio_for_each_segment(bv, bio, i) {
  592. dst = page_address(bv->bv_page) + bv->bv_offset;
  593. for (off = 0; off < bv->bv_len;
  594. off += TAPEBLOCK_HSEC_SIZE) {
  595. ccw->flags = CCW_FLAG_CC;
  596. ccw->cmd_code = READ_FORWARD;
  597. ccw->count = TAPEBLOCK_HSEC_SIZE;
  598. set_normalized_cda(ccw, (void *) __pa(dst));
  599. ccw++;
  600. dst += TAPEBLOCK_HSEC_SIZE;
  601. }
  602. if (off > bv->bv_len)
  603. BUG();
  604. }
  605. }
  606. ccw = tape_ccw_end(ccw, NOP, 0, NULL);
  607. DBF_EVENT(6, "xBREDccwg\n");
  608. return request;
  609. }
  610. static void
  611. tape_3590_free_bread(struct tape_request *request)
  612. {
  613. struct ccw1 *ccw;
  614. /* Last ccw is a nop and doesn't need clear_normalized_cda */
  615. for (ccw = request->cpaddr; ccw->flags & CCW_FLAG_CC; ccw++)
  616. if (ccw->cmd_code == READ_FORWARD)
  617. clear_normalized_cda(ccw);
  618. tape_free_request(request);
  619. }
  620. /*
  621. * check_locate is called just before the tape request is passed to
  622. * the common io layer for execution. It has to check the current
  623. * tape position and insert a locate ccw if it doesn't match the
  624. * start block for the request.
  625. */
  626. static void
  627. tape_3590_check_locate(struct tape_device *device, struct tape_request *request)
  628. {
  629. __u32 *start_block;
  630. start_block = (__u32 *) request->cpdata;
  631. if (*start_block != device->blk_data.block_position) {
  632. /* Add the start offset of the file to get the real block. */
  633. *start_block += device->bof;
  634. tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
  635. }
  636. }
  637. #endif
  638. static void tape_3590_med_state_set(struct tape_device *device,
  639. struct tape_3590_med_sense *sense)
  640. {
  641. struct tape390_crypt_info *c_info;
  642. c_info = &TAPE_3590_CRYPT_INFO(device);
  643. if (sense->masst == MSENSE_UNASSOCIATED) {
  644. tape_med_state_set(device, MS_UNLOADED);
  645. TAPE_3590_CRYPT_INFO(device).medium_status = 0;
  646. return;
  647. }
  648. if (sense->masst != MSENSE_ASSOCIATED_MOUNT) {
  649. PRINT_ERR("Unknown medium state: %x\n", sense->masst);
  650. return;
  651. }
  652. tape_med_state_set(device, MS_LOADED);
  653. c_info->medium_status |= TAPE390_MEDIUM_LOADED_MASK;
  654. if (sense->flags & MSENSE_CRYPT_MASK) {
  655. PRINT_INFO("Medium is encrypted (%04x)\n", sense->flags);
  656. c_info->medium_status |= TAPE390_MEDIUM_ENCRYPTED_MASK;
  657. } else {
  658. DBF_EVENT(6, "Medium is not encrypted %04x\n", sense->flags);
  659. c_info->medium_status &= ~TAPE390_MEDIUM_ENCRYPTED_MASK;
  660. }
  661. }
  662. /*
  663. * The done handler is called at device/channel end and wakes up the sleeping
  664. * process
  665. */
  666. static int
  667. tape_3590_done(struct tape_device *device, struct tape_request *request)
  668. {
  669. struct tape_3590_disc_data *disc_data;
  670. DBF_EVENT(6, "%s done\n", tape_op_verbose[request->op]);
  671. disc_data = device->discdata;
  672. switch (request->op) {
  673. case TO_BSB:
  674. case TO_BSF:
  675. case TO_DSE:
  676. case TO_FSB:
  677. case TO_FSF:
  678. case TO_LBL:
  679. case TO_RFO:
  680. case TO_RBA:
  681. case TO_REW:
  682. case TO_WRI:
  683. case TO_WTM:
  684. case TO_BLOCK:
  685. case TO_LOAD:
  686. tape_med_state_set(device, MS_LOADED);
  687. break;
  688. case TO_RUN:
  689. tape_med_state_set(device, MS_UNLOADED);
  690. tape_3590_schedule_work(device, TO_CRYPT_OFF);
  691. break;
  692. case TO_MSEN:
  693. tape_3590_med_state_set(device, request->cpdata);
  694. break;
  695. case TO_CRYPT_ON:
  696. TAPE_3590_CRYPT_INFO(device).status
  697. |= TAPE390_CRYPT_ON_MASK;
  698. *(device->modeset_byte) |= 0x03;
  699. break;
  700. case TO_CRYPT_OFF:
  701. TAPE_3590_CRYPT_INFO(device).status
  702. &= ~TAPE390_CRYPT_ON_MASK;
  703. *(device->modeset_byte) &= ~0x03;
  704. break;
  705. case TO_RBI: /* RBI seems to succeed even without medium loaded. */
  706. case TO_NOP: /* Same to NOP. */
  707. case TO_READ_CONFIG:
  708. case TO_READ_ATTMSG:
  709. case TO_DIS:
  710. case TO_ASSIGN:
  711. case TO_UNASSIGN:
  712. case TO_SIZE:
  713. case TO_KEKL_SET:
  714. case TO_KEKL_QUERY:
  715. case TO_RDC:
  716. break;
  717. }
  718. return TAPE_IO_SUCCESS;
  719. }
  720. /*
  721. * This fuction is called, when error recovery was successfull
  722. */
  723. static inline int
  724. tape_3590_erp_succeded(struct tape_device *device, struct tape_request *request)
  725. {
  726. DBF_EVENT(3, "Error Recovery successfull for %s\n",
  727. tape_op_verbose[request->op]);
  728. return tape_3590_done(device, request);
  729. }
  730. /*
  731. * This fuction is called, when error recovery was not successfull
  732. */
  733. static inline int
  734. tape_3590_erp_failed(struct tape_device *device, struct tape_request *request,
  735. struct irb *irb, int rc)
  736. {
  737. DBF_EVENT(3, "Error Recovery failed for %s\n",
  738. tape_op_verbose[request->op]);
  739. tape_dump_sense_dbf(device, request, irb);
  740. return rc;
  741. }
  742. /*
  743. * Error Recovery do retry
  744. */
  745. static inline int
  746. tape_3590_erp_retry(struct tape_device *device, struct tape_request *request,
  747. struct irb *irb)
  748. {
  749. DBF_EVENT(2, "Retry: %s\n", tape_op_verbose[request->op]);
  750. tape_dump_sense_dbf(device, request, irb);
  751. return TAPE_IO_RETRY;
  752. }
  753. /*
  754. * Handle unsolicited interrupts
  755. */
  756. static int
  757. tape_3590_unsolicited_irq(struct tape_device *device, struct irb *irb)
  758. {
  759. if (irb->scsw.dstat == DEV_STAT_CHN_END)
  760. /* Probably result of halt ssch */
  761. return TAPE_IO_PENDING;
  762. else if (irb->scsw.dstat == 0x85)
  763. /* Device Ready -> check medium state */
  764. tape_3590_schedule_work(device, TO_MSEN);
  765. else if (irb->scsw.dstat & DEV_STAT_ATTENTION)
  766. tape_3590_schedule_work(device, TO_READ_ATTMSG);
  767. else {
  768. DBF_EVENT(3, "unsol.irq! dev end: %08x\n", device->cdev_id);
  769. PRINT_WARN("Unsolicited IRQ (Device End) caught.\n");
  770. tape_dump_sense(device, NULL, irb);
  771. }
  772. return TAPE_IO_SUCCESS;
  773. }
  774. /*
  775. * Basic Recovery routine
  776. */
  777. static int
  778. tape_3590_erp_basic(struct tape_device *device, struct tape_request *request,
  779. struct irb *irb, int rc)
  780. {
  781. struct tape_3590_sense *sense;
  782. sense = (struct tape_3590_sense *) irb->ecw;
  783. switch (sense->bra) {
  784. case SENSE_BRA_PER:
  785. return tape_3590_erp_failed(device, request, irb, rc);
  786. case SENSE_BRA_CONT:
  787. return tape_3590_erp_succeded(device, request);
  788. case SENSE_BRA_RE:
  789. return tape_3590_erp_retry(device, request, irb);
  790. case SENSE_BRA_DRE:
  791. return tape_3590_erp_failed(device, request, irb, rc);
  792. default:
  793. PRINT_ERR("Unknown BRA %x - This should not happen!\n",
  794. sense->bra);
  795. BUG();
  796. return TAPE_IO_STOP;
  797. }
  798. }
  799. /*
  800. * RDL: Read Device (buffered) log
  801. */
  802. static int
  803. tape_3590_erp_read_buf_log(struct tape_device *device,
  804. struct tape_request *request, struct irb *irb)
  805. {
  806. /*
  807. * We just do the basic error recovery at the moment (retry).
  808. * Perhaps in the future, we read the log and dump it somewhere...
  809. */
  810. return tape_3590_erp_basic(device, request, irb, -EIO);
  811. }
  812. /*
  813. * SWAP: Swap Devices
  814. */
  815. static int
  816. tape_3590_erp_swap(struct tape_device *device, struct tape_request *request,
  817. struct irb *irb)
  818. {
  819. /*
  820. * This error recovery should swap the tapes
  821. * if the original has a problem. The operation
  822. * should proceed with the new tape... this
  823. * should probably be done in user space!
  824. */
  825. PRINT_WARN("(%s): Swap Tape Device!\n", device->cdev->dev.bus_id);
  826. return tape_3590_erp_basic(device, request, irb, -EIO);
  827. }
  828. /*
  829. * LBY: Long Busy
  830. */
  831. static int
  832. tape_3590_erp_long_busy(struct tape_device *device,
  833. struct tape_request *request, struct irb *irb)
  834. {
  835. DBF_EVENT(6, "Device is busy\n");
  836. return TAPE_IO_LONG_BUSY;
  837. }
  838. /*
  839. * SPI: Special Intercept
  840. */
  841. static int
  842. tape_3590_erp_special_interrupt(struct tape_device *device,
  843. struct tape_request *request, struct irb *irb)
  844. {
  845. return tape_3590_erp_basic(device, request, irb, -EIO);
  846. }
  847. /*
  848. * RDA: Read Alternate
  849. */
  850. static int
  851. tape_3590_erp_read_alternate(struct tape_device *device,
  852. struct tape_request *request, struct irb *irb)
  853. {
  854. struct tape_3590_disc_data *data;
  855. /*
  856. * The issued Read Backward or Read Previous command is not
  857. * supported by the device
  858. * The recovery action should be to issue another command:
  859. * Read Revious: if Read Backward is not supported
  860. * Read Backward: if Read Previous is not supported
  861. */
  862. data = device->discdata;
  863. if (data->read_back_op == READ_PREVIOUS) {
  864. DBF_EVENT(2, "(%08x): No support for READ_PREVIOUS command\n",
  865. device->cdev_id);
  866. data->read_back_op = READ_BACKWARD;
  867. } else {
  868. DBF_EVENT(2, "(%08x): No support for READ_BACKWARD command\n",
  869. device->cdev_id);
  870. data->read_back_op = READ_PREVIOUS;
  871. }
  872. tape_3590_read_opposite(device, request);
  873. return tape_3590_erp_retry(device, request, irb);
  874. }
  875. /*
  876. * Error Recovery read opposite
  877. */
  878. static int
  879. tape_3590_erp_read_opposite(struct tape_device *device,
  880. struct tape_request *request, struct irb *irb)
  881. {
  882. switch (request->op) {
  883. case TO_RFO:
  884. /*
  885. * We did read forward, but the data could not be read.
  886. * We will read backward and then skip forward again.
  887. */
  888. tape_3590_read_opposite(device, request);
  889. return tape_3590_erp_retry(device, request, irb);
  890. case TO_RBA:
  891. /* We tried to read forward and backward, but hat no success */
  892. return tape_3590_erp_failed(device, request, irb, -EIO);
  893. break;
  894. default:
  895. PRINT_WARN("read_opposite_recovery_called_with_op: %s\n",
  896. tape_op_verbose[request->op]);
  897. return tape_3590_erp_failed(device, request, irb, -EIO);
  898. }
  899. }
  900. /*
  901. * Print an MIM (Media Information Message) (message code f0)
  902. */
  903. static void
  904. tape_3590_print_mim_msg_f0(struct tape_device *device, struct irb *irb)
  905. {
  906. struct tape_3590_sense *sense;
  907. sense = (struct tape_3590_sense *) irb->ecw;
  908. /* Exception Message */
  909. switch (sense->fmt.f70.emc) {
  910. case 0x02:
  911. PRINT_WARN("(%s): Data degraded\n", device->cdev->dev.bus_id);
  912. break;
  913. case 0x03:
  914. PRINT_WARN("(%s): Data degraded in partion %i\n",
  915. device->cdev->dev.bus_id, sense->fmt.f70.mp);
  916. break;
  917. case 0x04:
  918. PRINT_WARN("(%s): Medium degraded\n", device->cdev->dev.bus_id);
  919. break;
  920. case 0x05:
  921. PRINT_WARN("(%s): Medium degraded in partition %i\n",
  922. device->cdev->dev.bus_id, sense->fmt.f70.mp);
  923. break;
  924. case 0x06:
  925. PRINT_WARN("(%s): Block 0 Error\n", device->cdev->dev.bus_id);
  926. break;
  927. case 0x07:
  928. PRINT_WARN("(%s): Medium Exception 0x%02x\n",
  929. device->cdev->dev.bus_id, sense->fmt.f70.md);
  930. break;
  931. default:
  932. PRINT_WARN("(%s): MIM ExMsg: 0x%02x\n",
  933. device->cdev->dev.bus_id, sense->fmt.f70.emc);
  934. break;
  935. }
  936. /* Service Message */
  937. switch (sense->fmt.f70.smc) {
  938. case 0x02:
  939. PRINT_WARN("(%s): Reference Media maintenance procedure %i\n",
  940. device->cdev->dev.bus_id, sense->fmt.f70.md);
  941. break;
  942. default:
  943. PRINT_WARN("(%s): MIM ServiceMsg: 0x%02x\n",
  944. device->cdev->dev.bus_id, sense->fmt.f70.smc);
  945. break;
  946. }
  947. }
  948. /*
  949. * Print an I/O Subsystem Service Information Message (message code f1)
  950. */
  951. static void
  952. tape_3590_print_io_sim_msg_f1(struct tape_device *device, struct irb *irb)
  953. {
  954. struct tape_3590_sense *sense;
  955. sense = (struct tape_3590_sense *) irb->ecw;
  956. /* Exception Message */
  957. switch (sense->fmt.f71.emc) {
  958. case 0x01:
  959. PRINT_WARN("(%s): Effect of failure is unknown\n",
  960. device->cdev->dev.bus_id);
  961. break;
  962. case 0x02:
  963. PRINT_WARN("(%s): CU Exception - no performance impact\n",
  964. device->cdev->dev.bus_id);
  965. break;
  966. case 0x03:
  967. PRINT_WARN("(%s): CU Exception on channel interface 0x%02x\n",
  968. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  969. break;
  970. case 0x04:
  971. PRINT_WARN("(%s): CU Exception on device path 0x%02x\n",
  972. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  973. break;
  974. case 0x05:
  975. PRINT_WARN("(%s): CU Exception on library path 0x%02x\n",
  976. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  977. break;
  978. case 0x06:
  979. PRINT_WARN("(%s): CU Exception on node 0x%02x\n",
  980. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  981. break;
  982. case 0x07:
  983. PRINT_WARN("(%s): CU Exception on partition 0x%02x\n",
  984. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  985. break;
  986. default:
  987. PRINT_WARN("(%s): SIM ExMsg: 0x%02x\n",
  988. device->cdev->dev.bus_id, sense->fmt.f71.emc);
  989. }
  990. /* Service Message */
  991. switch (sense->fmt.f71.smc) {
  992. case 0x01:
  993. PRINT_WARN("(%s): Repair impact is unknown\n",
  994. device->cdev->dev.bus_id);
  995. break;
  996. case 0x02:
  997. PRINT_WARN("(%s): Repair will not impact cu performance\n",
  998. device->cdev->dev.bus_id);
  999. break;
  1000. case 0x03:
  1001. if (sense->fmt.f71.mdf == 0)
  1002. PRINT_WARN("(%s): Repair will disable node "
  1003. "0x%x on CU\n",
  1004. device->cdev->dev.bus_id,
  1005. sense->fmt.f71.md[1]);
  1006. else
  1007. PRINT_WARN("(%s): Repair will disable nodes "
  1008. "(0x%x-0x%x) on CU\n",
  1009. device->cdev->dev.bus_id,
  1010. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  1011. break;
  1012. case 0x04:
  1013. if (sense->fmt.f71.mdf == 0)
  1014. PRINT_WARN("(%s): Repair will disable cannel path "
  1015. "0x%x on CU\n",
  1016. device->cdev->dev.bus_id,
  1017. sense->fmt.f71.md[1]);
  1018. else
  1019. PRINT_WARN("(%s): Repair will disable cannel paths "
  1020. "(0x%x-0x%x) on CU\n",
  1021. device->cdev->dev.bus_id,
  1022. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  1023. break;
  1024. case 0x05:
  1025. if (sense->fmt.f71.mdf == 0)
  1026. PRINT_WARN("(%s): Repair will disable device path "
  1027. "0x%x on CU\n",
  1028. device->cdev->dev.bus_id,
  1029. sense->fmt.f71.md[1]);
  1030. else
  1031. PRINT_WARN("(%s): Repair will disable device paths "
  1032. "(0x%x-0x%x) on CU\n",
  1033. device->cdev->dev.bus_id,
  1034. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  1035. break;
  1036. case 0x06:
  1037. if (sense->fmt.f71.mdf == 0)
  1038. PRINT_WARN("(%s): Repair will disable library path "
  1039. "0x%x on CU\n",
  1040. device->cdev->dev.bus_id,
  1041. sense->fmt.f71.md[1]);
  1042. else
  1043. PRINT_WARN("(%s): Repair will disable library paths "
  1044. "(0x%x-0x%x) on CU\n",
  1045. device->cdev->dev.bus_id,
  1046. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  1047. break;
  1048. case 0x07:
  1049. PRINT_WARN("(%s): Repair will disable access to CU\n",
  1050. device->cdev->dev.bus_id);
  1051. break;
  1052. default:
  1053. PRINT_WARN("(%s): SIM ServiceMsg: 0x%02x\n",
  1054. device->cdev->dev.bus_id, sense->fmt.f71.smc);
  1055. }
  1056. }
  1057. /*
  1058. * Print an Device Subsystem Service Information Message (message code f2)
  1059. */
  1060. static void
  1061. tape_3590_print_dev_sim_msg_f2(struct tape_device *device, struct irb *irb)
  1062. {
  1063. struct tape_3590_sense *sense;
  1064. sense = (struct tape_3590_sense *) irb->ecw;
  1065. /* Exception Message */
  1066. switch (sense->fmt.f71.emc) {
  1067. case 0x01:
  1068. PRINT_WARN("(%s): Effect of failure is unknown\n",
  1069. device->cdev->dev.bus_id);
  1070. break;
  1071. case 0x02:
  1072. PRINT_WARN("(%s): DV Exception - no performance impact\n",
  1073. device->cdev->dev.bus_id);
  1074. break;
  1075. case 0x03:
  1076. PRINT_WARN("(%s): DV Exception on channel interface 0x%02x\n",
  1077. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  1078. break;
  1079. case 0x04:
  1080. PRINT_WARN("(%s): DV Exception on loader 0x%02x\n",
  1081. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  1082. break;
  1083. case 0x05:
  1084. PRINT_WARN("(%s): DV Exception on message display 0x%02x\n",
  1085. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  1086. break;
  1087. case 0x06:
  1088. PRINT_WARN("(%s): DV Exception in tape path\n",
  1089. device->cdev->dev.bus_id);
  1090. break;
  1091. case 0x07:
  1092. PRINT_WARN("(%s): DV Exception in drive\n",
  1093. device->cdev->dev.bus_id);
  1094. break;
  1095. default:
  1096. PRINT_WARN("(%s): DSIM ExMsg: 0x%02x\n",
  1097. device->cdev->dev.bus_id, sense->fmt.f71.emc);
  1098. }
  1099. /* Service Message */
  1100. switch (sense->fmt.f71.smc) {
  1101. case 0x01:
  1102. PRINT_WARN("(%s): Repair impact is unknown\n",
  1103. device->cdev->dev.bus_id);
  1104. break;
  1105. case 0x02:
  1106. PRINT_WARN("(%s): Repair will not impact device performance\n",
  1107. device->cdev->dev.bus_id);
  1108. break;
  1109. case 0x03:
  1110. if (sense->fmt.f71.mdf == 0)
  1111. PRINT_WARN("(%s): Repair will disable channel path "
  1112. "0x%x on DV\n",
  1113. device->cdev->dev.bus_id,
  1114. sense->fmt.f71.md[1]);
  1115. else
  1116. PRINT_WARN("(%s): Repair will disable channel path "
  1117. "(0x%x-0x%x) on DV\n",
  1118. device->cdev->dev.bus_id,
  1119. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  1120. break;
  1121. case 0x04:
  1122. if (sense->fmt.f71.mdf == 0)
  1123. PRINT_WARN("(%s): Repair will disable interface 0x%x "
  1124. "on DV\n",
  1125. device->cdev->dev.bus_id,
  1126. sense->fmt.f71.md[1]);
  1127. else
  1128. PRINT_WARN("(%s): Repair will disable interfaces "
  1129. "(0x%x-0x%x) on DV\n",
  1130. device->cdev->dev.bus_id,
  1131. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  1132. break;
  1133. case 0x05:
  1134. if (sense->fmt.f71.mdf == 0)
  1135. PRINT_WARN("(%s): Repair will disable loader 0x%x "
  1136. "on DV\n",
  1137. device->cdev->dev.bus_id,
  1138. sense->fmt.f71.md[1]);
  1139. else
  1140. PRINT_WARN("(%s): Repair will disable loader "
  1141. "(0x%x-0x%x) on DV\n",
  1142. device->cdev->dev.bus_id,
  1143. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  1144. break;
  1145. case 0x07:
  1146. PRINT_WARN("(%s): Repair will disable access to DV\n",
  1147. device->cdev->dev.bus_id);
  1148. break;
  1149. case 0x08:
  1150. if (sense->fmt.f71.mdf == 0)
  1151. PRINT_WARN("(%s): Repair will disable message "
  1152. "display 0x%x on DV\n",
  1153. device->cdev->dev.bus_id,
  1154. sense->fmt.f71.md[1]);
  1155. else
  1156. PRINT_WARN("(%s): Repair will disable message "
  1157. "displays (0x%x-0x%x) on DV\n",
  1158. device->cdev->dev.bus_id,
  1159. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  1160. break;
  1161. case 0x09:
  1162. PRINT_WARN("(%s): Clean DV\n", device->cdev->dev.bus_id);
  1163. break;
  1164. default:
  1165. PRINT_WARN("(%s): DSIM ServiceMsg: 0x%02x\n",
  1166. device->cdev->dev.bus_id, sense->fmt.f71.smc);
  1167. }
  1168. }
  1169. /*
  1170. * Print standard ERA Message
  1171. */
  1172. static void
  1173. tape_3590_print_era_msg(struct tape_device *device, struct irb *irb)
  1174. {
  1175. struct tape_3590_sense *sense;
  1176. sense = (struct tape_3590_sense *) irb->ecw;
  1177. if (sense->mc == 0)
  1178. return;
  1179. if ((sense->mc > 0) && (sense->mc < TAPE_3590_MAX_MSG)) {
  1180. if (tape_3590_msg[sense->mc] != NULL)
  1181. PRINT_WARN("(%s): %s\n", device->cdev->dev.bus_id,
  1182. tape_3590_msg[sense->mc]);
  1183. else {
  1184. PRINT_WARN("(%s): Message Code 0x%x\n",
  1185. device->cdev->dev.bus_id, sense->mc);
  1186. }
  1187. return;
  1188. }
  1189. if (sense->mc == 0xf0) {
  1190. /* Standard Media Information Message */
  1191. PRINT_WARN("(%s): MIM SEV=%i, MC=%02x, ES=%x/%x, "
  1192. "RC=%02x-%04x-%02x\n", device->cdev->dev.bus_id,
  1193. sense->fmt.f70.sev, sense->mc,
  1194. sense->fmt.f70.emc, sense->fmt.f70.smc,
  1195. sense->fmt.f70.refcode, sense->fmt.f70.mid,
  1196. sense->fmt.f70.fid);
  1197. tape_3590_print_mim_msg_f0(device, irb);
  1198. return;
  1199. }
  1200. if (sense->mc == 0xf1) {
  1201. /* Standard I/O Subsystem Service Information Message */
  1202. PRINT_WARN("(%s): IOSIM SEV=%i, DEVTYPE=3590/%02x, "
  1203. "MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n",
  1204. device->cdev->dev.bus_id, sense->fmt.f71.sev,
  1205. device->cdev->id.dev_model,
  1206. sense->mc, sense->fmt.f71.emc,
  1207. sense->fmt.f71.smc, sense->fmt.f71.refcode1,
  1208. sense->fmt.f71.refcode2, sense->fmt.f71.refcode3);
  1209. tape_3590_print_io_sim_msg_f1(device, irb);
  1210. return;
  1211. }
  1212. if (sense->mc == 0xf2) {
  1213. /* Standard Device Service Information Message */
  1214. PRINT_WARN("(%s): DEVSIM SEV=%i, DEVTYPE=3590/%02x, "
  1215. "MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n",
  1216. device->cdev->dev.bus_id, sense->fmt.f71.sev,
  1217. device->cdev->id.dev_model,
  1218. sense->mc, sense->fmt.f71.emc,
  1219. sense->fmt.f71.smc, sense->fmt.f71.refcode1,
  1220. sense->fmt.f71.refcode2, sense->fmt.f71.refcode3);
  1221. tape_3590_print_dev_sim_msg_f2(device, irb);
  1222. return;
  1223. }
  1224. if (sense->mc == 0xf3) {
  1225. /* Standard Library Service Information Message */
  1226. return;
  1227. }
  1228. PRINT_WARN("(%s): Device Message(%x)\n",
  1229. device->cdev->dev.bus_id, sense->mc);
  1230. }
  1231. static int tape_3590_crypt_error(struct tape_device *device,
  1232. struct tape_request *request, struct irb *irb)
  1233. {
  1234. u8 cu_rc, ekm_rc1;
  1235. u16 ekm_rc2;
  1236. u32 drv_rc;
  1237. char *bus_id, *sense;
  1238. sense = ((struct tape_3590_sense *) irb->ecw)->fmt.data;
  1239. bus_id = device->cdev->dev.bus_id;
  1240. cu_rc = sense[0];
  1241. drv_rc = *((u32*) &sense[5]) & 0xffffff;
  1242. ekm_rc1 = sense[9];
  1243. ekm_rc2 = *((u16*) &sense[10]);
  1244. if ((cu_rc == 0) && (ekm_rc2 == 0xee31))
  1245. /* key not defined on EKM */
  1246. return tape_3590_erp_basic(device, request, irb, -EKEYREJECTED);
  1247. if ((cu_rc == 1) || (cu_rc == 2))
  1248. /* No connection to EKM */
  1249. return tape_3590_erp_basic(device, request, irb, -ENOTCONN);
  1250. PRINT_ERR("(%s): Unable to get encryption key from EKM\n", bus_id);
  1251. PRINT_ERR("(%s): CU=%02X DRIVE=%06X EKM=%02X:%04X\n", bus_id, cu_rc,
  1252. drv_rc, ekm_rc1, ekm_rc2);
  1253. return tape_3590_erp_basic(device, request, irb, -ENOKEY);
  1254. }
  1255. /*
  1256. * 3590 error Recovery routine:
  1257. * If possible, it tries to recover from the error. If this is not possible,
  1258. * inform the user about the problem.
  1259. */
  1260. static int
  1261. tape_3590_unit_check(struct tape_device *device, struct tape_request *request,
  1262. struct irb *irb)
  1263. {
  1264. struct tape_3590_sense *sense;
  1265. int rc;
  1266. #ifdef CONFIG_S390_TAPE_BLOCK
  1267. if (request->op == TO_BLOCK) {
  1268. /*
  1269. * Recovery for block device requests. Set the block_position
  1270. * to something invalid and retry.
  1271. */
  1272. device->blk_data.block_position = -1;
  1273. if (request->retries-- <= 0)
  1274. return tape_3590_erp_failed(device, request, irb, -EIO);
  1275. else
  1276. return tape_3590_erp_retry(device, request, irb);
  1277. }
  1278. #endif
  1279. sense = (struct tape_3590_sense *) irb->ecw;
  1280. DBF_EVENT(6, "Unit Check: RQC = %x\n", sense->rc_rqc);
  1281. /*
  1282. * First check all RC-QRCs where we want to do something special
  1283. * - "break": basic error recovery is done
  1284. * - "goto out:": just print error message if available
  1285. */
  1286. rc = -EIO;
  1287. switch (sense->rc_rqc) {
  1288. case 0x1110:
  1289. tape_3590_print_era_msg(device, irb);
  1290. return tape_3590_erp_read_buf_log(device, request, irb);
  1291. case 0x2011:
  1292. tape_3590_print_era_msg(device, irb);
  1293. return tape_3590_erp_read_alternate(device, request, irb);
  1294. case 0x2230:
  1295. case 0x2231:
  1296. tape_3590_print_era_msg(device, irb);
  1297. return tape_3590_erp_special_interrupt(device, request, irb);
  1298. case 0x2240:
  1299. return tape_3590_crypt_error(device, request, irb);
  1300. case 0x3010:
  1301. DBF_EVENT(2, "(%08x): Backward at Beginning of Partition\n",
  1302. device->cdev_id);
  1303. return tape_3590_erp_basic(device, request, irb, -ENOSPC);
  1304. case 0x3012:
  1305. DBF_EVENT(2, "(%08x): Forward at End of Partition\n",
  1306. device->cdev_id);
  1307. return tape_3590_erp_basic(device, request, irb, -ENOSPC);
  1308. case 0x3020:
  1309. DBF_EVENT(2, "(%08x): End of Data Mark\n", device->cdev_id);
  1310. return tape_3590_erp_basic(device, request, irb, -ENOSPC);
  1311. case 0x3122:
  1312. DBF_EVENT(2, "(%08x): Rewind Unload initiated\n",
  1313. device->cdev_id);
  1314. return tape_3590_erp_basic(device, request, irb, -EIO);
  1315. case 0x3123:
  1316. DBF_EVENT(2, "(%08x): Rewind Unload complete\n",
  1317. device->cdev_id);
  1318. tape_med_state_set(device, MS_UNLOADED);
  1319. tape_3590_schedule_work(device, TO_CRYPT_OFF);
  1320. return tape_3590_erp_basic(device, request, irb, 0);
  1321. case 0x4010:
  1322. /*
  1323. * print additional msg since default msg
  1324. * "device intervention" is not very meaningfull
  1325. */
  1326. PRINT_WARN("(%s): Tape operation when medium not loaded\n",
  1327. device->cdev->dev.bus_id);
  1328. tape_med_state_set(device, MS_UNLOADED);
  1329. tape_3590_schedule_work(device, TO_CRYPT_OFF);
  1330. return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM);
  1331. case 0x4012: /* Device Long Busy */
  1332. /* XXX: Also use long busy handling here? */
  1333. DBF_EVENT(6, "(%08x): LONG BUSY\n", device->cdev_id);
  1334. tape_3590_print_era_msg(device, irb);
  1335. return tape_3590_erp_basic(device, request, irb, -EBUSY);
  1336. case 0x4014:
  1337. DBF_EVENT(6, "(%08x): Crypto LONG BUSY\n", device->cdev_id);
  1338. return tape_3590_erp_long_busy(device, request, irb);
  1339. case 0x5010:
  1340. if (sense->rac == 0xd0) {
  1341. /* Swap */
  1342. tape_3590_print_era_msg(device, irb);
  1343. return tape_3590_erp_swap(device, request, irb);
  1344. }
  1345. if (sense->rac == 0x26) {
  1346. /* Read Opposite */
  1347. tape_3590_print_era_msg(device, irb);
  1348. return tape_3590_erp_read_opposite(device, request,
  1349. irb);
  1350. }
  1351. return tape_3590_erp_basic(device, request, irb, -EIO);
  1352. case 0x5020:
  1353. case 0x5021:
  1354. case 0x5022:
  1355. case 0x5040:
  1356. case 0x5041:
  1357. case 0x5042:
  1358. tape_3590_print_era_msg(device, irb);
  1359. return tape_3590_erp_swap(device, request, irb);
  1360. case 0x5110:
  1361. case 0x5111:
  1362. return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE);
  1363. case 0x5120:
  1364. case 0x1120:
  1365. tape_med_state_set(device, MS_UNLOADED);
  1366. tape_3590_schedule_work(device, TO_CRYPT_OFF);
  1367. return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM);
  1368. case 0x6020:
  1369. PRINT_WARN("(%s): Cartridge of wrong type ?\n",
  1370. device->cdev->dev.bus_id);
  1371. return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE);
  1372. case 0x8011:
  1373. PRINT_WARN("(%s): Another host has reserved the tape device\n",
  1374. device->cdev->dev.bus_id);
  1375. return tape_3590_erp_basic(device, request, irb, -EPERM);
  1376. case 0x8013:
  1377. PRINT_WARN("(%s): Another host has priviliged access to the "
  1378. "tape device\n", device->cdev->dev.bus_id);
  1379. PRINT_WARN("(%s): To solve the problem unload the current "
  1380. "cartridge!\n", device->cdev->dev.bus_id);
  1381. return tape_3590_erp_basic(device, request, irb, -EPERM);
  1382. default:
  1383. return tape_3590_erp_basic(device, request, irb, -EIO);
  1384. }
  1385. }
  1386. /*
  1387. * 3590 interrupt handler:
  1388. */
  1389. static int
  1390. tape_3590_irq(struct tape_device *device, struct tape_request *request,
  1391. struct irb *irb)
  1392. {
  1393. if (request == NULL)
  1394. return tape_3590_unsolicited_irq(device, irb);
  1395. if ((irb->scsw.dstat & DEV_STAT_UNIT_EXCEP) &&
  1396. (irb->scsw.dstat & DEV_STAT_DEV_END) && (request->op == TO_WRI)) {
  1397. /* Write at end of volume */
  1398. DBF_EVENT(2, "End of volume\n");
  1399. return tape_3590_erp_failed(device, request, irb, -ENOSPC);
  1400. }
  1401. if (irb->scsw.dstat & DEV_STAT_UNIT_CHECK)
  1402. return tape_3590_unit_check(device, request, irb);
  1403. if (irb->scsw.dstat & DEV_STAT_DEV_END) {
  1404. if (irb->scsw.dstat == DEV_STAT_UNIT_EXCEP) {
  1405. if (request->op == TO_FSB || request->op == TO_BSB)
  1406. request->rescnt++;
  1407. else
  1408. DBF_EVENT(5, "Unit Exception!\n");
  1409. }
  1410. return tape_3590_done(device, request);
  1411. }
  1412. if (irb->scsw.dstat & DEV_STAT_CHN_END) {
  1413. DBF_EVENT(2, "cannel end\n");
  1414. return TAPE_IO_PENDING;
  1415. }
  1416. if (irb->scsw.dstat & DEV_STAT_ATTENTION) {
  1417. DBF_EVENT(2, "Unit Attention when busy..\n");
  1418. return TAPE_IO_PENDING;
  1419. }
  1420. DBF_EVENT(6, "xunknownirq\n");
  1421. PRINT_ERR("Unexpected interrupt.\n");
  1422. PRINT_ERR("Current op is: %s", tape_op_verbose[request->op]);
  1423. tape_dump_sense(device, request, irb);
  1424. return TAPE_IO_STOP;
  1425. }
  1426. static int tape_3590_read_dev_chars(struct tape_device *device,
  1427. struct tape_3590_rdc_data *rdc_data)
  1428. {
  1429. int rc;
  1430. struct tape_request *request;
  1431. request = tape_alloc_request(1, sizeof(*rdc_data));
  1432. if (IS_ERR(request))
  1433. return PTR_ERR(request);
  1434. request->op = TO_RDC;
  1435. tape_ccw_end(request->cpaddr, CCW_CMD_RDC, sizeof(*rdc_data),
  1436. request->cpdata);
  1437. rc = tape_do_io(device, request);
  1438. if (rc == 0)
  1439. memcpy(rdc_data, request->cpdata, sizeof(*rdc_data));
  1440. tape_free_request(request);
  1441. return rc;
  1442. }
  1443. /*
  1444. * Setup device function
  1445. */
  1446. static int
  1447. tape_3590_setup_device(struct tape_device *device)
  1448. {
  1449. int rc;
  1450. struct tape_3590_disc_data *data;
  1451. struct tape_3590_rdc_data *rdc_data;
  1452. DBF_EVENT(6, "3590 device setup\n");
  1453. data = kzalloc(sizeof(struct tape_3590_disc_data), GFP_KERNEL | GFP_DMA);
  1454. if (data == NULL)
  1455. return -ENOMEM;
  1456. data->read_back_op = READ_PREVIOUS;
  1457. device->discdata = data;
  1458. rdc_data = kmalloc(sizeof(*rdc_data), GFP_KERNEL | GFP_DMA);
  1459. if (!rdc_data) {
  1460. rc = -ENOMEM;
  1461. goto fail_kmalloc;
  1462. }
  1463. rc = tape_3590_read_dev_chars(device, rdc_data);
  1464. if (rc) {
  1465. DBF_LH(3, "Read device characteristics failed!\n");
  1466. goto fail_kmalloc;
  1467. }
  1468. rc = tape_std_assign(device);
  1469. if (rc)
  1470. goto fail_rdc_data;
  1471. if (rdc_data->data[31] == 0x13) {
  1472. PRINT_INFO("Device has crypto support\n");
  1473. data->crypt_info.capability |= TAPE390_CRYPT_SUPPORTED_MASK;
  1474. tape_3592_disable_crypt(device);
  1475. } else {
  1476. DBF_EVENT(6, "Device has NO crypto support\n");
  1477. }
  1478. /* Try to find out if medium is loaded */
  1479. rc = tape_3590_sense_medium(device);
  1480. if (rc) {
  1481. DBF_LH(3, "3590 medium sense returned %d\n", rc);
  1482. goto fail_rdc_data;
  1483. }
  1484. return 0;
  1485. fail_rdc_data:
  1486. kfree(rdc_data);
  1487. fail_kmalloc:
  1488. kfree(data);
  1489. return rc;
  1490. }
  1491. /*
  1492. * Cleanup device function
  1493. */
  1494. static void
  1495. tape_3590_cleanup_device(struct tape_device *device)
  1496. {
  1497. flush_scheduled_work();
  1498. tape_std_unassign(device);
  1499. kfree(device->discdata);
  1500. device->discdata = NULL;
  1501. }
  1502. /*
  1503. * List of 3590 magnetic tape commands.
  1504. */
  1505. static tape_mtop_fn tape_3590_mtop[TAPE_NR_MTOPS] = {
  1506. [MTRESET] = tape_std_mtreset,
  1507. [MTFSF] = tape_std_mtfsf,
  1508. [MTBSF] = tape_std_mtbsf,
  1509. [MTFSR] = tape_std_mtfsr,
  1510. [MTBSR] = tape_std_mtbsr,
  1511. [MTWEOF] = tape_std_mtweof,
  1512. [MTREW] = tape_std_mtrew,
  1513. [MTOFFL] = tape_std_mtoffl,
  1514. [MTNOP] = tape_std_mtnop,
  1515. [MTRETEN] = tape_std_mtreten,
  1516. [MTBSFM] = tape_std_mtbsfm,
  1517. [MTFSFM] = tape_std_mtfsfm,
  1518. [MTEOM] = tape_std_mteom,
  1519. [MTERASE] = tape_std_mterase,
  1520. [MTRAS1] = NULL,
  1521. [MTRAS2] = NULL,
  1522. [MTRAS3] = NULL,
  1523. [MTSETBLK] = tape_std_mtsetblk,
  1524. [MTSETDENSITY] = NULL,
  1525. [MTSEEK] = tape_3590_mtseek,
  1526. [MTTELL] = tape_3590_mttell,
  1527. [MTSETDRVBUFFER] = NULL,
  1528. [MTFSS] = NULL,
  1529. [MTBSS] = NULL,
  1530. [MTWSM] = NULL,
  1531. [MTLOCK] = NULL,
  1532. [MTUNLOCK] = NULL,
  1533. [MTLOAD] = tape_std_mtload,
  1534. [MTUNLOAD] = tape_std_mtunload,
  1535. [MTCOMPRESSION] = tape_std_mtcompression,
  1536. [MTSETPART] = NULL,
  1537. [MTMKPART] = NULL
  1538. };
  1539. /*
  1540. * Tape discipline structure for 3590.
  1541. */
  1542. static struct tape_discipline tape_discipline_3590 = {
  1543. .owner = THIS_MODULE,
  1544. .setup_device = tape_3590_setup_device,
  1545. .cleanup_device = tape_3590_cleanup_device,
  1546. .process_eov = tape_std_process_eov,
  1547. .irq = tape_3590_irq,
  1548. .read_block = tape_std_read_block,
  1549. .write_block = tape_std_write_block,
  1550. #ifdef CONFIG_S390_TAPE_BLOCK
  1551. .bread = tape_3590_bread,
  1552. .free_bread = tape_3590_free_bread,
  1553. .check_locate = tape_3590_check_locate,
  1554. #endif
  1555. .ioctl_fn = tape_3590_ioctl,
  1556. .mtop_array = tape_3590_mtop
  1557. };
  1558. static struct ccw_device_id tape_3590_ids[] = {
  1559. {CCW_DEVICE_DEVTYPE(0x3590, 0, 0x3590, 0), .driver_info = tape_3590},
  1560. {CCW_DEVICE_DEVTYPE(0x3592, 0, 0x3592, 0), .driver_info = tape_3592},
  1561. { /* end of list */ }
  1562. };
  1563. static int
  1564. tape_3590_online(struct ccw_device *cdev)
  1565. {
  1566. return tape_generic_online(cdev->dev.driver_data,
  1567. &tape_discipline_3590);
  1568. }
  1569. static int
  1570. tape_3590_offline(struct ccw_device *cdev)
  1571. {
  1572. return tape_generic_offline(cdev->dev.driver_data);
  1573. }
  1574. static struct ccw_driver tape_3590_driver = {
  1575. .name = "tape_3590",
  1576. .owner = THIS_MODULE,
  1577. .ids = tape_3590_ids,
  1578. .probe = tape_generic_probe,
  1579. .remove = tape_generic_remove,
  1580. .set_offline = tape_3590_offline,
  1581. .set_online = tape_3590_online,
  1582. };
  1583. /*
  1584. * Setup discipline structure.
  1585. */
  1586. static int
  1587. tape_3590_init(void)
  1588. {
  1589. int rc;
  1590. TAPE_DBF_AREA = debug_register("tape_3590", 2, 2, 4 * sizeof(long));
  1591. debug_register_view(TAPE_DBF_AREA, &debug_sprintf_view);
  1592. #ifdef DBF_LIKE_HELL
  1593. debug_set_level(TAPE_DBF_AREA, 6);
  1594. #endif
  1595. DBF_EVENT(3, "3590 init\n");
  1596. /* Register driver for 3590 tapes. */
  1597. rc = ccw_driver_register(&tape_3590_driver);
  1598. if (rc)
  1599. DBF_EVENT(3, "3590 init failed\n");
  1600. else
  1601. DBF_EVENT(3, "3590 registered\n");
  1602. return rc;
  1603. }
  1604. static void
  1605. tape_3590_exit(void)
  1606. {
  1607. ccw_driver_unregister(&tape_3590_driver);
  1608. debug_unregister(TAPE_DBF_AREA);
  1609. }
  1610. MODULE_DEVICE_TABLE(ccw, tape_3590_ids);
  1611. MODULE_AUTHOR("(C) 2001,2006 IBM Corporation");
  1612. MODULE_DESCRIPTION("Linux on zSeries channel attached 3590 tape device driver");
  1613. MODULE_LICENSE("GPL");
  1614. module_init(tape_3590_init);
  1615. module_exit(tape_3590_exit);