tape_3590.c 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766
  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;
  565. unsigned off;
  566. char *dst;
  567. struct bio_vec *bv;
  568. struct req_iterator iter;
  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_segment(bv, req, iter)
  573. count += bv->bv_len >> (TAPEBLOCK_HSEC_S2B + 9);
  574. request = tape_alloc_request(2 + count + 1, 4);
  575. if (IS_ERR(request))
  576. return request;
  577. request->op = TO_BLOCK;
  578. *(__u32 *) request->cpdata = start_block;
  579. ccw = request->cpaddr;
  580. ccw = tape_ccw_cc(ccw, MODE_SET_DB, 1, device->modeset_byte);
  581. /*
  582. * We always setup a nop after the mode set ccw. This slot is
  583. * used in tape_std_check_locate to insert a locate ccw if the
  584. * current tape position doesn't match the start block to be read.
  585. */
  586. ccw = tape_ccw_cc(ccw, NOP, 0, NULL);
  587. rq_for_each_segment(bv, req, iter) {
  588. dst = page_address(bv->bv_page) + bv->bv_offset;
  589. for (off = 0; off < bv->bv_len; off += TAPEBLOCK_HSEC_SIZE) {
  590. ccw->flags = CCW_FLAG_CC;
  591. ccw->cmd_code = READ_FORWARD;
  592. ccw->count = TAPEBLOCK_HSEC_SIZE;
  593. set_normalized_cda(ccw, (void *) __pa(dst));
  594. ccw++;
  595. dst += TAPEBLOCK_HSEC_SIZE;
  596. }
  597. if (off > bv->bv_len)
  598. BUG();
  599. }
  600. ccw = tape_ccw_end(ccw, NOP, 0, NULL);
  601. DBF_EVENT(6, "xBREDccwg\n");
  602. return request;
  603. }
  604. static void
  605. tape_3590_free_bread(struct tape_request *request)
  606. {
  607. struct ccw1 *ccw;
  608. /* Last ccw is a nop and doesn't need clear_normalized_cda */
  609. for (ccw = request->cpaddr; ccw->flags & CCW_FLAG_CC; ccw++)
  610. if (ccw->cmd_code == READ_FORWARD)
  611. clear_normalized_cda(ccw);
  612. tape_free_request(request);
  613. }
  614. /*
  615. * check_locate is called just before the tape request is passed to
  616. * the common io layer for execution. It has to check the current
  617. * tape position and insert a locate ccw if it doesn't match the
  618. * start block for the request.
  619. */
  620. static void
  621. tape_3590_check_locate(struct tape_device *device, struct tape_request *request)
  622. {
  623. __u32 *start_block;
  624. start_block = (__u32 *) request->cpdata;
  625. if (*start_block != device->blk_data.block_position) {
  626. /* Add the start offset of the file to get the real block. */
  627. *start_block += device->bof;
  628. tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
  629. }
  630. }
  631. #endif
  632. static void tape_3590_med_state_set(struct tape_device *device,
  633. struct tape_3590_med_sense *sense)
  634. {
  635. struct tape390_crypt_info *c_info;
  636. c_info = &TAPE_3590_CRYPT_INFO(device);
  637. DBF_EVENT(6, "medium state: %x:%x\n", sense->macst, sense->masst);
  638. switch (sense->macst) {
  639. case 0x04:
  640. case 0x05:
  641. case 0x06:
  642. tape_med_state_set(device, MS_UNLOADED);
  643. TAPE_3590_CRYPT_INFO(device).medium_status = 0;
  644. return;
  645. case 0x08:
  646. case 0x09:
  647. tape_med_state_set(device, MS_LOADED);
  648. break;
  649. default:
  650. tape_med_state_set(device, MS_UNKNOWN);
  651. return;
  652. }
  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 */
  764. DBF_EVENT(3, "unsol.irq! tape ready: %08x\n", device->cdev_id);
  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. /* check medium state */
  773. tape_3590_schedule_work(device, TO_MSEN);
  774. return TAPE_IO_SUCCESS;
  775. }
  776. /*
  777. * Basic Recovery routine
  778. */
  779. static int
  780. tape_3590_erp_basic(struct tape_device *device, struct tape_request *request,
  781. struct irb *irb, int rc)
  782. {
  783. struct tape_3590_sense *sense;
  784. sense = (struct tape_3590_sense *) irb->ecw;
  785. switch (sense->bra) {
  786. case SENSE_BRA_PER:
  787. return tape_3590_erp_failed(device, request, irb, rc);
  788. case SENSE_BRA_CONT:
  789. return tape_3590_erp_succeded(device, request);
  790. case SENSE_BRA_RE:
  791. return tape_3590_erp_retry(device, request, irb);
  792. case SENSE_BRA_DRE:
  793. return tape_3590_erp_failed(device, request, irb, rc);
  794. default:
  795. PRINT_ERR("Unknown BRA %x - This should not happen!\n",
  796. sense->bra);
  797. BUG();
  798. return TAPE_IO_STOP;
  799. }
  800. }
  801. /*
  802. * RDL: Read Device (buffered) log
  803. */
  804. static int
  805. tape_3590_erp_read_buf_log(struct tape_device *device,
  806. struct tape_request *request, struct irb *irb)
  807. {
  808. /*
  809. * We just do the basic error recovery at the moment (retry).
  810. * Perhaps in the future, we read the log and dump it somewhere...
  811. */
  812. return tape_3590_erp_basic(device, request, irb, -EIO);
  813. }
  814. /*
  815. * SWAP: Swap Devices
  816. */
  817. static int
  818. tape_3590_erp_swap(struct tape_device *device, struct tape_request *request,
  819. struct irb *irb)
  820. {
  821. /*
  822. * This error recovery should swap the tapes
  823. * if the original has a problem. The operation
  824. * should proceed with the new tape... this
  825. * should probably be done in user space!
  826. */
  827. PRINT_WARN("(%s): Swap Tape Device!\n", device->cdev->dev.bus_id);
  828. return tape_3590_erp_basic(device, request, irb, -EIO);
  829. }
  830. /*
  831. * LBY: Long Busy
  832. */
  833. static int
  834. tape_3590_erp_long_busy(struct tape_device *device,
  835. struct tape_request *request, struct irb *irb)
  836. {
  837. DBF_EVENT(6, "Device is busy\n");
  838. return TAPE_IO_LONG_BUSY;
  839. }
  840. /*
  841. * SPI: Special Intercept
  842. */
  843. static int
  844. tape_3590_erp_special_interrupt(struct tape_device *device,
  845. struct tape_request *request, struct irb *irb)
  846. {
  847. return tape_3590_erp_basic(device, request, irb, -EIO);
  848. }
  849. /*
  850. * RDA: Read Alternate
  851. */
  852. static int
  853. tape_3590_erp_read_alternate(struct tape_device *device,
  854. struct tape_request *request, struct irb *irb)
  855. {
  856. struct tape_3590_disc_data *data;
  857. /*
  858. * The issued Read Backward or Read Previous command is not
  859. * supported by the device
  860. * The recovery action should be to issue another command:
  861. * Read Revious: if Read Backward is not supported
  862. * Read Backward: if Read Previous is not supported
  863. */
  864. data = device->discdata;
  865. if (data->read_back_op == READ_PREVIOUS) {
  866. DBF_EVENT(2, "(%08x): No support for READ_PREVIOUS command\n",
  867. device->cdev_id);
  868. data->read_back_op = READ_BACKWARD;
  869. } else {
  870. DBF_EVENT(2, "(%08x): No support for READ_BACKWARD command\n",
  871. device->cdev_id);
  872. data->read_back_op = READ_PREVIOUS;
  873. }
  874. tape_3590_read_opposite(device, request);
  875. return tape_3590_erp_retry(device, request, irb);
  876. }
  877. /*
  878. * Error Recovery read opposite
  879. */
  880. static int
  881. tape_3590_erp_read_opposite(struct tape_device *device,
  882. struct tape_request *request, struct irb *irb)
  883. {
  884. switch (request->op) {
  885. case TO_RFO:
  886. /*
  887. * We did read forward, but the data could not be read.
  888. * We will read backward and then skip forward again.
  889. */
  890. tape_3590_read_opposite(device, request);
  891. return tape_3590_erp_retry(device, request, irb);
  892. case TO_RBA:
  893. /* We tried to read forward and backward, but hat no success */
  894. return tape_3590_erp_failed(device, request, irb, -EIO);
  895. break;
  896. default:
  897. PRINT_WARN("read_opposite_recovery_called_with_op: %s\n",
  898. tape_op_verbose[request->op]);
  899. return tape_3590_erp_failed(device, request, irb, -EIO);
  900. }
  901. }
  902. /*
  903. * Print an MIM (Media Information Message) (message code f0)
  904. */
  905. static void
  906. tape_3590_print_mim_msg_f0(struct tape_device *device, struct irb *irb)
  907. {
  908. struct tape_3590_sense *sense;
  909. sense = (struct tape_3590_sense *) irb->ecw;
  910. /* Exception Message */
  911. switch (sense->fmt.f70.emc) {
  912. case 0x02:
  913. PRINT_WARN("(%s): Data degraded\n", device->cdev->dev.bus_id);
  914. break;
  915. case 0x03:
  916. PRINT_WARN("(%s): Data degraded in partion %i\n",
  917. device->cdev->dev.bus_id, sense->fmt.f70.mp);
  918. break;
  919. case 0x04:
  920. PRINT_WARN("(%s): Medium degraded\n", device->cdev->dev.bus_id);
  921. break;
  922. case 0x05:
  923. PRINT_WARN("(%s): Medium degraded in partition %i\n",
  924. device->cdev->dev.bus_id, sense->fmt.f70.mp);
  925. break;
  926. case 0x06:
  927. PRINT_WARN("(%s): Block 0 Error\n", device->cdev->dev.bus_id);
  928. break;
  929. case 0x07:
  930. PRINT_WARN("(%s): Medium Exception 0x%02x\n",
  931. device->cdev->dev.bus_id, sense->fmt.f70.md);
  932. break;
  933. default:
  934. PRINT_WARN("(%s): MIM ExMsg: 0x%02x\n",
  935. device->cdev->dev.bus_id, sense->fmt.f70.emc);
  936. break;
  937. }
  938. /* Service Message */
  939. switch (sense->fmt.f70.smc) {
  940. case 0x02:
  941. PRINT_WARN("(%s): Reference Media maintenance procedure %i\n",
  942. device->cdev->dev.bus_id, sense->fmt.f70.md);
  943. break;
  944. default:
  945. PRINT_WARN("(%s): MIM ServiceMsg: 0x%02x\n",
  946. device->cdev->dev.bus_id, sense->fmt.f70.smc);
  947. break;
  948. }
  949. }
  950. /*
  951. * Print an I/O Subsystem Service Information Message (message code f1)
  952. */
  953. static void
  954. tape_3590_print_io_sim_msg_f1(struct tape_device *device, struct irb *irb)
  955. {
  956. struct tape_3590_sense *sense;
  957. sense = (struct tape_3590_sense *) irb->ecw;
  958. /* Exception Message */
  959. switch (sense->fmt.f71.emc) {
  960. case 0x01:
  961. PRINT_WARN("(%s): Effect of failure is unknown\n",
  962. device->cdev->dev.bus_id);
  963. break;
  964. case 0x02:
  965. PRINT_WARN("(%s): CU Exception - no performance impact\n",
  966. device->cdev->dev.bus_id);
  967. break;
  968. case 0x03:
  969. PRINT_WARN("(%s): CU Exception on channel interface 0x%02x\n",
  970. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  971. break;
  972. case 0x04:
  973. PRINT_WARN("(%s): CU Exception on device path 0x%02x\n",
  974. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  975. break;
  976. case 0x05:
  977. PRINT_WARN("(%s): CU Exception on library path 0x%02x\n",
  978. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  979. break;
  980. case 0x06:
  981. PRINT_WARN("(%s): CU Exception on node 0x%02x\n",
  982. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  983. break;
  984. case 0x07:
  985. PRINT_WARN("(%s): CU Exception on partition 0x%02x\n",
  986. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  987. break;
  988. default:
  989. PRINT_WARN("(%s): SIM ExMsg: 0x%02x\n",
  990. device->cdev->dev.bus_id, sense->fmt.f71.emc);
  991. }
  992. /* Service Message */
  993. switch (sense->fmt.f71.smc) {
  994. case 0x01:
  995. PRINT_WARN("(%s): Repair impact is unknown\n",
  996. device->cdev->dev.bus_id);
  997. break;
  998. case 0x02:
  999. PRINT_WARN("(%s): Repair will not impact cu performance\n",
  1000. device->cdev->dev.bus_id);
  1001. break;
  1002. case 0x03:
  1003. if (sense->fmt.f71.mdf == 0)
  1004. PRINT_WARN("(%s): Repair will disable node "
  1005. "0x%x on CU\n",
  1006. device->cdev->dev.bus_id,
  1007. sense->fmt.f71.md[1]);
  1008. else
  1009. PRINT_WARN("(%s): Repair will disable nodes "
  1010. "(0x%x-0x%x) on CU\n",
  1011. device->cdev->dev.bus_id,
  1012. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  1013. break;
  1014. case 0x04:
  1015. if (sense->fmt.f71.mdf == 0)
  1016. PRINT_WARN("(%s): Repair will disable cannel path "
  1017. "0x%x on CU\n",
  1018. device->cdev->dev.bus_id,
  1019. sense->fmt.f71.md[1]);
  1020. else
  1021. PRINT_WARN("(%s): Repair will disable cannel paths "
  1022. "(0x%x-0x%x) on CU\n",
  1023. device->cdev->dev.bus_id,
  1024. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  1025. break;
  1026. case 0x05:
  1027. if (sense->fmt.f71.mdf == 0)
  1028. PRINT_WARN("(%s): Repair will disable device path "
  1029. "0x%x on CU\n",
  1030. device->cdev->dev.bus_id,
  1031. sense->fmt.f71.md[1]);
  1032. else
  1033. PRINT_WARN("(%s): Repair will disable device paths "
  1034. "(0x%x-0x%x) on CU\n",
  1035. device->cdev->dev.bus_id,
  1036. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  1037. break;
  1038. case 0x06:
  1039. if (sense->fmt.f71.mdf == 0)
  1040. PRINT_WARN("(%s): Repair will disable library path "
  1041. "0x%x on CU\n",
  1042. device->cdev->dev.bus_id,
  1043. sense->fmt.f71.md[1]);
  1044. else
  1045. PRINT_WARN("(%s): Repair will disable library paths "
  1046. "(0x%x-0x%x) on CU\n",
  1047. device->cdev->dev.bus_id,
  1048. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  1049. break;
  1050. case 0x07:
  1051. PRINT_WARN("(%s): Repair will disable access to CU\n",
  1052. device->cdev->dev.bus_id);
  1053. break;
  1054. default:
  1055. PRINT_WARN("(%s): SIM ServiceMsg: 0x%02x\n",
  1056. device->cdev->dev.bus_id, sense->fmt.f71.smc);
  1057. }
  1058. }
  1059. /*
  1060. * Print an Device Subsystem Service Information Message (message code f2)
  1061. */
  1062. static void
  1063. tape_3590_print_dev_sim_msg_f2(struct tape_device *device, struct irb *irb)
  1064. {
  1065. struct tape_3590_sense *sense;
  1066. sense = (struct tape_3590_sense *) irb->ecw;
  1067. /* Exception Message */
  1068. switch (sense->fmt.f71.emc) {
  1069. case 0x01:
  1070. PRINT_WARN("(%s): Effect of failure is unknown\n",
  1071. device->cdev->dev.bus_id);
  1072. break;
  1073. case 0x02:
  1074. PRINT_WARN("(%s): DV Exception - no performance impact\n",
  1075. device->cdev->dev.bus_id);
  1076. break;
  1077. case 0x03:
  1078. PRINT_WARN("(%s): DV Exception on channel interface 0x%02x\n",
  1079. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  1080. break;
  1081. case 0x04:
  1082. PRINT_WARN("(%s): DV Exception on loader 0x%02x\n",
  1083. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  1084. break;
  1085. case 0x05:
  1086. PRINT_WARN("(%s): DV Exception on message display 0x%02x\n",
  1087. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  1088. break;
  1089. case 0x06:
  1090. PRINT_WARN("(%s): DV Exception in tape path\n",
  1091. device->cdev->dev.bus_id);
  1092. break;
  1093. case 0x07:
  1094. PRINT_WARN("(%s): DV Exception in drive\n",
  1095. device->cdev->dev.bus_id);
  1096. break;
  1097. default:
  1098. PRINT_WARN("(%s): DSIM ExMsg: 0x%02x\n",
  1099. device->cdev->dev.bus_id, sense->fmt.f71.emc);
  1100. }
  1101. /* Service Message */
  1102. switch (sense->fmt.f71.smc) {
  1103. case 0x01:
  1104. PRINT_WARN("(%s): Repair impact is unknown\n",
  1105. device->cdev->dev.bus_id);
  1106. break;
  1107. case 0x02:
  1108. PRINT_WARN("(%s): Repair will not impact device performance\n",
  1109. device->cdev->dev.bus_id);
  1110. break;
  1111. case 0x03:
  1112. if (sense->fmt.f71.mdf == 0)
  1113. PRINT_WARN("(%s): Repair will disable channel path "
  1114. "0x%x on DV\n",
  1115. device->cdev->dev.bus_id,
  1116. sense->fmt.f71.md[1]);
  1117. else
  1118. PRINT_WARN("(%s): Repair will disable channel path "
  1119. "(0x%x-0x%x) on DV\n",
  1120. device->cdev->dev.bus_id,
  1121. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  1122. break;
  1123. case 0x04:
  1124. if (sense->fmt.f71.mdf == 0)
  1125. PRINT_WARN("(%s): Repair will disable interface 0x%x "
  1126. "on DV\n",
  1127. device->cdev->dev.bus_id,
  1128. sense->fmt.f71.md[1]);
  1129. else
  1130. PRINT_WARN("(%s): Repair will disable interfaces "
  1131. "(0x%x-0x%x) on DV\n",
  1132. device->cdev->dev.bus_id,
  1133. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  1134. break;
  1135. case 0x05:
  1136. if (sense->fmt.f71.mdf == 0)
  1137. PRINT_WARN("(%s): Repair will disable loader 0x%x "
  1138. "on DV\n",
  1139. device->cdev->dev.bus_id,
  1140. sense->fmt.f71.md[1]);
  1141. else
  1142. PRINT_WARN("(%s): Repair will disable loader "
  1143. "(0x%x-0x%x) on DV\n",
  1144. device->cdev->dev.bus_id,
  1145. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  1146. break;
  1147. case 0x07:
  1148. PRINT_WARN("(%s): Repair will disable access to DV\n",
  1149. device->cdev->dev.bus_id);
  1150. break;
  1151. case 0x08:
  1152. if (sense->fmt.f71.mdf == 0)
  1153. PRINT_WARN("(%s): Repair will disable message "
  1154. "display 0x%x on DV\n",
  1155. device->cdev->dev.bus_id,
  1156. sense->fmt.f71.md[1]);
  1157. else
  1158. PRINT_WARN("(%s): Repair will disable message "
  1159. "displays (0x%x-0x%x) on DV\n",
  1160. device->cdev->dev.bus_id,
  1161. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  1162. break;
  1163. case 0x09:
  1164. PRINT_WARN("(%s): Clean DV\n", device->cdev->dev.bus_id);
  1165. break;
  1166. default:
  1167. PRINT_WARN("(%s): DSIM ServiceMsg: 0x%02x\n",
  1168. device->cdev->dev.bus_id, sense->fmt.f71.smc);
  1169. }
  1170. }
  1171. /*
  1172. * Print standard ERA Message
  1173. */
  1174. static void
  1175. tape_3590_print_era_msg(struct tape_device *device, struct irb *irb)
  1176. {
  1177. struct tape_3590_sense *sense;
  1178. sense = (struct tape_3590_sense *) irb->ecw;
  1179. if (sense->mc == 0)
  1180. return;
  1181. if ((sense->mc > 0) && (sense->mc < TAPE_3590_MAX_MSG)) {
  1182. if (tape_3590_msg[sense->mc] != NULL)
  1183. PRINT_WARN("(%s): %s\n", device->cdev->dev.bus_id,
  1184. tape_3590_msg[sense->mc]);
  1185. else {
  1186. PRINT_WARN("(%s): Message Code 0x%x\n",
  1187. device->cdev->dev.bus_id, sense->mc);
  1188. }
  1189. return;
  1190. }
  1191. if (sense->mc == 0xf0) {
  1192. /* Standard Media Information Message */
  1193. PRINT_WARN("(%s): MIM SEV=%i, MC=%02x, ES=%x/%x, "
  1194. "RC=%02x-%04x-%02x\n", device->cdev->dev.bus_id,
  1195. sense->fmt.f70.sev, sense->mc,
  1196. sense->fmt.f70.emc, sense->fmt.f70.smc,
  1197. sense->fmt.f70.refcode, sense->fmt.f70.mid,
  1198. sense->fmt.f70.fid);
  1199. tape_3590_print_mim_msg_f0(device, irb);
  1200. return;
  1201. }
  1202. if (sense->mc == 0xf1) {
  1203. /* Standard I/O Subsystem Service Information Message */
  1204. PRINT_WARN("(%s): IOSIM SEV=%i, DEVTYPE=3590/%02x, "
  1205. "MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n",
  1206. device->cdev->dev.bus_id, sense->fmt.f71.sev,
  1207. device->cdev->id.dev_model,
  1208. sense->mc, sense->fmt.f71.emc,
  1209. sense->fmt.f71.smc, sense->fmt.f71.refcode1,
  1210. sense->fmt.f71.refcode2, sense->fmt.f71.refcode3);
  1211. tape_3590_print_io_sim_msg_f1(device, irb);
  1212. return;
  1213. }
  1214. if (sense->mc == 0xf2) {
  1215. /* Standard Device Service Information Message */
  1216. PRINT_WARN("(%s): DEVSIM SEV=%i, DEVTYPE=3590/%02x, "
  1217. "MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n",
  1218. device->cdev->dev.bus_id, sense->fmt.f71.sev,
  1219. device->cdev->id.dev_model,
  1220. sense->mc, sense->fmt.f71.emc,
  1221. sense->fmt.f71.smc, sense->fmt.f71.refcode1,
  1222. sense->fmt.f71.refcode2, sense->fmt.f71.refcode3);
  1223. tape_3590_print_dev_sim_msg_f2(device, irb);
  1224. return;
  1225. }
  1226. if (sense->mc == 0xf3) {
  1227. /* Standard Library Service Information Message */
  1228. return;
  1229. }
  1230. PRINT_WARN("(%s): Device Message(%x)\n",
  1231. device->cdev->dev.bus_id, sense->mc);
  1232. }
  1233. static int tape_3590_crypt_error(struct tape_device *device,
  1234. struct tape_request *request, struct irb *irb)
  1235. {
  1236. u8 cu_rc, ekm_rc1;
  1237. u16 ekm_rc2;
  1238. u32 drv_rc;
  1239. char *bus_id, *sense;
  1240. sense = ((struct tape_3590_sense *) irb->ecw)->fmt.data;
  1241. bus_id = device->cdev->dev.bus_id;
  1242. cu_rc = sense[0];
  1243. drv_rc = *((u32*) &sense[5]) & 0xffffff;
  1244. ekm_rc1 = sense[9];
  1245. ekm_rc2 = *((u16*) &sense[10]);
  1246. if ((cu_rc == 0) && (ekm_rc2 == 0xee31))
  1247. /* key not defined on EKM */
  1248. return tape_3590_erp_basic(device, request, irb, -EKEYREJECTED);
  1249. if ((cu_rc == 1) || (cu_rc == 2))
  1250. /* No connection to EKM */
  1251. return tape_3590_erp_basic(device, request, irb, -ENOTCONN);
  1252. PRINT_ERR("(%s): Unable to get encryption key from EKM\n", bus_id);
  1253. PRINT_ERR("(%s): CU=%02X DRIVE=%06X EKM=%02X:%04X\n", bus_id, cu_rc,
  1254. drv_rc, ekm_rc1, ekm_rc2);
  1255. return tape_3590_erp_basic(device, request, irb, -ENOKEY);
  1256. }
  1257. /*
  1258. * 3590 error Recovery routine:
  1259. * If possible, it tries to recover from the error. If this is not possible,
  1260. * inform the user about the problem.
  1261. */
  1262. static int
  1263. tape_3590_unit_check(struct tape_device *device, struct tape_request *request,
  1264. struct irb *irb)
  1265. {
  1266. struct tape_3590_sense *sense;
  1267. int rc;
  1268. #ifdef CONFIG_S390_TAPE_BLOCK
  1269. if (request->op == TO_BLOCK) {
  1270. /*
  1271. * Recovery for block device requests. Set the block_position
  1272. * to something invalid and retry.
  1273. */
  1274. device->blk_data.block_position = -1;
  1275. if (request->retries-- <= 0)
  1276. return tape_3590_erp_failed(device, request, irb, -EIO);
  1277. else
  1278. return tape_3590_erp_retry(device, request, irb);
  1279. }
  1280. #endif
  1281. sense = (struct tape_3590_sense *) irb->ecw;
  1282. DBF_EVENT(6, "Unit Check: RQC = %x\n", sense->rc_rqc);
  1283. /*
  1284. * First check all RC-QRCs where we want to do something special
  1285. * - "break": basic error recovery is done
  1286. * - "goto out:": just print error message if available
  1287. */
  1288. rc = -EIO;
  1289. switch (sense->rc_rqc) {
  1290. case 0x1110:
  1291. tape_3590_print_era_msg(device, irb);
  1292. return tape_3590_erp_read_buf_log(device, request, irb);
  1293. case 0x2011:
  1294. tape_3590_print_era_msg(device, irb);
  1295. return tape_3590_erp_read_alternate(device, request, irb);
  1296. case 0x2230:
  1297. case 0x2231:
  1298. tape_3590_print_era_msg(device, irb);
  1299. return tape_3590_erp_special_interrupt(device, request, irb);
  1300. case 0x2240:
  1301. return tape_3590_crypt_error(device, request, irb);
  1302. case 0x3010:
  1303. DBF_EVENT(2, "(%08x): Backward at Beginning of Partition\n",
  1304. device->cdev_id);
  1305. return tape_3590_erp_basic(device, request, irb, -ENOSPC);
  1306. case 0x3012:
  1307. DBF_EVENT(2, "(%08x): Forward at End of Partition\n",
  1308. device->cdev_id);
  1309. return tape_3590_erp_basic(device, request, irb, -ENOSPC);
  1310. case 0x3020:
  1311. DBF_EVENT(2, "(%08x): End of Data Mark\n", device->cdev_id);
  1312. return tape_3590_erp_basic(device, request, irb, -ENOSPC);
  1313. case 0x3122:
  1314. DBF_EVENT(2, "(%08x): Rewind Unload initiated\n",
  1315. device->cdev_id);
  1316. return tape_3590_erp_basic(device, request, irb, -EIO);
  1317. case 0x3123:
  1318. DBF_EVENT(2, "(%08x): Rewind Unload complete\n",
  1319. device->cdev_id);
  1320. tape_med_state_set(device, MS_UNLOADED);
  1321. tape_3590_schedule_work(device, TO_CRYPT_OFF);
  1322. return tape_3590_erp_basic(device, request, irb, 0);
  1323. case 0x4010:
  1324. /*
  1325. * print additional msg since default msg
  1326. * "device intervention" is not very meaningfull
  1327. */
  1328. PRINT_WARN("(%s): Tape operation when medium not loaded\n",
  1329. device->cdev->dev.bus_id);
  1330. tape_med_state_set(device, MS_UNLOADED);
  1331. tape_3590_schedule_work(device, TO_CRYPT_OFF);
  1332. return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM);
  1333. case 0x4012: /* Device Long Busy */
  1334. /* XXX: Also use long busy handling here? */
  1335. DBF_EVENT(6, "(%08x): LONG BUSY\n", device->cdev_id);
  1336. tape_3590_print_era_msg(device, irb);
  1337. return tape_3590_erp_basic(device, request, irb, -EBUSY);
  1338. case 0x4014:
  1339. DBF_EVENT(6, "(%08x): Crypto LONG BUSY\n", device->cdev_id);
  1340. return tape_3590_erp_long_busy(device, request, irb);
  1341. case 0x5010:
  1342. if (sense->rac == 0xd0) {
  1343. /* Swap */
  1344. tape_3590_print_era_msg(device, irb);
  1345. return tape_3590_erp_swap(device, request, irb);
  1346. }
  1347. if (sense->rac == 0x26) {
  1348. /* Read Opposite */
  1349. tape_3590_print_era_msg(device, irb);
  1350. return tape_3590_erp_read_opposite(device, request,
  1351. irb);
  1352. }
  1353. return tape_3590_erp_basic(device, request, irb, -EIO);
  1354. case 0x5020:
  1355. case 0x5021:
  1356. case 0x5022:
  1357. case 0x5040:
  1358. case 0x5041:
  1359. case 0x5042:
  1360. tape_3590_print_era_msg(device, irb);
  1361. return tape_3590_erp_swap(device, request, irb);
  1362. case 0x5110:
  1363. case 0x5111:
  1364. return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE);
  1365. case 0x5120:
  1366. case 0x1120:
  1367. tape_med_state_set(device, MS_UNLOADED);
  1368. tape_3590_schedule_work(device, TO_CRYPT_OFF);
  1369. return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM);
  1370. case 0x6020:
  1371. PRINT_WARN("(%s): Cartridge of wrong type ?\n",
  1372. device->cdev->dev.bus_id);
  1373. return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE);
  1374. case 0x8011:
  1375. PRINT_WARN("(%s): Another host has reserved the tape device\n",
  1376. device->cdev->dev.bus_id);
  1377. return tape_3590_erp_basic(device, request, irb, -EPERM);
  1378. case 0x8013:
  1379. PRINT_WARN("(%s): Another host has priviliged access to the "
  1380. "tape device\n", device->cdev->dev.bus_id);
  1381. PRINT_WARN("(%s): To solve the problem unload the current "
  1382. "cartridge!\n", device->cdev->dev.bus_id);
  1383. return tape_3590_erp_basic(device, request, irb, -EPERM);
  1384. default:
  1385. return tape_3590_erp_basic(device, request, irb, -EIO);
  1386. }
  1387. }
  1388. /*
  1389. * 3590 interrupt handler:
  1390. */
  1391. static int
  1392. tape_3590_irq(struct tape_device *device, struct tape_request *request,
  1393. struct irb *irb)
  1394. {
  1395. if (request == NULL)
  1396. return tape_3590_unsolicited_irq(device, irb);
  1397. if ((irb->scsw.dstat & DEV_STAT_UNIT_EXCEP) &&
  1398. (irb->scsw.dstat & DEV_STAT_DEV_END) && (request->op == TO_WRI)) {
  1399. /* Write at end of volume */
  1400. DBF_EVENT(2, "End of volume\n");
  1401. return tape_3590_erp_failed(device, request, irb, -ENOSPC);
  1402. }
  1403. if (irb->scsw.dstat & DEV_STAT_UNIT_CHECK)
  1404. return tape_3590_unit_check(device, request, irb);
  1405. if (irb->scsw.dstat & DEV_STAT_DEV_END) {
  1406. if (irb->scsw.dstat == DEV_STAT_UNIT_EXCEP) {
  1407. if (request->op == TO_FSB || request->op == TO_BSB)
  1408. request->rescnt++;
  1409. else
  1410. DBF_EVENT(5, "Unit Exception!\n");
  1411. }
  1412. return tape_3590_done(device, request);
  1413. }
  1414. if (irb->scsw.dstat & DEV_STAT_CHN_END) {
  1415. DBF_EVENT(2, "cannel end\n");
  1416. return TAPE_IO_PENDING;
  1417. }
  1418. if (irb->scsw.dstat & DEV_STAT_ATTENTION) {
  1419. DBF_EVENT(2, "Unit Attention when busy..\n");
  1420. return TAPE_IO_PENDING;
  1421. }
  1422. DBF_EVENT(6, "xunknownirq\n");
  1423. PRINT_ERR("Unexpected interrupt.\n");
  1424. PRINT_ERR("Current op is: %s", tape_op_verbose[request->op]);
  1425. tape_dump_sense(device, request, irb);
  1426. return TAPE_IO_STOP;
  1427. }
  1428. static int tape_3590_read_dev_chars(struct tape_device *device,
  1429. struct tape_3590_rdc_data *rdc_data)
  1430. {
  1431. int rc;
  1432. struct tape_request *request;
  1433. request = tape_alloc_request(1, sizeof(*rdc_data));
  1434. if (IS_ERR(request))
  1435. return PTR_ERR(request);
  1436. request->op = TO_RDC;
  1437. tape_ccw_end(request->cpaddr, CCW_CMD_RDC, sizeof(*rdc_data),
  1438. request->cpdata);
  1439. rc = tape_do_io(device, request);
  1440. if (rc == 0)
  1441. memcpy(rdc_data, request->cpdata, sizeof(*rdc_data));
  1442. tape_free_request(request);
  1443. return rc;
  1444. }
  1445. /*
  1446. * Setup device function
  1447. */
  1448. static int
  1449. tape_3590_setup_device(struct tape_device *device)
  1450. {
  1451. int rc;
  1452. struct tape_3590_disc_data *data;
  1453. struct tape_3590_rdc_data *rdc_data;
  1454. DBF_EVENT(6, "3590 device setup\n");
  1455. data = kzalloc(sizeof(struct tape_3590_disc_data), GFP_KERNEL | GFP_DMA);
  1456. if (data == NULL)
  1457. return -ENOMEM;
  1458. data->read_back_op = READ_PREVIOUS;
  1459. device->discdata = data;
  1460. rdc_data = kmalloc(sizeof(*rdc_data), GFP_KERNEL | GFP_DMA);
  1461. if (!rdc_data) {
  1462. rc = -ENOMEM;
  1463. goto fail_kmalloc;
  1464. }
  1465. rc = tape_3590_read_dev_chars(device, rdc_data);
  1466. if (rc) {
  1467. DBF_LH(3, "Read device characteristics failed!\n");
  1468. goto fail_kmalloc;
  1469. }
  1470. rc = tape_std_assign(device);
  1471. if (rc)
  1472. goto fail_rdc_data;
  1473. if (rdc_data->data[31] == 0x13) {
  1474. PRINT_INFO("Device has crypto support\n");
  1475. data->crypt_info.capability |= TAPE390_CRYPT_SUPPORTED_MASK;
  1476. tape_3592_disable_crypt(device);
  1477. } else {
  1478. DBF_EVENT(6, "Device has NO crypto support\n");
  1479. }
  1480. /* Try to find out if medium is loaded */
  1481. rc = tape_3590_sense_medium(device);
  1482. if (rc) {
  1483. DBF_LH(3, "3590 medium sense returned %d\n", rc);
  1484. goto fail_rdc_data;
  1485. }
  1486. return 0;
  1487. fail_rdc_data:
  1488. kfree(rdc_data);
  1489. fail_kmalloc:
  1490. kfree(data);
  1491. return rc;
  1492. }
  1493. /*
  1494. * Cleanup device function
  1495. */
  1496. static void
  1497. tape_3590_cleanup_device(struct tape_device *device)
  1498. {
  1499. flush_scheduled_work();
  1500. tape_std_unassign(device);
  1501. kfree(device->discdata);
  1502. device->discdata = NULL;
  1503. }
  1504. /*
  1505. * List of 3590 magnetic tape commands.
  1506. */
  1507. static tape_mtop_fn tape_3590_mtop[TAPE_NR_MTOPS] = {
  1508. [MTRESET] = tape_std_mtreset,
  1509. [MTFSF] = tape_std_mtfsf,
  1510. [MTBSF] = tape_std_mtbsf,
  1511. [MTFSR] = tape_std_mtfsr,
  1512. [MTBSR] = tape_std_mtbsr,
  1513. [MTWEOF] = tape_std_mtweof,
  1514. [MTREW] = tape_std_mtrew,
  1515. [MTOFFL] = tape_std_mtoffl,
  1516. [MTNOP] = tape_std_mtnop,
  1517. [MTRETEN] = tape_std_mtreten,
  1518. [MTBSFM] = tape_std_mtbsfm,
  1519. [MTFSFM] = tape_std_mtfsfm,
  1520. [MTEOM] = tape_std_mteom,
  1521. [MTERASE] = tape_std_mterase,
  1522. [MTRAS1] = NULL,
  1523. [MTRAS2] = NULL,
  1524. [MTRAS3] = NULL,
  1525. [MTSETBLK] = tape_std_mtsetblk,
  1526. [MTSETDENSITY] = NULL,
  1527. [MTSEEK] = tape_3590_mtseek,
  1528. [MTTELL] = tape_3590_mttell,
  1529. [MTSETDRVBUFFER] = NULL,
  1530. [MTFSS] = NULL,
  1531. [MTBSS] = NULL,
  1532. [MTWSM] = NULL,
  1533. [MTLOCK] = NULL,
  1534. [MTUNLOCK] = NULL,
  1535. [MTLOAD] = tape_std_mtload,
  1536. [MTUNLOAD] = tape_std_mtunload,
  1537. [MTCOMPRESSION] = tape_std_mtcompression,
  1538. [MTSETPART] = NULL,
  1539. [MTMKPART] = NULL
  1540. };
  1541. /*
  1542. * Tape discipline structure for 3590.
  1543. */
  1544. static struct tape_discipline tape_discipline_3590 = {
  1545. .owner = THIS_MODULE,
  1546. .setup_device = tape_3590_setup_device,
  1547. .cleanup_device = tape_3590_cleanup_device,
  1548. .process_eov = tape_std_process_eov,
  1549. .irq = tape_3590_irq,
  1550. .read_block = tape_std_read_block,
  1551. .write_block = tape_std_write_block,
  1552. #ifdef CONFIG_S390_TAPE_BLOCK
  1553. .bread = tape_3590_bread,
  1554. .free_bread = tape_3590_free_bread,
  1555. .check_locate = tape_3590_check_locate,
  1556. #endif
  1557. .ioctl_fn = tape_3590_ioctl,
  1558. .mtop_array = tape_3590_mtop
  1559. };
  1560. static struct ccw_device_id tape_3590_ids[] = {
  1561. {CCW_DEVICE_DEVTYPE(0x3590, 0, 0x3590, 0), .driver_info = tape_3590},
  1562. {CCW_DEVICE_DEVTYPE(0x3592, 0, 0x3592, 0), .driver_info = tape_3592},
  1563. { /* end of list */ }
  1564. };
  1565. static int
  1566. tape_3590_online(struct ccw_device *cdev)
  1567. {
  1568. return tape_generic_online(cdev->dev.driver_data,
  1569. &tape_discipline_3590);
  1570. }
  1571. static int
  1572. tape_3590_offline(struct ccw_device *cdev)
  1573. {
  1574. return tape_generic_offline(cdev->dev.driver_data);
  1575. }
  1576. static struct ccw_driver tape_3590_driver = {
  1577. .name = "tape_3590",
  1578. .owner = THIS_MODULE,
  1579. .ids = tape_3590_ids,
  1580. .probe = tape_generic_probe,
  1581. .remove = tape_generic_remove,
  1582. .set_offline = tape_3590_offline,
  1583. .set_online = tape_3590_online,
  1584. };
  1585. /*
  1586. * Setup discipline structure.
  1587. */
  1588. static int
  1589. tape_3590_init(void)
  1590. {
  1591. int rc;
  1592. TAPE_DBF_AREA = debug_register("tape_3590", 2, 2, 4 * sizeof(long));
  1593. debug_register_view(TAPE_DBF_AREA, &debug_sprintf_view);
  1594. #ifdef DBF_LIKE_HELL
  1595. debug_set_level(TAPE_DBF_AREA, 6);
  1596. #endif
  1597. DBF_EVENT(3, "3590 init\n");
  1598. /* Register driver for 3590 tapes. */
  1599. rc = ccw_driver_register(&tape_3590_driver);
  1600. if (rc)
  1601. DBF_EVENT(3, "3590 init failed\n");
  1602. else
  1603. DBF_EVENT(3, "3590 registered\n");
  1604. return rc;
  1605. }
  1606. static void
  1607. tape_3590_exit(void)
  1608. {
  1609. ccw_driver_unregister(&tape_3590_driver);
  1610. debug_unregister(TAPE_DBF_AREA);
  1611. }
  1612. MODULE_DEVICE_TABLE(ccw, tape_3590_ids);
  1613. MODULE_AUTHOR("(C) 2001,2006 IBM Corporation");
  1614. MODULE_DESCRIPTION("Linux on zSeries channel attached 3590 tape device driver");
  1615. MODULE_LICENSE("GPL");
  1616. module_init(tape_3590_init);
  1617. module_exit(tape_3590_exit);