tape_3590.c 46 KB

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