dasd_3990_erp.c 67 KB

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