dasd_3990_erp.c 68 KB

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