dasd_3990_erp.c 68 KB

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