dasd_3990_erp.c 69 KB

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