dasd_3990_erp.c 70 KB

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