dasd_3990_erp.c 71 KB

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