dasd_3990_erp.c 67 KB

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