dasd_3990_erp.c 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773
  1. /*
  2. * File...........: linux/drivers/s390/block/dasd_3990_erp.c
  3. * Author(s)......: Horst Hummel <Horst.Hummel@de.ibm.com>
  4. * Holger Smolinski <Holger.Smolinski@de.ibm.com>
  5. * Bugreports.to..: <Linux390@de.ibm.com>
  6. * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000, 2001
  7. *
  8. */
  9. #define KMSG_COMPONENT "dasd-eckd"
  10. #include <linux/timer.h>
  11. #include <asm/idals.h>
  12. #define PRINTK_HEADER "dasd_erp(3990): "
  13. #include "dasd_int.h"
  14. #include "dasd_eckd.h"
  15. struct DCTL_data {
  16. unsigned char subcommand; /* e.g Inhibit Write, Enable Write,... */
  17. unsigned char modifier; /* Subcommand modifier */
  18. unsigned short res; /* reserved */
  19. } __attribute__ ((packed));
  20. /*
  21. *****************************************************************************
  22. * SECTION ERP HANDLING
  23. *****************************************************************************
  24. */
  25. /*
  26. *****************************************************************************
  27. * 24 and 32 byte sense ERP functions
  28. *****************************************************************************
  29. */
  30. /*
  31. * DASD_3990_ERP_CLEANUP
  32. *
  33. * DESCRIPTION
  34. * Removes the already build but not necessary ERP request and sets
  35. * the status of the original cqr / erp to the given (final) status
  36. *
  37. * PARAMETER
  38. * erp request to be blocked
  39. * final_status either DASD_CQR_DONE or DASD_CQR_FAILED
  40. *
  41. * RETURN VALUES
  42. * cqr original cqr
  43. */
  44. static struct dasd_ccw_req *
  45. dasd_3990_erp_cleanup(struct dasd_ccw_req * erp, char final_status)
  46. {
  47. struct dasd_ccw_req *cqr = erp->refers;
  48. dasd_free_erp_request(erp, erp->memdev);
  49. cqr->status = final_status;
  50. return cqr;
  51. } /* end dasd_3990_erp_cleanup */
  52. /*
  53. * DASD_3990_ERP_BLOCK_QUEUE
  54. *
  55. * DESCRIPTION
  56. * Block the given device request queue to prevent from further
  57. * processing until the started timer has expired or an related
  58. * interrupt was received.
  59. */
  60. static void dasd_3990_erp_block_queue(struct dasd_ccw_req *erp, int expires)
  61. {
  62. struct dasd_device *device = erp->startdev;
  63. unsigned long flags;
  64. DBF_DEV_EVENT(DBF_INFO, device,
  65. "blocking request queue for %is", expires/HZ);
  66. spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
  67. dasd_device_set_stop_bits(device, DASD_STOPPED_PENDING);
  68. spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
  69. erp->status = DASD_CQR_FILLED;
  70. if (erp->block)
  71. dasd_block_set_timer(erp->block, expires);
  72. else
  73. dasd_device_set_timer(device, expires);
  74. }
  75. /*
  76. * DASD_3990_ERP_INT_REQ
  77. *
  78. * DESCRIPTION
  79. * Handles 'Intervention Required' error.
  80. * This means either device offline or not installed.
  81. *
  82. * PARAMETER
  83. * erp current erp
  84. * RETURN VALUES
  85. * erp modified erp
  86. */
  87. static struct dasd_ccw_req *
  88. dasd_3990_erp_int_req(struct dasd_ccw_req * erp)
  89. {
  90. struct dasd_device *device = erp->startdev;
  91. /* first time set initial retry counter and erp_function */
  92. /* and retry once without blocking queue */
  93. /* (this enables easier enqueing of the cqr) */
  94. if (erp->function != dasd_3990_erp_int_req) {
  95. erp->retries = 256;
  96. erp->function = dasd_3990_erp_int_req;
  97. } else {
  98. /* issue a message and wait for 'device ready' interrupt */
  99. dev_err(&device->cdev->dev,
  100. "is offline or not installed - "
  101. "INTERVENTION REQUIRED!!\n");
  102. dasd_3990_erp_block_queue(erp, 60*HZ);
  103. }
  104. return erp;
  105. } /* end dasd_3990_erp_int_req */
  106. /*
  107. * DASD_3990_ERP_ALTERNATE_PATH
  108. *
  109. * DESCRIPTION
  110. * Repeat the operation on a different channel path.
  111. * If all alternate paths have been tried, the request is posted with a
  112. * permanent error.
  113. *
  114. * PARAMETER
  115. * erp pointer to the current ERP
  116. *
  117. * RETURN VALUES
  118. * erp modified pointer to the ERP
  119. */
  120. static void
  121. dasd_3990_erp_alternate_path(struct dasd_ccw_req * erp)
  122. {
  123. struct dasd_device *device = erp->startdev;
  124. __u8 opm;
  125. unsigned long flags;
  126. /* try alternate valid path */
  127. spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
  128. opm = ccw_device_get_path_mask(device->cdev);
  129. spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
  130. if (erp->lpm == 0)
  131. erp->lpm = device->path_data.opm &
  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_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 = erp->startdev->path_data.opm;
  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 syn 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 syn 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 D - 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. dev_err(&device->cdev->dev, "An error occurred in the DASD "
  975. "device driver, reason=%s\n", "09");
  976. erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  977. }
  978. return erp;
  979. } /* end dasd_3990_erp_com_rej */
  980. /*
  981. * DASD_3990_ERP_BUS_OUT
  982. *
  983. * DESCRIPTION
  984. * Handles 24 byte 'Bus Out Parity Check' error.
  985. *
  986. * PARAMETER
  987. * erp current erp_head
  988. * RETURN VALUES
  989. * erp new erp_head - pointer to new ERP
  990. */
  991. static struct dasd_ccw_req *
  992. dasd_3990_erp_bus_out(struct dasd_ccw_req * erp)
  993. {
  994. struct dasd_device *device = erp->startdev;
  995. /* first time set initial retry counter and erp_function */
  996. /* and retry once without blocking queue */
  997. /* (this enables easier enqueing of the cqr) */
  998. if (erp->function != dasd_3990_erp_bus_out) {
  999. erp->retries = 256;
  1000. erp->function = dasd_3990_erp_bus_out;
  1001. } else {
  1002. /* issue a message and wait for 'device ready' interrupt */
  1003. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1004. "bus out parity error or BOPC requested by "
  1005. "channel");
  1006. dasd_3990_erp_block_queue(erp, 60*HZ);
  1007. }
  1008. return erp;
  1009. } /* end dasd_3990_erp_bus_out */
  1010. /*
  1011. * DASD_3990_ERP_EQUIP_CHECK
  1012. *
  1013. * DESCRIPTION
  1014. * Handles 24 byte 'Equipment Check' error.
  1015. *
  1016. * PARAMETER
  1017. * erp current erp_head
  1018. * RETURN VALUES
  1019. * erp new erp_head - pointer to new ERP
  1020. */
  1021. static struct dasd_ccw_req *
  1022. dasd_3990_erp_equip_check(struct dasd_ccw_req * erp, char *sense)
  1023. {
  1024. struct dasd_device *device = erp->startdev;
  1025. erp->function = dasd_3990_erp_equip_check;
  1026. if (sense[1] & SNS1_WRITE_INHIBITED) {
  1027. dev_info(&device->cdev->dev,
  1028. "Write inhibited path encountered\n");
  1029. /* vary path offline
  1030. internal error 04 - Path should be varied off-line.*/
  1031. dev_err(&device->cdev->dev, "An error occurred in the DASD "
  1032. "device driver, reason=%s\n", "04");
  1033. erp = dasd_3990_erp_action_1(erp);
  1034. } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
  1035. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1036. "Equipment Check - " "environmental data present");
  1037. dasd_3990_handle_env_data(erp, sense);
  1038. erp = dasd_3990_erp_action_4(erp, sense);
  1039. } else if (sense[1] & SNS1_PERM_ERR) {
  1040. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1041. "Equipment Check - retry exhausted or "
  1042. "undesirable");
  1043. erp = dasd_3990_erp_action_1(erp);
  1044. } else {
  1045. /* all other equipment checks - Action 5 */
  1046. /* rest is done when retries == 0 */
  1047. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1048. "Equipment check or processing error");
  1049. erp = dasd_3990_erp_action_5(erp);
  1050. }
  1051. return erp;
  1052. } /* end dasd_3990_erp_equip_check */
  1053. /*
  1054. * DASD_3990_ERP_DATA_CHECK
  1055. *
  1056. * DESCRIPTION
  1057. * Handles 24 byte 'Data Check' error.
  1058. *
  1059. * PARAMETER
  1060. * erp current erp_head
  1061. * RETURN VALUES
  1062. * erp new erp_head - pointer to new ERP
  1063. */
  1064. static struct dasd_ccw_req *
  1065. dasd_3990_erp_data_check(struct dasd_ccw_req * erp, char *sense)
  1066. {
  1067. struct dasd_device *device = erp->startdev;
  1068. erp->function = dasd_3990_erp_data_check;
  1069. if (sense[2] & SNS2_CORRECTABLE) { /* correctable data check */
  1070. /* issue message that the data has been corrected */
  1071. dev_emerg(&device->cdev->dev,
  1072. "Data recovered during retry with PCI "
  1073. "fetch mode active\n");
  1074. /* not possible to handle this situation in Linux */
  1075. panic("No way to inform application about the possibly "
  1076. "incorrect data");
  1077. } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
  1078. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1079. "Uncorrectable data check recovered secondary "
  1080. "addr of duplex pair");
  1081. erp = dasd_3990_erp_action_4(erp, sense);
  1082. } else if (sense[1] & SNS1_PERM_ERR) {
  1083. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1084. "Uncorrectable data check with internal "
  1085. "retry exhausted");
  1086. erp = dasd_3990_erp_action_1(erp);
  1087. } else {
  1088. /* all other data checks */
  1089. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1090. "Uncorrectable data check with retry count "
  1091. "exhausted...");
  1092. erp = dasd_3990_erp_action_5(erp);
  1093. }
  1094. return erp;
  1095. } /* end dasd_3990_erp_data_check */
  1096. /*
  1097. * DASD_3990_ERP_OVERRUN
  1098. *
  1099. * DESCRIPTION
  1100. * Handles 24 byte 'Overrun' error.
  1101. *
  1102. * PARAMETER
  1103. * erp current erp_head
  1104. * RETURN VALUES
  1105. * erp new erp_head - pointer to new ERP
  1106. */
  1107. static struct dasd_ccw_req *
  1108. dasd_3990_erp_overrun(struct dasd_ccw_req * erp, char *sense)
  1109. {
  1110. struct dasd_device *device = erp->startdev;
  1111. erp->function = dasd_3990_erp_overrun;
  1112. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1113. "Overrun - service overrun or overrun"
  1114. " error requested by channel");
  1115. erp = dasd_3990_erp_action_5(erp);
  1116. return erp;
  1117. } /* end dasd_3990_erp_overrun */
  1118. /*
  1119. * DASD_3990_ERP_INV_FORMAT
  1120. *
  1121. * DESCRIPTION
  1122. * Handles 24 byte 'Invalid Track Format' error.
  1123. *
  1124. * PARAMETER
  1125. * erp current erp_head
  1126. * RETURN VALUES
  1127. * erp new erp_head - pointer to new ERP
  1128. */
  1129. static struct dasd_ccw_req *
  1130. dasd_3990_erp_inv_format(struct dasd_ccw_req * erp, char *sense)
  1131. {
  1132. struct dasd_device *device = erp->startdev;
  1133. erp->function = dasd_3990_erp_inv_format;
  1134. if (sense[2] & SNS2_ENV_DATA_PRESENT) {
  1135. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1136. "Track format error when destaging or "
  1137. "staging data");
  1138. dasd_3990_handle_env_data(erp, sense);
  1139. erp = dasd_3990_erp_action_4(erp, sense);
  1140. } else {
  1141. /* internal error 06 - The track format is not valid*/
  1142. dev_err(&device->cdev->dev,
  1143. "An error occurred in the DASD device driver, "
  1144. "reason=%s\n", "06");
  1145. erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  1146. }
  1147. return erp;
  1148. } /* end dasd_3990_erp_inv_format */
  1149. /*
  1150. * DASD_3990_ERP_EOC
  1151. *
  1152. * DESCRIPTION
  1153. * Handles 24 byte 'End-of-Cylinder' error.
  1154. *
  1155. * PARAMETER
  1156. * erp already added default erp
  1157. * RETURN VALUES
  1158. * erp pointer to original (failed) cqr.
  1159. */
  1160. static struct dasd_ccw_req *
  1161. dasd_3990_erp_EOC(struct dasd_ccw_req * default_erp, char *sense)
  1162. {
  1163. struct dasd_device *device = default_erp->startdev;
  1164. dev_err(&device->cdev->dev,
  1165. "The cylinder data for accessing the DASD is inconsistent\n");
  1166. /* implement action 7 - BUG */
  1167. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1168. } /* end dasd_3990_erp_EOC */
  1169. /*
  1170. * DASD_3990_ERP_ENV_DATA
  1171. *
  1172. * DESCRIPTION
  1173. * Handles 24 byte 'Environmental-Data Present' error.
  1174. *
  1175. * PARAMETER
  1176. * erp current erp_head
  1177. * RETURN VALUES
  1178. * erp new erp_head - pointer to new ERP
  1179. */
  1180. static struct dasd_ccw_req *
  1181. dasd_3990_erp_env_data(struct dasd_ccw_req * erp, char *sense)
  1182. {
  1183. struct dasd_device *device = erp->startdev;
  1184. erp->function = dasd_3990_erp_env_data;
  1185. DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Environmental data present");
  1186. dasd_3990_handle_env_data(erp, sense);
  1187. /* don't retry on disabled interface */
  1188. if (sense[7] != 0x0F) {
  1189. erp = dasd_3990_erp_action_4(erp, sense);
  1190. } else {
  1191. erp->status = DASD_CQR_FILLED;
  1192. }
  1193. return erp;
  1194. } /* end dasd_3990_erp_env_data */
  1195. /*
  1196. * DASD_3990_ERP_NO_REC
  1197. *
  1198. * DESCRIPTION
  1199. * Handles 24 byte 'No Record Found' error.
  1200. *
  1201. * PARAMETER
  1202. * erp already added default ERP
  1203. *
  1204. * RETURN VALUES
  1205. * erp new erp_head - pointer to new ERP
  1206. */
  1207. static struct dasd_ccw_req *
  1208. dasd_3990_erp_no_rec(struct dasd_ccw_req * default_erp, char *sense)
  1209. {
  1210. struct dasd_device *device = default_erp->startdev;
  1211. dev_err(&device->cdev->dev,
  1212. "The specified record was not found\n");
  1213. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1214. } /* end dasd_3990_erp_no_rec */
  1215. /*
  1216. * DASD_3990_ERP_FILE_PROT
  1217. *
  1218. * DESCRIPTION
  1219. * Handles 24 byte 'File Protected' error.
  1220. * Note: Seek related recovery is not implemented because
  1221. * wee don't use the seek command yet.
  1222. *
  1223. * PARAMETER
  1224. * erp current erp_head
  1225. * RETURN VALUES
  1226. * erp new erp_head - pointer to new ERP
  1227. */
  1228. static struct dasd_ccw_req *
  1229. dasd_3990_erp_file_prot(struct dasd_ccw_req * erp)
  1230. {
  1231. struct dasd_device *device = erp->startdev;
  1232. dev_err(&device->cdev->dev, "Accessing the DASD failed because of "
  1233. "a hardware error\n");
  1234. return dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  1235. } /* end dasd_3990_erp_file_prot */
  1236. /*
  1237. * DASD_3990_ERP_INSPECT_ALIAS
  1238. *
  1239. * DESCRIPTION
  1240. * Checks if the original request was started on an alias device.
  1241. * If yes, it modifies the original and the erp request so that
  1242. * the erp request can be started on a base device.
  1243. *
  1244. * PARAMETER
  1245. * erp pointer to the currently created default ERP
  1246. *
  1247. * RETURN VALUES
  1248. * erp pointer to the modified ERP, or NULL
  1249. */
  1250. static struct dasd_ccw_req *dasd_3990_erp_inspect_alias(
  1251. struct dasd_ccw_req *erp)
  1252. {
  1253. struct dasd_ccw_req *cqr = erp->refers;
  1254. char *sense;
  1255. if (cqr->block &&
  1256. (cqr->block->base != cqr->startdev)) {
  1257. sense = dasd_get_sense(&erp->refers->irb);
  1258. /*
  1259. * dynamic pav may have changed base alias mapping
  1260. */
  1261. if (!test_bit(DASD_FLAG_OFFLINE, &cqr->startdev->flags) && sense
  1262. && (sense[0] == 0x10) && (sense[7] == 0x0F)
  1263. && (sense[8] == 0x67)) {
  1264. /*
  1265. * remove device from alias handling to prevent new
  1266. * requests from being scheduled on the
  1267. * wrong alias device
  1268. */
  1269. dasd_alias_remove_device(cqr->startdev);
  1270. /* schedule worker to reload device */
  1271. dasd_reload_device(cqr->startdev);
  1272. }
  1273. if (cqr->startdev->features & DASD_FEATURE_ERPLOG) {
  1274. DBF_DEV_EVENT(DBF_ERR, cqr->startdev,
  1275. "ERP on alias device for request %p,"
  1276. " recover on base device %s", cqr,
  1277. dev_name(&cqr->block->base->cdev->dev));
  1278. }
  1279. dasd_eckd_reset_ccw_to_base_io(cqr);
  1280. erp->startdev = cqr->block->base;
  1281. erp->function = dasd_3990_erp_inspect_alias;
  1282. return erp;
  1283. } else
  1284. return NULL;
  1285. }
  1286. /*
  1287. * DASD_3990_ERP_INSPECT_24
  1288. *
  1289. * DESCRIPTION
  1290. * Does a detailed inspection of the 24 byte sense data
  1291. * and sets up a related error recovery action.
  1292. *
  1293. * PARAMETER
  1294. * sense sense data of the actual error
  1295. * erp pointer to the currently created default ERP
  1296. *
  1297. * RETURN VALUES
  1298. * erp pointer to the (addtitional) ERP
  1299. */
  1300. static struct dasd_ccw_req *
  1301. dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense)
  1302. {
  1303. struct dasd_ccw_req *erp_filled = NULL;
  1304. /* Check sense for .... */
  1305. /* 'Command Reject' */
  1306. if ((erp_filled == NULL) && (sense[0] & SNS0_CMD_REJECT)) {
  1307. erp_filled = dasd_3990_erp_com_rej(erp, sense);
  1308. }
  1309. /* 'Intervention Required' */
  1310. if ((erp_filled == NULL) && (sense[0] & SNS0_INTERVENTION_REQ)) {
  1311. erp_filled = dasd_3990_erp_int_req(erp);
  1312. }
  1313. /* 'Bus Out Parity Check' */
  1314. if ((erp_filled == NULL) && (sense[0] & SNS0_BUS_OUT_CHECK)) {
  1315. erp_filled = dasd_3990_erp_bus_out(erp);
  1316. }
  1317. /* 'Equipment Check' */
  1318. if ((erp_filled == NULL) && (sense[0] & SNS0_EQUIPMENT_CHECK)) {
  1319. erp_filled = dasd_3990_erp_equip_check(erp, sense);
  1320. }
  1321. /* 'Data Check' */
  1322. if ((erp_filled == NULL) && (sense[0] & SNS0_DATA_CHECK)) {
  1323. erp_filled = dasd_3990_erp_data_check(erp, sense);
  1324. }
  1325. /* 'Overrun' */
  1326. if ((erp_filled == NULL) && (sense[0] & SNS0_OVERRUN)) {
  1327. erp_filled = dasd_3990_erp_overrun(erp, sense);
  1328. }
  1329. /* 'Invalid Track Format' */
  1330. if ((erp_filled == NULL) && (sense[1] & SNS1_INV_TRACK_FORMAT)) {
  1331. erp_filled = dasd_3990_erp_inv_format(erp, sense);
  1332. }
  1333. /* 'End-of-Cylinder' */
  1334. if ((erp_filled == NULL) && (sense[1] & SNS1_EOC)) {
  1335. erp_filled = dasd_3990_erp_EOC(erp, sense);
  1336. }
  1337. /* 'Environmental Data' */
  1338. if ((erp_filled == NULL) && (sense[2] & SNS2_ENV_DATA_PRESENT)) {
  1339. erp_filled = dasd_3990_erp_env_data(erp, sense);
  1340. }
  1341. /* 'No Record Found' */
  1342. if ((erp_filled == NULL) && (sense[1] & SNS1_NO_REC_FOUND)) {
  1343. erp_filled = dasd_3990_erp_no_rec(erp, sense);
  1344. }
  1345. /* 'File Protected' */
  1346. if ((erp_filled == NULL) && (sense[1] & SNS1_FILE_PROTECTED)) {
  1347. erp_filled = dasd_3990_erp_file_prot(erp);
  1348. }
  1349. /* other (unknown) error - do default ERP */
  1350. if (erp_filled == NULL) {
  1351. erp_filled = erp;
  1352. }
  1353. return erp_filled;
  1354. } /* END dasd_3990_erp_inspect_24 */
  1355. /*
  1356. *****************************************************************************
  1357. * 32 byte sense ERP functions (only)
  1358. *****************************************************************************
  1359. */
  1360. /*
  1361. * DASD_3990_ERPACTION_10_32
  1362. *
  1363. * DESCRIPTION
  1364. * Handles 32 byte 'Action 10' of Single Program Action Codes.
  1365. * Just retry and if retry doesn't work, return with error.
  1366. *
  1367. * PARAMETER
  1368. * erp current erp_head
  1369. * sense current sense data
  1370. * RETURN VALUES
  1371. * erp modified erp_head
  1372. */
  1373. static struct dasd_ccw_req *
  1374. dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp, char *sense)
  1375. {
  1376. struct dasd_device *device = erp->startdev;
  1377. erp->retries = 256;
  1378. erp->function = dasd_3990_erp_action_10_32;
  1379. DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Perform logging requested");
  1380. return erp;
  1381. } /* end dasd_3990_erp_action_10_32 */
  1382. /*
  1383. * DASD_3990_ERP_ACTION_1B_32
  1384. *
  1385. * DESCRIPTION
  1386. * Handles 32 byte 'Action 1B' of Single Program Action Codes.
  1387. * A write operation could not be finished because of an unexpected
  1388. * condition.
  1389. * The already created 'default erp' is used to get the link to
  1390. * the erp chain, but it can not be used for this recovery
  1391. * action because it contains no DE/LO data space.
  1392. *
  1393. * PARAMETER
  1394. * default_erp already added default erp.
  1395. * sense current sense data
  1396. *
  1397. * RETURN VALUES
  1398. * erp new erp or
  1399. * default_erp in case of imprecise ending or error
  1400. */
  1401. static struct dasd_ccw_req *
  1402. dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp, char *sense)
  1403. {
  1404. struct dasd_device *device = default_erp->startdev;
  1405. __u32 cpa = 0;
  1406. struct dasd_ccw_req *cqr;
  1407. struct dasd_ccw_req *erp;
  1408. struct DE_eckd_data *DE_data;
  1409. struct PFX_eckd_data *PFX_data;
  1410. char *LO_data; /* LO_eckd_data_t */
  1411. struct ccw1 *ccw, *oldccw;
  1412. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1413. "Write not finished because of unexpected condition");
  1414. default_erp->function = dasd_3990_erp_action_1B_32;
  1415. /* determine the original cqr */
  1416. cqr = default_erp;
  1417. while (cqr->refers != NULL) {
  1418. cqr = cqr->refers;
  1419. }
  1420. if (scsw_is_tm(&cqr->irb.scsw)) {
  1421. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1422. "32 bit sense, action 1B is not defined"
  1423. " in transport mode - just retry");
  1424. return default_erp;
  1425. }
  1426. /* for imprecise ending just do default erp */
  1427. if (sense[1] & 0x01) {
  1428. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1429. "Imprecise ending is set - just retry");
  1430. return default_erp;
  1431. }
  1432. /* determine the address of the CCW to be restarted */
  1433. /* Imprecise ending is not set -> addr from IRB-SCSW */
  1434. cpa = default_erp->refers->irb.scsw.cmd.cpa;
  1435. if (cpa == 0) {
  1436. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1437. "Unable to determine address of the CCW "
  1438. "to be restarted");
  1439. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1440. }
  1441. /* Build new ERP request including DE/LO */
  1442. erp = dasd_alloc_erp_request((char *) &cqr->magic,
  1443. 2 + 1,/* DE/LO + TIC */
  1444. sizeof(struct DE_eckd_data) +
  1445. sizeof(struct LO_eckd_data), device);
  1446. if (IS_ERR(erp)) {
  1447. /* internal error 01 - Unable to allocate ERP */
  1448. dev_err(&device->cdev->dev, "An error occurred in the DASD "
  1449. "device driver, reason=%s\n", "01");
  1450. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1451. }
  1452. /* use original DE */
  1453. DE_data = erp->data;
  1454. oldccw = cqr->cpaddr;
  1455. if (oldccw->cmd_code == DASD_ECKD_CCW_PFX) {
  1456. PFX_data = cqr->data;
  1457. memcpy(DE_data, &PFX_data->define_extent,
  1458. sizeof(struct DE_eckd_data));
  1459. } else
  1460. memcpy(DE_data, cqr->data, sizeof(struct DE_eckd_data));
  1461. /* create LO */
  1462. LO_data = erp->data + sizeof(struct DE_eckd_data);
  1463. if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
  1464. /* should not */
  1465. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1466. }
  1467. if ((sense[7] & 0x3F) == 0x01) {
  1468. /* operation code is WRITE DATA -> data area orientation */
  1469. LO_data[0] = 0x81;
  1470. } else if ((sense[7] & 0x3F) == 0x03) {
  1471. /* operation code is FORMAT WRITE -> index orientation */
  1472. LO_data[0] = 0xC3;
  1473. } else {
  1474. LO_data[0] = sense[7]; /* operation */
  1475. }
  1476. LO_data[1] = sense[8]; /* auxiliary */
  1477. LO_data[2] = sense[9];
  1478. LO_data[3] = sense[3]; /* count */
  1479. LO_data[4] = sense[29]; /* seek_addr.cyl */
  1480. LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
  1481. LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
  1482. memcpy(&(LO_data[8]), &(sense[11]), 8);
  1483. /* create DE ccw */
  1484. ccw = erp->cpaddr;
  1485. memset(ccw, 0, sizeof(struct ccw1));
  1486. ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
  1487. ccw->flags = CCW_FLAG_CC;
  1488. ccw->count = 16;
  1489. ccw->cda = (__u32)(addr_t) DE_data;
  1490. /* create LO ccw */
  1491. ccw++;
  1492. memset(ccw, 0, sizeof(struct ccw1));
  1493. ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
  1494. ccw->flags = CCW_FLAG_CC;
  1495. ccw->count = 16;
  1496. ccw->cda = (__u32)(addr_t) LO_data;
  1497. /* TIC to the failed ccw */
  1498. ccw++;
  1499. ccw->cmd_code = CCW_CMD_TIC;
  1500. ccw->cda = cpa;
  1501. /* fill erp related fields */
  1502. erp->flags = default_erp->flags;
  1503. erp->function = dasd_3990_erp_action_1B_32;
  1504. erp->refers = default_erp->refers;
  1505. erp->startdev = device;
  1506. erp->memdev = device;
  1507. erp->magic = default_erp->magic;
  1508. erp->expires = 0;
  1509. erp->retries = 256;
  1510. erp->buildclk = get_clock();
  1511. erp->status = DASD_CQR_FILLED;
  1512. /* remove the default erp */
  1513. dasd_free_erp_request(default_erp, device);
  1514. return erp;
  1515. } /* end dasd_3990_erp_action_1B_32 */
  1516. /*
  1517. * DASD_3990_UPDATE_1B
  1518. *
  1519. * DESCRIPTION
  1520. * Handles the update to the 32 byte 'Action 1B' of Single Program
  1521. * Action Codes in case the first action was not successful.
  1522. * The already created 'previous_erp' is the currently not successful
  1523. * ERP.
  1524. *
  1525. * PARAMETER
  1526. * previous_erp already created previous erp.
  1527. * sense current sense data
  1528. * RETURN VALUES
  1529. * erp modified erp
  1530. */
  1531. static struct dasd_ccw_req *
  1532. dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
  1533. {
  1534. struct dasd_device *device = previous_erp->startdev;
  1535. __u32 cpa = 0;
  1536. struct dasd_ccw_req *cqr;
  1537. struct dasd_ccw_req *erp;
  1538. char *LO_data; /* struct LO_eckd_data */
  1539. struct ccw1 *ccw;
  1540. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1541. "Write not finished because of unexpected condition"
  1542. " - follow on");
  1543. /* determine the original cqr */
  1544. cqr = previous_erp;
  1545. while (cqr->refers != NULL) {
  1546. cqr = cqr->refers;
  1547. }
  1548. if (scsw_is_tm(&cqr->irb.scsw)) {
  1549. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1550. "32 bit sense, action 1B, update,"
  1551. " in transport mode - just retry");
  1552. return previous_erp;
  1553. }
  1554. /* for imprecise ending just do default erp */
  1555. if (sense[1] & 0x01) {
  1556. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1557. "Imprecise ending is set - just retry");
  1558. previous_erp->status = DASD_CQR_FILLED;
  1559. return previous_erp;
  1560. }
  1561. /* determine the address of the CCW to be restarted */
  1562. /* Imprecise ending is not set -> addr from IRB-SCSW */
  1563. cpa = previous_erp->irb.scsw.cmd.cpa;
  1564. if (cpa == 0) {
  1565. /* internal error 02 -
  1566. Unable to determine address of the CCW to be restarted */
  1567. dev_err(&device->cdev->dev, "An error occurred in the DASD "
  1568. "device driver, reason=%s\n", "02");
  1569. previous_erp->status = DASD_CQR_FAILED;
  1570. return previous_erp;
  1571. }
  1572. erp = previous_erp;
  1573. /* update the LO with the new returned sense data */
  1574. LO_data = erp->data + sizeof(struct DE_eckd_data);
  1575. if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
  1576. /* should not happen */
  1577. previous_erp->status = DASD_CQR_FAILED;
  1578. return previous_erp;
  1579. }
  1580. if ((sense[7] & 0x3F) == 0x01) {
  1581. /* operation code is WRITE DATA -> data area orientation */
  1582. LO_data[0] = 0x81;
  1583. } else if ((sense[7] & 0x3F) == 0x03) {
  1584. /* operation code is FORMAT WRITE -> index orientation */
  1585. LO_data[0] = 0xC3;
  1586. } else {
  1587. LO_data[0] = sense[7]; /* operation */
  1588. }
  1589. LO_data[1] = sense[8]; /* auxiliary */
  1590. LO_data[2] = sense[9];
  1591. LO_data[3] = sense[3]; /* count */
  1592. LO_data[4] = sense[29]; /* seek_addr.cyl */
  1593. LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
  1594. LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
  1595. memcpy(&(LO_data[8]), &(sense[11]), 8);
  1596. /* TIC to the failed ccw */
  1597. ccw = erp->cpaddr; /* addr of DE ccw */
  1598. ccw++; /* addr of LE ccw */
  1599. ccw++; /* addr of TIC ccw */
  1600. ccw->cda = cpa;
  1601. erp->status = DASD_CQR_FILLED;
  1602. return erp;
  1603. } /* end dasd_3990_update_1B */
  1604. /*
  1605. * DASD_3990_ERP_COMPOUND_RETRY
  1606. *
  1607. * DESCRIPTION
  1608. * Handles the compound ERP action retry code.
  1609. * NOTE: At least one retry is done even if zero is specified
  1610. * by the sense data. This makes enqueueing of the request
  1611. * easier.
  1612. *
  1613. * PARAMETER
  1614. * sense sense data of the actual error
  1615. * erp pointer to the currently created ERP
  1616. *
  1617. * RETURN VALUES
  1618. * erp modified ERP pointer
  1619. *
  1620. */
  1621. static void
  1622. dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense)
  1623. {
  1624. switch (sense[25] & 0x03) {
  1625. case 0x00: /* no not retry */
  1626. erp->retries = 1;
  1627. break;
  1628. case 0x01: /* retry 2 times */
  1629. erp->retries = 2;
  1630. break;
  1631. case 0x02: /* retry 10 times */
  1632. erp->retries = 10;
  1633. break;
  1634. case 0x03: /* retry 256 times */
  1635. erp->retries = 256;
  1636. break;
  1637. default:
  1638. BUG();
  1639. }
  1640. erp->function = dasd_3990_erp_compound_retry;
  1641. } /* end dasd_3990_erp_compound_retry */
  1642. /*
  1643. * DASD_3990_ERP_COMPOUND_PATH
  1644. *
  1645. * DESCRIPTION
  1646. * Handles the compound ERP action for retry on alternate
  1647. * channel path.
  1648. *
  1649. * PARAMETER
  1650. * sense sense data of the actual error
  1651. * erp pointer to the currently created ERP
  1652. *
  1653. * RETURN VALUES
  1654. * erp modified ERP pointer
  1655. *
  1656. */
  1657. static void
  1658. dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
  1659. {
  1660. if (sense[25] & DASD_SENSE_BIT_3) {
  1661. dasd_3990_erp_alternate_path(erp);
  1662. if (erp->status == DASD_CQR_FAILED &&
  1663. !test_bit(DASD_CQR_VERIFY_PATH, &erp->flags)) {
  1664. /* reset the lpm and the status to be able to
  1665. * try further actions. */
  1666. erp->lpm = erp->startdev->path_data.opm;
  1667. erp->status = DASD_CQR_NEED_ERP;
  1668. }
  1669. }
  1670. erp->function = dasd_3990_erp_compound_path;
  1671. } /* end dasd_3990_erp_compound_path */
  1672. /*
  1673. * DASD_3990_ERP_COMPOUND_CODE
  1674. *
  1675. * DESCRIPTION
  1676. * Handles the compound ERP action for retry code.
  1677. *
  1678. * PARAMETER
  1679. * sense sense data of the actual error
  1680. * erp pointer to the currently created ERP
  1681. *
  1682. * RETURN VALUES
  1683. * erp NEW ERP pointer
  1684. *
  1685. */
  1686. static struct dasd_ccw_req *
  1687. dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
  1688. {
  1689. if (sense[25] & DASD_SENSE_BIT_2) {
  1690. switch (sense[28]) {
  1691. case 0x17:
  1692. /* issue a Diagnostic Control command with an
  1693. * Inhibit Write subcommand and controller modifier */
  1694. erp = dasd_3990_erp_DCTL(erp, 0x20);
  1695. break;
  1696. case 0x25:
  1697. /* wait for 5 seconds and retry again */
  1698. erp->retries = 1;
  1699. dasd_3990_erp_block_queue (erp, 5*HZ);
  1700. break;
  1701. default:
  1702. /* should not happen - continue */
  1703. break;
  1704. }
  1705. }
  1706. erp->function = dasd_3990_erp_compound_code;
  1707. return erp;
  1708. } /* end dasd_3990_erp_compound_code */
  1709. /*
  1710. * DASD_3990_ERP_COMPOUND_CONFIG
  1711. *
  1712. * DESCRIPTION
  1713. * Handles the compound ERP action for configruation
  1714. * dependent error.
  1715. * Note: duplex handling is not implemented (yet).
  1716. *
  1717. * PARAMETER
  1718. * sense sense data of the actual error
  1719. * erp pointer to the currently created ERP
  1720. *
  1721. * RETURN VALUES
  1722. * erp modified ERP pointer
  1723. *
  1724. */
  1725. static void
  1726. dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense)
  1727. {
  1728. if ((sense[25] & DASD_SENSE_BIT_1) && (sense[26] & DASD_SENSE_BIT_2)) {
  1729. /* set to suspended duplex state then restart
  1730. internal error 05 - Set device to suspended duplex state
  1731. should be done */
  1732. struct dasd_device *device = erp->startdev;
  1733. dev_err(&device->cdev->dev,
  1734. "An error occurred in the DASD device driver, "
  1735. "reason=%s\n", "05");
  1736. }
  1737. erp->function = dasd_3990_erp_compound_config;
  1738. } /* end dasd_3990_erp_compound_config */
  1739. /*
  1740. * DASD_3990_ERP_COMPOUND
  1741. *
  1742. * DESCRIPTION
  1743. * Does the further compound program action if
  1744. * compound retry was not successful.
  1745. *
  1746. * PARAMETER
  1747. * sense sense data of the actual error
  1748. * erp pointer to the current (failed) ERP
  1749. *
  1750. * RETURN VALUES
  1751. * erp (additional) ERP pointer
  1752. *
  1753. */
  1754. static struct dasd_ccw_req *
  1755. dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense)
  1756. {
  1757. if ((erp->function == dasd_3990_erp_compound_retry) &&
  1758. (erp->status == DASD_CQR_NEED_ERP)) {
  1759. dasd_3990_erp_compound_path(erp, sense);
  1760. }
  1761. if ((erp->function == dasd_3990_erp_compound_path) &&
  1762. (erp->status == DASD_CQR_NEED_ERP)) {
  1763. erp = dasd_3990_erp_compound_code(erp, sense);
  1764. }
  1765. if ((erp->function == dasd_3990_erp_compound_code) &&
  1766. (erp->status == DASD_CQR_NEED_ERP)) {
  1767. dasd_3990_erp_compound_config(erp, sense);
  1768. }
  1769. /* if no compound action ERP specified, the request failed */
  1770. if (erp->status == DASD_CQR_NEED_ERP)
  1771. erp->status = DASD_CQR_FAILED;
  1772. return erp;
  1773. } /* end dasd_3990_erp_compound */
  1774. /*
  1775. *DASD_3990_ERP_HANDLE_SIM
  1776. *
  1777. *DESCRIPTION
  1778. * inspects the SIM SENSE data and starts an appropriate action
  1779. *
  1780. * PARAMETER
  1781. * sense sense data of the actual error
  1782. *
  1783. * RETURN VALUES
  1784. * none
  1785. */
  1786. void
  1787. dasd_3990_erp_handle_sim(struct dasd_device *device, char *sense)
  1788. {
  1789. /* print message according to log or message to operator mode */
  1790. if ((sense[24] & DASD_SIM_MSG_TO_OP) || (sense[1] & 0x10)) {
  1791. /* print SIM SRC from RefCode */
  1792. dev_err(&device->cdev->dev, "SIM - SRC: "
  1793. "%02x%02x%02x%02x\n", sense[22],
  1794. sense[23], sense[11], sense[12]);
  1795. } else if (sense[24] & DASD_SIM_LOG) {
  1796. /* print SIM SRC Refcode */
  1797. dev_warn(&device->cdev->dev, "log SIM - SRC: "
  1798. "%02x%02x%02x%02x\n", sense[22],
  1799. sense[23], sense[11], sense[12]);
  1800. }
  1801. }
  1802. /*
  1803. * DASD_3990_ERP_INSPECT_32
  1804. *
  1805. * DESCRIPTION
  1806. * Does a detailed inspection of the 32 byte sense data
  1807. * and sets up a related error recovery action.
  1808. *
  1809. * PARAMETER
  1810. * sense sense data of the actual error
  1811. * erp pointer to the currently created default ERP
  1812. *
  1813. * RETURN VALUES
  1814. * erp_filled pointer to the ERP
  1815. *
  1816. */
  1817. static struct dasd_ccw_req *
  1818. dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
  1819. {
  1820. struct dasd_device *device = erp->startdev;
  1821. erp->function = dasd_3990_erp_inspect_32;
  1822. /* check for SIM sense data */
  1823. if ((sense[6] & DASD_SIM_SENSE) == DASD_SIM_SENSE)
  1824. dasd_3990_erp_handle_sim(device, sense);
  1825. if (sense[25] & DASD_SENSE_BIT_0) {
  1826. /* compound program action codes (byte25 bit 0 == '1') */
  1827. dasd_3990_erp_compound_retry(erp, sense);
  1828. } else {
  1829. /* single program action codes (byte25 bit 0 == '0') */
  1830. switch (sense[25]) {
  1831. case 0x00: /* success - use default ERP for retries */
  1832. DBF_DEV_EVENT(DBF_DEBUG, device, "%s",
  1833. "ERP called for successful request"
  1834. " - just retry");
  1835. break;
  1836. case 0x01: /* fatal error */
  1837. dev_err(&device->cdev->dev,
  1838. "ERP failed for the DASD\n");
  1839. erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  1840. break;
  1841. case 0x02: /* intervention required */
  1842. case 0x03: /* intervention required during dual copy */
  1843. erp = dasd_3990_erp_int_req(erp);
  1844. break;
  1845. case 0x0F: /* length mismatch during update write command
  1846. internal error 08 - update write command error*/
  1847. dev_err(&device->cdev->dev, "An error occurred in the "
  1848. "DASD device driver, reason=%s\n", "08");
  1849. erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  1850. break;
  1851. case 0x10: /* logging required for other channel program */
  1852. erp = dasd_3990_erp_action_10_32(erp, sense);
  1853. break;
  1854. case 0x15: /* next track outside defined extend
  1855. internal error 07 - The next track is not
  1856. within the defined storage extent */
  1857. dev_err(&device->cdev->dev,
  1858. "An error occurred in the DASD device driver, "
  1859. "reason=%s\n", "07");
  1860. erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  1861. break;
  1862. case 0x1B: /* unexpected condition during write */
  1863. erp = dasd_3990_erp_action_1B_32(erp, sense);
  1864. break;
  1865. case 0x1C: /* invalid data */
  1866. dev_emerg(&device->cdev->dev,
  1867. "Data recovered during retry with PCI "
  1868. "fetch mode active\n");
  1869. /* not possible to handle this situation in Linux */
  1870. panic
  1871. ("Invalid data - No way to inform application "
  1872. "about the possibly incorrect data");
  1873. break;
  1874. case 0x1D: /* state-change pending */
  1875. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1876. "A State change pending condition exists "
  1877. "for the subsystem or device");
  1878. erp = dasd_3990_erp_action_4(erp, sense);
  1879. break;
  1880. case 0x1E: /* busy */
  1881. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1882. "Busy condition exists "
  1883. "for the subsystem or device");
  1884. erp = dasd_3990_erp_action_4(erp, sense);
  1885. break;
  1886. default: /* all others errors - default erp */
  1887. break;
  1888. }
  1889. }
  1890. return erp;
  1891. } /* end dasd_3990_erp_inspect_32 */
  1892. /*
  1893. *****************************************************************************
  1894. * main ERP control functions (24 and 32 byte sense)
  1895. *****************************************************************************
  1896. */
  1897. /*
  1898. * DASD_3990_ERP_CONTROL_CHECK
  1899. *
  1900. * DESCRIPTION
  1901. * Does a generic inspection if a control check occurred and sets up
  1902. * the related error recovery procedure
  1903. *
  1904. * PARAMETER
  1905. * erp pointer to the currently created default ERP
  1906. *
  1907. * RETURN VALUES
  1908. * erp_filled pointer to the erp
  1909. */
  1910. static struct dasd_ccw_req *
  1911. dasd_3990_erp_control_check(struct dasd_ccw_req *erp)
  1912. {
  1913. struct dasd_device *device = erp->startdev;
  1914. if (scsw_cstat(&erp->refers->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK
  1915. | SCHN_STAT_CHN_CTRL_CHK)) {
  1916. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1917. "channel or interface control check");
  1918. erp = dasd_3990_erp_action_4(erp, NULL);
  1919. }
  1920. return erp;
  1921. }
  1922. /*
  1923. * DASD_3990_ERP_INSPECT
  1924. *
  1925. * DESCRIPTION
  1926. * Does a detailed inspection for sense data by calling either
  1927. * the 24-byte or the 32-byte inspection routine.
  1928. *
  1929. * PARAMETER
  1930. * erp pointer to the currently created default ERP
  1931. * RETURN VALUES
  1932. * erp_new contens was possibly modified
  1933. */
  1934. static struct dasd_ccw_req *
  1935. dasd_3990_erp_inspect(struct dasd_ccw_req *erp)
  1936. {
  1937. struct dasd_ccw_req *erp_new = NULL;
  1938. char *sense;
  1939. /* if this problem occurred on an alias retry on base */
  1940. erp_new = dasd_3990_erp_inspect_alias(erp);
  1941. if (erp_new)
  1942. return erp_new;
  1943. /* sense data are located in the refers record of the
  1944. * already set up new ERP !
  1945. * check if concurrent sens is available
  1946. */
  1947. sense = dasd_get_sense(&erp->refers->irb);
  1948. if (!sense)
  1949. erp_new = dasd_3990_erp_control_check(erp);
  1950. /* distinguish between 24 and 32 byte sense data */
  1951. else if (sense[27] & DASD_SENSE_BIT_0) {
  1952. /* inspect the 24 byte sense data */
  1953. erp_new = dasd_3990_erp_inspect_24(erp, sense);
  1954. } else {
  1955. /* inspect the 32 byte sense data */
  1956. erp_new = dasd_3990_erp_inspect_32(erp, sense);
  1957. } /* end distinguish between 24 and 32 byte sense data */
  1958. return erp_new;
  1959. }
  1960. /*
  1961. * DASD_3990_ERP_ADD_ERP
  1962. *
  1963. * DESCRIPTION
  1964. * This function adds an additional request block (ERP) to the head of
  1965. * the given cqr (or erp).
  1966. * For a command mode cqr the erp is initialized as an default erp
  1967. * (retry TIC).
  1968. * For transport mode we make a copy of the original TCW (points to
  1969. * the original TCCB, TIDALs, etc.) but give it a fresh
  1970. * TSB so the original sense data will not be changed.
  1971. *
  1972. * PARAMETER
  1973. * cqr head of the current ERP-chain (or single cqr if
  1974. * first error)
  1975. * RETURN VALUES
  1976. * erp pointer to new ERP-chain head
  1977. */
  1978. static struct dasd_ccw_req *dasd_3990_erp_add_erp(struct dasd_ccw_req *cqr)
  1979. {
  1980. struct dasd_device *device = cqr->startdev;
  1981. struct ccw1 *ccw;
  1982. struct dasd_ccw_req *erp;
  1983. int cplength, datasize;
  1984. struct tcw *tcw;
  1985. struct tsb *tsb;
  1986. if (cqr->cpmode == 1) {
  1987. cplength = 0;
  1988. /* TCW needs to be 64 byte aligned, so leave enough room */
  1989. datasize = 64 + sizeof(struct tcw) + sizeof(struct tsb);
  1990. } else {
  1991. cplength = 2;
  1992. datasize = 0;
  1993. }
  1994. /* allocate additional request block */
  1995. erp = dasd_alloc_erp_request((char *) &cqr->magic,
  1996. cplength, datasize, device);
  1997. if (IS_ERR(erp)) {
  1998. if (cqr->retries <= 0) {
  1999. DBF_DEV_EVENT(DBF_ERR, device, "%s",
  2000. "Unable to allocate ERP request");
  2001. cqr->status = DASD_CQR_FAILED;
  2002. cqr->stopclk = get_clock ();
  2003. } else {
  2004. DBF_DEV_EVENT(DBF_ERR, device,
  2005. "Unable to allocate ERP request "
  2006. "(%i retries left)",
  2007. cqr->retries);
  2008. dasd_block_set_timer(device->block, (HZ << 3));
  2009. }
  2010. return erp;
  2011. }
  2012. ccw = cqr->cpaddr;
  2013. if (cqr->cpmode == 1) {
  2014. /* make a shallow copy of the original tcw but set new tsb */
  2015. erp->cpmode = 1;
  2016. erp->cpaddr = PTR_ALIGN(erp->data, 64);
  2017. tcw = erp->cpaddr;
  2018. tsb = (struct tsb *) &tcw[1];
  2019. *tcw = *((struct tcw *)cqr->cpaddr);
  2020. tcw->tsb = (long)tsb;
  2021. } else if (ccw->cmd_code == DASD_ECKD_CCW_PSF) {
  2022. /* PSF cannot be chained from NOOP/TIC */
  2023. erp->cpaddr = cqr->cpaddr;
  2024. } else {
  2025. /* initialize request with default TIC to current ERP/CQR */
  2026. ccw = erp->cpaddr;
  2027. ccw->cmd_code = CCW_CMD_NOOP;
  2028. ccw->flags = CCW_FLAG_CC;
  2029. ccw++;
  2030. ccw->cmd_code = CCW_CMD_TIC;
  2031. ccw->cda = (long)(cqr->cpaddr);
  2032. }
  2033. erp->flags = cqr->flags;
  2034. erp->function = dasd_3990_erp_add_erp;
  2035. erp->refers = cqr;
  2036. erp->startdev = device;
  2037. erp->memdev = device;
  2038. erp->block = cqr->block;
  2039. erp->magic = cqr->magic;
  2040. erp->expires = 0;
  2041. erp->retries = 256;
  2042. erp->buildclk = get_clock();
  2043. erp->status = DASD_CQR_FILLED;
  2044. return erp;
  2045. }
  2046. /*
  2047. * DASD_3990_ERP_ADDITIONAL_ERP
  2048. *
  2049. * DESCRIPTION
  2050. * An additional ERP is needed to handle the current error.
  2051. * Add ERP to the head of the ERP-chain containing the ERP processing
  2052. * determined based on the sense data.
  2053. *
  2054. * PARAMETER
  2055. * cqr head of the current ERP-chain (or single cqr if
  2056. * first error)
  2057. *
  2058. * RETURN VALUES
  2059. * erp pointer to new ERP-chain head
  2060. */
  2061. static struct dasd_ccw_req *
  2062. dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)
  2063. {
  2064. struct dasd_ccw_req *erp = NULL;
  2065. /* add erp and initialize with default TIC */
  2066. erp = dasd_3990_erp_add_erp(cqr);
  2067. if (IS_ERR(erp))
  2068. return erp;
  2069. /* inspect sense, determine specific ERP if possible */
  2070. if (erp != cqr) {
  2071. erp = dasd_3990_erp_inspect(erp);
  2072. }
  2073. return erp;
  2074. } /* end dasd_3990_erp_additional_erp */
  2075. /*
  2076. * DASD_3990_ERP_ERROR_MATCH
  2077. *
  2078. * DESCRIPTION
  2079. * Check if the device status of the given cqr is the same.
  2080. * This means that the failed CCW and the relevant sense data
  2081. * must match.
  2082. * I don't distinguish between 24 and 32 byte sense because in case of
  2083. * 24 byte sense byte 25 and 27 is set as well.
  2084. *
  2085. * PARAMETER
  2086. * cqr1 first cqr, which will be compared with the
  2087. * cqr2 second cqr.
  2088. *
  2089. * RETURN VALUES
  2090. * match 'boolean' for match found
  2091. * returns 1 if match found, otherwise 0.
  2092. */
  2093. static int dasd_3990_erp_error_match(struct dasd_ccw_req *cqr1,
  2094. struct dasd_ccw_req *cqr2)
  2095. {
  2096. char *sense1, *sense2;
  2097. if (cqr1->startdev != cqr2->startdev)
  2098. return 0;
  2099. sense1 = dasd_get_sense(&cqr1->irb);
  2100. sense2 = dasd_get_sense(&cqr2->irb);
  2101. /* one request has sense data, the other not -> no match, return 0 */
  2102. if (!sense1 != !sense2)
  2103. return 0;
  2104. /* no sense data in both cases -> check cstat for IFCC */
  2105. if (!sense1 && !sense2) {
  2106. if ((scsw_cstat(&cqr1->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
  2107. SCHN_STAT_CHN_CTRL_CHK)) ==
  2108. (scsw_cstat(&cqr2->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
  2109. SCHN_STAT_CHN_CTRL_CHK)))
  2110. return 1; /* match with ifcc*/
  2111. }
  2112. /* check sense data; byte 0-2,25,27 */
  2113. if (!(sense1 && sense2 &&
  2114. (memcmp(sense1, sense2, 3) == 0) &&
  2115. (sense1[27] == sense2[27]) &&
  2116. (sense1[25] == sense2[25]))) {
  2117. return 0; /* sense doesn't match */
  2118. }
  2119. return 1; /* match */
  2120. } /* end dasd_3990_erp_error_match */
  2121. /*
  2122. * DASD_3990_ERP_IN_ERP
  2123. *
  2124. * DESCRIPTION
  2125. * check if the current error already happened before.
  2126. * quick exit if current cqr is not an ERP (cqr->refers=NULL)
  2127. *
  2128. * PARAMETER
  2129. * cqr failed cqr (either original cqr or already an erp)
  2130. *
  2131. * RETURN VALUES
  2132. * erp erp-pointer to the already defined error
  2133. * recovery procedure OR
  2134. * NULL if a 'new' error occurred.
  2135. */
  2136. static struct dasd_ccw_req *
  2137. dasd_3990_erp_in_erp(struct dasd_ccw_req *cqr)
  2138. {
  2139. struct dasd_ccw_req *erp_head = cqr, /* save erp chain head */
  2140. *erp_match = NULL; /* save erp chain head */
  2141. int match = 0; /* 'boolean' for matching error found */
  2142. if (cqr->refers == NULL) { /* return if not in erp */
  2143. return NULL;
  2144. }
  2145. /* check the erp/cqr chain for current error */
  2146. do {
  2147. match = dasd_3990_erp_error_match(erp_head, cqr->refers);
  2148. erp_match = cqr; /* save possible matching erp */
  2149. cqr = cqr->refers; /* check next erp/cqr in queue */
  2150. } while ((cqr->refers != NULL) && (!match));
  2151. if (!match) {
  2152. return NULL; /* no match was found */
  2153. }
  2154. return erp_match; /* return address of matching erp */
  2155. } /* END dasd_3990_erp_in_erp */
  2156. /*
  2157. * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense)
  2158. *
  2159. * DESCRIPTION
  2160. * No retry is left for the current ERP. Check what has to be done
  2161. * with the ERP.
  2162. * - do further defined ERP action or
  2163. * - wait for interrupt or
  2164. * - exit with permanent error
  2165. *
  2166. * PARAMETER
  2167. * erp ERP which is in progress with no retry left
  2168. *
  2169. * RETURN VALUES
  2170. * erp modified/additional ERP
  2171. */
  2172. static struct dasd_ccw_req *
  2173. dasd_3990_erp_further_erp(struct dasd_ccw_req *erp)
  2174. {
  2175. struct dasd_device *device = erp->startdev;
  2176. char *sense = dasd_get_sense(&erp->irb);
  2177. /* check for 24 byte sense ERP */
  2178. if ((erp->function == dasd_3990_erp_bus_out) ||
  2179. (erp->function == dasd_3990_erp_action_1) ||
  2180. (erp->function == dasd_3990_erp_action_4)) {
  2181. erp = dasd_3990_erp_action_1(erp);
  2182. } else if (erp->function == dasd_3990_erp_action_1_sec) {
  2183. erp = dasd_3990_erp_action_1_sec(erp);
  2184. } else if (erp->function == dasd_3990_erp_action_5) {
  2185. /* retries have not been successful */
  2186. /* prepare erp for retry on different channel path */
  2187. erp = dasd_3990_erp_action_1(erp);
  2188. if (sense && !(sense[2] & DASD_SENSE_BIT_0)) {
  2189. /* issue a Diagnostic Control command with an
  2190. * Inhibit Write subcommand */
  2191. switch (sense[25]) {
  2192. case 0x17:
  2193. case 0x57:{ /* controller */
  2194. erp = dasd_3990_erp_DCTL(erp, 0x20);
  2195. break;
  2196. }
  2197. case 0x18:
  2198. case 0x58:{ /* channel path */
  2199. erp = dasd_3990_erp_DCTL(erp, 0x40);
  2200. break;
  2201. }
  2202. case 0x19:
  2203. case 0x59:{ /* storage director */
  2204. erp = dasd_3990_erp_DCTL(erp, 0x80);
  2205. break;
  2206. }
  2207. default:
  2208. DBF_DEV_EVENT(DBF_WARNING, device,
  2209. "invalid subcommand modifier 0x%x "
  2210. "for Diagnostic Control Command",
  2211. sense[25]);
  2212. }
  2213. }
  2214. /* check for 32 byte sense ERP */
  2215. } else if (sense &&
  2216. ((erp->function == dasd_3990_erp_compound_retry) ||
  2217. (erp->function == dasd_3990_erp_compound_path) ||
  2218. (erp->function == dasd_3990_erp_compound_code) ||
  2219. (erp->function == dasd_3990_erp_compound_config))) {
  2220. erp = dasd_3990_erp_compound(erp, sense);
  2221. } else {
  2222. /*
  2223. * No retry left and no additional special handling
  2224. * necessary
  2225. */
  2226. dev_err(&device->cdev->dev,
  2227. "ERP %p has run out of retries and failed\n", erp);
  2228. erp->status = DASD_CQR_FAILED;
  2229. }
  2230. return erp;
  2231. } /* end dasd_3990_erp_further_erp */
  2232. /*
  2233. * DASD_3990_ERP_HANDLE_MATCH_ERP
  2234. *
  2235. * DESCRIPTION
  2236. * An error occurred again and an ERP has been detected which is already
  2237. * used to handle this error (e.g. retries).
  2238. * All prior ERP's are asumed to be successful and therefore removed
  2239. * from queue.
  2240. * If retry counter of matching erp is already 0, it is checked if further
  2241. * action is needed (besides retry) or if the ERP has failed.
  2242. *
  2243. * PARAMETER
  2244. * erp_head first ERP in ERP-chain
  2245. * erp ERP that handles the actual error.
  2246. * (matching erp)
  2247. *
  2248. * RETURN VALUES
  2249. * erp modified/additional ERP
  2250. */
  2251. static struct dasd_ccw_req *
  2252. dasd_3990_erp_handle_match_erp(struct dasd_ccw_req *erp_head,
  2253. struct dasd_ccw_req *erp)
  2254. {
  2255. struct dasd_device *device = erp_head->startdev;
  2256. struct dasd_ccw_req *erp_done = erp_head; /* finished req */
  2257. struct dasd_ccw_req *erp_free = NULL; /* req to be freed */
  2258. /* loop over successful ERPs and remove them from chanq */
  2259. while (erp_done != erp) {
  2260. if (erp_done == NULL) /* end of chain reached */
  2261. panic(PRINTK_HEADER "Programming error in ERP! The "
  2262. "original request was lost\n");
  2263. /* remove the request from the device queue */
  2264. list_del(&erp_done->blocklist);
  2265. erp_free = erp_done;
  2266. erp_done = erp_done->refers;
  2267. /* free the finished erp request */
  2268. dasd_free_erp_request(erp_free, erp_free->memdev);
  2269. } /* end while */
  2270. if (erp->retries > 0) {
  2271. char *sense = dasd_get_sense(&erp->refers->irb);
  2272. /* check for special retries */
  2273. if (sense && erp->function == dasd_3990_erp_action_4) {
  2274. erp = dasd_3990_erp_action_4(erp, sense);
  2275. } else if (sense &&
  2276. erp->function == dasd_3990_erp_action_1B_32) {
  2277. erp = dasd_3990_update_1B(erp, sense);
  2278. } else if (sense && erp->function == dasd_3990_erp_int_req) {
  2279. erp = dasd_3990_erp_int_req(erp);
  2280. } else {
  2281. /* simple retry */
  2282. DBF_DEV_EVENT(DBF_DEBUG, device,
  2283. "%i retries left for erp %p",
  2284. erp->retries, erp);
  2285. /* handle the request again... */
  2286. erp->status = DASD_CQR_FILLED;
  2287. }
  2288. } else {
  2289. /* no retry left - check for further necessary action */
  2290. /* if no further actions, handle rest as permanent error */
  2291. erp = dasd_3990_erp_further_erp(erp);
  2292. }
  2293. return erp;
  2294. } /* end dasd_3990_erp_handle_match_erp */
  2295. /*
  2296. * DASD_3990_ERP_ACTION
  2297. *
  2298. * DESCRIPTION
  2299. * control routine for 3990 erp actions.
  2300. * Has to be called with the queue lock (namely the s390_irq_lock) acquired.
  2301. *
  2302. * PARAMETER
  2303. * cqr failed cqr (either original cqr or already an erp)
  2304. *
  2305. * RETURN VALUES
  2306. * erp erp-pointer to the head of the ERP action chain.
  2307. * This means:
  2308. * - either a ptr to an additional ERP cqr or
  2309. * - the original given cqr (which's status might
  2310. * be modified)
  2311. */
  2312. struct dasd_ccw_req *
  2313. dasd_3990_erp_action(struct dasd_ccw_req * cqr)
  2314. {
  2315. struct dasd_ccw_req *erp = NULL;
  2316. struct dasd_device *device = cqr->startdev;
  2317. struct dasd_ccw_req *temp_erp = NULL;
  2318. if (device->features & DASD_FEATURE_ERPLOG) {
  2319. /* print current erp_chain */
  2320. dev_err(&device->cdev->dev,
  2321. "ERP chain at BEGINNING of ERP-ACTION\n");
  2322. for (temp_erp = cqr;
  2323. temp_erp != NULL; temp_erp = temp_erp->refers) {
  2324. dev_err(&device->cdev->dev,
  2325. "ERP %p (%02x) refers to %p\n",
  2326. temp_erp, temp_erp->status,
  2327. temp_erp->refers);
  2328. }
  2329. }
  2330. /* double-check if current erp/cqr was successful */
  2331. if ((scsw_cstat(&cqr->irb.scsw) == 0x00) &&
  2332. (scsw_dstat(&cqr->irb.scsw) ==
  2333. (DEV_STAT_CHN_END | DEV_STAT_DEV_END))) {
  2334. DBF_DEV_EVENT(DBF_DEBUG, device,
  2335. "ERP called for successful request %p"
  2336. " - NO ERP necessary", cqr);
  2337. cqr->status = DASD_CQR_DONE;
  2338. return cqr;
  2339. }
  2340. /* check if error happened before */
  2341. erp = dasd_3990_erp_in_erp(cqr);
  2342. if (erp == NULL) {
  2343. /* no matching erp found - set up erp */
  2344. erp = dasd_3990_erp_additional_erp(cqr);
  2345. if (IS_ERR(erp))
  2346. return erp;
  2347. } else {
  2348. /* matching erp found - set all leading erp's to DONE */
  2349. erp = dasd_3990_erp_handle_match_erp(cqr, erp);
  2350. }
  2351. if (device->features & DASD_FEATURE_ERPLOG) {
  2352. /* print current erp_chain */
  2353. dev_err(&device->cdev->dev,
  2354. "ERP chain at END of ERP-ACTION\n");
  2355. for (temp_erp = erp;
  2356. temp_erp != NULL; temp_erp = temp_erp->refers) {
  2357. dev_err(&device->cdev->dev,
  2358. "ERP %p (%02x) refers to %p\n",
  2359. temp_erp, temp_erp->status,
  2360. temp_erp->refers);
  2361. }
  2362. }
  2363. /* enqueue ERP request if it's a new one */
  2364. if (list_empty(&erp->blocklist)) {
  2365. cqr->status = DASD_CQR_IN_ERP;
  2366. /* add erp request before the cqr */
  2367. list_add_tail(&erp->blocklist, &cqr->blocklist);
  2368. }
  2369. return erp;
  2370. } /* end dasd_3990_erp_action */