dasd_3990_erp.c 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672
  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. /* for imprecise ending just do default erp */
  1370. if (sense[1] & 0x01) {
  1371. DEV_MESSAGE(KERN_DEBUG, device, "%s",
  1372. "Imprecise ending is set - just retry");
  1373. return default_erp;
  1374. }
  1375. /* determine the address of the CCW to be restarted */
  1376. /* Imprecise ending is not set -> addr from IRB-SCSW */
  1377. cpa = default_erp->refers->irb.scsw.cmd.cpa;
  1378. if (cpa == 0) {
  1379. DEV_MESSAGE(KERN_DEBUG, device, "%s",
  1380. "Unable to determine address of the CCW "
  1381. "to be restarted");
  1382. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1383. }
  1384. /* Build new ERP request including DE/LO */
  1385. erp = dasd_alloc_erp_request((char *) &cqr->magic,
  1386. 2 + 1,/* DE/LO + TIC */
  1387. sizeof(struct DE_eckd_data) +
  1388. sizeof(struct LO_eckd_data), device);
  1389. if (IS_ERR(erp)) {
  1390. DEV_MESSAGE(KERN_ERR, device, "%s", "Unable to allocate ERP");
  1391. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1392. }
  1393. /* use original DE */
  1394. DE_data = erp->data;
  1395. oldccw = cqr->cpaddr;
  1396. if (oldccw->cmd_code == DASD_ECKD_CCW_PFX) {
  1397. PFX_data = cqr->data;
  1398. memcpy(DE_data, &PFX_data->define_extend,
  1399. sizeof(struct DE_eckd_data));
  1400. } else
  1401. memcpy(DE_data, cqr->data, sizeof(struct DE_eckd_data));
  1402. /* create LO */
  1403. LO_data = erp->data + sizeof(struct DE_eckd_data);
  1404. if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
  1405. DEV_MESSAGE(KERN_ERR, device, "%s",
  1406. "BUG - this should not happen");
  1407. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1408. }
  1409. if ((sense[7] & 0x3F) == 0x01) {
  1410. /* operation code is WRITE DATA -> data area orientation */
  1411. LO_data[0] = 0x81;
  1412. } else if ((sense[7] & 0x3F) == 0x03) {
  1413. /* operation code is FORMAT WRITE -> index orientation */
  1414. LO_data[0] = 0xC3;
  1415. } else {
  1416. LO_data[0] = sense[7]; /* operation */
  1417. }
  1418. LO_data[1] = sense[8]; /* auxiliary */
  1419. LO_data[2] = sense[9];
  1420. LO_data[3] = sense[3]; /* count */
  1421. LO_data[4] = sense[29]; /* seek_addr.cyl */
  1422. LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
  1423. LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
  1424. memcpy(&(LO_data[8]), &(sense[11]), 8);
  1425. /* create DE ccw */
  1426. ccw = erp->cpaddr;
  1427. memset(ccw, 0, sizeof(struct ccw1));
  1428. ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
  1429. ccw->flags = CCW_FLAG_CC;
  1430. ccw->count = 16;
  1431. ccw->cda = (__u32)(addr_t) DE_data;
  1432. /* create LO ccw */
  1433. ccw++;
  1434. memset(ccw, 0, sizeof(struct ccw1));
  1435. ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
  1436. ccw->flags = CCW_FLAG_CC;
  1437. ccw->count = 16;
  1438. ccw->cda = (__u32)(addr_t) LO_data;
  1439. /* TIC to the failed ccw */
  1440. ccw++;
  1441. ccw->cmd_code = CCW_CMD_TIC;
  1442. ccw->cda = cpa;
  1443. /* fill erp related fields */
  1444. erp->function = dasd_3990_erp_action_1B_32;
  1445. erp->refers = default_erp->refers;
  1446. erp->startdev = device;
  1447. erp->memdev = device;
  1448. erp->magic = default_erp->magic;
  1449. erp->expires = 0;
  1450. erp->retries = 256;
  1451. erp->buildclk = get_clock();
  1452. erp->status = DASD_CQR_FILLED;
  1453. /* remove the default erp */
  1454. dasd_free_erp_request(default_erp, device);
  1455. return erp;
  1456. } /* end dasd_3990_erp_action_1B_32 */
  1457. /*
  1458. * DASD_3990_UPDATE_1B
  1459. *
  1460. * DESCRIPTION
  1461. * Handles the update to the 32 byte 'Action 1B' of Single Program
  1462. * Action Codes in case the first action was not successful.
  1463. * The already created 'previous_erp' is the currently not successful
  1464. * ERP.
  1465. *
  1466. * PARAMETER
  1467. * previous_erp already created previous erp.
  1468. * sense current sense data
  1469. * RETURN VALUES
  1470. * erp modified erp
  1471. */
  1472. static struct dasd_ccw_req *
  1473. dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
  1474. {
  1475. struct dasd_device *device = previous_erp->startdev;
  1476. __u32 cpa = 0;
  1477. struct dasd_ccw_req *cqr;
  1478. struct dasd_ccw_req *erp;
  1479. char *LO_data; /* struct LO_eckd_data */
  1480. struct ccw1 *ccw;
  1481. DEV_MESSAGE(KERN_DEBUG, device, "%s",
  1482. "Write not finished because of unexpected condition"
  1483. " - follow on");
  1484. /* determine the original cqr */
  1485. cqr = previous_erp;
  1486. while (cqr->refers != NULL) {
  1487. cqr = cqr->refers;
  1488. }
  1489. /* for imprecise ending just do default erp */
  1490. if (sense[1] & 0x01) {
  1491. DEV_MESSAGE(KERN_DEBUG, device, "%s",
  1492. "Imprecise ending is set - just retry");
  1493. previous_erp->status = DASD_CQR_FILLED;
  1494. return previous_erp;
  1495. }
  1496. /* determine the address of the CCW to be restarted */
  1497. /* Imprecise ending is not set -> addr from IRB-SCSW */
  1498. cpa = previous_erp->irb.scsw.cmd.cpa;
  1499. if (cpa == 0) {
  1500. DEV_MESSAGE(KERN_DEBUG, device, "%s",
  1501. "Unable to determine address of the CCW "
  1502. "to be restarted");
  1503. previous_erp->status = DASD_CQR_FAILED;
  1504. return previous_erp;
  1505. }
  1506. erp = previous_erp;
  1507. /* update the LO with the new returned sense data */
  1508. LO_data = erp->data + sizeof(struct DE_eckd_data);
  1509. if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
  1510. DEV_MESSAGE(KERN_ERR, device, "%s",
  1511. "BUG - this should not happen");
  1512. previous_erp->status = DASD_CQR_FAILED;
  1513. return previous_erp;
  1514. }
  1515. if ((sense[7] & 0x3F) == 0x01) {
  1516. /* operation code is WRITE DATA -> data area orientation */
  1517. LO_data[0] = 0x81;
  1518. } else if ((sense[7] & 0x3F) == 0x03) {
  1519. /* operation code is FORMAT WRITE -> index orientation */
  1520. LO_data[0] = 0xC3;
  1521. } else {
  1522. LO_data[0] = sense[7]; /* operation */
  1523. }
  1524. LO_data[1] = sense[8]; /* auxiliary */
  1525. LO_data[2] = sense[9];
  1526. LO_data[3] = sense[3]; /* count */
  1527. LO_data[4] = sense[29]; /* seek_addr.cyl */
  1528. LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
  1529. LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
  1530. memcpy(&(LO_data[8]), &(sense[11]), 8);
  1531. /* TIC to the failed ccw */
  1532. ccw = erp->cpaddr; /* addr of DE ccw */
  1533. ccw++; /* addr of LE ccw */
  1534. ccw++; /* addr of TIC ccw */
  1535. ccw->cda = cpa;
  1536. erp->status = DASD_CQR_FILLED;
  1537. return erp;
  1538. } /* end dasd_3990_update_1B */
  1539. /*
  1540. * DASD_3990_ERP_COMPOUND_RETRY
  1541. *
  1542. * DESCRIPTION
  1543. * Handles the compound ERP action retry code.
  1544. * NOTE: At least one retry is done even if zero is specified
  1545. * by the sense data. This makes enqueueing of the request
  1546. * easier.
  1547. *
  1548. * PARAMETER
  1549. * sense sense data of the actual error
  1550. * erp pointer to the currently created ERP
  1551. *
  1552. * RETURN VALUES
  1553. * erp modified ERP pointer
  1554. *
  1555. */
  1556. static void
  1557. dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense)
  1558. {
  1559. switch (sense[25] & 0x03) {
  1560. case 0x00: /* no not retry */
  1561. erp->retries = 1;
  1562. break;
  1563. case 0x01: /* retry 2 times */
  1564. erp->retries = 2;
  1565. break;
  1566. case 0x02: /* retry 10 times */
  1567. erp->retries = 10;
  1568. break;
  1569. case 0x03: /* retry 256 times */
  1570. erp->retries = 256;
  1571. break;
  1572. default:
  1573. BUG();
  1574. }
  1575. erp->function = dasd_3990_erp_compound_retry;
  1576. } /* end dasd_3990_erp_compound_retry */
  1577. /*
  1578. * DASD_3990_ERP_COMPOUND_PATH
  1579. *
  1580. * DESCRIPTION
  1581. * Handles the compound ERP action for retry on alternate
  1582. * channel path.
  1583. *
  1584. * PARAMETER
  1585. * sense sense data of the actual error
  1586. * erp pointer to the currently created ERP
  1587. *
  1588. * RETURN VALUES
  1589. * erp modified ERP pointer
  1590. *
  1591. */
  1592. static void
  1593. dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
  1594. {
  1595. if (sense[25] & DASD_SENSE_BIT_3) {
  1596. dasd_3990_erp_alternate_path(erp);
  1597. if (erp->status == DASD_CQR_FAILED) {
  1598. /* reset the lpm and the status to be able to
  1599. * try further actions. */
  1600. erp->lpm = 0;
  1601. erp->status = DASD_CQR_NEED_ERP;
  1602. }
  1603. }
  1604. erp->function = dasd_3990_erp_compound_path;
  1605. } /* end dasd_3990_erp_compound_path */
  1606. /*
  1607. * DASD_3990_ERP_COMPOUND_CODE
  1608. *
  1609. * DESCRIPTION
  1610. * Handles the compound ERP action for retry code.
  1611. *
  1612. * PARAMETER
  1613. * sense sense data of the actual error
  1614. * erp pointer to the currently created ERP
  1615. *
  1616. * RETURN VALUES
  1617. * erp NEW ERP pointer
  1618. *
  1619. */
  1620. static struct dasd_ccw_req *
  1621. dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
  1622. {
  1623. if (sense[25] & DASD_SENSE_BIT_2) {
  1624. switch (sense[28]) {
  1625. case 0x17:
  1626. /* issue a Diagnostic Control command with an
  1627. * Inhibit Write subcommand and controller modifier */
  1628. erp = dasd_3990_erp_DCTL(erp, 0x20);
  1629. break;
  1630. case 0x25:
  1631. /* wait for 5 seconds and retry again */
  1632. erp->retries = 1;
  1633. dasd_3990_erp_block_queue (erp, 5*HZ);
  1634. break;
  1635. default:
  1636. /* should not happen - continue */
  1637. break;
  1638. }
  1639. }
  1640. erp->function = dasd_3990_erp_compound_code;
  1641. return erp;
  1642. } /* end dasd_3990_erp_compound_code */
  1643. /*
  1644. * DASD_3990_ERP_COMPOUND_CONFIG
  1645. *
  1646. * DESCRIPTION
  1647. * Handles the compound ERP action for configruation
  1648. * dependent error.
  1649. * Note: duplex handling is not implemented (yet).
  1650. *
  1651. * PARAMETER
  1652. * sense sense data of the actual error
  1653. * erp pointer to the currently created ERP
  1654. *
  1655. * RETURN VALUES
  1656. * erp modified ERP pointer
  1657. *
  1658. */
  1659. static void
  1660. dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense)
  1661. {
  1662. if ((sense[25] & DASD_SENSE_BIT_1) && (sense[26] & DASD_SENSE_BIT_2)) {
  1663. /* set to suspended duplex state then restart */
  1664. struct dasd_device *device = erp->startdev;
  1665. DEV_MESSAGE(KERN_ERR, device, "%s",
  1666. "Set device to suspended duplex state should be "
  1667. "done!\n"
  1668. "This is not implemented yet (for compound ERP)"
  1669. " - please report to linux390@de.ibm.com");
  1670. }
  1671. erp->function = dasd_3990_erp_compound_config;
  1672. } /* end dasd_3990_erp_compound_config */
  1673. /*
  1674. * DASD_3990_ERP_COMPOUND
  1675. *
  1676. * DESCRIPTION
  1677. * Does the further compound program action if
  1678. * compound retry was not successful.
  1679. *
  1680. * PARAMETER
  1681. * sense sense data of the actual error
  1682. * erp pointer to the current (failed) ERP
  1683. *
  1684. * RETURN VALUES
  1685. * erp (additional) ERP pointer
  1686. *
  1687. */
  1688. static struct dasd_ccw_req *
  1689. dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense)
  1690. {
  1691. if ((erp->function == dasd_3990_erp_compound_retry) &&
  1692. (erp->status == DASD_CQR_NEED_ERP)) {
  1693. dasd_3990_erp_compound_path(erp, sense);
  1694. }
  1695. if ((erp->function == dasd_3990_erp_compound_path) &&
  1696. (erp->status == DASD_CQR_NEED_ERP)) {
  1697. erp = dasd_3990_erp_compound_code(erp, sense);
  1698. }
  1699. if ((erp->function == dasd_3990_erp_compound_code) &&
  1700. (erp->status == DASD_CQR_NEED_ERP)) {
  1701. dasd_3990_erp_compound_config(erp, sense);
  1702. }
  1703. /* if no compound action ERP specified, the request failed */
  1704. if (erp->status == DASD_CQR_NEED_ERP)
  1705. erp->status = DASD_CQR_FAILED;
  1706. return erp;
  1707. } /* end dasd_3990_erp_compound */
  1708. /*
  1709. *DASD_3990_ERP_HANDLE_SIM
  1710. *
  1711. *DESCRIPTION
  1712. * inspects the SIM SENSE data and starts an appropriate action
  1713. *
  1714. * PARAMETER
  1715. * sense sense data of the actual error
  1716. *
  1717. * RETURN VALUES
  1718. * none
  1719. */
  1720. void
  1721. dasd_3990_erp_handle_sim(struct dasd_device *device, char *sense)
  1722. {
  1723. /* print message according to log or message to operator mode */
  1724. if ((sense[24] & DASD_SIM_MSG_TO_OP) || (sense[1] & 0x10)) {
  1725. /* print SIM SRC from RefCode */
  1726. DEV_MESSAGE(KERN_ERR, device, "SIM - SRC: "
  1727. "%02x%02x%02x%02x", sense[22],
  1728. sense[23], sense[11], sense[12]);
  1729. } else if (sense[24] & DASD_SIM_LOG) {
  1730. /* print SIM SRC Refcode */
  1731. DEV_MESSAGE(KERN_WARNING, device, "SIM - SRC: "
  1732. "%02x%02x%02x%02x", sense[22],
  1733. sense[23], sense[11], sense[12]);
  1734. }
  1735. }
  1736. /*
  1737. * DASD_3990_ERP_INSPECT_32
  1738. *
  1739. * DESCRIPTION
  1740. * Does a detailed inspection of the 32 byte sense data
  1741. * and sets up a related error recovery action.
  1742. *
  1743. * PARAMETER
  1744. * sense sense data of the actual error
  1745. * erp pointer to the currently created default ERP
  1746. *
  1747. * RETURN VALUES
  1748. * erp_filled pointer to the ERP
  1749. *
  1750. */
  1751. static struct dasd_ccw_req *
  1752. dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
  1753. {
  1754. struct dasd_device *device = erp->startdev;
  1755. erp->function = dasd_3990_erp_inspect_32;
  1756. /* check for SIM sense data */
  1757. if ((sense[6] & DASD_SIM_SENSE) == DASD_SIM_SENSE)
  1758. dasd_3990_erp_handle_sim(device, sense);
  1759. if (sense[25] & DASD_SENSE_BIT_0) {
  1760. /* compound program action codes (byte25 bit 0 == '1') */
  1761. dasd_3990_erp_compound_retry(erp, sense);
  1762. } else {
  1763. /* single program action codes (byte25 bit 0 == '0') */
  1764. switch (sense[25]) {
  1765. case 0x00: /* success - use default ERP for retries */
  1766. DEV_MESSAGE(KERN_DEBUG, device, "%s",
  1767. "ERP called for successful request"
  1768. " - just retry");
  1769. break;
  1770. case 0x01: /* fatal error */
  1771. DEV_MESSAGE(KERN_ERR, device, "%s",
  1772. "Retry not recommended - Fatal error");
  1773. erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  1774. break;
  1775. case 0x02: /* intervention required */
  1776. case 0x03: /* intervention required during dual copy */
  1777. erp = dasd_3990_erp_int_req(erp);
  1778. break;
  1779. case 0x0F: /* length mismatch during update write command */
  1780. DEV_MESSAGE(KERN_ERR, device, "%s",
  1781. "update write command error - should not "
  1782. "happen;\n"
  1783. "Please send this message together with "
  1784. "the above sense data to linux390@de."
  1785. "ibm.com");
  1786. erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  1787. break;
  1788. case 0x10: /* logging required for other channel program */
  1789. erp = dasd_3990_erp_action_10_32(erp, sense);
  1790. break;
  1791. case 0x15: /* next track outside defined extend */
  1792. DEV_MESSAGE(KERN_ERR, device, "%s",
  1793. "next track outside defined extend - "
  1794. "should not 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 0x1B: /* unexpected condition during write */
  1801. erp = dasd_3990_erp_action_1B_32(erp, sense);
  1802. break;
  1803. case 0x1C: /* invalid data */
  1804. DEV_MESSAGE(KERN_EMERG, device, "%s",
  1805. "Data recovered during retry with PCI "
  1806. "fetch mode active");
  1807. /* not possible to handle this situation in Linux */
  1808. panic
  1809. ("Invalid data - No way to inform application "
  1810. "about the possibly incorrect data");
  1811. break;
  1812. case 0x1D: /* state-change pending */
  1813. DEV_MESSAGE(KERN_DEBUG, device, "%s",
  1814. "A State change pending condition exists "
  1815. "for the subsystem or device");
  1816. erp = dasd_3990_erp_action_4(erp, sense);
  1817. break;
  1818. case 0x1E: /* busy */
  1819. DEV_MESSAGE(KERN_DEBUG, device, "%s",
  1820. "Busy condition exists "
  1821. "for the subsystem or device");
  1822. erp = dasd_3990_erp_action_4(erp, sense);
  1823. break;
  1824. default: /* all others errors - default erp */
  1825. break;
  1826. }
  1827. }
  1828. return erp;
  1829. } /* end dasd_3990_erp_inspect_32 */
  1830. /*
  1831. *****************************************************************************
  1832. * main ERP control fuctions (24 and 32 byte sense)
  1833. *****************************************************************************
  1834. */
  1835. /*
  1836. * DASD_3990_ERP_CONTROL_CHECK
  1837. *
  1838. * DESCRIPTION
  1839. * Does a generic inspection if a control check occured and sets up
  1840. * the related error recovery procedure
  1841. *
  1842. * PARAMETER
  1843. * erp pointer to the currently created default ERP
  1844. *
  1845. * RETURN VALUES
  1846. * erp_filled pointer to the erp
  1847. */
  1848. static struct dasd_ccw_req *
  1849. dasd_3990_erp_control_check(struct dasd_ccw_req *erp)
  1850. {
  1851. struct dasd_device *device = erp->startdev;
  1852. if (erp->refers->irb.scsw.cmd.cstat & (SCHN_STAT_INTF_CTRL_CHK
  1853. | SCHN_STAT_CHN_CTRL_CHK)) {
  1854. DEV_MESSAGE(KERN_DEBUG, device, "%s",
  1855. "channel or interface control check");
  1856. erp = dasd_3990_erp_action_4(erp, NULL);
  1857. }
  1858. return erp;
  1859. }
  1860. /*
  1861. * DASD_3990_ERP_INSPECT
  1862. *
  1863. * DESCRIPTION
  1864. * Does a detailed inspection for sense data by calling either
  1865. * the 24-byte or the 32-byte inspection routine.
  1866. *
  1867. * PARAMETER
  1868. * erp pointer to the currently created default ERP
  1869. * RETURN VALUES
  1870. * erp_new contens was possibly modified
  1871. */
  1872. static struct dasd_ccw_req *
  1873. dasd_3990_erp_inspect(struct dasd_ccw_req * erp)
  1874. {
  1875. struct dasd_ccw_req *erp_new = NULL;
  1876. /* sense data are located in the refers record of the */
  1877. /* already set up new ERP ! */
  1878. char *sense = erp->refers->irb.ecw;
  1879. /* if this problem occured on an alias retry on base */
  1880. erp_new = dasd_3990_erp_inspect_alias(erp);
  1881. if (erp_new)
  1882. return erp_new;
  1883. /* check if no concurrent sens is available */
  1884. if (!erp->refers->irb.esw.esw0.erw.cons)
  1885. erp_new = dasd_3990_erp_control_check(erp);
  1886. /* distinguish between 24 and 32 byte sense data */
  1887. else if (sense[27] & DASD_SENSE_BIT_0) {
  1888. /* inspect the 24 byte sense data */
  1889. erp_new = dasd_3990_erp_inspect_24(erp, sense);
  1890. } else {
  1891. /* inspect the 32 byte sense data */
  1892. erp_new = dasd_3990_erp_inspect_32(erp, sense);
  1893. } /* end distinguish between 24 and 32 byte sense data */
  1894. return erp_new;
  1895. }
  1896. /*
  1897. * DASD_3990_ERP_ADD_ERP
  1898. *
  1899. * DESCRIPTION
  1900. * This funtion adds an additional request block (ERP) to the head of
  1901. * the given cqr (or erp).
  1902. * This erp is initialized as an default erp (retry TIC)
  1903. *
  1904. * PARAMETER
  1905. * cqr head of the current ERP-chain (or single cqr if
  1906. * first error)
  1907. * RETURN VALUES
  1908. * erp pointer to new ERP-chain head
  1909. */
  1910. static struct dasd_ccw_req *
  1911. dasd_3990_erp_add_erp(struct dasd_ccw_req * cqr)
  1912. {
  1913. struct dasd_device *device = cqr->startdev;
  1914. struct ccw1 *ccw;
  1915. /* allocate additional request block */
  1916. struct dasd_ccw_req *erp;
  1917. erp = dasd_alloc_erp_request((char *) &cqr->magic, 2, 0, device);
  1918. if (IS_ERR(erp)) {
  1919. if (cqr->retries <= 0) {
  1920. DEV_MESSAGE(KERN_ERR, device, "%s",
  1921. "Unable to allocate ERP request");
  1922. cqr->status = DASD_CQR_FAILED;
  1923. cqr->stopclk = get_clock ();
  1924. } else {
  1925. DEV_MESSAGE (KERN_ERR, device,
  1926. "Unable to allocate ERP request "
  1927. "(%i retries left)",
  1928. cqr->retries);
  1929. dasd_block_set_timer(device->block, (HZ << 3));
  1930. }
  1931. return cqr;
  1932. }
  1933. /* initialize request with default TIC to current ERP/CQR */
  1934. ccw = erp->cpaddr;
  1935. ccw->cmd_code = CCW_CMD_NOOP;
  1936. ccw->flags = CCW_FLAG_CC;
  1937. ccw++;
  1938. ccw->cmd_code = CCW_CMD_TIC;
  1939. ccw->cda = (long)(cqr->cpaddr);
  1940. erp->function = dasd_3990_erp_add_erp;
  1941. erp->refers = cqr;
  1942. erp->startdev = device;
  1943. erp->memdev = device;
  1944. erp->block = cqr->block;
  1945. erp->magic = cqr->magic;
  1946. erp->expires = 0;
  1947. erp->retries = 256;
  1948. erp->buildclk = get_clock();
  1949. erp->status = DASD_CQR_FILLED;
  1950. return erp;
  1951. }
  1952. /*
  1953. * DASD_3990_ERP_ADDITIONAL_ERP
  1954. *
  1955. * DESCRIPTION
  1956. * An additional ERP is needed to handle the current error.
  1957. * Add ERP to the head of the ERP-chain containing the ERP processing
  1958. * determined based on the sense data.
  1959. *
  1960. * PARAMETER
  1961. * cqr head of the current ERP-chain (or single cqr if
  1962. * first error)
  1963. *
  1964. * RETURN VALUES
  1965. * erp pointer to new ERP-chain head
  1966. */
  1967. static struct dasd_ccw_req *
  1968. dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)
  1969. {
  1970. struct dasd_ccw_req *erp = NULL;
  1971. /* add erp and initialize with default TIC */
  1972. erp = dasd_3990_erp_add_erp(cqr);
  1973. /* inspect sense, determine specific ERP if possible */
  1974. if (erp != cqr) {
  1975. erp = dasd_3990_erp_inspect(erp);
  1976. }
  1977. return erp;
  1978. } /* end dasd_3990_erp_additional_erp */
  1979. /*
  1980. * DASD_3990_ERP_ERROR_MATCH
  1981. *
  1982. * DESCRIPTION
  1983. * Check if the device status of the given cqr is the same.
  1984. * This means that the failed CCW and the relevant sense data
  1985. * must match.
  1986. * I don't distinguish between 24 and 32 byte sense because in case of
  1987. * 24 byte sense byte 25 and 27 is set as well.
  1988. *
  1989. * PARAMETER
  1990. * cqr1 first cqr, which will be compared with the
  1991. * cqr2 second cqr.
  1992. *
  1993. * RETURN VALUES
  1994. * match 'boolean' for match found
  1995. * returns 1 if match found, otherwise 0.
  1996. */
  1997. static int
  1998. dasd_3990_erp_error_match(struct dasd_ccw_req *cqr1, struct dasd_ccw_req *cqr2)
  1999. {
  2000. if (cqr1->startdev != cqr2->startdev)
  2001. return 0;
  2002. if (cqr1->irb.esw.esw0.erw.cons != cqr2->irb.esw.esw0.erw.cons)
  2003. return 0;
  2004. if ((cqr1->irb.esw.esw0.erw.cons == 0) &&
  2005. (cqr2->irb.esw.esw0.erw.cons == 0)) {
  2006. if ((cqr1->irb.scsw.cmd.cstat & (SCHN_STAT_INTF_CTRL_CHK |
  2007. SCHN_STAT_CHN_CTRL_CHK)) ==
  2008. (cqr2->irb.scsw.cmd.cstat & (SCHN_STAT_INTF_CTRL_CHK |
  2009. SCHN_STAT_CHN_CTRL_CHK)))
  2010. return 1; /* match with ifcc*/
  2011. }
  2012. /* check sense data; byte 0-2,25,27 */
  2013. if (!((memcmp (cqr1->irb.ecw, cqr2->irb.ecw, 3) == 0) &&
  2014. (cqr1->irb.ecw[27] == cqr2->irb.ecw[27]) &&
  2015. (cqr1->irb.ecw[25] == cqr2->irb.ecw[25]))) {
  2016. return 0; /* sense doesn't match */
  2017. }
  2018. return 1; /* match */
  2019. } /* end dasd_3990_erp_error_match */
  2020. /*
  2021. * DASD_3990_ERP_IN_ERP
  2022. *
  2023. * DESCRIPTION
  2024. * check if the current error already happened before.
  2025. * quick exit if current cqr is not an ERP (cqr->refers=NULL)
  2026. *
  2027. * PARAMETER
  2028. * cqr failed cqr (either original cqr or already an erp)
  2029. *
  2030. * RETURN VALUES
  2031. * erp erp-pointer to the already defined error
  2032. * recovery procedure OR
  2033. * NULL if a 'new' error occurred.
  2034. */
  2035. static struct dasd_ccw_req *
  2036. dasd_3990_erp_in_erp(struct dasd_ccw_req *cqr)
  2037. {
  2038. struct dasd_ccw_req *erp_head = cqr, /* save erp chain head */
  2039. *erp_match = NULL; /* save erp chain head */
  2040. int match = 0; /* 'boolean' for matching error found */
  2041. if (cqr->refers == NULL) { /* return if not in erp */
  2042. return NULL;
  2043. }
  2044. /* check the erp/cqr chain for current error */
  2045. do {
  2046. match = dasd_3990_erp_error_match(erp_head, cqr->refers);
  2047. erp_match = cqr; /* save possible matching erp */
  2048. cqr = cqr->refers; /* check next erp/cqr in queue */
  2049. } while ((cqr->refers != NULL) && (!match));
  2050. if (!match) {
  2051. return NULL; /* no match was found */
  2052. }
  2053. return erp_match; /* return address of matching erp */
  2054. } /* END dasd_3990_erp_in_erp */
  2055. /*
  2056. * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense)
  2057. *
  2058. * DESCRIPTION
  2059. * No retry is left for the current ERP. Check what has to be done
  2060. * with the ERP.
  2061. * - do further defined ERP action or
  2062. * - wait for interrupt or
  2063. * - exit with permanent error
  2064. *
  2065. * PARAMETER
  2066. * erp ERP which is in progress with no retry left
  2067. *
  2068. * RETURN VALUES
  2069. * erp modified/additional ERP
  2070. */
  2071. static struct dasd_ccw_req *
  2072. dasd_3990_erp_further_erp(struct dasd_ccw_req *erp)
  2073. {
  2074. struct dasd_device *device = erp->startdev;
  2075. char *sense = erp->irb.ecw;
  2076. /* check for 24 byte sense ERP */
  2077. if ((erp->function == dasd_3990_erp_bus_out) ||
  2078. (erp->function == dasd_3990_erp_action_1) ||
  2079. (erp->function == dasd_3990_erp_action_4)) {
  2080. erp = dasd_3990_erp_action_1(erp);
  2081. } else if (erp->function == dasd_3990_erp_action_5) {
  2082. /* retries have not been successful */
  2083. /* prepare erp for retry on different channel path */
  2084. erp = dasd_3990_erp_action_1(erp);
  2085. if (!(sense[2] & DASD_SENSE_BIT_0)) {
  2086. /* issue a Diagnostic Control command with an
  2087. * Inhibit Write subcommand */
  2088. switch (sense[25]) {
  2089. case 0x17:
  2090. case 0x57:{ /* controller */
  2091. erp = dasd_3990_erp_DCTL(erp, 0x20);
  2092. break;
  2093. }
  2094. case 0x18:
  2095. case 0x58:{ /* channel path */
  2096. erp = dasd_3990_erp_DCTL(erp, 0x40);
  2097. break;
  2098. }
  2099. case 0x19:
  2100. case 0x59:{ /* storage director */
  2101. erp = dasd_3990_erp_DCTL(erp, 0x80);
  2102. break;
  2103. }
  2104. default:
  2105. DEV_MESSAGE(KERN_DEBUG, device,
  2106. "invalid subcommand modifier 0x%x "
  2107. "for Diagnostic Control Command",
  2108. sense[25]);
  2109. }
  2110. }
  2111. /* check for 32 byte sense ERP */
  2112. } else if ((erp->function == dasd_3990_erp_compound_retry) ||
  2113. (erp->function == dasd_3990_erp_compound_path) ||
  2114. (erp->function == dasd_3990_erp_compound_code) ||
  2115. (erp->function == dasd_3990_erp_compound_config)) {
  2116. erp = dasd_3990_erp_compound(erp, sense);
  2117. } else {
  2118. /* No retry left and no additional special handling */
  2119. /*necessary */
  2120. DEV_MESSAGE(KERN_ERR, device,
  2121. "no retries left for erp %p - "
  2122. "set status to FAILED", erp);
  2123. erp->status = DASD_CQR_FAILED;
  2124. }
  2125. return erp;
  2126. } /* end dasd_3990_erp_further_erp */
  2127. /*
  2128. * DASD_3990_ERP_HANDLE_MATCH_ERP
  2129. *
  2130. * DESCRIPTION
  2131. * An error occurred again and an ERP has been detected which is already
  2132. * used to handle this error (e.g. retries).
  2133. * All prior ERP's are asumed to be successful and therefore removed
  2134. * from queue.
  2135. * If retry counter of matching erp is already 0, it is checked if further
  2136. * action is needed (besides retry) or if the ERP has failed.
  2137. *
  2138. * PARAMETER
  2139. * erp_head first ERP in ERP-chain
  2140. * erp ERP that handles the actual error.
  2141. * (matching erp)
  2142. *
  2143. * RETURN VALUES
  2144. * erp modified/additional ERP
  2145. */
  2146. static struct dasd_ccw_req *
  2147. dasd_3990_erp_handle_match_erp(struct dasd_ccw_req *erp_head,
  2148. struct dasd_ccw_req *erp)
  2149. {
  2150. struct dasd_device *device = erp_head->startdev;
  2151. struct dasd_ccw_req *erp_done = erp_head; /* finished req */
  2152. struct dasd_ccw_req *erp_free = NULL; /* req to be freed */
  2153. /* loop over successful ERPs and remove them from chanq */
  2154. while (erp_done != erp) {
  2155. if (erp_done == NULL) /* end of chain reached */
  2156. panic(PRINTK_HEADER "Programming error in ERP! The "
  2157. "original request was lost\n");
  2158. /* remove the request from the device queue */
  2159. list_del(&erp_done->blocklist);
  2160. erp_free = erp_done;
  2161. erp_done = erp_done->refers;
  2162. /* free the finished erp request */
  2163. dasd_free_erp_request(erp_free, erp_free->memdev);
  2164. } /* end while */
  2165. if (erp->retries > 0) {
  2166. char *sense = erp->refers->irb.ecw;
  2167. /* check for special retries */
  2168. if (erp->function == dasd_3990_erp_action_4) {
  2169. erp = dasd_3990_erp_action_4(erp, sense);
  2170. } else if (erp->function == dasd_3990_erp_action_1B_32) {
  2171. erp = dasd_3990_update_1B(erp, sense);
  2172. } else if (erp->function == dasd_3990_erp_int_req) {
  2173. erp = dasd_3990_erp_int_req(erp);
  2174. } else {
  2175. /* simple retry */
  2176. DEV_MESSAGE(KERN_DEBUG, device,
  2177. "%i retries left for erp %p",
  2178. erp->retries, erp);
  2179. /* handle the request again... */
  2180. erp->status = DASD_CQR_FILLED;
  2181. }
  2182. } else {
  2183. /* no retry left - check for further necessary action */
  2184. /* if no further actions, handle rest as permanent error */
  2185. erp = dasd_3990_erp_further_erp(erp);
  2186. }
  2187. return erp;
  2188. } /* end dasd_3990_erp_handle_match_erp */
  2189. /*
  2190. * DASD_3990_ERP_ACTION
  2191. *
  2192. * DESCRIPTION
  2193. * control routine for 3990 erp actions.
  2194. * Has to be called with the queue lock (namely the s390_irq_lock) acquired.
  2195. *
  2196. * PARAMETER
  2197. * cqr failed cqr (either original cqr or already an erp)
  2198. *
  2199. * RETURN VALUES
  2200. * erp erp-pointer to the head of the ERP action chain.
  2201. * This means:
  2202. * - either a ptr to an additional ERP cqr or
  2203. * - the original given cqr (which's status might
  2204. * be modified)
  2205. */
  2206. struct dasd_ccw_req *
  2207. dasd_3990_erp_action(struct dasd_ccw_req * cqr)
  2208. {
  2209. struct dasd_ccw_req *erp = NULL;
  2210. struct dasd_device *device = cqr->startdev;
  2211. struct dasd_ccw_req *temp_erp = NULL;
  2212. if (device->features & DASD_FEATURE_ERPLOG) {
  2213. /* print current erp_chain */
  2214. DEV_MESSAGE(KERN_ERR, device, "%s",
  2215. "ERP chain at BEGINNING of ERP-ACTION");
  2216. for (temp_erp = cqr;
  2217. temp_erp != NULL; temp_erp = temp_erp->refers) {
  2218. DEV_MESSAGE(KERN_ERR, device,
  2219. " erp %p (%02x) refers to %p",
  2220. temp_erp, temp_erp->status,
  2221. temp_erp->refers);
  2222. }
  2223. }
  2224. /* double-check if current erp/cqr was successfull */
  2225. if ((cqr->irb.scsw.cmd.cstat == 0x00) &&
  2226. (cqr->irb.scsw.cmd.dstat ==
  2227. (DEV_STAT_CHN_END | DEV_STAT_DEV_END))) {
  2228. DEV_MESSAGE(KERN_DEBUG, device,
  2229. "ERP called for successful request %p"
  2230. " - NO ERP necessary", cqr);
  2231. cqr->status = DASD_CQR_DONE;
  2232. return cqr;
  2233. }
  2234. /* check if error happened before */
  2235. erp = dasd_3990_erp_in_erp(cqr);
  2236. if (erp == NULL) {
  2237. /* no matching erp found - set up erp */
  2238. erp = dasd_3990_erp_additional_erp(cqr);
  2239. } else {
  2240. /* matching erp found - set all leading erp's to DONE */
  2241. erp = dasd_3990_erp_handle_match_erp(cqr, erp);
  2242. }
  2243. if (device->features & DASD_FEATURE_ERPLOG) {
  2244. /* print current erp_chain */
  2245. DEV_MESSAGE(KERN_ERR, device, "%s",
  2246. "ERP chain at END of ERP-ACTION");
  2247. for (temp_erp = erp;
  2248. temp_erp != NULL; temp_erp = temp_erp->refers) {
  2249. DEV_MESSAGE(KERN_ERR, device,
  2250. " erp %p (%02x) refers to %p",
  2251. temp_erp, temp_erp->status,
  2252. temp_erp->refers);
  2253. }
  2254. }
  2255. /* enqueue ERP request if it's a new one */
  2256. if (list_empty(&erp->blocklist)) {
  2257. cqr->status = DASD_CQR_IN_ERP;
  2258. /* add erp request before the cqr */
  2259. list_add_tail(&erp->blocklist, &cqr->blocklist);
  2260. }
  2261. return erp;
  2262. } /* end dasd_3990_erp_action */