dasd_3990_erp.c 69 KB

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