dasd_3990_erp.c 67 KB

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