dasd_3990_erp.c 69 KB

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