dasd_3990_erp.c 67 KB

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