dasd_3990_erp.c 68 KB

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