dasd_3990_erp.c 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721
  1. /*
  2. * File...........: linux/drivers/s390/block/dasd_3990_erp.c
  3. * Author(s)......: Horst Hummel <Horst.Hummel@de.ibm.com>
  4. * Holger Smolinski <Holger.Smolinski@de.ibm.com>
  5. * Bugreports.to..: <Linux390@de.ibm.com>
  6. * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000, 2001
  7. *
  8. */
  9. #define KMSG_COMPONENT "dasd-eckd"
  10. #include <linux/timer.h>
  11. #include <linux/slab.h>
  12. #include <asm/idals.h>
  13. #include <asm/todclk.h>
  14. #define PRINTK_HEADER "dasd_erp(3990): "
  15. #include "dasd_int.h"
  16. #include "dasd_eckd.h"
  17. struct DCTL_data {
  18. unsigned char subcommand; /* e.g Inhibit Write, Enable Write,... */
  19. unsigned char modifier; /* Subcommand modifier */
  20. unsigned short res; /* reserved */
  21. } __attribute__ ((packed));
  22. /*
  23. *****************************************************************************
  24. * SECTION ERP HANDLING
  25. *****************************************************************************
  26. */
  27. /*
  28. *****************************************************************************
  29. * 24 and 32 byte sense ERP functions
  30. *****************************************************************************
  31. */
  32. /*
  33. * DASD_3990_ERP_CLEANUP
  34. *
  35. * DESCRIPTION
  36. * Removes the already build but not necessary ERP request and sets
  37. * the status of the original cqr / erp to the given (final) status
  38. *
  39. * PARAMETER
  40. * erp request to be blocked
  41. * final_status either DASD_CQR_DONE or DASD_CQR_FAILED
  42. *
  43. * RETURN VALUES
  44. * cqr original cqr
  45. */
  46. static struct dasd_ccw_req *
  47. dasd_3990_erp_cleanup(struct dasd_ccw_req * erp, char final_status)
  48. {
  49. struct dasd_ccw_req *cqr = erp->refers;
  50. dasd_free_erp_request(erp, erp->memdev);
  51. cqr->status = final_status;
  52. return cqr;
  53. } /* end dasd_3990_erp_cleanup */
  54. /*
  55. * DASD_3990_ERP_BLOCK_QUEUE
  56. *
  57. * DESCRIPTION
  58. * Block the given device request queue to prevent from further
  59. * processing until the started timer has expired or an related
  60. * interrupt was received.
  61. */
  62. static void
  63. dasd_3990_erp_block_queue(struct dasd_ccw_req * erp, int expires)
  64. {
  65. struct dasd_device *device = erp->startdev;
  66. unsigned long flags;
  67. DBF_DEV_EVENT(DBF_INFO, device,
  68. "blocking request queue for %is", expires/HZ);
  69. spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
  70. device->stopped |= DASD_STOPPED_PENDING;
  71. spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
  72. erp->status = DASD_CQR_FILLED;
  73. dasd_block_set_timer(device->block, expires);
  74. }
  75. /*
  76. * DASD_3990_ERP_INT_REQ
  77. *
  78. * DESCRIPTION
  79. * Handles 'Intervention Required' error.
  80. * This means either device offline or not installed.
  81. *
  82. * PARAMETER
  83. * erp current erp
  84. * RETURN VALUES
  85. * erp modified erp
  86. */
  87. static struct dasd_ccw_req *
  88. dasd_3990_erp_int_req(struct dasd_ccw_req * erp)
  89. {
  90. struct dasd_device *device = erp->startdev;
  91. /* first time set initial retry counter and erp_function */
  92. /* and retry once without blocking queue */
  93. /* (this enables easier enqueing of the cqr) */
  94. if (erp->function != dasd_3990_erp_int_req) {
  95. erp->retries = 256;
  96. erp->function = dasd_3990_erp_int_req;
  97. } else {
  98. /* issue a message and wait for 'device ready' interrupt */
  99. dev_err(&device->cdev->dev,
  100. "is offline or not installed - "
  101. "INTERVENTION REQUIRED!!\n");
  102. dasd_3990_erp_block_queue(erp, 60*HZ);
  103. }
  104. return erp;
  105. } /* end dasd_3990_erp_int_req */
  106. /*
  107. * DASD_3990_ERP_ALTERNATE_PATH
  108. *
  109. * DESCRIPTION
  110. * Repeat the operation on a different channel path.
  111. * If all alternate paths have been tried, the request is posted with a
  112. * permanent error.
  113. *
  114. * PARAMETER
  115. * erp pointer to the current ERP
  116. *
  117. * RETURN VALUES
  118. * erp modified pointer to the ERP
  119. */
  120. static void
  121. dasd_3990_erp_alternate_path(struct dasd_ccw_req * erp)
  122. {
  123. struct dasd_device *device = erp->startdev;
  124. __u8 opm;
  125. unsigned long flags;
  126. /* try alternate valid path */
  127. spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
  128. opm = ccw_device_get_path_mask(device->cdev);
  129. spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
  130. //FIXME: start with get_opm ?
  131. if (erp->lpm == 0)
  132. erp->lpm = LPM_ANYPATH & ~(erp->irb.esw.esw0.sublog.lpum);
  133. else
  134. erp->lpm &= ~(erp->irb.esw.esw0.sublog.lpum);
  135. if ((erp->lpm & opm) != 0x00) {
  136. DBF_DEV_EVENT(DBF_WARNING, device,
  137. "try alternate lpm=%x (lpum=%x / opm=%x)",
  138. erp->lpm, erp->irb.esw.esw0.sublog.lpum, opm);
  139. /* reset status to submit the request again... */
  140. erp->status = DASD_CQR_FILLED;
  141. erp->retries = 10;
  142. } else {
  143. dev_err(&device->cdev->dev,
  144. "The DASD cannot be reached on any path (lpum=%x"
  145. "/opm=%x)\n", erp->irb.esw.esw0.sublog.lpum, opm);
  146. /* post request with permanent error */
  147. erp->status = DASD_CQR_FAILED;
  148. }
  149. } /* end dasd_3990_erp_alternate_path */
  150. /*
  151. * DASD_3990_ERP_DCTL
  152. *
  153. * DESCRIPTION
  154. * Setup cqr to do the Diagnostic Control (DCTL) command with an
  155. * Inhibit Write subcommand (0x20) and the given modifier.
  156. *
  157. * PARAMETER
  158. * erp pointer to the current (failed) ERP
  159. * modifier subcommand modifier
  160. *
  161. * RETURN VALUES
  162. * dctl_cqr pointer to NEW dctl_cqr
  163. *
  164. */
  165. static struct dasd_ccw_req *
  166. dasd_3990_erp_DCTL(struct dasd_ccw_req * erp, char modifier)
  167. {
  168. struct dasd_device *device = erp->startdev;
  169. struct DCTL_data *DCTL_data;
  170. struct ccw1 *ccw;
  171. struct dasd_ccw_req *dctl_cqr;
  172. dctl_cqr = dasd_alloc_erp_request((char *) &erp->magic, 1,
  173. sizeof(struct DCTL_data),
  174. device);
  175. if (IS_ERR(dctl_cqr)) {
  176. dev_err(&device->cdev->dev,
  177. "Unable to allocate DCTL-CQR\n");
  178. erp->status = DASD_CQR_FAILED;
  179. return erp;
  180. }
  181. DCTL_data = dctl_cqr->data;
  182. DCTL_data->subcommand = 0x02; /* Inhibit Write */
  183. DCTL_data->modifier = modifier;
  184. ccw = dctl_cqr->cpaddr;
  185. memset(ccw, 0, sizeof(struct ccw1));
  186. ccw->cmd_code = CCW_CMD_DCTL;
  187. ccw->count = 4;
  188. ccw->cda = (__u32)(addr_t) DCTL_data;
  189. dctl_cqr->function = dasd_3990_erp_DCTL;
  190. dctl_cqr->refers = erp;
  191. dctl_cqr->startdev = device;
  192. dctl_cqr->memdev = device;
  193. dctl_cqr->magic = erp->magic;
  194. dctl_cqr->expires = 5 * 60 * HZ;
  195. dctl_cqr->retries = 2;
  196. dctl_cqr->buildclk = get_clock();
  197. dctl_cqr->status = DASD_CQR_FILLED;
  198. return dctl_cqr;
  199. } /* end dasd_3990_erp_DCTL */
  200. /*
  201. * DASD_3990_ERP_ACTION_1
  202. *
  203. * DESCRIPTION
  204. * Setup ERP to do the ERP action 1 (see Reference manual).
  205. * Repeat the operation on a different channel path.
  206. * If all alternate paths have been tried, the request is posted with a
  207. * permanent error.
  208. * Note: duplex handling is not implemented (yet).
  209. *
  210. * PARAMETER
  211. * erp pointer to the current ERP
  212. *
  213. * RETURN VALUES
  214. * erp pointer to the ERP
  215. *
  216. */
  217. static struct dasd_ccw_req *
  218. dasd_3990_erp_action_1(struct dasd_ccw_req * erp)
  219. {
  220. erp->function = dasd_3990_erp_action_1;
  221. dasd_3990_erp_alternate_path(erp);
  222. return erp;
  223. } /* end dasd_3990_erp_action_1 */
  224. /*
  225. * DASD_3990_ERP_ACTION_4
  226. *
  227. * DESCRIPTION
  228. * Setup ERP to do the ERP action 4 (see Reference manual).
  229. * Set the current request to PENDING to block the CQR queue for that device
  230. * until the state change interrupt appears.
  231. * Use a timer (20 seconds) to retry the cqr if the interrupt is still
  232. * missing.
  233. *
  234. * PARAMETER
  235. * sense sense data of the actual error
  236. * erp pointer to the current ERP
  237. *
  238. * RETURN VALUES
  239. * erp pointer to the ERP
  240. *
  241. */
  242. static struct dasd_ccw_req *
  243. dasd_3990_erp_action_4(struct dasd_ccw_req * erp, char *sense)
  244. {
  245. struct dasd_device *device = erp->startdev;
  246. /* first time set initial retry counter and erp_function */
  247. /* and retry once without waiting for state change pending */
  248. /* interrupt (this enables easier enqueing of the cqr) */
  249. if (erp->function != dasd_3990_erp_action_4) {
  250. DBF_DEV_EVENT(DBF_INFO, device, "%s",
  251. "dasd_3990_erp_action_4: first time retry");
  252. erp->retries = 256;
  253. erp->function = dasd_3990_erp_action_4;
  254. } else {
  255. if (sense && (sense[25] == 0x1D)) { /* state change pending */
  256. DBF_DEV_EVENT(DBF_INFO, device,
  257. "waiting for state change pending "
  258. "interrupt, %d retries left",
  259. erp->retries);
  260. dasd_3990_erp_block_queue(erp, 30*HZ);
  261. } else if (sense && (sense[25] == 0x1E)) { /* busy */
  262. DBF_DEV_EVENT(DBF_INFO, device,
  263. "busy - redriving request later, "
  264. "%d retries left",
  265. erp->retries);
  266. dasd_3990_erp_block_queue(erp, HZ);
  267. } else {
  268. /* no state change pending - retry */
  269. DBF_DEV_EVENT(DBF_INFO, device,
  270. "redriving request immediately, "
  271. "%d retries left",
  272. erp->retries);
  273. erp->status = DASD_CQR_FILLED;
  274. }
  275. }
  276. return erp;
  277. } /* end dasd_3990_erp_action_4 */
  278. /*
  279. *****************************************************************************
  280. * 24 byte sense ERP functions (only)
  281. *****************************************************************************
  282. */
  283. /*
  284. * DASD_3990_ERP_ACTION_5
  285. *
  286. * DESCRIPTION
  287. * Setup ERP to do the ERP action 5 (see Reference manual).
  288. * NOTE: Further handling is done in xxx_further_erp after the retries.
  289. *
  290. * PARAMETER
  291. * erp pointer to the current ERP
  292. *
  293. * RETURN VALUES
  294. * erp pointer to the ERP
  295. *
  296. */
  297. static struct dasd_ccw_req *
  298. dasd_3990_erp_action_5(struct dasd_ccw_req * erp)
  299. {
  300. /* first of all retry */
  301. erp->retries = 10;
  302. erp->function = dasd_3990_erp_action_5;
  303. return erp;
  304. } /* end dasd_3990_erp_action_5 */
  305. /*
  306. * DASD_3990_HANDLE_ENV_DATA
  307. *
  308. * DESCRIPTION
  309. * Handles 24 byte 'Environmental data present'.
  310. * Does a analysis of the sense data (message Format)
  311. * and prints the error messages.
  312. *
  313. * PARAMETER
  314. * sense current sense data
  315. *
  316. * RETURN VALUES
  317. * void
  318. */
  319. static void
  320. dasd_3990_handle_env_data(struct dasd_ccw_req * erp, char *sense)
  321. {
  322. struct dasd_device *device = erp->startdev;
  323. char msg_format = (sense[7] & 0xF0);
  324. char msg_no = (sense[7] & 0x0F);
  325. char errorstring[ERRORLENGTH];
  326. switch (msg_format) {
  327. case 0x00: /* Format 0 - Program or System Checks */
  328. if (sense[1] & 0x10) { /* check message to operator bit */
  329. switch (msg_no) {
  330. case 0x00: /* No Message */
  331. break;
  332. case 0x01:
  333. dev_warn(&device->cdev->dev,
  334. "FORMAT 0 - Invalid Command\n");
  335. break;
  336. case 0x02:
  337. dev_warn(&device->cdev->dev,
  338. "FORMAT 0 - Invalid Command "
  339. "Sequence\n");
  340. break;
  341. case 0x03:
  342. dev_warn(&device->cdev->dev,
  343. "FORMAT 0 - CCW Count less than "
  344. "required\n");
  345. break;
  346. case 0x04:
  347. dev_warn(&device->cdev->dev,
  348. "FORMAT 0 - Invalid Parameter\n");
  349. break;
  350. case 0x05:
  351. dev_warn(&device->cdev->dev,
  352. "FORMAT 0 - Diagnostic of Special"
  353. " Command Violates File Mask\n");
  354. break;
  355. case 0x07:
  356. dev_warn(&device->cdev->dev,
  357. "FORMAT 0 - Channel Returned with "
  358. "Incorrect retry CCW\n");
  359. break;
  360. case 0x08:
  361. dev_warn(&device->cdev->dev,
  362. "FORMAT 0 - Reset Notification\n");
  363. break;
  364. case 0x09:
  365. dev_warn(&device->cdev->dev,
  366. "FORMAT 0 - Storage Path Restart\n");
  367. break;
  368. case 0x0A:
  369. dev_warn(&device->cdev->dev,
  370. "FORMAT 0 - Channel requested "
  371. "... %02x\n", sense[8]);
  372. break;
  373. case 0x0B:
  374. dev_warn(&device->cdev->dev,
  375. "FORMAT 0 - Invalid Defective/"
  376. "Alternate Track Pointer\n");
  377. break;
  378. case 0x0C:
  379. dev_warn(&device->cdev->dev,
  380. "FORMAT 0 - DPS Installation "
  381. "Check\n");
  382. break;
  383. case 0x0E:
  384. dev_warn(&device->cdev->dev,
  385. "FORMAT 0 - Command Invalid on "
  386. "Secondary Address\n");
  387. break;
  388. case 0x0F:
  389. dev_warn(&device->cdev->dev,
  390. "FORMAT 0 - Status Not As "
  391. "Required: reason %02x\n",
  392. sense[8]);
  393. break;
  394. default:
  395. dev_warn(&device->cdev->dev,
  396. "FORMAT 0 - Reserved\n");
  397. }
  398. } else {
  399. switch (msg_no) {
  400. case 0x00: /* No Message */
  401. break;
  402. case 0x01:
  403. dev_warn(&device->cdev->dev,
  404. "FORMAT 0 - Device Error "
  405. "Source\n");
  406. break;
  407. case 0x02:
  408. dev_warn(&device->cdev->dev,
  409. "FORMAT 0 - Reserved\n");
  410. break;
  411. case 0x03:
  412. dev_warn(&device->cdev->dev,
  413. "FORMAT 0 - Device Fenced - "
  414. "device = %02x\n", sense[4]);
  415. break;
  416. case 0x04:
  417. dev_warn(&device->cdev->dev,
  418. "FORMAT 0 - Data Pinned for "
  419. "Device\n");
  420. break;
  421. default:
  422. dev_warn(&device->cdev->dev,
  423. "FORMAT 0 - Reserved\n");
  424. }
  425. }
  426. break;
  427. case 0x10: /* Format 1 - Device Equipment Checks */
  428. switch (msg_no) {
  429. case 0x00: /* No Message */
  430. break;
  431. case 0x01:
  432. dev_warn(&device->cdev->dev,
  433. "FORMAT 1 - Device Status 1 not as "
  434. "expected\n");
  435. break;
  436. case 0x03:
  437. dev_warn(&device->cdev->dev,
  438. "FORMAT 1 - Index missing\n");
  439. break;
  440. case 0x04:
  441. dev_warn(&device->cdev->dev,
  442. "FORMAT 1 - Interruption cannot be "
  443. "reset\n");
  444. break;
  445. case 0x05:
  446. dev_warn(&device->cdev->dev,
  447. "FORMAT 1 - Device did not respond to "
  448. "selection\n");
  449. break;
  450. case 0x06:
  451. dev_warn(&device->cdev->dev,
  452. "FORMAT 1 - Device check-2 error or Set "
  453. "Sector is not complete\n");
  454. break;
  455. case 0x07:
  456. dev_warn(&device->cdev->dev,
  457. "FORMAT 1 - Head address does not "
  458. "compare\n");
  459. break;
  460. case 0x08:
  461. dev_warn(&device->cdev->dev,
  462. "FORMAT 1 - Device status 1 not valid\n");
  463. break;
  464. case 0x09:
  465. dev_warn(&device->cdev->dev,
  466. "FORMAT 1 - Device not ready\n");
  467. break;
  468. case 0x0A:
  469. dev_warn(&device->cdev->dev,
  470. "FORMAT 1 - Track physical address did "
  471. "not compare\n");
  472. break;
  473. case 0x0B:
  474. dev_warn(&device->cdev->dev,
  475. "FORMAT 1 - Missing device address bit\n");
  476. break;
  477. case 0x0C:
  478. dev_warn(&device->cdev->dev,
  479. "FORMAT 1 - Drive motor switch is off\n");
  480. break;
  481. case 0x0D:
  482. dev_warn(&device->cdev->dev,
  483. "FORMAT 1 - Seek incomplete\n");
  484. break;
  485. case 0x0E:
  486. dev_warn(&device->cdev->dev,
  487. "FORMAT 1 - Cylinder address did not "
  488. "compare\n");
  489. break;
  490. case 0x0F:
  491. dev_warn(&device->cdev->dev,
  492. "FORMAT 1 - Offset active cannot be "
  493. "reset\n");
  494. break;
  495. default:
  496. dev_warn(&device->cdev->dev,
  497. "FORMAT 1 - Reserved\n");
  498. }
  499. break;
  500. case 0x20: /* Format 2 - 3990 Equipment Checks */
  501. switch (msg_no) {
  502. case 0x08:
  503. dev_warn(&device->cdev->dev,
  504. "FORMAT 2 - 3990 check-2 error\n");
  505. break;
  506. case 0x0E:
  507. dev_warn(&device->cdev->dev,
  508. "FORMAT 2 - Support facility errors\n");
  509. break;
  510. case 0x0F:
  511. dev_warn(&device->cdev->dev,
  512. "FORMAT 2 - Microcode detected error "
  513. "%02x\n",
  514. sense[8]);
  515. break;
  516. default:
  517. dev_warn(&device->cdev->dev,
  518. "FORMAT 2 - Reserved\n");
  519. }
  520. break;
  521. case 0x30: /* Format 3 - 3990 Control Checks */
  522. switch (msg_no) {
  523. case 0x0F:
  524. dev_warn(&device->cdev->dev,
  525. "FORMAT 3 - Allegiance terminated\n");
  526. break;
  527. default:
  528. dev_warn(&device->cdev->dev,
  529. "FORMAT 3 - Reserved\n");
  530. }
  531. break;
  532. case 0x40: /* Format 4 - Data Checks */
  533. switch (msg_no) {
  534. case 0x00:
  535. dev_warn(&device->cdev->dev,
  536. "FORMAT 4 - Home address area error\n");
  537. break;
  538. case 0x01:
  539. dev_warn(&device->cdev->dev,
  540. "FORMAT 4 - Count area error\n");
  541. break;
  542. case 0x02:
  543. dev_warn(&device->cdev->dev,
  544. "FORMAT 4 - Key area error\n");
  545. break;
  546. case 0x03:
  547. dev_warn(&device->cdev->dev,
  548. "FORMAT 4 - Data area error\n");
  549. break;
  550. case 0x04:
  551. dev_warn(&device->cdev->dev,
  552. "FORMAT 4 - No sync byte in home address "
  553. "area\n");
  554. break;
  555. case 0x05:
  556. dev_warn(&device->cdev->dev,
  557. "FORMAT 4 - No sync byte in count address "
  558. "area\n");
  559. break;
  560. case 0x06:
  561. dev_warn(&device->cdev->dev,
  562. "FORMAT 4 - No sync byte in key area\n");
  563. break;
  564. case 0x07:
  565. dev_warn(&device->cdev->dev,
  566. "FORMAT 4 - No sync byte in data area\n");
  567. break;
  568. case 0x08:
  569. dev_warn(&device->cdev->dev,
  570. "FORMAT 4 - Home address area error; "
  571. "offset active\n");
  572. break;
  573. case 0x09:
  574. dev_warn(&device->cdev->dev,
  575. "FORMAT 4 - Count area error; offset "
  576. "active\n");
  577. break;
  578. case 0x0A:
  579. dev_warn(&device->cdev->dev,
  580. "FORMAT 4 - Key area error; offset "
  581. "active\n");
  582. break;
  583. case 0x0B:
  584. dev_warn(&device->cdev->dev,
  585. "FORMAT 4 - Data area error; "
  586. "offset active\n");
  587. break;
  588. case 0x0C:
  589. dev_warn(&device->cdev->dev,
  590. "FORMAT 4 - No sync byte in home "
  591. "address area; offset active\n");
  592. break;
  593. case 0x0D:
  594. dev_warn(&device->cdev->dev,
  595. "FORMAT 4 - No syn byte in count "
  596. "address area; offset active\n");
  597. break;
  598. case 0x0E:
  599. dev_warn(&device->cdev->dev,
  600. "FORMAT 4 - No sync byte in key area; "
  601. "offset active\n");
  602. break;
  603. case 0x0F:
  604. dev_warn(&device->cdev->dev,
  605. "FORMAT 4 - No syn byte in data area; "
  606. "offset active\n");
  607. break;
  608. default:
  609. dev_warn(&device->cdev->dev,
  610. "FORMAT 4 - Reserved\n");
  611. }
  612. break;
  613. case 0x50: /* Format 5 - Data Check with displacement information */
  614. switch (msg_no) {
  615. case 0x00:
  616. dev_warn(&device->cdev->dev,
  617. "FORMAT 5 - Data Check in the "
  618. "home address area\n");
  619. break;
  620. case 0x01:
  621. dev_warn(&device->cdev->dev,
  622. "FORMAT 5 - Data Check in the count "
  623. "area\n");
  624. break;
  625. case 0x02:
  626. dev_warn(&device->cdev->dev,
  627. "FORMAT 5 - Data Check in the key area\n");
  628. break;
  629. case 0x03:
  630. dev_warn(&device->cdev->dev,
  631. "FORMAT 5 - Data Check in the data "
  632. "area\n");
  633. break;
  634. case 0x08:
  635. dev_warn(&device->cdev->dev,
  636. "FORMAT 5 - Data Check in the "
  637. "home address area; offset active\n");
  638. break;
  639. case 0x09:
  640. dev_warn(&device->cdev->dev,
  641. "FORMAT 5 - Data Check in the count area; "
  642. "offset active\n");
  643. break;
  644. case 0x0A:
  645. dev_warn(&device->cdev->dev,
  646. "FORMAT 5 - Data Check in the key area; "
  647. "offset active\n");
  648. break;
  649. case 0x0B:
  650. dev_warn(&device->cdev->dev,
  651. "FORMAT 5 - Data Check in the data area; "
  652. "offset active\n");
  653. break;
  654. default:
  655. dev_warn(&device->cdev->dev,
  656. "FORMAT 5 - Reserved\n");
  657. }
  658. break;
  659. case 0x60: /* Format 6 - Usage Statistics/Overrun Errors */
  660. switch (msg_no) {
  661. case 0x00:
  662. dev_warn(&device->cdev->dev,
  663. "FORMAT 6 - Overrun on channel A\n");
  664. break;
  665. case 0x01:
  666. dev_warn(&device->cdev->dev,
  667. "FORMAT 6 - Overrun on channel B\n");
  668. break;
  669. case 0x02:
  670. dev_warn(&device->cdev->dev,
  671. "FORMAT 6 - Overrun on channel C\n");
  672. break;
  673. case 0x03:
  674. dev_warn(&device->cdev->dev,
  675. "FORMAT 6 - Overrun on channel D\n");
  676. break;
  677. case 0x04:
  678. dev_warn(&device->cdev->dev,
  679. "FORMAT 6 - Overrun on channel E\n");
  680. break;
  681. case 0x05:
  682. dev_warn(&device->cdev->dev,
  683. "FORMAT 6 - Overrun on channel F\n");
  684. break;
  685. case 0x06:
  686. dev_warn(&device->cdev->dev,
  687. "FORMAT 6 - Overrun on channel G\n");
  688. break;
  689. case 0x07:
  690. dev_warn(&device->cdev->dev,
  691. "FORMAT 6 - Overrun on channel H\n");
  692. break;
  693. default:
  694. dev_warn(&device->cdev->dev,
  695. "FORMAT 6 - Reserved\n");
  696. }
  697. break;
  698. case 0x70: /* Format 7 - Device Connection Control Checks */
  699. switch (msg_no) {
  700. case 0x00:
  701. dev_warn(&device->cdev->dev,
  702. "FORMAT 7 - RCC initiated by a connection "
  703. "check alert\n");
  704. break;
  705. case 0x01:
  706. dev_warn(&device->cdev->dev,
  707. "FORMAT 7 - RCC 1 sequence not "
  708. "successful\n");
  709. break;
  710. case 0x02:
  711. dev_warn(&device->cdev->dev,
  712. "FORMAT 7 - RCC 1 and RCC 2 sequences not "
  713. "successful\n");
  714. break;
  715. case 0x03:
  716. dev_warn(&device->cdev->dev,
  717. "FORMAT 7 - Invalid tag-in during "
  718. "selection sequence\n");
  719. break;
  720. case 0x04:
  721. dev_warn(&device->cdev->dev,
  722. "FORMAT 7 - extra RCC required\n");
  723. break;
  724. case 0x05:
  725. dev_warn(&device->cdev->dev,
  726. "FORMAT 7 - Invalid DCC selection "
  727. "response or timeout\n");
  728. break;
  729. case 0x06:
  730. dev_warn(&device->cdev->dev,
  731. "FORMAT 7 - Missing end operation; device "
  732. "transfer complete\n");
  733. break;
  734. case 0x07:
  735. dev_warn(&device->cdev->dev,
  736. "FORMAT 7 - Missing end operation; device "
  737. "transfer incomplete\n");
  738. break;
  739. case 0x08:
  740. dev_warn(&device->cdev->dev,
  741. "FORMAT 7 - Invalid tag-in for an "
  742. "immediate command sequence\n");
  743. break;
  744. case 0x09:
  745. dev_warn(&device->cdev->dev,
  746. "FORMAT 7 - Invalid tag-in for an "
  747. "extended command sequence\n");
  748. break;
  749. case 0x0A:
  750. dev_warn(&device->cdev->dev,
  751. "FORMAT 7 - 3990 microcode time out when "
  752. "stopping selection\n");
  753. break;
  754. case 0x0B:
  755. dev_warn(&device->cdev->dev,
  756. "FORMAT 7 - No response to selection "
  757. "after a poll interruption\n");
  758. break;
  759. case 0x0C:
  760. dev_warn(&device->cdev->dev,
  761. "FORMAT 7 - Permanent path error (DASD "
  762. "controller not available)\n");
  763. break;
  764. case 0x0D:
  765. dev_warn(&device->cdev->dev,
  766. "FORMAT 7 - DASD controller not available"
  767. " on disconnected command chain\n");
  768. break;
  769. default:
  770. dev_warn(&device->cdev->dev,
  771. "FORMAT 7 - Reserved\n");
  772. }
  773. break;
  774. case 0x80: /* Format 8 - Additional Device Equipment Checks */
  775. switch (msg_no) {
  776. case 0x00: /* No Message */
  777. case 0x01:
  778. dev_warn(&device->cdev->dev,
  779. "FORMAT 8 - Error correction code "
  780. "hardware fault\n");
  781. break;
  782. case 0x03:
  783. dev_warn(&device->cdev->dev,
  784. "FORMAT 8 - Unexpected end operation "
  785. "response code\n");
  786. break;
  787. case 0x04:
  788. dev_warn(&device->cdev->dev,
  789. "FORMAT 8 - End operation with transfer "
  790. "count not zero\n");
  791. break;
  792. case 0x05:
  793. dev_warn(&device->cdev->dev,
  794. "FORMAT 8 - End operation with transfer "
  795. "count zero\n");
  796. break;
  797. case 0x06:
  798. dev_warn(&device->cdev->dev,
  799. "FORMAT 8 - DPS checks after a system "
  800. "reset or selective reset\n");
  801. break;
  802. case 0x07:
  803. dev_warn(&device->cdev->dev,
  804. "FORMAT 8 - DPS cannot be filled\n");
  805. break;
  806. case 0x08:
  807. dev_warn(&device->cdev->dev,
  808. "FORMAT 8 - Short busy time-out during "
  809. "device selection\n");
  810. break;
  811. case 0x09:
  812. dev_warn(&device->cdev->dev,
  813. "FORMAT 8 - DASD controller failed to "
  814. "set or reset the long busy latch\n");
  815. break;
  816. case 0x0A:
  817. dev_warn(&device->cdev->dev,
  818. "FORMAT 8 - No interruption from device "
  819. "during a command chain\n");
  820. break;
  821. default:
  822. dev_warn(&device->cdev->dev,
  823. "FORMAT 8 - Reserved\n");
  824. }
  825. break;
  826. case 0x90: /* Format 9 - Device Read, Write, and Seek Checks */
  827. switch (msg_no) {
  828. case 0x00:
  829. break; /* No Message */
  830. case 0x06:
  831. dev_warn(&device->cdev->dev,
  832. "FORMAT 9 - Device check-2 error\n");
  833. break;
  834. case 0x07:
  835. dev_warn(&device->cdev->dev,
  836. "FORMAT 9 - Head address did not "
  837. "compare\n");
  838. break;
  839. case 0x0A:
  840. dev_warn(&device->cdev->dev,
  841. "FORMAT 9 - Track physical address did "
  842. "not compare while oriented\n");
  843. break;
  844. case 0x0E:
  845. dev_warn(&device->cdev->dev,
  846. "FORMAT 9 - Cylinder address did not "
  847. "compare\n");
  848. break;
  849. default:
  850. dev_warn(&device->cdev->dev,
  851. "FORMAT 9 - Reserved\n");
  852. }
  853. break;
  854. case 0xF0: /* Format F - Cache Storage Checks */
  855. switch (msg_no) {
  856. case 0x00:
  857. dev_warn(&device->cdev->dev,
  858. "FORMAT F - Operation Terminated\n");
  859. break;
  860. case 0x01:
  861. dev_warn(&device->cdev->dev,
  862. "FORMAT F - Subsystem Processing Error\n");
  863. break;
  864. case 0x02:
  865. dev_warn(&device->cdev->dev,
  866. "FORMAT F - Cache or nonvolatile storage "
  867. "equipment failure\n");
  868. break;
  869. case 0x04:
  870. dev_warn(&device->cdev->dev,
  871. "FORMAT F - Caching terminated\n");
  872. break;
  873. case 0x06:
  874. dev_warn(&device->cdev->dev,
  875. "FORMAT F - Cache fast write access not "
  876. "authorized\n");
  877. break;
  878. case 0x07:
  879. dev_warn(&device->cdev->dev,
  880. "FORMAT F - Track format incorrect\n");
  881. break;
  882. case 0x09:
  883. dev_warn(&device->cdev->dev,
  884. "FORMAT F - Caching reinitiated\n");
  885. break;
  886. case 0x0A:
  887. dev_warn(&device->cdev->dev,
  888. "FORMAT F - Nonvolatile storage "
  889. "terminated\n");
  890. break;
  891. case 0x0B:
  892. dev_warn(&device->cdev->dev,
  893. "FORMAT F - Volume is suspended duplex\n");
  894. /* call extended error reporting (EER) */
  895. dasd_eer_write(device, erp->refers,
  896. DASD_EER_PPRCSUSPEND);
  897. break;
  898. case 0x0C:
  899. dev_warn(&device->cdev->dev,
  900. "FORMAT F - Subsystem status cannot be "
  901. "determined\n");
  902. break;
  903. case 0x0D:
  904. dev_warn(&device->cdev->dev,
  905. "FORMAT F - Caching status reset to "
  906. "default\n");
  907. break;
  908. case 0x0E:
  909. dev_warn(&device->cdev->dev,
  910. "FORMAT F - DASD Fast Write inhibited\n");
  911. break;
  912. default:
  913. dev_warn(&device->cdev->dev,
  914. "FORMAT D - Reserved\n");
  915. }
  916. break;
  917. default: /* unknown message format - should not happen
  918. internal error 03 - unknown message format */
  919. snprintf(errorstring, ERRORLENGTH, "03 %x02", msg_format);
  920. dev_err(&device->cdev->dev,
  921. "An error occurred in the DASD device driver, "
  922. "reason=%s\n", errorstring);
  923. break;
  924. } /* end switch message format */
  925. } /* end dasd_3990_handle_env_data */
  926. /*
  927. * DASD_3990_ERP_COM_REJ
  928. *
  929. * DESCRIPTION
  930. * Handles 24 byte 'Command Reject' error.
  931. *
  932. * PARAMETER
  933. * erp current erp_head
  934. * sense current sense data
  935. *
  936. * RETURN VALUES
  937. * erp 'new' erp_head - pointer to new ERP
  938. */
  939. static struct dasd_ccw_req *
  940. dasd_3990_erp_com_rej(struct dasd_ccw_req * erp, char *sense)
  941. {
  942. struct dasd_device *device = erp->startdev;
  943. erp->function = dasd_3990_erp_com_rej;
  944. /* env data present (ACTION 10 - retry should work) */
  945. if (sense[2] & SNS2_ENV_DATA_PRESENT) {
  946. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  947. "Command Reject - environmental data present");
  948. dasd_3990_handle_env_data(erp, sense);
  949. erp->retries = 5;
  950. } else {
  951. /* fatal error - set status to FAILED
  952. internal error 09 - Command Reject */
  953. dev_err(&device->cdev->dev, "An error occurred in the DASD "
  954. "device driver, reason=%s\n", "09");
  955. erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  956. }
  957. return erp;
  958. } /* end dasd_3990_erp_com_rej */
  959. /*
  960. * DASD_3990_ERP_BUS_OUT
  961. *
  962. * DESCRIPTION
  963. * Handles 24 byte 'Bus Out Parity Check' error.
  964. *
  965. * PARAMETER
  966. * erp current erp_head
  967. * RETURN VALUES
  968. * erp new erp_head - pointer to new ERP
  969. */
  970. static struct dasd_ccw_req *
  971. dasd_3990_erp_bus_out(struct dasd_ccw_req * erp)
  972. {
  973. struct dasd_device *device = erp->startdev;
  974. /* first time set initial retry counter and erp_function */
  975. /* and retry once without blocking queue */
  976. /* (this enables easier enqueing of the cqr) */
  977. if (erp->function != dasd_3990_erp_bus_out) {
  978. erp->retries = 256;
  979. erp->function = dasd_3990_erp_bus_out;
  980. } else {
  981. /* issue a message and wait for 'device ready' interrupt */
  982. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  983. "bus out parity error or BOPC requested by "
  984. "channel");
  985. dasd_3990_erp_block_queue(erp, 60*HZ);
  986. }
  987. return erp;
  988. } /* end dasd_3990_erp_bus_out */
  989. /*
  990. * DASD_3990_ERP_EQUIP_CHECK
  991. *
  992. * DESCRIPTION
  993. * Handles 24 byte 'Equipment Check' error.
  994. *
  995. * PARAMETER
  996. * erp current erp_head
  997. * RETURN VALUES
  998. * erp new erp_head - pointer to new ERP
  999. */
  1000. static struct dasd_ccw_req *
  1001. dasd_3990_erp_equip_check(struct dasd_ccw_req * erp, char *sense)
  1002. {
  1003. struct dasd_device *device = erp->startdev;
  1004. erp->function = dasd_3990_erp_equip_check;
  1005. if (sense[1] & SNS1_WRITE_INHIBITED) {
  1006. dev_info(&device->cdev->dev,
  1007. "Write inhibited path encountered\n");
  1008. /* vary path offline
  1009. internal error 04 - Path should be varied off-line.*/
  1010. dev_err(&device->cdev->dev, "An error occurred in the DASD "
  1011. "device driver, reason=%s\n", "04");
  1012. erp = dasd_3990_erp_action_1(erp);
  1013. } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
  1014. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1015. "Equipment Check - " "environmental data present");
  1016. dasd_3990_handle_env_data(erp, sense);
  1017. erp = dasd_3990_erp_action_4(erp, sense);
  1018. } else if (sense[1] & SNS1_PERM_ERR) {
  1019. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1020. "Equipment Check - retry exhausted or "
  1021. "undesirable");
  1022. erp = dasd_3990_erp_action_1(erp);
  1023. } else {
  1024. /* all other equipment checks - Action 5 */
  1025. /* rest is done when retries == 0 */
  1026. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1027. "Equipment check or processing error");
  1028. erp = dasd_3990_erp_action_5(erp);
  1029. }
  1030. return erp;
  1031. } /* end dasd_3990_erp_equip_check */
  1032. /*
  1033. * DASD_3990_ERP_DATA_CHECK
  1034. *
  1035. * DESCRIPTION
  1036. * Handles 24 byte 'Data Check' error.
  1037. *
  1038. * PARAMETER
  1039. * erp current erp_head
  1040. * RETURN VALUES
  1041. * erp new erp_head - pointer to new ERP
  1042. */
  1043. static struct dasd_ccw_req *
  1044. dasd_3990_erp_data_check(struct dasd_ccw_req * erp, char *sense)
  1045. {
  1046. struct dasd_device *device = erp->startdev;
  1047. erp->function = dasd_3990_erp_data_check;
  1048. if (sense[2] & SNS2_CORRECTABLE) { /* correctable data check */
  1049. /* issue message that the data has been corrected */
  1050. dev_emerg(&device->cdev->dev,
  1051. "Data recovered during retry with PCI "
  1052. "fetch mode active\n");
  1053. /* not possible to handle this situation in Linux */
  1054. panic("No way to inform application about the possibly "
  1055. "incorrect data");
  1056. } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
  1057. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1058. "Uncorrectable data check recovered secondary "
  1059. "addr of duplex pair");
  1060. erp = dasd_3990_erp_action_4(erp, sense);
  1061. } else if (sense[1] & SNS1_PERM_ERR) {
  1062. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1063. "Uncorrectable data check with internal "
  1064. "retry exhausted");
  1065. erp = dasd_3990_erp_action_1(erp);
  1066. } else {
  1067. /* all other data checks */
  1068. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1069. "Uncorrectable data check with retry count "
  1070. "exhausted...");
  1071. erp = dasd_3990_erp_action_5(erp);
  1072. }
  1073. return erp;
  1074. } /* end dasd_3990_erp_data_check */
  1075. /*
  1076. * DASD_3990_ERP_OVERRUN
  1077. *
  1078. * DESCRIPTION
  1079. * Handles 24 byte 'Overrun' error.
  1080. *
  1081. * PARAMETER
  1082. * erp current erp_head
  1083. * RETURN VALUES
  1084. * erp new erp_head - pointer to new ERP
  1085. */
  1086. static struct dasd_ccw_req *
  1087. dasd_3990_erp_overrun(struct dasd_ccw_req * erp, char *sense)
  1088. {
  1089. struct dasd_device *device = erp->startdev;
  1090. erp->function = dasd_3990_erp_overrun;
  1091. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1092. "Overrun - service overrun or overrun"
  1093. " error requested by channel");
  1094. erp = dasd_3990_erp_action_5(erp);
  1095. return erp;
  1096. } /* end dasd_3990_erp_overrun */
  1097. /*
  1098. * DASD_3990_ERP_INV_FORMAT
  1099. *
  1100. * DESCRIPTION
  1101. * Handles 24 byte 'Invalid Track Format' error.
  1102. *
  1103. * PARAMETER
  1104. * erp current erp_head
  1105. * RETURN VALUES
  1106. * erp new erp_head - pointer to new ERP
  1107. */
  1108. static struct dasd_ccw_req *
  1109. dasd_3990_erp_inv_format(struct dasd_ccw_req * erp, char *sense)
  1110. {
  1111. struct dasd_device *device = erp->startdev;
  1112. erp->function = dasd_3990_erp_inv_format;
  1113. if (sense[2] & SNS2_ENV_DATA_PRESENT) {
  1114. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1115. "Track format error when destaging or "
  1116. "staging data");
  1117. dasd_3990_handle_env_data(erp, sense);
  1118. erp = dasd_3990_erp_action_4(erp, sense);
  1119. } else {
  1120. /* internal error 06 - The track format is not valid*/
  1121. dev_err(&device->cdev->dev,
  1122. "An error occurred in the DASD device driver, "
  1123. "reason=%s\n", "06");
  1124. erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  1125. }
  1126. return erp;
  1127. } /* end dasd_3990_erp_inv_format */
  1128. /*
  1129. * DASD_3990_ERP_EOC
  1130. *
  1131. * DESCRIPTION
  1132. * Handles 24 byte 'End-of-Cylinder' error.
  1133. *
  1134. * PARAMETER
  1135. * erp already added default erp
  1136. * RETURN VALUES
  1137. * erp pointer to original (failed) cqr.
  1138. */
  1139. static struct dasd_ccw_req *
  1140. dasd_3990_erp_EOC(struct dasd_ccw_req * default_erp, char *sense)
  1141. {
  1142. struct dasd_device *device = default_erp->startdev;
  1143. dev_err(&device->cdev->dev,
  1144. "The cylinder data for accessing the DASD is inconsistent\n");
  1145. /* implement action 7 - BUG */
  1146. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1147. } /* end dasd_3990_erp_EOC */
  1148. /*
  1149. * DASD_3990_ERP_ENV_DATA
  1150. *
  1151. * DESCRIPTION
  1152. * Handles 24 byte 'Environmental-Data Present' error.
  1153. *
  1154. * PARAMETER
  1155. * erp current erp_head
  1156. * RETURN VALUES
  1157. * erp new erp_head - pointer to new ERP
  1158. */
  1159. static struct dasd_ccw_req *
  1160. dasd_3990_erp_env_data(struct dasd_ccw_req * erp, char *sense)
  1161. {
  1162. struct dasd_device *device = erp->startdev;
  1163. erp->function = dasd_3990_erp_env_data;
  1164. DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Environmental data present");
  1165. dasd_3990_handle_env_data(erp, sense);
  1166. /* don't retry on disabled interface */
  1167. if (sense[7] != 0x0F) {
  1168. erp = dasd_3990_erp_action_4(erp, sense);
  1169. } else {
  1170. erp->status = DASD_CQR_FILLED;
  1171. }
  1172. return erp;
  1173. } /* end dasd_3990_erp_env_data */
  1174. /*
  1175. * DASD_3990_ERP_NO_REC
  1176. *
  1177. * DESCRIPTION
  1178. * Handles 24 byte 'No Record Found' error.
  1179. *
  1180. * PARAMETER
  1181. * erp already added default ERP
  1182. *
  1183. * RETURN VALUES
  1184. * erp new erp_head - pointer to new ERP
  1185. */
  1186. static struct dasd_ccw_req *
  1187. dasd_3990_erp_no_rec(struct dasd_ccw_req * default_erp, char *sense)
  1188. {
  1189. struct dasd_device *device = default_erp->startdev;
  1190. dev_err(&device->cdev->dev,
  1191. "The specified record was not found\n");
  1192. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1193. } /* end dasd_3990_erp_no_rec */
  1194. /*
  1195. * DASD_3990_ERP_FILE_PROT
  1196. *
  1197. * DESCRIPTION
  1198. * Handles 24 byte 'File Protected' error.
  1199. * Note: Seek related recovery is not implemented because
  1200. * wee don't use the seek command yet.
  1201. *
  1202. * PARAMETER
  1203. * erp current erp_head
  1204. * RETURN VALUES
  1205. * erp new erp_head - pointer to new ERP
  1206. */
  1207. static struct dasd_ccw_req *
  1208. dasd_3990_erp_file_prot(struct dasd_ccw_req * erp)
  1209. {
  1210. struct dasd_device *device = erp->startdev;
  1211. dev_err(&device->cdev->dev, "Accessing the DASD failed because of "
  1212. "a hardware error\n");
  1213. return dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  1214. } /* end dasd_3990_erp_file_prot */
  1215. /*
  1216. * DASD_3990_ERP_INSPECT_ALIAS
  1217. *
  1218. * DESCRIPTION
  1219. * Checks if the original request was started on an alias device.
  1220. * If yes, it modifies the original and the erp request so that
  1221. * the erp request can be started on a base device.
  1222. *
  1223. * PARAMETER
  1224. * erp pointer to the currently created default ERP
  1225. *
  1226. * RETURN VALUES
  1227. * erp pointer to the modified ERP, or NULL
  1228. */
  1229. static struct dasd_ccw_req *dasd_3990_erp_inspect_alias(
  1230. struct dasd_ccw_req *erp)
  1231. {
  1232. struct dasd_ccw_req *cqr = erp->refers;
  1233. if (cqr->block &&
  1234. (cqr->block->base != cqr->startdev)) {
  1235. if (cqr->startdev->features & DASD_FEATURE_ERPLOG) {
  1236. DBF_DEV_EVENT(DBF_ERR, cqr->startdev,
  1237. "ERP on alias device for request %p,"
  1238. " recover on base device %s", cqr,
  1239. dev_name(&cqr->block->base->cdev->dev));
  1240. }
  1241. dasd_eckd_reset_ccw_to_base_io(cqr);
  1242. erp->startdev = cqr->block->base;
  1243. erp->function = dasd_3990_erp_inspect_alias;
  1244. return erp;
  1245. } else
  1246. return NULL;
  1247. }
  1248. /*
  1249. * DASD_3990_ERP_INSPECT_24
  1250. *
  1251. * DESCRIPTION
  1252. * Does a detailed inspection of the 24 byte sense data
  1253. * and sets up a related error recovery action.
  1254. *
  1255. * PARAMETER
  1256. * sense sense data of the actual error
  1257. * erp pointer to the currently created default ERP
  1258. *
  1259. * RETURN VALUES
  1260. * erp pointer to the (addtitional) ERP
  1261. */
  1262. static struct dasd_ccw_req *
  1263. dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense)
  1264. {
  1265. struct dasd_ccw_req *erp_filled = NULL;
  1266. /* Check sense for .... */
  1267. /* 'Command Reject' */
  1268. if ((erp_filled == NULL) && (sense[0] & SNS0_CMD_REJECT)) {
  1269. erp_filled = dasd_3990_erp_com_rej(erp, sense);
  1270. }
  1271. /* 'Intervention Required' */
  1272. if ((erp_filled == NULL) && (sense[0] & SNS0_INTERVENTION_REQ)) {
  1273. erp_filled = dasd_3990_erp_int_req(erp);
  1274. }
  1275. /* 'Bus Out Parity Check' */
  1276. if ((erp_filled == NULL) && (sense[0] & SNS0_BUS_OUT_CHECK)) {
  1277. erp_filled = dasd_3990_erp_bus_out(erp);
  1278. }
  1279. /* 'Equipment Check' */
  1280. if ((erp_filled == NULL) && (sense[0] & SNS0_EQUIPMENT_CHECK)) {
  1281. erp_filled = dasd_3990_erp_equip_check(erp, sense);
  1282. }
  1283. /* 'Data Check' */
  1284. if ((erp_filled == NULL) && (sense[0] & SNS0_DATA_CHECK)) {
  1285. erp_filled = dasd_3990_erp_data_check(erp, sense);
  1286. }
  1287. /* 'Overrun' */
  1288. if ((erp_filled == NULL) && (sense[0] & SNS0_OVERRUN)) {
  1289. erp_filled = dasd_3990_erp_overrun(erp, sense);
  1290. }
  1291. /* 'Invalid Track Format' */
  1292. if ((erp_filled == NULL) && (sense[1] & SNS1_INV_TRACK_FORMAT)) {
  1293. erp_filled = dasd_3990_erp_inv_format(erp, sense);
  1294. }
  1295. /* 'End-of-Cylinder' */
  1296. if ((erp_filled == NULL) && (sense[1] & SNS1_EOC)) {
  1297. erp_filled = dasd_3990_erp_EOC(erp, sense);
  1298. }
  1299. /* 'Environmental Data' */
  1300. if ((erp_filled == NULL) && (sense[2] & SNS2_ENV_DATA_PRESENT)) {
  1301. erp_filled = dasd_3990_erp_env_data(erp, sense);
  1302. }
  1303. /* 'No Record Found' */
  1304. if ((erp_filled == NULL) && (sense[1] & SNS1_NO_REC_FOUND)) {
  1305. erp_filled = dasd_3990_erp_no_rec(erp, sense);
  1306. }
  1307. /* 'File Protected' */
  1308. if ((erp_filled == NULL) && (sense[1] & SNS1_FILE_PROTECTED)) {
  1309. erp_filled = dasd_3990_erp_file_prot(erp);
  1310. }
  1311. /* other (unknown) error - do default ERP */
  1312. if (erp_filled == NULL) {
  1313. erp_filled = erp;
  1314. }
  1315. return erp_filled;
  1316. } /* END dasd_3990_erp_inspect_24 */
  1317. /*
  1318. *****************************************************************************
  1319. * 32 byte sense ERP functions (only)
  1320. *****************************************************************************
  1321. */
  1322. /*
  1323. * DASD_3990_ERPACTION_10_32
  1324. *
  1325. * DESCRIPTION
  1326. * Handles 32 byte 'Action 10' of Single Program Action Codes.
  1327. * Just retry and if retry doesn't work, return with error.
  1328. *
  1329. * PARAMETER
  1330. * erp current erp_head
  1331. * sense current sense data
  1332. * RETURN VALUES
  1333. * erp modified erp_head
  1334. */
  1335. static struct dasd_ccw_req *
  1336. dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp, char *sense)
  1337. {
  1338. struct dasd_device *device = erp->startdev;
  1339. erp->retries = 256;
  1340. erp->function = dasd_3990_erp_action_10_32;
  1341. DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Perform logging requested");
  1342. return erp;
  1343. } /* end dasd_3990_erp_action_10_32 */
  1344. /*
  1345. * DASD_3990_ERP_ACTION_1B_32
  1346. *
  1347. * DESCRIPTION
  1348. * Handles 32 byte 'Action 1B' of Single Program Action Codes.
  1349. * A write operation could not be finished because of an unexpected
  1350. * condition.
  1351. * The already created 'default erp' is used to get the link to
  1352. * the erp chain, but it can not be used for this recovery
  1353. * action because it contains no DE/LO data space.
  1354. *
  1355. * PARAMETER
  1356. * default_erp already added default erp.
  1357. * sense current sense data
  1358. *
  1359. * RETURN VALUES
  1360. * erp new erp or
  1361. * default_erp in case of imprecise ending or error
  1362. */
  1363. static struct dasd_ccw_req *
  1364. dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp, char *sense)
  1365. {
  1366. struct dasd_device *device = default_erp->startdev;
  1367. __u32 cpa = 0;
  1368. struct dasd_ccw_req *cqr;
  1369. struct dasd_ccw_req *erp;
  1370. struct DE_eckd_data *DE_data;
  1371. struct PFX_eckd_data *PFX_data;
  1372. char *LO_data; /* LO_eckd_data_t */
  1373. struct ccw1 *ccw, *oldccw;
  1374. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1375. "Write not finished because of unexpected condition");
  1376. default_erp->function = dasd_3990_erp_action_1B_32;
  1377. /* determine the original cqr */
  1378. cqr = default_erp;
  1379. while (cqr->refers != NULL) {
  1380. cqr = cqr->refers;
  1381. }
  1382. if (scsw_is_tm(&cqr->irb.scsw)) {
  1383. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1384. "32 bit sense, action 1B is not defined"
  1385. " in transport mode - just retry");
  1386. return default_erp;
  1387. }
  1388. /* for imprecise ending just do default erp */
  1389. if (sense[1] & 0x01) {
  1390. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1391. "Imprecise ending is set - just retry");
  1392. return default_erp;
  1393. }
  1394. /* determine the address of the CCW to be restarted */
  1395. /* Imprecise ending is not set -> addr from IRB-SCSW */
  1396. cpa = default_erp->refers->irb.scsw.cmd.cpa;
  1397. if (cpa == 0) {
  1398. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1399. "Unable to determine address of the CCW "
  1400. "to be restarted");
  1401. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1402. }
  1403. /* Build new ERP request including DE/LO */
  1404. erp = dasd_alloc_erp_request((char *) &cqr->magic,
  1405. 2 + 1,/* DE/LO + TIC */
  1406. sizeof(struct DE_eckd_data) +
  1407. sizeof(struct LO_eckd_data), device);
  1408. if (IS_ERR(erp)) {
  1409. /* internal error 01 - Unable to allocate ERP */
  1410. dev_err(&device->cdev->dev, "An error occurred in the DASD "
  1411. "device driver, reason=%s\n", "01");
  1412. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1413. }
  1414. /* use original DE */
  1415. DE_data = erp->data;
  1416. oldccw = cqr->cpaddr;
  1417. if (oldccw->cmd_code == DASD_ECKD_CCW_PFX) {
  1418. PFX_data = cqr->data;
  1419. memcpy(DE_data, &PFX_data->define_extent,
  1420. sizeof(struct DE_eckd_data));
  1421. } else
  1422. memcpy(DE_data, cqr->data, sizeof(struct DE_eckd_data));
  1423. /* create LO */
  1424. LO_data = erp->data + sizeof(struct DE_eckd_data);
  1425. if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
  1426. /* should not */
  1427. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1428. }
  1429. if ((sense[7] & 0x3F) == 0x01) {
  1430. /* operation code is WRITE DATA -> data area orientation */
  1431. LO_data[0] = 0x81;
  1432. } else if ((sense[7] & 0x3F) == 0x03) {
  1433. /* operation code is FORMAT WRITE -> index orientation */
  1434. LO_data[0] = 0xC3;
  1435. } else {
  1436. LO_data[0] = sense[7]; /* operation */
  1437. }
  1438. LO_data[1] = sense[8]; /* auxiliary */
  1439. LO_data[2] = sense[9];
  1440. LO_data[3] = sense[3]; /* count */
  1441. LO_data[4] = sense[29]; /* seek_addr.cyl */
  1442. LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
  1443. LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
  1444. memcpy(&(LO_data[8]), &(sense[11]), 8);
  1445. /* create DE ccw */
  1446. ccw = erp->cpaddr;
  1447. memset(ccw, 0, sizeof(struct ccw1));
  1448. ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
  1449. ccw->flags = CCW_FLAG_CC;
  1450. ccw->count = 16;
  1451. ccw->cda = (__u32)(addr_t) DE_data;
  1452. /* create LO ccw */
  1453. ccw++;
  1454. memset(ccw, 0, sizeof(struct ccw1));
  1455. ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
  1456. ccw->flags = CCW_FLAG_CC;
  1457. ccw->count = 16;
  1458. ccw->cda = (__u32)(addr_t) LO_data;
  1459. /* TIC to the failed ccw */
  1460. ccw++;
  1461. ccw->cmd_code = CCW_CMD_TIC;
  1462. ccw->cda = cpa;
  1463. /* fill erp related fields */
  1464. erp->function = dasd_3990_erp_action_1B_32;
  1465. erp->refers = default_erp->refers;
  1466. erp->startdev = device;
  1467. erp->memdev = device;
  1468. erp->magic = default_erp->magic;
  1469. erp->expires = 0;
  1470. erp->retries = 256;
  1471. erp->buildclk = get_clock();
  1472. erp->status = DASD_CQR_FILLED;
  1473. /* remove the default erp */
  1474. dasd_free_erp_request(default_erp, device);
  1475. return erp;
  1476. } /* end dasd_3990_erp_action_1B_32 */
  1477. /*
  1478. * DASD_3990_UPDATE_1B
  1479. *
  1480. * DESCRIPTION
  1481. * Handles the update to the 32 byte 'Action 1B' of Single Program
  1482. * Action Codes in case the first action was not successful.
  1483. * The already created 'previous_erp' is the currently not successful
  1484. * ERP.
  1485. *
  1486. * PARAMETER
  1487. * previous_erp already created previous erp.
  1488. * sense current sense data
  1489. * RETURN VALUES
  1490. * erp modified erp
  1491. */
  1492. static struct dasd_ccw_req *
  1493. dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
  1494. {
  1495. struct dasd_device *device = previous_erp->startdev;
  1496. __u32 cpa = 0;
  1497. struct dasd_ccw_req *cqr;
  1498. struct dasd_ccw_req *erp;
  1499. char *LO_data; /* struct LO_eckd_data */
  1500. struct ccw1 *ccw;
  1501. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1502. "Write not finished because of unexpected condition"
  1503. " - follow on");
  1504. /* determine the original cqr */
  1505. cqr = previous_erp;
  1506. while (cqr->refers != NULL) {
  1507. cqr = cqr->refers;
  1508. }
  1509. if (scsw_is_tm(&cqr->irb.scsw)) {
  1510. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1511. "32 bit sense, action 1B, update,"
  1512. " in transport mode - just retry");
  1513. return previous_erp;
  1514. }
  1515. /* for imprecise ending just do default erp */
  1516. if (sense[1] & 0x01) {
  1517. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1518. "Imprecise ending is set - just retry");
  1519. previous_erp->status = DASD_CQR_FILLED;
  1520. return previous_erp;
  1521. }
  1522. /* determine the address of the CCW to be restarted */
  1523. /* Imprecise ending is not set -> addr from IRB-SCSW */
  1524. cpa = previous_erp->irb.scsw.cmd.cpa;
  1525. if (cpa == 0) {
  1526. /* internal error 02 -
  1527. Unable to determine address of the CCW to be restarted */
  1528. dev_err(&device->cdev->dev, "An error occurred in the DASD "
  1529. "device driver, reason=%s\n", "02");
  1530. previous_erp->status = DASD_CQR_FAILED;
  1531. return previous_erp;
  1532. }
  1533. erp = previous_erp;
  1534. /* update the LO with the new returned sense data */
  1535. LO_data = erp->data + sizeof(struct DE_eckd_data);
  1536. if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
  1537. /* should not happen */
  1538. previous_erp->status = DASD_CQR_FAILED;
  1539. return previous_erp;
  1540. }
  1541. if ((sense[7] & 0x3F) == 0x01) {
  1542. /* operation code is WRITE DATA -> data area orientation */
  1543. LO_data[0] = 0x81;
  1544. } else if ((sense[7] & 0x3F) == 0x03) {
  1545. /* operation code is FORMAT WRITE -> index orientation */
  1546. LO_data[0] = 0xC3;
  1547. } else {
  1548. LO_data[0] = sense[7]; /* operation */
  1549. }
  1550. LO_data[1] = sense[8]; /* auxiliary */
  1551. LO_data[2] = sense[9];
  1552. LO_data[3] = sense[3]; /* count */
  1553. LO_data[4] = sense[29]; /* seek_addr.cyl */
  1554. LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
  1555. LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
  1556. memcpy(&(LO_data[8]), &(sense[11]), 8);
  1557. /* TIC to the failed ccw */
  1558. ccw = erp->cpaddr; /* addr of DE ccw */
  1559. ccw++; /* addr of LE ccw */
  1560. ccw++; /* addr of TIC ccw */
  1561. ccw->cda = cpa;
  1562. erp->status = DASD_CQR_FILLED;
  1563. return erp;
  1564. } /* end dasd_3990_update_1B */
  1565. /*
  1566. * DASD_3990_ERP_COMPOUND_RETRY
  1567. *
  1568. * DESCRIPTION
  1569. * Handles the compound ERP action retry code.
  1570. * NOTE: At least one retry is done even if zero is specified
  1571. * by the sense data. This makes enqueueing of the request
  1572. * easier.
  1573. *
  1574. * PARAMETER
  1575. * sense sense data of the actual error
  1576. * erp pointer to the currently created ERP
  1577. *
  1578. * RETURN VALUES
  1579. * erp modified ERP pointer
  1580. *
  1581. */
  1582. static void
  1583. dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense)
  1584. {
  1585. switch (sense[25] & 0x03) {
  1586. case 0x00: /* no not retry */
  1587. erp->retries = 1;
  1588. break;
  1589. case 0x01: /* retry 2 times */
  1590. erp->retries = 2;
  1591. break;
  1592. case 0x02: /* retry 10 times */
  1593. erp->retries = 10;
  1594. break;
  1595. case 0x03: /* retry 256 times */
  1596. erp->retries = 256;
  1597. break;
  1598. default:
  1599. BUG();
  1600. }
  1601. erp->function = dasd_3990_erp_compound_retry;
  1602. } /* end dasd_3990_erp_compound_retry */
  1603. /*
  1604. * DASD_3990_ERP_COMPOUND_PATH
  1605. *
  1606. * DESCRIPTION
  1607. * Handles the compound ERP action for retry on alternate
  1608. * channel path.
  1609. *
  1610. * PARAMETER
  1611. * sense sense data of the actual error
  1612. * erp pointer to the currently created ERP
  1613. *
  1614. * RETURN VALUES
  1615. * erp modified ERP pointer
  1616. *
  1617. */
  1618. static void
  1619. dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
  1620. {
  1621. if (sense[25] & DASD_SENSE_BIT_3) {
  1622. dasd_3990_erp_alternate_path(erp);
  1623. if (erp->status == DASD_CQR_FAILED) {
  1624. /* reset the lpm and the status to be able to
  1625. * try further actions. */
  1626. erp->lpm = 0;
  1627. erp->status = DASD_CQR_NEED_ERP;
  1628. }
  1629. }
  1630. erp->function = dasd_3990_erp_compound_path;
  1631. } /* end dasd_3990_erp_compound_path */
  1632. /*
  1633. * DASD_3990_ERP_COMPOUND_CODE
  1634. *
  1635. * DESCRIPTION
  1636. * Handles the compound ERP action for retry code.
  1637. *
  1638. * PARAMETER
  1639. * sense sense data of the actual error
  1640. * erp pointer to the currently created ERP
  1641. *
  1642. * RETURN VALUES
  1643. * erp NEW ERP pointer
  1644. *
  1645. */
  1646. static struct dasd_ccw_req *
  1647. dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
  1648. {
  1649. if (sense[25] & DASD_SENSE_BIT_2) {
  1650. switch (sense[28]) {
  1651. case 0x17:
  1652. /* issue a Diagnostic Control command with an
  1653. * Inhibit Write subcommand and controller modifier */
  1654. erp = dasd_3990_erp_DCTL(erp, 0x20);
  1655. break;
  1656. case 0x25:
  1657. /* wait for 5 seconds and retry again */
  1658. erp->retries = 1;
  1659. dasd_3990_erp_block_queue (erp, 5*HZ);
  1660. break;
  1661. default:
  1662. /* should not happen - continue */
  1663. break;
  1664. }
  1665. }
  1666. erp->function = dasd_3990_erp_compound_code;
  1667. return erp;
  1668. } /* end dasd_3990_erp_compound_code */
  1669. /*
  1670. * DASD_3990_ERP_COMPOUND_CONFIG
  1671. *
  1672. * DESCRIPTION
  1673. * Handles the compound ERP action for configruation
  1674. * dependent error.
  1675. * Note: duplex handling is not implemented (yet).
  1676. *
  1677. * PARAMETER
  1678. * sense sense data of the actual error
  1679. * erp pointer to the currently created ERP
  1680. *
  1681. * RETURN VALUES
  1682. * erp modified ERP pointer
  1683. *
  1684. */
  1685. static void
  1686. dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense)
  1687. {
  1688. if ((sense[25] & DASD_SENSE_BIT_1) && (sense[26] & DASD_SENSE_BIT_2)) {
  1689. /* set to suspended duplex state then restart
  1690. internal error 05 - Set device to suspended duplex state
  1691. should be done */
  1692. struct dasd_device *device = erp->startdev;
  1693. dev_err(&device->cdev->dev,
  1694. "An error occurred in the DASD device driver, "
  1695. "reason=%s\n", "05");
  1696. }
  1697. erp->function = dasd_3990_erp_compound_config;
  1698. } /* end dasd_3990_erp_compound_config */
  1699. /*
  1700. * DASD_3990_ERP_COMPOUND
  1701. *
  1702. * DESCRIPTION
  1703. * Does the further compound program action if
  1704. * compound retry was not successful.
  1705. *
  1706. * PARAMETER
  1707. * sense sense data of the actual error
  1708. * erp pointer to the current (failed) ERP
  1709. *
  1710. * RETURN VALUES
  1711. * erp (additional) ERP pointer
  1712. *
  1713. */
  1714. static struct dasd_ccw_req *
  1715. dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense)
  1716. {
  1717. if ((erp->function == dasd_3990_erp_compound_retry) &&
  1718. (erp->status == DASD_CQR_NEED_ERP)) {
  1719. dasd_3990_erp_compound_path(erp, sense);
  1720. }
  1721. if ((erp->function == dasd_3990_erp_compound_path) &&
  1722. (erp->status == DASD_CQR_NEED_ERP)) {
  1723. erp = dasd_3990_erp_compound_code(erp, sense);
  1724. }
  1725. if ((erp->function == dasd_3990_erp_compound_code) &&
  1726. (erp->status == DASD_CQR_NEED_ERP)) {
  1727. dasd_3990_erp_compound_config(erp, sense);
  1728. }
  1729. /* if no compound action ERP specified, the request failed */
  1730. if (erp->status == DASD_CQR_NEED_ERP)
  1731. erp->status = DASD_CQR_FAILED;
  1732. return erp;
  1733. } /* end dasd_3990_erp_compound */
  1734. /*
  1735. *DASD_3990_ERP_HANDLE_SIM
  1736. *
  1737. *DESCRIPTION
  1738. * inspects the SIM SENSE data and starts an appropriate action
  1739. *
  1740. * PARAMETER
  1741. * sense sense data of the actual error
  1742. *
  1743. * RETURN VALUES
  1744. * none
  1745. */
  1746. void
  1747. dasd_3990_erp_handle_sim(struct dasd_device *device, char *sense)
  1748. {
  1749. /* print message according to log or message to operator mode */
  1750. if ((sense[24] & DASD_SIM_MSG_TO_OP) || (sense[1] & 0x10)) {
  1751. /* print SIM SRC from RefCode */
  1752. dev_err(&device->cdev->dev, "SIM - SRC: "
  1753. "%02x%02x%02x%02x\n", sense[22],
  1754. sense[23], sense[11], sense[12]);
  1755. } else if (sense[24] & DASD_SIM_LOG) {
  1756. /* print SIM SRC Refcode */
  1757. dev_warn(&device->cdev->dev, "log SIM - SRC: "
  1758. "%02x%02x%02x%02x\n", sense[22],
  1759. sense[23], sense[11], sense[12]);
  1760. }
  1761. }
  1762. /*
  1763. * DASD_3990_ERP_INSPECT_32
  1764. *
  1765. * DESCRIPTION
  1766. * Does a detailed inspection of the 32 byte sense data
  1767. * and sets up a related error recovery action.
  1768. *
  1769. * PARAMETER
  1770. * sense sense data of the actual error
  1771. * erp pointer to the currently created default ERP
  1772. *
  1773. * RETURN VALUES
  1774. * erp_filled pointer to the ERP
  1775. *
  1776. */
  1777. static struct dasd_ccw_req *
  1778. dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
  1779. {
  1780. struct dasd_device *device = erp->startdev;
  1781. erp->function = dasd_3990_erp_inspect_32;
  1782. /* check for SIM sense data */
  1783. if ((sense[6] & DASD_SIM_SENSE) == DASD_SIM_SENSE)
  1784. dasd_3990_erp_handle_sim(device, sense);
  1785. if (sense[25] & DASD_SENSE_BIT_0) {
  1786. /* compound program action codes (byte25 bit 0 == '1') */
  1787. dasd_3990_erp_compound_retry(erp, sense);
  1788. } else {
  1789. /* single program action codes (byte25 bit 0 == '0') */
  1790. switch (sense[25]) {
  1791. case 0x00: /* success - use default ERP for retries */
  1792. DBF_DEV_EVENT(DBF_DEBUG, device, "%s",
  1793. "ERP called for successful request"
  1794. " - just retry");
  1795. break;
  1796. case 0x01: /* fatal error */
  1797. dev_err(&device->cdev->dev,
  1798. "ERP failed for the DASD\n");
  1799. erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  1800. break;
  1801. case 0x02: /* intervention required */
  1802. case 0x03: /* intervention required during dual copy */
  1803. erp = dasd_3990_erp_int_req(erp);
  1804. break;
  1805. case 0x0F: /* length mismatch during update write command
  1806. internal error 08 - update write command error*/
  1807. dev_err(&device->cdev->dev, "An error occurred in the "
  1808. "DASD device driver, reason=%s\n", "08");
  1809. erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  1810. break;
  1811. case 0x10: /* logging required for other channel program */
  1812. erp = dasd_3990_erp_action_10_32(erp, sense);
  1813. break;
  1814. case 0x15: /* next track outside defined extend
  1815. internal error 07 - The next track is not
  1816. within the defined storage extent */
  1817. dev_err(&device->cdev->dev,
  1818. "An error occurred in the DASD device driver, "
  1819. "reason=%s\n", "07");
  1820. erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  1821. break;
  1822. case 0x1B: /* unexpected condition during write */
  1823. erp = dasd_3990_erp_action_1B_32(erp, sense);
  1824. break;
  1825. case 0x1C: /* invalid data */
  1826. dev_emerg(&device->cdev->dev,
  1827. "Data recovered during retry with PCI "
  1828. "fetch mode active\n");
  1829. /* not possible to handle this situation in Linux */
  1830. panic
  1831. ("Invalid data - No way to inform application "
  1832. "about the possibly incorrect data");
  1833. break;
  1834. case 0x1D: /* state-change pending */
  1835. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1836. "A State change pending condition exists "
  1837. "for the subsystem or device");
  1838. erp = dasd_3990_erp_action_4(erp, sense);
  1839. break;
  1840. case 0x1E: /* busy */
  1841. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1842. "Busy condition exists "
  1843. "for the subsystem or device");
  1844. erp = dasd_3990_erp_action_4(erp, sense);
  1845. break;
  1846. default: /* all others errors - default erp */
  1847. break;
  1848. }
  1849. }
  1850. return erp;
  1851. } /* end dasd_3990_erp_inspect_32 */
  1852. /*
  1853. *****************************************************************************
  1854. * main ERP control fuctions (24 and 32 byte sense)
  1855. *****************************************************************************
  1856. */
  1857. /*
  1858. * DASD_3990_ERP_CONTROL_CHECK
  1859. *
  1860. * DESCRIPTION
  1861. * Does a generic inspection if a control check occured and sets up
  1862. * the related error recovery procedure
  1863. *
  1864. * PARAMETER
  1865. * erp pointer to the currently created default ERP
  1866. *
  1867. * RETURN VALUES
  1868. * erp_filled pointer to the erp
  1869. */
  1870. static struct dasd_ccw_req *
  1871. dasd_3990_erp_control_check(struct dasd_ccw_req *erp)
  1872. {
  1873. struct dasd_device *device = erp->startdev;
  1874. if (scsw_cstat(&erp->refers->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK
  1875. | SCHN_STAT_CHN_CTRL_CHK)) {
  1876. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1877. "channel or interface control check");
  1878. erp = dasd_3990_erp_action_4(erp, NULL);
  1879. }
  1880. return erp;
  1881. }
  1882. /*
  1883. * DASD_3990_ERP_INSPECT
  1884. *
  1885. * DESCRIPTION
  1886. * Does a detailed inspection for sense data by calling either
  1887. * the 24-byte or the 32-byte inspection routine.
  1888. *
  1889. * PARAMETER
  1890. * erp pointer to the currently created default ERP
  1891. * RETURN VALUES
  1892. * erp_new contens was possibly modified
  1893. */
  1894. static struct dasd_ccw_req *
  1895. dasd_3990_erp_inspect(struct dasd_ccw_req *erp)
  1896. {
  1897. struct dasd_ccw_req *erp_new = NULL;
  1898. char *sense;
  1899. /* if this problem occured on an alias retry on base */
  1900. erp_new = dasd_3990_erp_inspect_alias(erp);
  1901. if (erp_new)
  1902. return erp_new;
  1903. /* sense data are located in the refers record of the
  1904. * already set up new ERP !
  1905. * check if concurrent sens is available
  1906. */
  1907. sense = dasd_get_sense(&erp->refers->irb);
  1908. if (!sense)
  1909. erp_new = dasd_3990_erp_control_check(erp);
  1910. /* distinguish between 24 and 32 byte sense data */
  1911. else if (sense[27] & DASD_SENSE_BIT_0) {
  1912. /* inspect the 24 byte sense data */
  1913. erp_new = dasd_3990_erp_inspect_24(erp, sense);
  1914. } else {
  1915. /* inspect the 32 byte sense data */
  1916. erp_new = dasd_3990_erp_inspect_32(erp, sense);
  1917. } /* end distinguish between 24 and 32 byte sense data */
  1918. return erp_new;
  1919. }
  1920. /*
  1921. * DASD_3990_ERP_ADD_ERP
  1922. *
  1923. * DESCRIPTION
  1924. * This funtion adds an additional request block (ERP) to the head of
  1925. * the given cqr (or erp).
  1926. * For a command mode cqr the erp is initialized as an default erp
  1927. * (retry TIC).
  1928. * For transport mode we make a copy of the original TCW (points to
  1929. * the original TCCB, TIDALs, etc.) but give it a fresh
  1930. * TSB so the original sense data will not be changed.
  1931. *
  1932. * PARAMETER
  1933. * cqr head of the current ERP-chain (or single cqr if
  1934. * first error)
  1935. * RETURN VALUES
  1936. * erp pointer to new ERP-chain head
  1937. */
  1938. static struct dasd_ccw_req *dasd_3990_erp_add_erp(struct dasd_ccw_req *cqr)
  1939. {
  1940. struct dasd_device *device = cqr->startdev;
  1941. struct ccw1 *ccw;
  1942. struct dasd_ccw_req *erp;
  1943. int cplength, datasize;
  1944. struct tcw *tcw;
  1945. struct tsb *tsb;
  1946. if (cqr->cpmode == 1) {
  1947. cplength = 0;
  1948. datasize = sizeof(struct tcw) + sizeof(struct tsb);
  1949. } else {
  1950. cplength = 2;
  1951. datasize = 0;
  1952. }
  1953. /* allocate additional request block */
  1954. erp = dasd_alloc_erp_request((char *) &cqr->magic,
  1955. cplength, datasize, device);
  1956. if (IS_ERR(erp)) {
  1957. if (cqr->retries <= 0) {
  1958. DBF_DEV_EVENT(DBF_ERR, device, "%s",
  1959. "Unable to allocate ERP request");
  1960. cqr->status = DASD_CQR_FAILED;
  1961. cqr->stopclk = get_clock ();
  1962. } else {
  1963. DBF_DEV_EVENT(DBF_ERR, device,
  1964. "Unable to allocate ERP request "
  1965. "(%i retries left)",
  1966. cqr->retries);
  1967. dasd_block_set_timer(device->block, (HZ << 3));
  1968. }
  1969. return cqr;
  1970. }
  1971. if (cqr->cpmode == 1) {
  1972. /* make a shallow copy of the original tcw but set new tsb */
  1973. erp->cpmode = 1;
  1974. erp->cpaddr = erp->data;
  1975. tcw = erp->data;
  1976. tsb = (struct tsb *) &tcw[1];
  1977. *tcw = *((struct tcw *)cqr->cpaddr);
  1978. tcw->tsb = (long)tsb;
  1979. } else {
  1980. /* initialize request with default TIC to current ERP/CQR */
  1981. ccw = erp->cpaddr;
  1982. ccw->cmd_code = CCW_CMD_NOOP;
  1983. ccw->flags = CCW_FLAG_CC;
  1984. ccw++;
  1985. ccw->cmd_code = CCW_CMD_TIC;
  1986. ccw->cda = (long)(cqr->cpaddr);
  1987. }
  1988. erp->function = dasd_3990_erp_add_erp;
  1989. erp->refers = cqr;
  1990. erp->startdev = device;
  1991. erp->memdev = device;
  1992. erp->block = cqr->block;
  1993. erp->magic = cqr->magic;
  1994. erp->expires = 0;
  1995. erp->retries = 256;
  1996. erp->buildclk = get_clock();
  1997. erp->status = DASD_CQR_FILLED;
  1998. return erp;
  1999. }
  2000. /*
  2001. * DASD_3990_ERP_ADDITIONAL_ERP
  2002. *
  2003. * DESCRIPTION
  2004. * An additional ERP is needed to handle the current error.
  2005. * Add ERP to the head of the ERP-chain containing the ERP processing
  2006. * determined based on the sense data.
  2007. *
  2008. * PARAMETER
  2009. * cqr head of the current ERP-chain (or single cqr if
  2010. * first error)
  2011. *
  2012. * RETURN VALUES
  2013. * erp pointer to new ERP-chain head
  2014. */
  2015. static struct dasd_ccw_req *
  2016. dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)
  2017. {
  2018. struct dasd_ccw_req *erp = NULL;
  2019. /* add erp and initialize with default TIC */
  2020. erp = dasd_3990_erp_add_erp(cqr);
  2021. /* inspect sense, determine specific ERP if possible */
  2022. if (erp != cqr) {
  2023. erp = dasd_3990_erp_inspect(erp);
  2024. }
  2025. return erp;
  2026. } /* end dasd_3990_erp_additional_erp */
  2027. /*
  2028. * DASD_3990_ERP_ERROR_MATCH
  2029. *
  2030. * DESCRIPTION
  2031. * Check if the device status of the given cqr is the same.
  2032. * This means that the failed CCW and the relevant sense data
  2033. * must match.
  2034. * I don't distinguish between 24 and 32 byte sense because in case of
  2035. * 24 byte sense byte 25 and 27 is set as well.
  2036. *
  2037. * PARAMETER
  2038. * cqr1 first cqr, which will be compared with the
  2039. * cqr2 second cqr.
  2040. *
  2041. * RETURN VALUES
  2042. * match 'boolean' for match found
  2043. * returns 1 if match found, otherwise 0.
  2044. */
  2045. static int dasd_3990_erp_error_match(struct dasd_ccw_req *cqr1,
  2046. struct dasd_ccw_req *cqr2)
  2047. {
  2048. char *sense1, *sense2;
  2049. if (cqr1->startdev != cqr2->startdev)
  2050. return 0;
  2051. sense1 = dasd_get_sense(&cqr1->irb);
  2052. sense2 = dasd_get_sense(&cqr2->irb);
  2053. /* one request has sense data, the other not -> no match, return 0 */
  2054. if (!sense1 != !sense2)
  2055. return 0;
  2056. /* no sense data in both cases -> check cstat for IFCC */
  2057. if (!sense1 && !sense2) {
  2058. if ((scsw_cstat(&cqr1->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
  2059. SCHN_STAT_CHN_CTRL_CHK)) ==
  2060. (scsw_cstat(&cqr2->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
  2061. SCHN_STAT_CHN_CTRL_CHK)))
  2062. return 1; /* match with ifcc*/
  2063. }
  2064. /* check sense data; byte 0-2,25,27 */
  2065. if (!(sense1 && sense2 &&
  2066. (memcmp(sense1, sense2, 3) == 0) &&
  2067. (sense1[27] == sense2[27]) &&
  2068. (sense1[25] == sense2[25]))) {
  2069. return 0; /* sense doesn't match */
  2070. }
  2071. return 1; /* match */
  2072. } /* end dasd_3990_erp_error_match */
  2073. /*
  2074. * DASD_3990_ERP_IN_ERP
  2075. *
  2076. * DESCRIPTION
  2077. * check if the current error already happened before.
  2078. * quick exit if current cqr is not an ERP (cqr->refers=NULL)
  2079. *
  2080. * PARAMETER
  2081. * cqr failed cqr (either original cqr or already an erp)
  2082. *
  2083. * RETURN VALUES
  2084. * erp erp-pointer to the already defined error
  2085. * recovery procedure OR
  2086. * NULL if a 'new' error occurred.
  2087. */
  2088. static struct dasd_ccw_req *
  2089. dasd_3990_erp_in_erp(struct dasd_ccw_req *cqr)
  2090. {
  2091. struct dasd_ccw_req *erp_head = cqr, /* save erp chain head */
  2092. *erp_match = NULL; /* save erp chain head */
  2093. int match = 0; /* 'boolean' for matching error found */
  2094. if (cqr->refers == NULL) { /* return if not in erp */
  2095. return NULL;
  2096. }
  2097. /* check the erp/cqr chain for current error */
  2098. do {
  2099. match = dasd_3990_erp_error_match(erp_head, cqr->refers);
  2100. erp_match = cqr; /* save possible matching erp */
  2101. cqr = cqr->refers; /* check next erp/cqr in queue */
  2102. } while ((cqr->refers != NULL) && (!match));
  2103. if (!match) {
  2104. return NULL; /* no match was found */
  2105. }
  2106. return erp_match; /* return address of matching erp */
  2107. } /* END dasd_3990_erp_in_erp */
  2108. /*
  2109. * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense)
  2110. *
  2111. * DESCRIPTION
  2112. * No retry is left for the current ERP. Check what has to be done
  2113. * with the ERP.
  2114. * - do further defined ERP action or
  2115. * - wait for interrupt or
  2116. * - exit with permanent error
  2117. *
  2118. * PARAMETER
  2119. * erp ERP which is in progress with no retry left
  2120. *
  2121. * RETURN VALUES
  2122. * erp modified/additional ERP
  2123. */
  2124. static struct dasd_ccw_req *
  2125. dasd_3990_erp_further_erp(struct dasd_ccw_req *erp)
  2126. {
  2127. struct dasd_device *device = erp->startdev;
  2128. char *sense = dasd_get_sense(&erp->irb);
  2129. /* check for 24 byte sense ERP */
  2130. if ((erp->function == dasd_3990_erp_bus_out) ||
  2131. (erp->function == dasd_3990_erp_action_1) ||
  2132. (erp->function == dasd_3990_erp_action_4)) {
  2133. erp = dasd_3990_erp_action_1(erp);
  2134. } else if (erp->function == dasd_3990_erp_action_5) {
  2135. /* retries have not been successful */
  2136. /* prepare erp for retry on different channel path */
  2137. erp = dasd_3990_erp_action_1(erp);
  2138. if (sense && !(sense[2] & DASD_SENSE_BIT_0)) {
  2139. /* issue a Diagnostic Control command with an
  2140. * Inhibit Write subcommand */
  2141. switch (sense[25]) {
  2142. case 0x17:
  2143. case 0x57:{ /* controller */
  2144. erp = dasd_3990_erp_DCTL(erp, 0x20);
  2145. break;
  2146. }
  2147. case 0x18:
  2148. case 0x58:{ /* channel path */
  2149. erp = dasd_3990_erp_DCTL(erp, 0x40);
  2150. break;
  2151. }
  2152. case 0x19:
  2153. case 0x59:{ /* storage director */
  2154. erp = dasd_3990_erp_DCTL(erp, 0x80);
  2155. break;
  2156. }
  2157. default:
  2158. DBF_DEV_EVENT(DBF_WARNING, device,
  2159. "invalid subcommand modifier 0x%x "
  2160. "for Diagnostic Control Command",
  2161. sense[25]);
  2162. }
  2163. }
  2164. /* check for 32 byte sense ERP */
  2165. } else if (sense &&
  2166. ((erp->function == dasd_3990_erp_compound_retry) ||
  2167. (erp->function == dasd_3990_erp_compound_path) ||
  2168. (erp->function == dasd_3990_erp_compound_code) ||
  2169. (erp->function == dasd_3990_erp_compound_config))) {
  2170. erp = dasd_3990_erp_compound(erp, sense);
  2171. } else {
  2172. /*
  2173. * No retry left and no additional special handling
  2174. * necessary
  2175. */
  2176. dev_err(&device->cdev->dev,
  2177. "ERP %p has run out of retries and failed\n", erp);
  2178. erp->status = DASD_CQR_FAILED;
  2179. }
  2180. return erp;
  2181. } /* end dasd_3990_erp_further_erp */
  2182. /*
  2183. * DASD_3990_ERP_HANDLE_MATCH_ERP
  2184. *
  2185. * DESCRIPTION
  2186. * An error occurred again and an ERP has been detected which is already
  2187. * used to handle this error (e.g. retries).
  2188. * All prior ERP's are asumed to be successful and therefore removed
  2189. * from queue.
  2190. * If retry counter of matching erp is already 0, it is checked if further
  2191. * action is needed (besides retry) or if the ERP has failed.
  2192. *
  2193. * PARAMETER
  2194. * erp_head first ERP in ERP-chain
  2195. * erp ERP that handles the actual error.
  2196. * (matching erp)
  2197. *
  2198. * RETURN VALUES
  2199. * erp modified/additional ERP
  2200. */
  2201. static struct dasd_ccw_req *
  2202. dasd_3990_erp_handle_match_erp(struct dasd_ccw_req *erp_head,
  2203. struct dasd_ccw_req *erp)
  2204. {
  2205. struct dasd_device *device = erp_head->startdev;
  2206. struct dasd_ccw_req *erp_done = erp_head; /* finished req */
  2207. struct dasd_ccw_req *erp_free = NULL; /* req to be freed */
  2208. /* loop over successful ERPs and remove them from chanq */
  2209. while (erp_done != erp) {
  2210. if (erp_done == NULL) /* end of chain reached */
  2211. panic(PRINTK_HEADER "Programming error in ERP! The "
  2212. "original request was lost\n");
  2213. /* remove the request from the device queue */
  2214. list_del(&erp_done->blocklist);
  2215. erp_free = erp_done;
  2216. erp_done = erp_done->refers;
  2217. /* free the finished erp request */
  2218. dasd_free_erp_request(erp_free, erp_free->memdev);
  2219. } /* end while */
  2220. if (erp->retries > 0) {
  2221. char *sense = dasd_get_sense(&erp->refers->irb);
  2222. /* check for special retries */
  2223. if (sense && erp->function == dasd_3990_erp_action_4) {
  2224. erp = dasd_3990_erp_action_4(erp, sense);
  2225. } else if (sense &&
  2226. erp->function == dasd_3990_erp_action_1B_32) {
  2227. erp = dasd_3990_update_1B(erp, sense);
  2228. } else if (sense && erp->function == dasd_3990_erp_int_req) {
  2229. erp = dasd_3990_erp_int_req(erp);
  2230. } else {
  2231. /* simple retry */
  2232. DBF_DEV_EVENT(DBF_DEBUG, device,
  2233. "%i retries left for erp %p",
  2234. erp->retries, erp);
  2235. /* handle the request again... */
  2236. erp->status = DASD_CQR_FILLED;
  2237. }
  2238. } else {
  2239. /* no retry left - check for further necessary action */
  2240. /* if no further actions, handle rest as permanent error */
  2241. erp = dasd_3990_erp_further_erp(erp);
  2242. }
  2243. return erp;
  2244. } /* end dasd_3990_erp_handle_match_erp */
  2245. /*
  2246. * DASD_3990_ERP_ACTION
  2247. *
  2248. * DESCRIPTION
  2249. * control routine for 3990 erp actions.
  2250. * Has to be called with the queue lock (namely the s390_irq_lock) acquired.
  2251. *
  2252. * PARAMETER
  2253. * cqr failed cqr (either original cqr or already an erp)
  2254. *
  2255. * RETURN VALUES
  2256. * erp erp-pointer to the head of the ERP action chain.
  2257. * This means:
  2258. * - either a ptr to an additional ERP cqr or
  2259. * - the original given cqr (which's status might
  2260. * be modified)
  2261. */
  2262. struct dasd_ccw_req *
  2263. dasd_3990_erp_action(struct dasd_ccw_req * cqr)
  2264. {
  2265. struct dasd_ccw_req *erp = NULL;
  2266. struct dasd_device *device = cqr->startdev;
  2267. struct dasd_ccw_req *temp_erp = NULL;
  2268. if (device->features & DASD_FEATURE_ERPLOG) {
  2269. /* print current erp_chain */
  2270. dev_err(&device->cdev->dev,
  2271. "ERP chain at BEGINNING of ERP-ACTION\n");
  2272. for (temp_erp = cqr;
  2273. temp_erp != NULL; temp_erp = temp_erp->refers) {
  2274. dev_err(&device->cdev->dev,
  2275. "ERP %p (%02x) refers to %p\n",
  2276. temp_erp, temp_erp->status,
  2277. temp_erp->refers);
  2278. }
  2279. }
  2280. /* double-check if current erp/cqr was successful */
  2281. if ((scsw_cstat(&cqr->irb.scsw) == 0x00) &&
  2282. (scsw_dstat(&cqr->irb.scsw) ==
  2283. (DEV_STAT_CHN_END | DEV_STAT_DEV_END))) {
  2284. DBF_DEV_EVENT(DBF_DEBUG, device,
  2285. "ERP called for successful request %p"
  2286. " - NO ERP necessary", cqr);
  2287. cqr->status = DASD_CQR_DONE;
  2288. return cqr;
  2289. }
  2290. /* check if error happened before */
  2291. erp = dasd_3990_erp_in_erp(cqr);
  2292. if (erp == NULL) {
  2293. /* no matching erp found - set up erp */
  2294. erp = dasd_3990_erp_additional_erp(cqr);
  2295. } else {
  2296. /* matching erp found - set all leading erp's to DONE */
  2297. erp = dasd_3990_erp_handle_match_erp(cqr, erp);
  2298. }
  2299. if (device->features & DASD_FEATURE_ERPLOG) {
  2300. /* print current erp_chain */
  2301. dev_err(&device->cdev->dev,
  2302. "ERP chain at END of ERP-ACTION\n");
  2303. for (temp_erp = erp;
  2304. temp_erp != NULL; temp_erp = temp_erp->refers) {
  2305. dev_err(&device->cdev->dev,
  2306. "ERP %p (%02x) refers to %p\n",
  2307. temp_erp, temp_erp->status,
  2308. temp_erp->refers);
  2309. }
  2310. }
  2311. /* enqueue ERP request if it's a new one */
  2312. if (list_empty(&erp->blocklist)) {
  2313. cqr->status = DASD_CQR_IN_ERP;
  2314. /* add erp request before the cqr */
  2315. list_add_tail(&erp->blocklist, &cqr->blocklist);
  2316. }
  2317. return erp;
  2318. } /* end dasd_3990_erp_action */