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