dasd_3990_erp.c 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745
  1. /*
  2. * File...........: linux/drivers/s390/block/dasd_3990_erp.c
  3. * Author(s)......: Horst Hummel <Horst.Hummel@de.ibm.com>
  4. * Holger Smolinski <Holger.Smolinski@de.ibm.com>
  5. * Bugreports.to..: <Linux390@de.ibm.com>
  6. * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000, 2001
  7. *
  8. */
  9. #define KMSG_COMPONENT "dasd-eckd"
  10. #include <linux/timer.h>
  11. #include <linux/slab.h>
  12. #include <asm/idals.h>
  13. #define PRINTK_HEADER "dasd_erp(3990): "
  14. #include "dasd_int.h"
  15. #include "dasd_eckd.h"
  16. struct DCTL_data {
  17. unsigned char subcommand; /* e.g Inhibit Write, Enable Write,... */
  18. unsigned char modifier; /* Subcommand modifier */
  19. unsigned short res; /* reserved */
  20. } __attribute__ ((packed));
  21. /*
  22. *****************************************************************************
  23. * SECTION ERP HANDLING
  24. *****************************************************************************
  25. */
  26. /*
  27. *****************************************************************************
  28. * 24 and 32 byte sense ERP functions
  29. *****************************************************************************
  30. */
  31. /*
  32. * DASD_3990_ERP_CLEANUP
  33. *
  34. * DESCRIPTION
  35. * Removes the already build but not necessary ERP request and sets
  36. * the status of the original cqr / erp to the given (final) status
  37. *
  38. * PARAMETER
  39. * erp request to be blocked
  40. * final_status either DASD_CQR_DONE or DASD_CQR_FAILED
  41. *
  42. * RETURN VALUES
  43. * cqr original cqr
  44. */
  45. static struct dasd_ccw_req *
  46. dasd_3990_erp_cleanup(struct dasd_ccw_req * erp, char final_status)
  47. {
  48. struct dasd_ccw_req *cqr = erp->refers;
  49. dasd_free_erp_request(erp, erp->memdev);
  50. cqr->status = final_status;
  51. return cqr;
  52. } /* end dasd_3990_erp_cleanup */
  53. /*
  54. * DASD_3990_ERP_BLOCK_QUEUE
  55. *
  56. * DESCRIPTION
  57. * Block the given device request queue to prevent from further
  58. * processing until the started timer has expired or an related
  59. * interrupt was received.
  60. */
  61. static void dasd_3990_erp_block_queue(struct dasd_ccw_req *erp, int expires)
  62. {
  63. struct dasd_device *device = erp->startdev;
  64. unsigned long flags;
  65. DBF_DEV_EVENT(DBF_INFO, device,
  66. "blocking request queue for %is", expires/HZ);
  67. spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
  68. dasd_device_set_stop_bits(device, DASD_STOPPED_PENDING);
  69. spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
  70. erp->status = DASD_CQR_FILLED;
  71. if (erp->block)
  72. dasd_block_set_timer(erp->block, expires);
  73. else
  74. dasd_device_set_timer(device, expires);
  75. }
  76. /*
  77. * DASD_3990_ERP_INT_REQ
  78. *
  79. * DESCRIPTION
  80. * Handles 'Intervention Required' error.
  81. * This means either device offline or not installed.
  82. *
  83. * PARAMETER
  84. * erp current erp
  85. * RETURN VALUES
  86. * erp modified erp
  87. */
  88. static struct dasd_ccw_req *
  89. dasd_3990_erp_int_req(struct dasd_ccw_req * erp)
  90. {
  91. struct dasd_device *device = erp->startdev;
  92. /* first time set initial retry counter and erp_function */
  93. /* and retry once without blocking queue */
  94. /* (this enables easier enqueing of the cqr) */
  95. if (erp->function != dasd_3990_erp_int_req) {
  96. erp->retries = 256;
  97. erp->function = dasd_3990_erp_int_req;
  98. } else {
  99. /* issue a message and wait for 'device ready' interrupt */
  100. dev_err(&device->cdev->dev,
  101. "is offline or not installed - "
  102. "INTERVENTION REQUIRED!!\n");
  103. dasd_3990_erp_block_queue(erp, 60*HZ);
  104. }
  105. return erp;
  106. } /* end dasd_3990_erp_int_req */
  107. /*
  108. * DASD_3990_ERP_ALTERNATE_PATH
  109. *
  110. * DESCRIPTION
  111. * Repeat the operation on a different channel path.
  112. * If all alternate paths have been tried, the request is posted with a
  113. * permanent error.
  114. *
  115. * PARAMETER
  116. * erp pointer to the current ERP
  117. *
  118. * RETURN VALUES
  119. * erp modified pointer to the ERP
  120. */
  121. static void
  122. dasd_3990_erp_alternate_path(struct dasd_ccw_req * erp)
  123. {
  124. struct dasd_device *device = erp->startdev;
  125. __u8 opm;
  126. unsigned long flags;
  127. /* try alternate valid path */
  128. spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
  129. opm = ccw_device_get_path_mask(device->cdev);
  130. spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
  131. //FIXME: start with get_opm ?
  132. if (erp->lpm == 0)
  133. erp->lpm = LPM_ANYPATH & ~(erp->irb.esw.esw0.sublog.lpum);
  134. else
  135. erp->lpm &= ~(erp->irb.esw.esw0.sublog.lpum);
  136. if ((erp->lpm & opm) != 0x00) {
  137. DBF_DEV_EVENT(DBF_WARNING, device,
  138. "try alternate lpm=%x (lpum=%x / opm=%x)",
  139. erp->lpm, erp->irb.esw.esw0.sublog.lpum, opm);
  140. /* reset status to submit the request again... */
  141. erp->status = DASD_CQR_FILLED;
  142. erp->retries = 10;
  143. } else {
  144. dev_err(&device->cdev->dev,
  145. "The DASD cannot be reached on any path (lpum=%x"
  146. "/opm=%x)\n", erp->irb.esw.esw0.sublog.lpum, opm);
  147. /* post request with permanent error */
  148. erp->status = DASD_CQR_FAILED;
  149. }
  150. } /* end dasd_3990_erp_alternate_path */
  151. /*
  152. * DASD_3990_ERP_DCTL
  153. *
  154. * DESCRIPTION
  155. * Setup cqr to do the Diagnostic Control (DCTL) command with an
  156. * Inhibit Write subcommand (0x20) and the given modifier.
  157. *
  158. * PARAMETER
  159. * erp pointer to the current (failed) ERP
  160. * modifier subcommand modifier
  161. *
  162. * RETURN VALUES
  163. * dctl_cqr pointer to NEW dctl_cqr
  164. *
  165. */
  166. static struct dasd_ccw_req *
  167. dasd_3990_erp_DCTL(struct dasd_ccw_req * erp, char modifier)
  168. {
  169. struct dasd_device *device = erp->startdev;
  170. struct DCTL_data *DCTL_data;
  171. struct ccw1 *ccw;
  172. struct dasd_ccw_req *dctl_cqr;
  173. dctl_cqr = dasd_alloc_erp_request((char *) &erp->magic, 1,
  174. sizeof(struct DCTL_data),
  175. device);
  176. if (IS_ERR(dctl_cqr)) {
  177. dev_err(&device->cdev->dev,
  178. "Unable to allocate DCTL-CQR\n");
  179. erp->status = DASD_CQR_FAILED;
  180. return erp;
  181. }
  182. DCTL_data = dctl_cqr->data;
  183. DCTL_data->subcommand = 0x02; /* Inhibit Write */
  184. DCTL_data->modifier = modifier;
  185. ccw = dctl_cqr->cpaddr;
  186. memset(ccw, 0, sizeof(struct ccw1));
  187. ccw->cmd_code = CCW_CMD_DCTL;
  188. ccw->count = 4;
  189. ccw->cda = (__u32)(addr_t) DCTL_data;
  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. if (cqr->block &&
  1254. (cqr->block->base != cqr->startdev)) {
  1255. if (cqr->startdev->features & DASD_FEATURE_ERPLOG) {
  1256. DBF_DEV_EVENT(DBF_ERR, cqr->startdev,
  1257. "ERP on alias device for request %p,"
  1258. " recover on base device %s", cqr,
  1259. dev_name(&cqr->block->base->cdev->dev));
  1260. }
  1261. dasd_eckd_reset_ccw_to_base_io(cqr);
  1262. erp->startdev = cqr->block->base;
  1263. erp->function = dasd_3990_erp_inspect_alias;
  1264. return erp;
  1265. } else
  1266. return NULL;
  1267. }
  1268. /*
  1269. * DASD_3990_ERP_INSPECT_24
  1270. *
  1271. * DESCRIPTION
  1272. * Does a detailed inspection of the 24 byte sense data
  1273. * and sets up a related error recovery action.
  1274. *
  1275. * PARAMETER
  1276. * sense sense data of the actual error
  1277. * erp pointer to the currently created default ERP
  1278. *
  1279. * RETURN VALUES
  1280. * erp pointer to the (addtitional) ERP
  1281. */
  1282. static struct dasd_ccw_req *
  1283. dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense)
  1284. {
  1285. struct dasd_ccw_req *erp_filled = NULL;
  1286. /* Check sense for .... */
  1287. /* 'Command Reject' */
  1288. if ((erp_filled == NULL) && (sense[0] & SNS0_CMD_REJECT)) {
  1289. erp_filled = dasd_3990_erp_com_rej(erp, sense);
  1290. }
  1291. /* 'Intervention Required' */
  1292. if ((erp_filled == NULL) && (sense[0] & SNS0_INTERVENTION_REQ)) {
  1293. erp_filled = dasd_3990_erp_int_req(erp);
  1294. }
  1295. /* 'Bus Out Parity Check' */
  1296. if ((erp_filled == NULL) && (sense[0] & SNS0_BUS_OUT_CHECK)) {
  1297. erp_filled = dasd_3990_erp_bus_out(erp);
  1298. }
  1299. /* 'Equipment Check' */
  1300. if ((erp_filled == NULL) && (sense[0] & SNS0_EQUIPMENT_CHECK)) {
  1301. erp_filled = dasd_3990_erp_equip_check(erp, sense);
  1302. }
  1303. /* 'Data Check' */
  1304. if ((erp_filled == NULL) && (sense[0] & SNS0_DATA_CHECK)) {
  1305. erp_filled = dasd_3990_erp_data_check(erp, sense);
  1306. }
  1307. /* 'Overrun' */
  1308. if ((erp_filled == NULL) && (sense[0] & SNS0_OVERRUN)) {
  1309. erp_filled = dasd_3990_erp_overrun(erp, sense);
  1310. }
  1311. /* 'Invalid Track Format' */
  1312. if ((erp_filled == NULL) && (sense[1] & SNS1_INV_TRACK_FORMAT)) {
  1313. erp_filled = dasd_3990_erp_inv_format(erp, sense);
  1314. }
  1315. /* 'End-of-Cylinder' */
  1316. if ((erp_filled == NULL) && (sense[1] & SNS1_EOC)) {
  1317. erp_filled = dasd_3990_erp_EOC(erp, sense);
  1318. }
  1319. /* 'Environmental Data' */
  1320. if ((erp_filled == NULL) && (sense[2] & SNS2_ENV_DATA_PRESENT)) {
  1321. erp_filled = dasd_3990_erp_env_data(erp, sense);
  1322. }
  1323. /* 'No Record Found' */
  1324. if ((erp_filled == NULL) && (sense[1] & SNS1_NO_REC_FOUND)) {
  1325. erp_filled = dasd_3990_erp_no_rec(erp, sense);
  1326. }
  1327. /* 'File Protected' */
  1328. if ((erp_filled == NULL) && (sense[1] & SNS1_FILE_PROTECTED)) {
  1329. erp_filled = dasd_3990_erp_file_prot(erp);
  1330. }
  1331. /* other (unknown) error - do default ERP */
  1332. if (erp_filled == NULL) {
  1333. erp_filled = erp;
  1334. }
  1335. return erp_filled;
  1336. } /* END dasd_3990_erp_inspect_24 */
  1337. /*
  1338. *****************************************************************************
  1339. * 32 byte sense ERP functions (only)
  1340. *****************************************************************************
  1341. */
  1342. /*
  1343. * DASD_3990_ERPACTION_10_32
  1344. *
  1345. * DESCRIPTION
  1346. * Handles 32 byte 'Action 10' of Single Program Action Codes.
  1347. * Just retry and if retry doesn't work, return with error.
  1348. *
  1349. * PARAMETER
  1350. * erp current erp_head
  1351. * sense current sense data
  1352. * RETURN VALUES
  1353. * erp modified erp_head
  1354. */
  1355. static struct dasd_ccw_req *
  1356. dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp, char *sense)
  1357. {
  1358. struct dasd_device *device = erp->startdev;
  1359. erp->retries = 256;
  1360. erp->function = dasd_3990_erp_action_10_32;
  1361. DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Perform logging requested");
  1362. return erp;
  1363. } /* end dasd_3990_erp_action_10_32 */
  1364. /*
  1365. * DASD_3990_ERP_ACTION_1B_32
  1366. *
  1367. * DESCRIPTION
  1368. * Handles 32 byte 'Action 1B' of Single Program Action Codes.
  1369. * A write operation could not be finished because of an unexpected
  1370. * condition.
  1371. * The already created 'default erp' is used to get the link to
  1372. * the erp chain, but it can not be used for this recovery
  1373. * action because it contains no DE/LO data space.
  1374. *
  1375. * PARAMETER
  1376. * default_erp already added default erp.
  1377. * sense current sense data
  1378. *
  1379. * RETURN VALUES
  1380. * erp new erp or
  1381. * default_erp in case of imprecise ending or error
  1382. */
  1383. static struct dasd_ccw_req *
  1384. dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp, char *sense)
  1385. {
  1386. struct dasd_device *device = default_erp->startdev;
  1387. __u32 cpa = 0;
  1388. struct dasd_ccw_req *cqr;
  1389. struct dasd_ccw_req *erp;
  1390. struct DE_eckd_data *DE_data;
  1391. struct PFX_eckd_data *PFX_data;
  1392. char *LO_data; /* LO_eckd_data_t */
  1393. struct ccw1 *ccw, *oldccw;
  1394. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1395. "Write not finished because of unexpected condition");
  1396. default_erp->function = dasd_3990_erp_action_1B_32;
  1397. /* determine the original cqr */
  1398. cqr = default_erp;
  1399. while (cqr->refers != NULL) {
  1400. cqr = cqr->refers;
  1401. }
  1402. if (scsw_is_tm(&cqr->irb.scsw)) {
  1403. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1404. "32 bit sense, action 1B is not defined"
  1405. " in transport mode - just retry");
  1406. return default_erp;
  1407. }
  1408. /* for imprecise ending just do default erp */
  1409. if (sense[1] & 0x01) {
  1410. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1411. "Imprecise ending is set - just retry");
  1412. return default_erp;
  1413. }
  1414. /* determine the address of the CCW to be restarted */
  1415. /* Imprecise ending is not set -> addr from IRB-SCSW */
  1416. cpa = default_erp->refers->irb.scsw.cmd.cpa;
  1417. if (cpa == 0) {
  1418. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1419. "Unable to determine address of the CCW "
  1420. "to be restarted");
  1421. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1422. }
  1423. /* Build new ERP request including DE/LO */
  1424. erp = dasd_alloc_erp_request((char *) &cqr->magic,
  1425. 2 + 1,/* DE/LO + TIC */
  1426. sizeof(struct DE_eckd_data) +
  1427. sizeof(struct LO_eckd_data), device);
  1428. if (IS_ERR(erp)) {
  1429. /* internal error 01 - Unable to allocate ERP */
  1430. dev_err(&device->cdev->dev, "An error occurred in the DASD "
  1431. "device driver, reason=%s\n", "01");
  1432. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1433. }
  1434. /* use original DE */
  1435. DE_data = erp->data;
  1436. oldccw = cqr->cpaddr;
  1437. if (oldccw->cmd_code == DASD_ECKD_CCW_PFX) {
  1438. PFX_data = cqr->data;
  1439. memcpy(DE_data, &PFX_data->define_extent,
  1440. sizeof(struct DE_eckd_data));
  1441. } else
  1442. memcpy(DE_data, cqr->data, sizeof(struct DE_eckd_data));
  1443. /* create LO */
  1444. LO_data = erp->data + sizeof(struct DE_eckd_data);
  1445. if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
  1446. /* should not */
  1447. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1448. }
  1449. if ((sense[7] & 0x3F) == 0x01) {
  1450. /* operation code is WRITE DATA -> data area orientation */
  1451. LO_data[0] = 0x81;
  1452. } else if ((sense[7] & 0x3F) == 0x03) {
  1453. /* operation code is FORMAT WRITE -> index orientation */
  1454. LO_data[0] = 0xC3;
  1455. } else {
  1456. LO_data[0] = sense[7]; /* operation */
  1457. }
  1458. LO_data[1] = sense[8]; /* auxiliary */
  1459. LO_data[2] = sense[9];
  1460. LO_data[3] = sense[3]; /* count */
  1461. LO_data[4] = sense[29]; /* seek_addr.cyl */
  1462. LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
  1463. LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
  1464. memcpy(&(LO_data[8]), &(sense[11]), 8);
  1465. /* create DE ccw */
  1466. ccw = erp->cpaddr;
  1467. memset(ccw, 0, sizeof(struct ccw1));
  1468. ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
  1469. ccw->flags = CCW_FLAG_CC;
  1470. ccw->count = 16;
  1471. ccw->cda = (__u32)(addr_t) DE_data;
  1472. /* create LO ccw */
  1473. ccw++;
  1474. memset(ccw, 0, sizeof(struct ccw1));
  1475. ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
  1476. ccw->flags = CCW_FLAG_CC;
  1477. ccw->count = 16;
  1478. ccw->cda = (__u32)(addr_t) LO_data;
  1479. /* TIC to the failed ccw */
  1480. ccw++;
  1481. ccw->cmd_code = CCW_CMD_TIC;
  1482. ccw->cda = cpa;
  1483. /* fill erp related fields */
  1484. erp->function = dasd_3990_erp_action_1B_32;
  1485. erp->refers = default_erp->refers;
  1486. erp->startdev = device;
  1487. erp->memdev = device;
  1488. erp->magic = default_erp->magic;
  1489. erp->expires = 0;
  1490. erp->retries = 256;
  1491. erp->buildclk = get_clock();
  1492. erp->status = DASD_CQR_FILLED;
  1493. /* remove the default erp */
  1494. dasd_free_erp_request(default_erp, device);
  1495. return erp;
  1496. } /* end dasd_3990_erp_action_1B_32 */
  1497. /*
  1498. * DASD_3990_UPDATE_1B
  1499. *
  1500. * DESCRIPTION
  1501. * Handles the update to the 32 byte 'Action 1B' of Single Program
  1502. * Action Codes in case the first action was not successful.
  1503. * The already created 'previous_erp' is the currently not successful
  1504. * ERP.
  1505. *
  1506. * PARAMETER
  1507. * previous_erp already created previous erp.
  1508. * sense current sense data
  1509. * RETURN VALUES
  1510. * erp modified erp
  1511. */
  1512. static struct dasd_ccw_req *
  1513. dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
  1514. {
  1515. struct dasd_device *device = previous_erp->startdev;
  1516. __u32 cpa = 0;
  1517. struct dasd_ccw_req *cqr;
  1518. struct dasd_ccw_req *erp;
  1519. char *LO_data; /* struct LO_eckd_data */
  1520. struct ccw1 *ccw;
  1521. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1522. "Write not finished because of unexpected condition"
  1523. " - follow on");
  1524. /* determine the original cqr */
  1525. cqr = previous_erp;
  1526. while (cqr->refers != NULL) {
  1527. cqr = cqr->refers;
  1528. }
  1529. if (scsw_is_tm(&cqr->irb.scsw)) {
  1530. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1531. "32 bit sense, action 1B, update,"
  1532. " in transport mode - just retry");
  1533. return previous_erp;
  1534. }
  1535. /* for imprecise ending just do default erp */
  1536. if (sense[1] & 0x01) {
  1537. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1538. "Imprecise ending is set - just retry");
  1539. previous_erp->status = DASD_CQR_FILLED;
  1540. return previous_erp;
  1541. }
  1542. /* determine the address of the CCW to be restarted */
  1543. /* Imprecise ending is not set -> addr from IRB-SCSW */
  1544. cpa = previous_erp->irb.scsw.cmd.cpa;
  1545. if (cpa == 0) {
  1546. /* internal error 02 -
  1547. Unable to determine address of the CCW to be restarted */
  1548. dev_err(&device->cdev->dev, "An error occurred in the DASD "
  1549. "device driver, reason=%s\n", "02");
  1550. previous_erp->status = DASD_CQR_FAILED;
  1551. return previous_erp;
  1552. }
  1553. erp = previous_erp;
  1554. /* update the LO with the new returned sense data */
  1555. LO_data = erp->data + sizeof(struct DE_eckd_data);
  1556. if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
  1557. /* should not happen */
  1558. previous_erp->status = DASD_CQR_FAILED;
  1559. return previous_erp;
  1560. }
  1561. if ((sense[7] & 0x3F) == 0x01) {
  1562. /* operation code is WRITE DATA -> data area orientation */
  1563. LO_data[0] = 0x81;
  1564. } else if ((sense[7] & 0x3F) == 0x03) {
  1565. /* operation code is FORMAT WRITE -> index orientation */
  1566. LO_data[0] = 0xC3;
  1567. } else {
  1568. LO_data[0] = sense[7]; /* operation */
  1569. }
  1570. LO_data[1] = sense[8]; /* auxiliary */
  1571. LO_data[2] = sense[9];
  1572. LO_data[3] = sense[3]; /* count */
  1573. LO_data[4] = sense[29]; /* seek_addr.cyl */
  1574. LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
  1575. LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
  1576. memcpy(&(LO_data[8]), &(sense[11]), 8);
  1577. /* TIC to the failed ccw */
  1578. ccw = erp->cpaddr; /* addr of DE ccw */
  1579. ccw++; /* addr of LE ccw */
  1580. ccw++; /* addr of TIC ccw */
  1581. ccw->cda = cpa;
  1582. erp->status = DASD_CQR_FILLED;
  1583. return erp;
  1584. } /* end dasd_3990_update_1B */
  1585. /*
  1586. * DASD_3990_ERP_COMPOUND_RETRY
  1587. *
  1588. * DESCRIPTION
  1589. * Handles the compound ERP action retry code.
  1590. * NOTE: At least one retry is done even if zero is specified
  1591. * by the sense data. This makes enqueueing of the request
  1592. * easier.
  1593. *
  1594. * PARAMETER
  1595. * sense sense data of the actual error
  1596. * erp pointer to the currently created ERP
  1597. *
  1598. * RETURN VALUES
  1599. * erp modified ERP pointer
  1600. *
  1601. */
  1602. static void
  1603. dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense)
  1604. {
  1605. switch (sense[25] & 0x03) {
  1606. case 0x00: /* no not retry */
  1607. erp->retries = 1;
  1608. break;
  1609. case 0x01: /* retry 2 times */
  1610. erp->retries = 2;
  1611. break;
  1612. case 0x02: /* retry 10 times */
  1613. erp->retries = 10;
  1614. break;
  1615. case 0x03: /* retry 256 times */
  1616. erp->retries = 256;
  1617. break;
  1618. default:
  1619. BUG();
  1620. }
  1621. erp->function = dasd_3990_erp_compound_retry;
  1622. } /* end dasd_3990_erp_compound_retry */
  1623. /*
  1624. * DASD_3990_ERP_COMPOUND_PATH
  1625. *
  1626. * DESCRIPTION
  1627. * Handles the compound ERP action for retry on alternate
  1628. * channel path.
  1629. *
  1630. * PARAMETER
  1631. * sense sense data of the actual error
  1632. * erp pointer to the currently created ERP
  1633. *
  1634. * RETURN VALUES
  1635. * erp modified ERP pointer
  1636. *
  1637. */
  1638. static void
  1639. dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
  1640. {
  1641. if (sense[25] & DASD_SENSE_BIT_3) {
  1642. dasd_3990_erp_alternate_path(erp);
  1643. if (erp->status == DASD_CQR_FAILED) {
  1644. /* reset the lpm and the status to be able to
  1645. * try further actions. */
  1646. erp->lpm = 0;
  1647. erp->status = DASD_CQR_NEED_ERP;
  1648. }
  1649. }
  1650. erp->function = dasd_3990_erp_compound_path;
  1651. } /* end dasd_3990_erp_compound_path */
  1652. /*
  1653. * DASD_3990_ERP_COMPOUND_CODE
  1654. *
  1655. * DESCRIPTION
  1656. * Handles the compound ERP action for retry code.
  1657. *
  1658. * PARAMETER
  1659. * sense sense data of the actual error
  1660. * erp pointer to the currently created ERP
  1661. *
  1662. * RETURN VALUES
  1663. * erp NEW ERP pointer
  1664. *
  1665. */
  1666. static struct dasd_ccw_req *
  1667. dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
  1668. {
  1669. if (sense[25] & DASD_SENSE_BIT_2) {
  1670. switch (sense[28]) {
  1671. case 0x17:
  1672. /* issue a Diagnostic Control command with an
  1673. * Inhibit Write subcommand and controller modifier */
  1674. erp = dasd_3990_erp_DCTL(erp, 0x20);
  1675. break;
  1676. case 0x25:
  1677. /* wait for 5 seconds and retry again */
  1678. erp->retries = 1;
  1679. dasd_3990_erp_block_queue (erp, 5*HZ);
  1680. break;
  1681. default:
  1682. /* should not happen - continue */
  1683. break;
  1684. }
  1685. }
  1686. erp->function = dasd_3990_erp_compound_code;
  1687. return erp;
  1688. } /* end dasd_3990_erp_compound_code */
  1689. /*
  1690. * DASD_3990_ERP_COMPOUND_CONFIG
  1691. *
  1692. * DESCRIPTION
  1693. * Handles the compound ERP action for configruation
  1694. * dependent error.
  1695. * Note: duplex handling is not implemented (yet).
  1696. *
  1697. * PARAMETER
  1698. * sense sense data of the actual error
  1699. * erp pointer to the currently created ERP
  1700. *
  1701. * RETURN VALUES
  1702. * erp modified ERP pointer
  1703. *
  1704. */
  1705. static void
  1706. dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense)
  1707. {
  1708. if ((sense[25] & DASD_SENSE_BIT_1) && (sense[26] & DASD_SENSE_BIT_2)) {
  1709. /* set to suspended duplex state then restart
  1710. internal error 05 - Set device to suspended duplex state
  1711. should be done */
  1712. struct dasd_device *device = erp->startdev;
  1713. dev_err(&device->cdev->dev,
  1714. "An error occurred in the DASD device driver, "
  1715. "reason=%s\n", "05");
  1716. }
  1717. erp->function = dasd_3990_erp_compound_config;
  1718. } /* end dasd_3990_erp_compound_config */
  1719. /*
  1720. * DASD_3990_ERP_COMPOUND
  1721. *
  1722. * DESCRIPTION
  1723. * Does the further compound program action if
  1724. * compound retry was not successful.
  1725. *
  1726. * PARAMETER
  1727. * sense sense data of the actual error
  1728. * erp pointer to the current (failed) ERP
  1729. *
  1730. * RETURN VALUES
  1731. * erp (additional) ERP pointer
  1732. *
  1733. */
  1734. static struct dasd_ccw_req *
  1735. dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense)
  1736. {
  1737. if ((erp->function == dasd_3990_erp_compound_retry) &&
  1738. (erp->status == DASD_CQR_NEED_ERP)) {
  1739. dasd_3990_erp_compound_path(erp, sense);
  1740. }
  1741. if ((erp->function == dasd_3990_erp_compound_path) &&
  1742. (erp->status == DASD_CQR_NEED_ERP)) {
  1743. erp = dasd_3990_erp_compound_code(erp, sense);
  1744. }
  1745. if ((erp->function == dasd_3990_erp_compound_code) &&
  1746. (erp->status == DASD_CQR_NEED_ERP)) {
  1747. dasd_3990_erp_compound_config(erp, sense);
  1748. }
  1749. /* if no compound action ERP specified, the request failed */
  1750. if (erp->status == DASD_CQR_NEED_ERP)
  1751. erp->status = DASD_CQR_FAILED;
  1752. return erp;
  1753. } /* end dasd_3990_erp_compound */
  1754. /*
  1755. *DASD_3990_ERP_HANDLE_SIM
  1756. *
  1757. *DESCRIPTION
  1758. * inspects the SIM SENSE data and starts an appropriate action
  1759. *
  1760. * PARAMETER
  1761. * sense sense data of the actual error
  1762. *
  1763. * RETURN VALUES
  1764. * none
  1765. */
  1766. void
  1767. dasd_3990_erp_handle_sim(struct dasd_device *device, char *sense)
  1768. {
  1769. /* print message according to log or message to operator mode */
  1770. if ((sense[24] & DASD_SIM_MSG_TO_OP) || (sense[1] & 0x10)) {
  1771. /* print SIM SRC from RefCode */
  1772. dev_err(&device->cdev->dev, "SIM - SRC: "
  1773. "%02x%02x%02x%02x\n", sense[22],
  1774. sense[23], sense[11], sense[12]);
  1775. } else if (sense[24] & DASD_SIM_LOG) {
  1776. /* print SIM SRC Refcode */
  1777. dev_warn(&device->cdev->dev, "log SIM - SRC: "
  1778. "%02x%02x%02x%02x\n", sense[22],
  1779. sense[23], sense[11], sense[12]);
  1780. }
  1781. }
  1782. /*
  1783. * DASD_3990_ERP_INSPECT_32
  1784. *
  1785. * DESCRIPTION
  1786. * Does a detailed inspection of the 32 byte sense data
  1787. * and sets up a related error recovery action.
  1788. *
  1789. * PARAMETER
  1790. * sense sense data of the actual error
  1791. * erp pointer to the currently created default ERP
  1792. *
  1793. * RETURN VALUES
  1794. * erp_filled pointer to the ERP
  1795. *
  1796. */
  1797. static struct dasd_ccw_req *
  1798. dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
  1799. {
  1800. struct dasd_device *device = erp->startdev;
  1801. erp->function = dasd_3990_erp_inspect_32;
  1802. /* check for SIM sense data */
  1803. if ((sense[6] & DASD_SIM_SENSE) == DASD_SIM_SENSE)
  1804. dasd_3990_erp_handle_sim(device, sense);
  1805. if (sense[25] & DASD_SENSE_BIT_0) {
  1806. /* compound program action codes (byte25 bit 0 == '1') */
  1807. dasd_3990_erp_compound_retry(erp, sense);
  1808. } else {
  1809. /* single program action codes (byte25 bit 0 == '0') */
  1810. switch (sense[25]) {
  1811. case 0x00: /* success - use default ERP for retries */
  1812. DBF_DEV_EVENT(DBF_DEBUG, device, "%s",
  1813. "ERP called for successful request"
  1814. " - just retry");
  1815. break;
  1816. case 0x01: /* fatal error */
  1817. dev_err(&device->cdev->dev,
  1818. "ERP failed for the DASD\n");
  1819. erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  1820. break;
  1821. case 0x02: /* intervention required */
  1822. case 0x03: /* intervention required during dual copy */
  1823. erp = dasd_3990_erp_int_req(erp);
  1824. break;
  1825. case 0x0F: /* length mismatch during update write command
  1826. internal error 08 - update write command error*/
  1827. dev_err(&device->cdev->dev, "An error occurred in the "
  1828. "DASD device driver, reason=%s\n", "08");
  1829. erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  1830. break;
  1831. case 0x10: /* logging required for other channel program */
  1832. erp = dasd_3990_erp_action_10_32(erp, sense);
  1833. break;
  1834. case 0x15: /* next track outside defined extend
  1835. internal error 07 - The next track is not
  1836. within the defined storage extent */
  1837. dev_err(&device->cdev->dev,
  1838. "An error occurred in the DASD device driver, "
  1839. "reason=%s\n", "07");
  1840. erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  1841. break;
  1842. case 0x1B: /* unexpected condition during write */
  1843. erp = dasd_3990_erp_action_1B_32(erp, sense);
  1844. break;
  1845. case 0x1C: /* invalid data */
  1846. dev_emerg(&device->cdev->dev,
  1847. "Data recovered during retry with PCI "
  1848. "fetch mode active\n");
  1849. /* not possible to handle this situation in Linux */
  1850. panic
  1851. ("Invalid data - No way to inform application "
  1852. "about the possibly incorrect data");
  1853. break;
  1854. case 0x1D: /* state-change pending */
  1855. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1856. "A State change pending condition exists "
  1857. "for the subsystem or device");
  1858. erp = dasd_3990_erp_action_4(erp, sense);
  1859. break;
  1860. case 0x1E: /* busy */
  1861. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1862. "Busy condition exists "
  1863. "for the subsystem or device");
  1864. erp = dasd_3990_erp_action_4(erp, sense);
  1865. break;
  1866. default: /* all others errors - default erp */
  1867. break;
  1868. }
  1869. }
  1870. return erp;
  1871. } /* end dasd_3990_erp_inspect_32 */
  1872. /*
  1873. *****************************************************************************
  1874. * main ERP control fuctions (24 and 32 byte sense)
  1875. *****************************************************************************
  1876. */
  1877. /*
  1878. * DASD_3990_ERP_CONTROL_CHECK
  1879. *
  1880. * DESCRIPTION
  1881. * Does a generic inspection if a control check occured and sets up
  1882. * the related error recovery procedure
  1883. *
  1884. * PARAMETER
  1885. * erp pointer to the currently created default ERP
  1886. *
  1887. * RETURN VALUES
  1888. * erp_filled pointer to the erp
  1889. */
  1890. static struct dasd_ccw_req *
  1891. dasd_3990_erp_control_check(struct dasd_ccw_req *erp)
  1892. {
  1893. struct dasd_device *device = erp->startdev;
  1894. if (scsw_cstat(&erp->refers->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK
  1895. | SCHN_STAT_CHN_CTRL_CHK)) {
  1896. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1897. "channel or interface control check");
  1898. erp = dasd_3990_erp_action_4(erp, NULL);
  1899. }
  1900. return erp;
  1901. }
  1902. /*
  1903. * DASD_3990_ERP_INSPECT
  1904. *
  1905. * DESCRIPTION
  1906. * Does a detailed inspection for sense data by calling either
  1907. * the 24-byte or the 32-byte inspection routine.
  1908. *
  1909. * PARAMETER
  1910. * erp pointer to the currently created default ERP
  1911. * RETURN VALUES
  1912. * erp_new contens was possibly modified
  1913. */
  1914. static struct dasd_ccw_req *
  1915. dasd_3990_erp_inspect(struct dasd_ccw_req *erp)
  1916. {
  1917. struct dasd_ccw_req *erp_new = NULL;
  1918. char *sense;
  1919. /* if this problem occured on an alias retry on base */
  1920. erp_new = dasd_3990_erp_inspect_alias(erp);
  1921. if (erp_new)
  1922. return erp_new;
  1923. /* sense data are located in the refers record of the
  1924. * already set up new ERP !
  1925. * check if concurrent sens is available
  1926. */
  1927. sense = dasd_get_sense(&erp->refers->irb);
  1928. if (!sense)
  1929. erp_new = dasd_3990_erp_control_check(erp);
  1930. /* distinguish between 24 and 32 byte sense data */
  1931. else if (sense[27] & DASD_SENSE_BIT_0) {
  1932. /* inspect the 24 byte sense data */
  1933. erp_new = dasd_3990_erp_inspect_24(erp, sense);
  1934. } else {
  1935. /* inspect the 32 byte sense data */
  1936. erp_new = dasd_3990_erp_inspect_32(erp, sense);
  1937. } /* end distinguish between 24 and 32 byte sense data */
  1938. return erp_new;
  1939. }
  1940. /*
  1941. * DASD_3990_ERP_ADD_ERP
  1942. *
  1943. * DESCRIPTION
  1944. * This funtion adds an additional request block (ERP) to the head of
  1945. * the given cqr (or erp).
  1946. * For a command mode cqr the erp is initialized as an default erp
  1947. * (retry TIC).
  1948. * For transport mode we make a copy of the original TCW (points to
  1949. * the original TCCB, TIDALs, etc.) but give it a fresh
  1950. * TSB so the original sense data will not be changed.
  1951. *
  1952. * PARAMETER
  1953. * cqr head of the current ERP-chain (or single cqr if
  1954. * first error)
  1955. * RETURN VALUES
  1956. * erp pointer to new ERP-chain head
  1957. */
  1958. static struct dasd_ccw_req *dasd_3990_erp_add_erp(struct dasd_ccw_req *cqr)
  1959. {
  1960. struct dasd_device *device = cqr->startdev;
  1961. struct ccw1 *ccw;
  1962. struct dasd_ccw_req *erp;
  1963. int cplength, datasize;
  1964. struct tcw *tcw;
  1965. struct tsb *tsb;
  1966. if (cqr->cpmode == 1) {
  1967. cplength = 0;
  1968. /* TCW needs to be 64 byte aligned, so leave enough room */
  1969. datasize = 64 + sizeof(struct tcw) + sizeof(struct tsb);
  1970. } else {
  1971. cplength = 2;
  1972. datasize = 0;
  1973. }
  1974. /* allocate additional request block */
  1975. erp = dasd_alloc_erp_request((char *) &cqr->magic,
  1976. cplength, datasize, device);
  1977. if (IS_ERR(erp)) {
  1978. if (cqr->retries <= 0) {
  1979. DBF_DEV_EVENT(DBF_ERR, device, "%s",
  1980. "Unable to allocate ERP request");
  1981. cqr->status = DASD_CQR_FAILED;
  1982. cqr->stopclk = get_clock ();
  1983. } else {
  1984. DBF_DEV_EVENT(DBF_ERR, device,
  1985. "Unable to allocate ERP request "
  1986. "(%i retries left)",
  1987. cqr->retries);
  1988. dasd_block_set_timer(device->block, (HZ << 3));
  1989. }
  1990. return cqr;
  1991. }
  1992. ccw = cqr->cpaddr;
  1993. if (cqr->cpmode == 1) {
  1994. /* make a shallow copy of the original tcw but set new tsb */
  1995. erp->cpmode = 1;
  1996. erp->cpaddr = PTR_ALIGN(erp->data, 64);
  1997. tcw = erp->cpaddr;
  1998. tsb = (struct tsb *) &tcw[1];
  1999. *tcw = *((struct tcw *)cqr->cpaddr);
  2000. tcw->tsb = (long)tsb;
  2001. } else if (ccw->cmd_code == DASD_ECKD_CCW_PSF) {
  2002. /* PSF cannot be chained from NOOP/TIC */
  2003. erp->cpaddr = cqr->cpaddr;
  2004. } else {
  2005. /* initialize request with default TIC to current ERP/CQR */
  2006. ccw = erp->cpaddr;
  2007. ccw->cmd_code = CCW_CMD_NOOP;
  2008. ccw->flags = CCW_FLAG_CC;
  2009. ccw++;
  2010. ccw->cmd_code = CCW_CMD_TIC;
  2011. ccw->cda = (long)(cqr->cpaddr);
  2012. }
  2013. erp->function = dasd_3990_erp_add_erp;
  2014. erp->refers = cqr;
  2015. erp->startdev = device;
  2016. erp->memdev = device;
  2017. erp->block = cqr->block;
  2018. erp->magic = cqr->magic;
  2019. erp->expires = 0;
  2020. erp->retries = 256;
  2021. erp->buildclk = get_clock();
  2022. erp->status = DASD_CQR_FILLED;
  2023. return erp;
  2024. }
  2025. /*
  2026. * DASD_3990_ERP_ADDITIONAL_ERP
  2027. *
  2028. * DESCRIPTION
  2029. * An additional ERP is needed to handle the current error.
  2030. * Add ERP to the head of the ERP-chain containing the ERP processing
  2031. * determined based on the sense data.
  2032. *
  2033. * PARAMETER
  2034. * cqr head of the current ERP-chain (or single cqr if
  2035. * first error)
  2036. *
  2037. * RETURN VALUES
  2038. * erp pointer to new ERP-chain head
  2039. */
  2040. static struct dasd_ccw_req *
  2041. dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)
  2042. {
  2043. struct dasd_ccw_req *erp = NULL;
  2044. /* add erp and initialize with default TIC */
  2045. erp = dasd_3990_erp_add_erp(cqr);
  2046. /* inspect sense, determine specific ERP if possible */
  2047. if (erp != cqr) {
  2048. erp = dasd_3990_erp_inspect(erp);
  2049. }
  2050. return erp;
  2051. } /* end dasd_3990_erp_additional_erp */
  2052. /*
  2053. * DASD_3990_ERP_ERROR_MATCH
  2054. *
  2055. * DESCRIPTION
  2056. * Check if the device status of the given cqr is the same.
  2057. * This means that the failed CCW and the relevant sense data
  2058. * must match.
  2059. * I don't distinguish between 24 and 32 byte sense because in case of
  2060. * 24 byte sense byte 25 and 27 is set as well.
  2061. *
  2062. * PARAMETER
  2063. * cqr1 first cqr, which will be compared with the
  2064. * cqr2 second cqr.
  2065. *
  2066. * RETURN VALUES
  2067. * match 'boolean' for match found
  2068. * returns 1 if match found, otherwise 0.
  2069. */
  2070. static int dasd_3990_erp_error_match(struct dasd_ccw_req *cqr1,
  2071. struct dasd_ccw_req *cqr2)
  2072. {
  2073. char *sense1, *sense2;
  2074. if (cqr1->startdev != cqr2->startdev)
  2075. return 0;
  2076. sense1 = dasd_get_sense(&cqr1->irb);
  2077. sense2 = dasd_get_sense(&cqr2->irb);
  2078. /* one request has sense data, the other not -> no match, return 0 */
  2079. if (!sense1 != !sense2)
  2080. return 0;
  2081. /* no sense data in both cases -> check cstat for IFCC */
  2082. if (!sense1 && !sense2) {
  2083. if ((scsw_cstat(&cqr1->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
  2084. SCHN_STAT_CHN_CTRL_CHK)) ==
  2085. (scsw_cstat(&cqr2->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
  2086. SCHN_STAT_CHN_CTRL_CHK)))
  2087. return 1; /* match with ifcc*/
  2088. }
  2089. /* check sense data; byte 0-2,25,27 */
  2090. if (!(sense1 && sense2 &&
  2091. (memcmp(sense1, sense2, 3) == 0) &&
  2092. (sense1[27] == sense2[27]) &&
  2093. (sense1[25] == sense2[25]))) {
  2094. return 0; /* sense doesn't match */
  2095. }
  2096. return 1; /* match */
  2097. } /* end dasd_3990_erp_error_match */
  2098. /*
  2099. * DASD_3990_ERP_IN_ERP
  2100. *
  2101. * DESCRIPTION
  2102. * check if the current error already happened before.
  2103. * quick exit if current cqr is not an ERP (cqr->refers=NULL)
  2104. *
  2105. * PARAMETER
  2106. * cqr failed cqr (either original cqr or already an erp)
  2107. *
  2108. * RETURN VALUES
  2109. * erp erp-pointer to the already defined error
  2110. * recovery procedure OR
  2111. * NULL if a 'new' error occurred.
  2112. */
  2113. static struct dasd_ccw_req *
  2114. dasd_3990_erp_in_erp(struct dasd_ccw_req *cqr)
  2115. {
  2116. struct dasd_ccw_req *erp_head = cqr, /* save erp chain head */
  2117. *erp_match = NULL; /* save erp chain head */
  2118. int match = 0; /* 'boolean' for matching error found */
  2119. if (cqr->refers == NULL) { /* return if not in erp */
  2120. return NULL;
  2121. }
  2122. /* check the erp/cqr chain for current error */
  2123. do {
  2124. match = dasd_3990_erp_error_match(erp_head, cqr->refers);
  2125. erp_match = cqr; /* save possible matching erp */
  2126. cqr = cqr->refers; /* check next erp/cqr in queue */
  2127. } while ((cqr->refers != NULL) && (!match));
  2128. if (!match) {
  2129. return NULL; /* no match was found */
  2130. }
  2131. return erp_match; /* return address of matching erp */
  2132. } /* END dasd_3990_erp_in_erp */
  2133. /*
  2134. * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense)
  2135. *
  2136. * DESCRIPTION
  2137. * No retry is left for the current ERP. Check what has to be done
  2138. * with the ERP.
  2139. * - do further defined ERP action or
  2140. * - wait for interrupt or
  2141. * - exit with permanent error
  2142. *
  2143. * PARAMETER
  2144. * erp ERP which is in progress with no retry left
  2145. *
  2146. * RETURN VALUES
  2147. * erp modified/additional ERP
  2148. */
  2149. static struct dasd_ccw_req *
  2150. dasd_3990_erp_further_erp(struct dasd_ccw_req *erp)
  2151. {
  2152. struct dasd_device *device = erp->startdev;
  2153. char *sense = dasd_get_sense(&erp->irb);
  2154. /* check for 24 byte sense ERP */
  2155. if ((erp->function == dasd_3990_erp_bus_out) ||
  2156. (erp->function == dasd_3990_erp_action_1) ||
  2157. (erp->function == dasd_3990_erp_action_4)) {
  2158. erp = dasd_3990_erp_action_1(erp);
  2159. } else if (erp->function == dasd_3990_erp_action_1_sec) {
  2160. erp = dasd_3990_erp_action_1_sec(erp);
  2161. } else if (erp->function == dasd_3990_erp_action_5) {
  2162. /* retries have not been successful */
  2163. /* prepare erp for retry on different channel path */
  2164. erp = dasd_3990_erp_action_1(erp);
  2165. if (sense && !(sense[2] & DASD_SENSE_BIT_0)) {
  2166. /* issue a Diagnostic Control command with an
  2167. * Inhibit Write subcommand */
  2168. switch (sense[25]) {
  2169. case 0x17:
  2170. case 0x57:{ /* controller */
  2171. erp = dasd_3990_erp_DCTL(erp, 0x20);
  2172. break;
  2173. }
  2174. case 0x18:
  2175. case 0x58:{ /* channel path */
  2176. erp = dasd_3990_erp_DCTL(erp, 0x40);
  2177. break;
  2178. }
  2179. case 0x19:
  2180. case 0x59:{ /* storage director */
  2181. erp = dasd_3990_erp_DCTL(erp, 0x80);
  2182. break;
  2183. }
  2184. default:
  2185. DBF_DEV_EVENT(DBF_WARNING, device,
  2186. "invalid subcommand modifier 0x%x "
  2187. "for Diagnostic Control Command",
  2188. sense[25]);
  2189. }
  2190. }
  2191. /* check for 32 byte sense ERP */
  2192. } else if (sense &&
  2193. ((erp->function == dasd_3990_erp_compound_retry) ||
  2194. (erp->function == dasd_3990_erp_compound_path) ||
  2195. (erp->function == dasd_3990_erp_compound_code) ||
  2196. (erp->function == dasd_3990_erp_compound_config))) {
  2197. erp = dasd_3990_erp_compound(erp, sense);
  2198. } else {
  2199. /*
  2200. * No retry left and no additional special handling
  2201. * necessary
  2202. */
  2203. dev_err(&device->cdev->dev,
  2204. "ERP %p has run out of retries and failed\n", erp);
  2205. erp->status = DASD_CQR_FAILED;
  2206. }
  2207. return erp;
  2208. } /* end dasd_3990_erp_further_erp */
  2209. /*
  2210. * DASD_3990_ERP_HANDLE_MATCH_ERP
  2211. *
  2212. * DESCRIPTION
  2213. * An error occurred again and an ERP has been detected which is already
  2214. * used to handle this error (e.g. retries).
  2215. * All prior ERP's are asumed to be successful and therefore removed
  2216. * from queue.
  2217. * If retry counter of matching erp is already 0, it is checked if further
  2218. * action is needed (besides retry) or if the ERP has failed.
  2219. *
  2220. * PARAMETER
  2221. * erp_head first ERP in ERP-chain
  2222. * erp ERP that handles the actual error.
  2223. * (matching erp)
  2224. *
  2225. * RETURN VALUES
  2226. * erp modified/additional ERP
  2227. */
  2228. static struct dasd_ccw_req *
  2229. dasd_3990_erp_handle_match_erp(struct dasd_ccw_req *erp_head,
  2230. struct dasd_ccw_req *erp)
  2231. {
  2232. struct dasd_device *device = erp_head->startdev;
  2233. struct dasd_ccw_req *erp_done = erp_head; /* finished req */
  2234. struct dasd_ccw_req *erp_free = NULL; /* req to be freed */
  2235. /* loop over successful ERPs and remove them from chanq */
  2236. while (erp_done != erp) {
  2237. if (erp_done == NULL) /* end of chain reached */
  2238. panic(PRINTK_HEADER "Programming error in ERP! The "
  2239. "original request was lost\n");
  2240. /* remove the request from the device queue */
  2241. list_del(&erp_done->blocklist);
  2242. erp_free = erp_done;
  2243. erp_done = erp_done->refers;
  2244. /* free the finished erp request */
  2245. dasd_free_erp_request(erp_free, erp_free->memdev);
  2246. } /* end while */
  2247. if (erp->retries > 0) {
  2248. char *sense = dasd_get_sense(&erp->refers->irb);
  2249. /* check for special retries */
  2250. if (sense && erp->function == dasd_3990_erp_action_4) {
  2251. erp = dasd_3990_erp_action_4(erp, sense);
  2252. } else if (sense &&
  2253. erp->function == dasd_3990_erp_action_1B_32) {
  2254. erp = dasd_3990_update_1B(erp, sense);
  2255. } else if (sense && erp->function == dasd_3990_erp_int_req) {
  2256. erp = dasd_3990_erp_int_req(erp);
  2257. } else {
  2258. /* simple retry */
  2259. DBF_DEV_EVENT(DBF_DEBUG, device,
  2260. "%i retries left for erp %p",
  2261. erp->retries, erp);
  2262. /* handle the request again... */
  2263. erp->status = DASD_CQR_FILLED;
  2264. }
  2265. } else {
  2266. /* no retry left - check for further necessary action */
  2267. /* if no further actions, handle rest as permanent error */
  2268. erp = dasd_3990_erp_further_erp(erp);
  2269. }
  2270. return erp;
  2271. } /* end dasd_3990_erp_handle_match_erp */
  2272. /*
  2273. * DASD_3990_ERP_ACTION
  2274. *
  2275. * DESCRIPTION
  2276. * control routine for 3990 erp actions.
  2277. * Has to be called with the queue lock (namely the s390_irq_lock) acquired.
  2278. *
  2279. * PARAMETER
  2280. * cqr failed cqr (either original cqr or already an erp)
  2281. *
  2282. * RETURN VALUES
  2283. * erp erp-pointer to the head of the ERP action chain.
  2284. * This means:
  2285. * - either a ptr to an additional ERP cqr or
  2286. * - the original given cqr (which's status might
  2287. * be modified)
  2288. */
  2289. struct dasd_ccw_req *
  2290. dasd_3990_erp_action(struct dasd_ccw_req * cqr)
  2291. {
  2292. struct dasd_ccw_req *erp = NULL;
  2293. struct dasd_device *device = cqr->startdev;
  2294. struct dasd_ccw_req *temp_erp = NULL;
  2295. if (device->features & DASD_FEATURE_ERPLOG) {
  2296. /* print current erp_chain */
  2297. dev_err(&device->cdev->dev,
  2298. "ERP chain at BEGINNING of ERP-ACTION\n");
  2299. for (temp_erp = cqr;
  2300. temp_erp != NULL; temp_erp = temp_erp->refers) {
  2301. dev_err(&device->cdev->dev,
  2302. "ERP %p (%02x) refers to %p\n",
  2303. temp_erp, temp_erp->status,
  2304. temp_erp->refers);
  2305. }
  2306. }
  2307. /* double-check if current erp/cqr was successful */
  2308. if ((scsw_cstat(&cqr->irb.scsw) == 0x00) &&
  2309. (scsw_dstat(&cqr->irb.scsw) ==
  2310. (DEV_STAT_CHN_END | DEV_STAT_DEV_END))) {
  2311. DBF_DEV_EVENT(DBF_DEBUG, device,
  2312. "ERP called for successful request %p"
  2313. " - NO ERP necessary", cqr);
  2314. cqr->status = DASD_CQR_DONE;
  2315. return cqr;
  2316. }
  2317. /* check if error happened before */
  2318. erp = dasd_3990_erp_in_erp(cqr);
  2319. if (erp == NULL) {
  2320. /* no matching erp found - set up erp */
  2321. erp = dasd_3990_erp_additional_erp(cqr);
  2322. } else {
  2323. /* matching erp found - set all leading erp's to DONE */
  2324. erp = dasd_3990_erp_handle_match_erp(cqr, erp);
  2325. }
  2326. if (device->features & DASD_FEATURE_ERPLOG) {
  2327. /* print current erp_chain */
  2328. dev_err(&device->cdev->dev,
  2329. "ERP chain at END of ERP-ACTION\n");
  2330. for (temp_erp = erp;
  2331. temp_erp != NULL; temp_erp = temp_erp->refers) {
  2332. dev_err(&device->cdev->dev,
  2333. "ERP %p (%02x) refers to %p\n",
  2334. temp_erp, temp_erp->status,
  2335. temp_erp->refers);
  2336. }
  2337. }
  2338. /* enqueue ERP request if it's a new one */
  2339. if (list_empty(&erp->blocklist)) {
  2340. cqr->status = DASD_CQR_IN_ERP;
  2341. /* add erp request before the cqr */
  2342. list_add_tail(&erp->blocklist, &cqr->blocklist);
  2343. }
  2344. return erp;
  2345. } /* end dasd_3990_erp_action */