dasd_3990_erp.c 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771
  1. /*
  2. * Author(s)......: Horst Hummel <Horst.Hummel@de.ibm.com>
  3. * Holger Smolinski <Holger.Smolinski@de.ibm.com>
  4. * Bugreports.to..: <Linux390@de.ibm.com>
  5. * Copyright IBM Corp. 2000, 2001
  6. *
  7. */
  8. #define KMSG_COMPONENT "dasd-eckd"
  9. #include <linux/timer.h>
  10. #include <asm/idals.h>
  11. #define PRINTK_HEADER "dasd_erp(3990): "
  12. #include "dasd_int.h"
  13. #include "dasd_eckd.h"
  14. struct DCTL_data {
  15. unsigned char subcommand; /* e.g Inhibit Write, Enable Write,... */
  16. unsigned char modifier; /* Subcommand modifier */
  17. unsigned short res; /* reserved */
  18. } __attribute__ ((packed));
  19. /*
  20. *****************************************************************************
  21. * SECTION ERP HANDLING
  22. *****************************************************************************
  23. */
  24. /*
  25. *****************************************************************************
  26. * 24 and 32 byte sense ERP functions
  27. *****************************************************************************
  28. */
  29. /*
  30. * DASD_3990_ERP_CLEANUP
  31. *
  32. * DESCRIPTION
  33. * Removes the already build but not necessary ERP request and sets
  34. * the status of the original cqr / erp to the given (final) status
  35. *
  36. * PARAMETER
  37. * erp request to be blocked
  38. * final_status either DASD_CQR_DONE or DASD_CQR_FAILED
  39. *
  40. * RETURN VALUES
  41. * cqr original cqr
  42. */
  43. static struct dasd_ccw_req *
  44. dasd_3990_erp_cleanup(struct dasd_ccw_req * erp, char final_status)
  45. {
  46. struct dasd_ccw_req *cqr = erp->refers;
  47. dasd_free_erp_request(erp, erp->memdev);
  48. cqr->status = final_status;
  49. return cqr;
  50. } /* end dasd_3990_erp_cleanup */
  51. /*
  52. * DASD_3990_ERP_BLOCK_QUEUE
  53. *
  54. * DESCRIPTION
  55. * Block the given device request queue to prevent from further
  56. * processing until the started timer has expired or an related
  57. * interrupt was received.
  58. */
  59. static void dasd_3990_erp_block_queue(struct dasd_ccw_req *erp, int expires)
  60. {
  61. struct dasd_device *device = erp->startdev;
  62. unsigned long flags;
  63. DBF_DEV_EVENT(DBF_INFO, device,
  64. "blocking request queue for %is", expires/HZ);
  65. spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
  66. dasd_device_set_stop_bits(device, DASD_STOPPED_PENDING);
  67. spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
  68. erp->status = DASD_CQR_FILLED;
  69. if (erp->block)
  70. dasd_block_set_timer(erp->block, expires);
  71. else
  72. dasd_device_set_timer(device, 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. if (erp->lpm == 0)
  130. erp->lpm = device->path_data.opm &
  131. ~(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->flags = erp->flags;
  189. dctl_cqr->function = dasd_3990_erp_DCTL;
  190. dctl_cqr->refers = erp;
  191. dctl_cqr->startdev = device;
  192. dctl_cqr->memdev = device;
  193. dctl_cqr->magic = erp->magic;
  194. dctl_cqr->expires = 5 * 60 * HZ;
  195. dctl_cqr->retries = 2;
  196. dctl_cqr->buildclk = get_tod_clock();
  197. dctl_cqr->status = DASD_CQR_FILLED;
  198. return dctl_cqr;
  199. } /* end dasd_3990_erp_DCTL */
  200. /*
  201. * DASD_3990_ERP_ACTION_1
  202. *
  203. * DESCRIPTION
  204. * Setup ERP to do the ERP action 1 (see Reference manual).
  205. * Repeat the operation on a different channel path.
  206. * As deviation from the recommended recovery action, we reset the path mask
  207. * after we have tried each path and go through all paths a second time.
  208. * This will cover situations where only one path at a time is actually down,
  209. * but all paths fail and recover just with the same sequence and timing as
  210. * we try to use them (flapping links).
  211. * If all alternate paths have been tried twice, the request is posted with
  212. * a permanent error.
  213. *
  214. * PARAMETER
  215. * erp pointer to the current ERP
  216. *
  217. * RETURN VALUES
  218. * erp pointer to the ERP
  219. *
  220. */
  221. static struct dasd_ccw_req *dasd_3990_erp_action_1_sec(struct dasd_ccw_req *erp)
  222. {
  223. erp->function = dasd_3990_erp_action_1_sec;
  224. dasd_3990_erp_alternate_path(erp);
  225. return erp;
  226. }
  227. static struct dasd_ccw_req *dasd_3990_erp_action_1(struct dasd_ccw_req *erp)
  228. {
  229. erp->function = dasd_3990_erp_action_1;
  230. dasd_3990_erp_alternate_path(erp);
  231. if (erp->status == DASD_CQR_FAILED &&
  232. !test_bit(DASD_CQR_VERIFY_PATH, &erp->flags)) {
  233. erp->status = DASD_CQR_FILLED;
  234. erp->retries = 10;
  235. erp->lpm = erp->startdev->path_data.opm;
  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. char *sense;
  1254. if (cqr->block &&
  1255. (cqr->block->base != cqr->startdev)) {
  1256. sense = dasd_get_sense(&erp->refers->irb);
  1257. /*
  1258. * dynamic pav may have changed base alias mapping
  1259. */
  1260. if (!test_bit(DASD_FLAG_OFFLINE, &cqr->startdev->flags) && sense
  1261. && (sense[0] == 0x10) && (sense[7] == 0x0F)
  1262. && (sense[8] == 0x67)) {
  1263. /*
  1264. * remove device from alias handling to prevent new
  1265. * requests from being scheduled on the
  1266. * wrong alias device
  1267. */
  1268. dasd_alias_remove_device(cqr->startdev);
  1269. /* schedule worker to reload device */
  1270. dasd_reload_device(cqr->startdev);
  1271. }
  1272. if (cqr->startdev->features & DASD_FEATURE_ERPLOG) {
  1273. DBF_DEV_EVENT(DBF_ERR, cqr->startdev,
  1274. "ERP on alias device for request %p,"
  1275. " recover on base device %s", cqr,
  1276. dev_name(&cqr->block->base->cdev->dev));
  1277. }
  1278. dasd_eckd_reset_ccw_to_base_io(cqr);
  1279. erp->startdev = cqr->block->base;
  1280. erp->function = dasd_3990_erp_inspect_alias;
  1281. return erp;
  1282. } else
  1283. return NULL;
  1284. }
  1285. /*
  1286. * DASD_3990_ERP_INSPECT_24
  1287. *
  1288. * DESCRIPTION
  1289. * Does a detailed inspection of the 24 byte sense data
  1290. * and sets up a related error recovery action.
  1291. *
  1292. * PARAMETER
  1293. * sense sense data of the actual error
  1294. * erp pointer to the currently created default ERP
  1295. *
  1296. * RETURN VALUES
  1297. * erp pointer to the (addtitional) ERP
  1298. */
  1299. static struct dasd_ccw_req *
  1300. dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense)
  1301. {
  1302. struct dasd_ccw_req *erp_filled = NULL;
  1303. /* Check sense for .... */
  1304. /* 'Command Reject' */
  1305. if ((erp_filled == NULL) && (sense[0] & SNS0_CMD_REJECT)) {
  1306. erp_filled = dasd_3990_erp_com_rej(erp, sense);
  1307. }
  1308. /* 'Intervention Required' */
  1309. if ((erp_filled == NULL) && (sense[0] & SNS0_INTERVENTION_REQ)) {
  1310. erp_filled = dasd_3990_erp_int_req(erp);
  1311. }
  1312. /* 'Bus Out Parity Check' */
  1313. if ((erp_filled == NULL) && (sense[0] & SNS0_BUS_OUT_CHECK)) {
  1314. erp_filled = dasd_3990_erp_bus_out(erp);
  1315. }
  1316. /* 'Equipment Check' */
  1317. if ((erp_filled == NULL) && (sense[0] & SNS0_EQUIPMENT_CHECK)) {
  1318. erp_filled = dasd_3990_erp_equip_check(erp, sense);
  1319. }
  1320. /* 'Data Check' */
  1321. if ((erp_filled == NULL) && (sense[0] & SNS0_DATA_CHECK)) {
  1322. erp_filled = dasd_3990_erp_data_check(erp, sense);
  1323. }
  1324. /* 'Overrun' */
  1325. if ((erp_filled == NULL) && (sense[0] & SNS0_OVERRUN)) {
  1326. erp_filled = dasd_3990_erp_overrun(erp, sense);
  1327. }
  1328. /* 'Invalid Track Format' */
  1329. if ((erp_filled == NULL) && (sense[1] & SNS1_INV_TRACK_FORMAT)) {
  1330. erp_filled = dasd_3990_erp_inv_format(erp, sense);
  1331. }
  1332. /* 'End-of-Cylinder' */
  1333. if ((erp_filled == NULL) && (sense[1] & SNS1_EOC)) {
  1334. erp_filled = dasd_3990_erp_EOC(erp, sense);
  1335. }
  1336. /* 'Environmental Data' */
  1337. if ((erp_filled == NULL) && (sense[2] & SNS2_ENV_DATA_PRESENT)) {
  1338. erp_filled = dasd_3990_erp_env_data(erp, sense);
  1339. }
  1340. /* 'No Record Found' */
  1341. if ((erp_filled == NULL) && (sense[1] & SNS1_NO_REC_FOUND)) {
  1342. erp_filled = dasd_3990_erp_no_rec(erp, sense);
  1343. }
  1344. /* 'File Protected' */
  1345. if ((erp_filled == NULL) && (sense[1] & SNS1_FILE_PROTECTED)) {
  1346. erp_filled = dasd_3990_erp_file_prot(erp);
  1347. }
  1348. /* other (unknown) error - do default ERP */
  1349. if (erp_filled == NULL) {
  1350. erp_filled = erp;
  1351. }
  1352. return erp_filled;
  1353. } /* END dasd_3990_erp_inspect_24 */
  1354. /*
  1355. *****************************************************************************
  1356. * 32 byte sense ERP functions (only)
  1357. *****************************************************************************
  1358. */
  1359. /*
  1360. * DASD_3990_ERPACTION_10_32
  1361. *
  1362. * DESCRIPTION
  1363. * Handles 32 byte 'Action 10' of Single Program Action Codes.
  1364. * Just retry and if retry doesn't work, return with error.
  1365. *
  1366. * PARAMETER
  1367. * erp current erp_head
  1368. * sense current sense data
  1369. * RETURN VALUES
  1370. * erp modified erp_head
  1371. */
  1372. static struct dasd_ccw_req *
  1373. dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp, char *sense)
  1374. {
  1375. struct dasd_device *device = erp->startdev;
  1376. erp->retries = 256;
  1377. erp->function = dasd_3990_erp_action_10_32;
  1378. DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Perform logging requested");
  1379. return erp;
  1380. } /* end dasd_3990_erp_action_10_32 */
  1381. /*
  1382. * DASD_3990_ERP_ACTION_1B_32
  1383. *
  1384. * DESCRIPTION
  1385. * Handles 32 byte 'Action 1B' of Single Program Action Codes.
  1386. * A write operation could not be finished because of an unexpected
  1387. * condition.
  1388. * The already created 'default erp' is used to get the link to
  1389. * the erp chain, but it can not be used for this recovery
  1390. * action because it contains no DE/LO data space.
  1391. *
  1392. * PARAMETER
  1393. * default_erp already added default erp.
  1394. * sense current sense data
  1395. *
  1396. * RETURN VALUES
  1397. * erp new erp or
  1398. * default_erp in case of imprecise ending or error
  1399. */
  1400. static struct dasd_ccw_req *
  1401. dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp, char *sense)
  1402. {
  1403. struct dasd_device *device = default_erp->startdev;
  1404. __u32 cpa = 0;
  1405. struct dasd_ccw_req *cqr;
  1406. struct dasd_ccw_req *erp;
  1407. struct DE_eckd_data *DE_data;
  1408. struct PFX_eckd_data *PFX_data;
  1409. char *LO_data; /* LO_eckd_data_t */
  1410. struct ccw1 *ccw, *oldccw;
  1411. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1412. "Write not finished because of unexpected condition");
  1413. default_erp->function = dasd_3990_erp_action_1B_32;
  1414. /* determine the original cqr */
  1415. cqr = default_erp;
  1416. while (cqr->refers != NULL) {
  1417. cqr = cqr->refers;
  1418. }
  1419. if (scsw_is_tm(&cqr->irb.scsw)) {
  1420. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1421. "32 bit sense, action 1B is not defined"
  1422. " in transport mode - just retry");
  1423. return default_erp;
  1424. }
  1425. /* for imprecise ending just do default erp */
  1426. if (sense[1] & 0x01) {
  1427. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1428. "Imprecise ending is set - just retry");
  1429. return default_erp;
  1430. }
  1431. /* determine the address of the CCW to be restarted */
  1432. /* Imprecise ending is not set -> addr from IRB-SCSW */
  1433. cpa = default_erp->refers->irb.scsw.cmd.cpa;
  1434. if (cpa == 0) {
  1435. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1436. "Unable to determine address of the CCW "
  1437. "to be restarted");
  1438. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1439. }
  1440. /* Build new ERP request including DE/LO */
  1441. erp = dasd_alloc_erp_request((char *) &cqr->magic,
  1442. 2 + 1,/* DE/LO + TIC */
  1443. sizeof(struct DE_eckd_data) +
  1444. sizeof(struct LO_eckd_data), device);
  1445. if (IS_ERR(erp)) {
  1446. /* internal error 01 - Unable to allocate ERP */
  1447. dev_err(&device->cdev->dev, "An error occurred in the DASD "
  1448. "device driver, reason=%s\n", "01");
  1449. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1450. }
  1451. /* use original DE */
  1452. DE_data = erp->data;
  1453. oldccw = cqr->cpaddr;
  1454. if (oldccw->cmd_code == DASD_ECKD_CCW_PFX) {
  1455. PFX_data = cqr->data;
  1456. memcpy(DE_data, &PFX_data->define_extent,
  1457. sizeof(struct DE_eckd_data));
  1458. } else
  1459. memcpy(DE_data, cqr->data, sizeof(struct DE_eckd_data));
  1460. /* create LO */
  1461. LO_data = erp->data + sizeof(struct DE_eckd_data);
  1462. if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
  1463. /* should not */
  1464. return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
  1465. }
  1466. if ((sense[7] & 0x3F) == 0x01) {
  1467. /* operation code is WRITE DATA -> data area orientation */
  1468. LO_data[0] = 0x81;
  1469. } else if ((sense[7] & 0x3F) == 0x03) {
  1470. /* operation code is FORMAT WRITE -> index orientation */
  1471. LO_data[0] = 0xC3;
  1472. } else {
  1473. LO_data[0] = sense[7]; /* operation */
  1474. }
  1475. LO_data[1] = sense[8]; /* auxiliary */
  1476. LO_data[2] = sense[9];
  1477. LO_data[3] = sense[3]; /* count */
  1478. LO_data[4] = sense[29]; /* seek_addr.cyl */
  1479. LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
  1480. LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
  1481. memcpy(&(LO_data[8]), &(sense[11]), 8);
  1482. /* create DE ccw */
  1483. ccw = erp->cpaddr;
  1484. memset(ccw, 0, sizeof(struct ccw1));
  1485. ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
  1486. ccw->flags = CCW_FLAG_CC;
  1487. ccw->count = 16;
  1488. ccw->cda = (__u32)(addr_t) DE_data;
  1489. /* create LO ccw */
  1490. ccw++;
  1491. memset(ccw, 0, sizeof(struct ccw1));
  1492. ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
  1493. ccw->flags = CCW_FLAG_CC;
  1494. ccw->count = 16;
  1495. ccw->cda = (__u32)(addr_t) LO_data;
  1496. /* TIC to the failed ccw */
  1497. ccw++;
  1498. ccw->cmd_code = CCW_CMD_TIC;
  1499. ccw->cda = cpa;
  1500. /* fill erp related fields */
  1501. erp->flags = default_erp->flags;
  1502. erp->function = dasd_3990_erp_action_1B_32;
  1503. erp->refers = default_erp->refers;
  1504. erp->startdev = device;
  1505. erp->memdev = device;
  1506. erp->magic = default_erp->magic;
  1507. erp->expires = default_erp->expires;
  1508. erp->retries = 256;
  1509. erp->buildclk = get_tod_clock();
  1510. erp->status = DASD_CQR_FILLED;
  1511. /* remove the default erp */
  1512. dasd_free_erp_request(default_erp, device);
  1513. return erp;
  1514. } /* end dasd_3990_erp_action_1B_32 */
  1515. /*
  1516. * DASD_3990_UPDATE_1B
  1517. *
  1518. * DESCRIPTION
  1519. * Handles the update to the 32 byte 'Action 1B' of Single Program
  1520. * Action Codes in case the first action was not successful.
  1521. * The already created 'previous_erp' is the currently not successful
  1522. * ERP.
  1523. *
  1524. * PARAMETER
  1525. * previous_erp already created previous erp.
  1526. * sense current sense data
  1527. * RETURN VALUES
  1528. * erp modified erp
  1529. */
  1530. static struct dasd_ccw_req *
  1531. dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
  1532. {
  1533. struct dasd_device *device = previous_erp->startdev;
  1534. __u32 cpa = 0;
  1535. struct dasd_ccw_req *cqr;
  1536. struct dasd_ccw_req *erp;
  1537. char *LO_data; /* struct LO_eckd_data */
  1538. struct ccw1 *ccw;
  1539. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1540. "Write not finished because of unexpected condition"
  1541. " - follow on");
  1542. /* determine the original cqr */
  1543. cqr = previous_erp;
  1544. while (cqr->refers != NULL) {
  1545. cqr = cqr->refers;
  1546. }
  1547. if (scsw_is_tm(&cqr->irb.scsw)) {
  1548. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1549. "32 bit sense, action 1B, update,"
  1550. " in transport mode - just retry");
  1551. return previous_erp;
  1552. }
  1553. /* for imprecise ending just do default erp */
  1554. if (sense[1] & 0x01) {
  1555. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1556. "Imprecise ending is set - just retry");
  1557. previous_erp->status = DASD_CQR_FILLED;
  1558. return previous_erp;
  1559. }
  1560. /* determine the address of the CCW to be restarted */
  1561. /* Imprecise ending is not set -> addr from IRB-SCSW */
  1562. cpa = previous_erp->irb.scsw.cmd.cpa;
  1563. if (cpa == 0) {
  1564. /* internal error 02 -
  1565. Unable to determine address of the CCW to be restarted */
  1566. dev_err(&device->cdev->dev, "An error occurred in the DASD "
  1567. "device driver, reason=%s\n", "02");
  1568. previous_erp->status = DASD_CQR_FAILED;
  1569. return previous_erp;
  1570. }
  1571. erp = previous_erp;
  1572. /* update the LO with the new returned sense data */
  1573. LO_data = erp->data + sizeof(struct DE_eckd_data);
  1574. if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
  1575. /* should not happen */
  1576. previous_erp->status = DASD_CQR_FAILED;
  1577. return previous_erp;
  1578. }
  1579. if ((sense[7] & 0x3F) == 0x01) {
  1580. /* operation code is WRITE DATA -> data area orientation */
  1581. LO_data[0] = 0x81;
  1582. } else if ((sense[7] & 0x3F) == 0x03) {
  1583. /* operation code is FORMAT WRITE -> index orientation */
  1584. LO_data[0] = 0xC3;
  1585. } else {
  1586. LO_data[0] = sense[7]; /* operation */
  1587. }
  1588. LO_data[1] = sense[8]; /* auxiliary */
  1589. LO_data[2] = sense[9];
  1590. LO_data[3] = sense[3]; /* count */
  1591. LO_data[4] = sense[29]; /* seek_addr.cyl */
  1592. LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
  1593. LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
  1594. memcpy(&(LO_data[8]), &(sense[11]), 8);
  1595. /* TIC to the failed ccw */
  1596. ccw = erp->cpaddr; /* addr of DE ccw */
  1597. ccw++; /* addr of LE ccw */
  1598. ccw++; /* addr of TIC ccw */
  1599. ccw->cda = cpa;
  1600. erp->status = DASD_CQR_FILLED;
  1601. return erp;
  1602. } /* end dasd_3990_update_1B */
  1603. /*
  1604. * DASD_3990_ERP_COMPOUND_RETRY
  1605. *
  1606. * DESCRIPTION
  1607. * Handles the compound ERP action retry code.
  1608. * NOTE: At least one retry is done even if zero is specified
  1609. * by the sense data. This makes enqueueing of the request
  1610. * easier.
  1611. *
  1612. * PARAMETER
  1613. * sense sense data of the actual error
  1614. * erp pointer to the currently created ERP
  1615. *
  1616. * RETURN VALUES
  1617. * erp modified ERP pointer
  1618. *
  1619. */
  1620. static void
  1621. dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense)
  1622. {
  1623. switch (sense[25] & 0x03) {
  1624. case 0x00: /* no not retry */
  1625. erp->retries = 1;
  1626. break;
  1627. case 0x01: /* retry 2 times */
  1628. erp->retries = 2;
  1629. break;
  1630. case 0x02: /* retry 10 times */
  1631. erp->retries = 10;
  1632. break;
  1633. case 0x03: /* retry 256 times */
  1634. erp->retries = 256;
  1635. break;
  1636. default:
  1637. BUG();
  1638. }
  1639. erp->function = dasd_3990_erp_compound_retry;
  1640. } /* end dasd_3990_erp_compound_retry */
  1641. /*
  1642. * DASD_3990_ERP_COMPOUND_PATH
  1643. *
  1644. * DESCRIPTION
  1645. * Handles the compound ERP action for retry on alternate
  1646. * channel path.
  1647. *
  1648. * PARAMETER
  1649. * sense sense data of the actual error
  1650. * erp pointer to the currently created ERP
  1651. *
  1652. * RETURN VALUES
  1653. * erp modified ERP pointer
  1654. *
  1655. */
  1656. static void
  1657. dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
  1658. {
  1659. if (sense[25] & DASD_SENSE_BIT_3) {
  1660. dasd_3990_erp_alternate_path(erp);
  1661. if (erp->status == DASD_CQR_FAILED &&
  1662. !test_bit(DASD_CQR_VERIFY_PATH, &erp->flags)) {
  1663. /* reset the lpm and the status to be able to
  1664. * try further actions. */
  1665. erp->lpm = erp->startdev->path_data.opm;
  1666. erp->status = DASD_CQR_NEED_ERP;
  1667. }
  1668. }
  1669. erp->function = dasd_3990_erp_compound_path;
  1670. } /* end dasd_3990_erp_compound_path */
  1671. /*
  1672. * DASD_3990_ERP_COMPOUND_CODE
  1673. *
  1674. * DESCRIPTION
  1675. * Handles the compound ERP action for retry code.
  1676. *
  1677. * PARAMETER
  1678. * sense sense data of the actual error
  1679. * erp pointer to the currently created ERP
  1680. *
  1681. * RETURN VALUES
  1682. * erp NEW ERP pointer
  1683. *
  1684. */
  1685. static struct dasd_ccw_req *
  1686. dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
  1687. {
  1688. if (sense[25] & DASD_SENSE_BIT_2) {
  1689. switch (sense[28]) {
  1690. case 0x17:
  1691. /* issue a Diagnostic Control command with an
  1692. * Inhibit Write subcommand and controller modifier */
  1693. erp = dasd_3990_erp_DCTL(erp, 0x20);
  1694. break;
  1695. case 0x25:
  1696. /* wait for 5 seconds and retry again */
  1697. erp->retries = 1;
  1698. dasd_3990_erp_block_queue (erp, 5*HZ);
  1699. break;
  1700. default:
  1701. /* should not happen - continue */
  1702. break;
  1703. }
  1704. }
  1705. erp->function = dasd_3990_erp_compound_code;
  1706. return erp;
  1707. } /* end dasd_3990_erp_compound_code */
  1708. /*
  1709. * DASD_3990_ERP_COMPOUND_CONFIG
  1710. *
  1711. * DESCRIPTION
  1712. * Handles the compound ERP action for configruation
  1713. * dependent error.
  1714. * Note: duplex handling is not implemented (yet).
  1715. *
  1716. * PARAMETER
  1717. * sense sense data of the actual error
  1718. * erp pointer to the currently created ERP
  1719. *
  1720. * RETURN VALUES
  1721. * erp modified ERP pointer
  1722. *
  1723. */
  1724. static void
  1725. dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense)
  1726. {
  1727. if ((sense[25] & DASD_SENSE_BIT_1) && (sense[26] & DASD_SENSE_BIT_2)) {
  1728. /* set to suspended duplex state then restart
  1729. internal error 05 - Set device to suspended duplex state
  1730. should be done */
  1731. struct dasd_device *device = erp->startdev;
  1732. dev_err(&device->cdev->dev,
  1733. "An error occurred in the DASD device driver, "
  1734. "reason=%s\n", "05");
  1735. }
  1736. erp->function = dasd_3990_erp_compound_config;
  1737. } /* end dasd_3990_erp_compound_config */
  1738. /*
  1739. * DASD_3990_ERP_COMPOUND
  1740. *
  1741. * DESCRIPTION
  1742. * Does the further compound program action if
  1743. * compound retry was not successful.
  1744. *
  1745. * PARAMETER
  1746. * sense sense data of the actual error
  1747. * erp pointer to the current (failed) ERP
  1748. *
  1749. * RETURN VALUES
  1750. * erp (additional) ERP pointer
  1751. *
  1752. */
  1753. static struct dasd_ccw_req *
  1754. dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense)
  1755. {
  1756. if ((erp->function == dasd_3990_erp_compound_retry) &&
  1757. (erp->status == DASD_CQR_NEED_ERP)) {
  1758. dasd_3990_erp_compound_path(erp, sense);
  1759. }
  1760. if ((erp->function == dasd_3990_erp_compound_path) &&
  1761. (erp->status == DASD_CQR_NEED_ERP)) {
  1762. erp = dasd_3990_erp_compound_code(erp, sense);
  1763. }
  1764. if ((erp->function == dasd_3990_erp_compound_code) &&
  1765. (erp->status == DASD_CQR_NEED_ERP)) {
  1766. dasd_3990_erp_compound_config(erp, sense);
  1767. }
  1768. /* if no compound action ERP specified, the request failed */
  1769. if (erp->status == DASD_CQR_NEED_ERP)
  1770. erp->status = DASD_CQR_FAILED;
  1771. return erp;
  1772. } /* end dasd_3990_erp_compound */
  1773. /*
  1774. *DASD_3990_ERP_HANDLE_SIM
  1775. *
  1776. *DESCRIPTION
  1777. * inspects the SIM SENSE data and starts an appropriate action
  1778. *
  1779. * PARAMETER
  1780. * sense sense data of the actual error
  1781. *
  1782. * RETURN VALUES
  1783. * none
  1784. */
  1785. void
  1786. dasd_3990_erp_handle_sim(struct dasd_device *device, char *sense)
  1787. {
  1788. /* print message according to log or message to operator mode */
  1789. if ((sense[24] & DASD_SIM_MSG_TO_OP) || (sense[1] & 0x10)) {
  1790. /* print SIM SRC from RefCode */
  1791. dev_err(&device->cdev->dev, "SIM - SRC: "
  1792. "%02x%02x%02x%02x\n", sense[22],
  1793. sense[23], sense[11], sense[12]);
  1794. } else if (sense[24] & DASD_SIM_LOG) {
  1795. /* print SIM SRC Refcode */
  1796. dev_warn(&device->cdev->dev, "log SIM - SRC: "
  1797. "%02x%02x%02x%02x\n", sense[22],
  1798. sense[23], sense[11], sense[12]);
  1799. }
  1800. }
  1801. /*
  1802. * DASD_3990_ERP_INSPECT_32
  1803. *
  1804. * DESCRIPTION
  1805. * Does a detailed inspection of the 32 byte sense data
  1806. * and sets up a related error recovery action.
  1807. *
  1808. * PARAMETER
  1809. * sense sense data of the actual error
  1810. * erp pointer to the currently created default ERP
  1811. *
  1812. * RETURN VALUES
  1813. * erp_filled pointer to the ERP
  1814. *
  1815. */
  1816. static struct dasd_ccw_req *
  1817. dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
  1818. {
  1819. struct dasd_device *device = erp->startdev;
  1820. erp->function = dasd_3990_erp_inspect_32;
  1821. /* check for SIM sense data */
  1822. if ((sense[6] & DASD_SIM_SENSE) == DASD_SIM_SENSE)
  1823. dasd_3990_erp_handle_sim(device, sense);
  1824. if (sense[25] & DASD_SENSE_BIT_0) {
  1825. /* compound program action codes (byte25 bit 0 == '1') */
  1826. dasd_3990_erp_compound_retry(erp, sense);
  1827. } else {
  1828. /* single program action codes (byte25 bit 0 == '0') */
  1829. switch (sense[25]) {
  1830. case 0x00: /* success - use default ERP for retries */
  1831. DBF_DEV_EVENT(DBF_DEBUG, device, "%s",
  1832. "ERP called for successful request"
  1833. " - just retry");
  1834. break;
  1835. case 0x01: /* fatal error */
  1836. dev_err(&device->cdev->dev,
  1837. "ERP failed for the DASD\n");
  1838. erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  1839. break;
  1840. case 0x02: /* intervention required */
  1841. case 0x03: /* intervention required during dual copy */
  1842. erp = dasd_3990_erp_int_req(erp);
  1843. break;
  1844. case 0x0F: /* length mismatch during update write command
  1845. internal error 08 - update write command error*/
  1846. dev_err(&device->cdev->dev, "An error occurred in the "
  1847. "DASD device driver, reason=%s\n", "08");
  1848. erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  1849. break;
  1850. case 0x10: /* logging required for other channel program */
  1851. erp = dasd_3990_erp_action_10_32(erp, sense);
  1852. break;
  1853. case 0x15: /* next track outside defined extend
  1854. internal error 07 - The next track is not
  1855. within the defined storage extent */
  1856. dev_err(&device->cdev->dev,
  1857. "An error occurred in the DASD device driver, "
  1858. "reason=%s\n", "07");
  1859. erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
  1860. break;
  1861. case 0x1B: /* unexpected condition during write */
  1862. erp = dasd_3990_erp_action_1B_32(erp, sense);
  1863. break;
  1864. case 0x1C: /* invalid data */
  1865. dev_emerg(&device->cdev->dev,
  1866. "Data recovered during retry with PCI "
  1867. "fetch mode active\n");
  1868. /* not possible to handle this situation in Linux */
  1869. panic
  1870. ("Invalid data - No way to inform application "
  1871. "about the possibly incorrect data");
  1872. break;
  1873. case 0x1D: /* state-change pending */
  1874. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1875. "A State change pending condition exists "
  1876. "for the subsystem or device");
  1877. erp = dasd_3990_erp_action_4(erp, sense);
  1878. break;
  1879. case 0x1E: /* busy */
  1880. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1881. "Busy condition exists "
  1882. "for the subsystem or device");
  1883. erp = dasd_3990_erp_action_4(erp, sense);
  1884. break;
  1885. default: /* all others errors - default erp */
  1886. break;
  1887. }
  1888. }
  1889. return erp;
  1890. } /* end dasd_3990_erp_inspect_32 */
  1891. /*
  1892. *****************************************************************************
  1893. * main ERP control functions (24 and 32 byte sense)
  1894. *****************************************************************************
  1895. */
  1896. /*
  1897. * DASD_3990_ERP_CONTROL_CHECK
  1898. *
  1899. * DESCRIPTION
  1900. * Does a generic inspection if a control check occurred and sets up
  1901. * the related error recovery procedure
  1902. *
  1903. * PARAMETER
  1904. * erp pointer to the currently created default ERP
  1905. *
  1906. * RETURN VALUES
  1907. * erp_filled pointer to the erp
  1908. */
  1909. static struct dasd_ccw_req *
  1910. dasd_3990_erp_control_check(struct dasd_ccw_req *erp)
  1911. {
  1912. struct dasd_device *device = erp->startdev;
  1913. if (scsw_cstat(&erp->refers->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK
  1914. | SCHN_STAT_CHN_CTRL_CHK)) {
  1915. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  1916. "channel or interface control check");
  1917. erp = dasd_3990_erp_action_4(erp, NULL);
  1918. }
  1919. return erp;
  1920. }
  1921. /*
  1922. * DASD_3990_ERP_INSPECT
  1923. *
  1924. * DESCRIPTION
  1925. * Does a detailed inspection for sense data by calling either
  1926. * the 24-byte or the 32-byte inspection routine.
  1927. *
  1928. * PARAMETER
  1929. * erp pointer to the currently created default ERP
  1930. * RETURN VALUES
  1931. * erp_new contens was possibly modified
  1932. */
  1933. static struct dasd_ccw_req *
  1934. dasd_3990_erp_inspect(struct dasd_ccw_req *erp)
  1935. {
  1936. struct dasd_ccw_req *erp_new = NULL;
  1937. char *sense;
  1938. /* if this problem occurred on an alias retry on base */
  1939. erp_new = dasd_3990_erp_inspect_alias(erp);
  1940. if (erp_new)
  1941. return erp_new;
  1942. /* sense data are located in the refers record of the
  1943. * already set up new ERP !
  1944. * check if concurrent sens is available
  1945. */
  1946. sense = dasd_get_sense(&erp->refers->irb);
  1947. if (!sense)
  1948. erp_new = dasd_3990_erp_control_check(erp);
  1949. /* distinguish between 24 and 32 byte sense data */
  1950. else if (sense[27] & DASD_SENSE_BIT_0) {
  1951. /* inspect the 24 byte sense data */
  1952. erp_new = dasd_3990_erp_inspect_24(erp, sense);
  1953. } else {
  1954. /* inspect the 32 byte sense data */
  1955. erp_new = dasd_3990_erp_inspect_32(erp, sense);
  1956. } /* end distinguish between 24 and 32 byte sense data */
  1957. return erp_new;
  1958. }
  1959. /*
  1960. * DASD_3990_ERP_ADD_ERP
  1961. *
  1962. * DESCRIPTION
  1963. * This function adds an additional request block (ERP) to the head of
  1964. * the given cqr (or erp).
  1965. * For a command mode cqr the erp is initialized as an default erp
  1966. * (retry TIC).
  1967. * For transport mode we make a copy of the original TCW (points to
  1968. * the original TCCB, TIDALs, etc.) but give it a fresh
  1969. * TSB so the original sense data will not be changed.
  1970. *
  1971. * PARAMETER
  1972. * cqr head of the current ERP-chain (or single cqr if
  1973. * first error)
  1974. * RETURN VALUES
  1975. * erp pointer to new ERP-chain head
  1976. */
  1977. static struct dasd_ccw_req *dasd_3990_erp_add_erp(struct dasd_ccw_req *cqr)
  1978. {
  1979. struct dasd_device *device = cqr->startdev;
  1980. struct ccw1 *ccw;
  1981. struct dasd_ccw_req *erp;
  1982. int cplength, datasize;
  1983. struct tcw *tcw;
  1984. struct tsb *tsb;
  1985. if (cqr->cpmode == 1) {
  1986. cplength = 0;
  1987. /* TCW needs to be 64 byte aligned, so leave enough room */
  1988. datasize = 64 + sizeof(struct tcw) + sizeof(struct tsb);
  1989. } else {
  1990. cplength = 2;
  1991. datasize = 0;
  1992. }
  1993. /* allocate additional request block */
  1994. erp = dasd_alloc_erp_request((char *) &cqr->magic,
  1995. cplength, datasize, device);
  1996. if (IS_ERR(erp)) {
  1997. if (cqr->retries <= 0) {
  1998. DBF_DEV_EVENT(DBF_ERR, device, "%s",
  1999. "Unable to allocate ERP request");
  2000. cqr->status = DASD_CQR_FAILED;
  2001. cqr->stopclk = get_tod_clock();
  2002. } else {
  2003. DBF_DEV_EVENT(DBF_ERR, device,
  2004. "Unable to allocate ERP request "
  2005. "(%i retries left)",
  2006. cqr->retries);
  2007. dasd_block_set_timer(device->block, (HZ << 3));
  2008. }
  2009. return erp;
  2010. }
  2011. ccw = cqr->cpaddr;
  2012. if (cqr->cpmode == 1) {
  2013. /* make a shallow copy of the original tcw but set new tsb */
  2014. erp->cpmode = 1;
  2015. erp->cpaddr = PTR_ALIGN(erp->data, 64);
  2016. tcw = erp->cpaddr;
  2017. tsb = (struct tsb *) &tcw[1];
  2018. *tcw = *((struct tcw *)cqr->cpaddr);
  2019. tcw->tsb = (long)tsb;
  2020. } else if (ccw->cmd_code == DASD_ECKD_CCW_PSF) {
  2021. /* PSF cannot be chained from NOOP/TIC */
  2022. erp->cpaddr = cqr->cpaddr;
  2023. } else {
  2024. /* initialize request with default TIC to current ERP/CQR */
  2025. ccw = erp->cpaddr;
  2026. ccw->cmd_code = CCW_CMD_NOOP;
  2027. ccw->flags = CCW_FLAG_CC;
  2028. ccw++;
  2029. ccw->cmd_code = CCW_CMD_TIC;
  2030. ccw->cda = (long)(cqr->cpaddr);
  2031. }
  2032. erp->flags = cqr->flags;
  2033. erp->function = dasd_3990_erp_add_erp;
  2034. erp->refers = cqr;
  2035. erp->startdev = device;
  2036. erp->memdev = device;
  2037. erp->block = cqr->block;
  2038. erp->magic = cqr->magic;
  2039. erp->expires = cqr->expires;
  2040. erp->retries = 256;
  2041. erp->buildclk = get_tod_clock();
  2042. erp->status = DASD_CQR_FILLED;
  2043. return erp;
  2044. }
  2045. /*
  2046. * DASD_3990_ERP_ADDITIONAL_ERP
  2047. *
  2048. * DESCRIPTION
  2049. * An additional ERP is needed to handle the current error.
  2050. * Add ERP to the head of the ERP-chain containing the ERP processing
  2051. * determined based on the sense data.
  2052. *
  2053. * PARAMETER
  2054. * cqr head of the current ERP-chain (or single cqr if
  2055. * first error)
  2056. *
  2057. * RETURN VALUES
  2058. * erp pointer to new ERP-chain head
  2059. */
  2060. static struct dasd_ccw_req *
  2061. dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)
  2062. {
  2063. struct dasd_ccw_req *erp = NULL;
  2064. /* add erp and initialize with default TIC */
  2065. erp = dasd_3990_erp_add_erp(cqr);
  2066. if (IS_ERR(erp))
  2067. return erp;
  2068. /* inspect sense, determine specific ERP if possible */
  2069. if (erp != cqr) {
  2070. erp = dasd_3990_erp_inspect(erp);
  2071. }
  2072. return erp;
  2073. } /* end dasd_3990_erp_additional_erp */
  2074. /*
  2075. * DASD_3990_ERP_ERROR_MATCH
  2076. *
  2077. * DESCRIPTION
  2078. * Check if the device status of the given cqr is the same.
  2079. * This means that the failed CCW and the relevant sense data
  2080. * must match.
  2081. * I don't distinguish between 24 and 32 byte sense because in case of
  2082. * 24 byte sense byte 25 and 27 is set as well.
  2083. *
  2084. * PARAMETER
  2085. * cqr1 first cqr, which will be compared with the
  2086. * cqr2 second cqr.
  2087. *
  2088. * RETURN VALUES
  2089. * match 'boolean' for match found
  2090. * returns 1 if match found, otherwise 0.
  2091. */
  2092. static int dasd_3990_erp_error_match(struct dasd_ccw_req *cqr1,
  2093. struct dasd_ccw_req *cqr2)
  2094. {
  2095. char *sense1, *sense2;
  2096. if (cqr1->startdev != cqr2->startdev)
  2097. return 0;
  2098. sense1 = dasd_get_sense(&cqr1->irb);
  2099. sense2 = dasd_get_sense(&cqr2->irb);
  2100. /* one request has sense data, the other not -> no match, return 0 */
  2101. if (!sense1 != !sense2)
  2102. return 0;
  2103. /* no sense data in both cases -> check cstat for IFCC */
  2104. if (!sense1 && !sense2) {
  2105. if ((scsw_cstat(&cqr1->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
  2106. SCHN_STAT_CHN_CTRL_CHK)) ==
  2107. (scsw_cstat(&cqr2->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
  2108. SCHN_STAT_CHN_CTRL_CHK)))
  2109. return 1; /* match with ifcc*/
  2110. }
  2111. /* check sense data; byte 0-2,25,27 */
  2112. if (!(sense1 && sense2 &&
  2113. (memcmp(sense1, sense2, 3) == 0) &&
  2114. (sense1[27] == sense2[27]) &&
  2115. (sense1[25] == sense2[25]))) {
  2116. return 0; /* sense doesn't match */
  2117. }
  2118. return 1; /* match */
  2119. } /* end dasd_3990_erp_error_match */
  2120. /*
  2121. * DASD_3990_ERP_IN_ERP
  2122. *
  2123. * DESCRIPTION
  2124. * check if the current error already happened before.
  2125. * quick exit if current cqr is not an ERP (cqr->refers=NULL)
  2126. *
  2127. * PARAMETER
  2128. * cqr failed cqr (either original cqr or already an erp)
  2129. *
  2130. * RETURN VALUES
  2131. * erp erp-pointer to the already defined error
  2132. * recovery procedure OR
  2133. * NULL if a 'new' error occurred.
  2134. */
  2135. static struct dasd_ccw_req *
  2136. dasd_3990_erp_in_erp(struct dasd_ccw_req *cqr)
  2137. {
  2138. struct dasd_ccw_req *erp_head = cqr, /* save erp chain head */
  2139. *erp_match = NULL; /* save erp chain head */
  2140. int match = 0; /* 'boolean' for matching error found */
  2141. if (cqr->refers == NULL) { /* return if not in erp */
  2142. return NULL;
  2143. }
  2144. /* check the erp/cqr chain for current error */
  2145. do {
  2146. match = dasd_3990_erp_error_match(erp_head, cqr->refers);
  2147. erp_match = cqr; /* save possible matching erp */
  2148. cqr = cqr->refers; /* check next erp/cqr in queue */
  2149. } while ((cqr->refers != NULL) && (!match));
  2150. if (!match) {
  2151. return NULL; /* no match was found */
  2152. }
  2153. return erp_match; /* return address of matching erp */
  2154. } /* END dasd_3990_erp_in_erp */
  2155. /*
  2156. * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense)
  2157. *
  2158. * DESCRIPTION
  2159. * No retry is left for the current ERP. Check what has to be done
  2160. * with the ERP.
  2161. * - do further defined ERP action or
  2162. * - wait for interrupt or
  2163. * - exit with permanent error
  2164. *
  2165. * PARAMETER
  2166. * erp ERP which is in progress with no retry left
  2167. *
  2168. * RETURN VALUES
  2169. * erp modified/additional ERP
  2170. */
  2171. static struct dasd_ccw_req *
  2172. dasd_3990_erp_further_erp(struct dasd_ccw_req *erp)
  2173. {
  2174. struct dasd_device *device = erp->startdev;
  2175. char *sense = dasd_get_sense(&erp->irb);
  2176. /* check for 24 byte sense ERP */
  2177. if ((erp->function == dasd_3990_erp_bus_out) ||
  2178. (erp->function == dasd_3990_erp_action_1) ||
  2179. (erp->function == dasd_3990_erp_action_4)) {
  2180. erp = dasd_3990_erp_action_1(erp);
  2181. } else if (erp->function == dasd_3990_erp_action_1_sec) {
  2182. erp = dasd_3990_erp_action_1_sec(erp);
  2183. } else if (erp->function == dasd_3990_erp_action_5) {
  2184. /* retries have not been successful */
  2185. /* prepare erp for retry on different channel path */
  2186. erp = dasd_3990_erp_action_1(erp);
  2187. if (sense && !(sense[2] & DASD_SENSE_BIT_0)) {
  2188. /* issue a Diagnostic Control command with an
  2189. * Inhibit Write subcommand */
  2190. switch (sense[25]) {
  2191. case 0x17:
  2192. case 0x57:{ /* controller */
  2193. erp = dasd_3990_erp_DCTL(erp, 0x20);
  2194. break;
  2195. }
  2196. case 0x18:
  2197. case 0x58:{ /* channel path */
  2198. erp = dasd_3990_erp_DCTL(erp, 0x40);
  2199. break;
  2200. }
  2201. case 0x19:
  2202. case 0x59:{ /* storage director */
  2203. erp = dasd_3990_erp_DCTL(erp, 0x80);
  2204. break;
  2205. }
  2206. default:
  2207. DBF_DEV_EVENT(DBF_WARNING, device,
  2208. "invalid subcommand modifier 0x%x "
  2209. "for Diagnostic Control Command",
  2210. sense[25]);
  2211. }
  2212. }
  2213. /* check for 32 byte sense ERP */
  2214. } else if (sense &&
  2215. ((erp->function == dasd_3990_erp_compound_retry) ||
  2216. (erp->function == dasd_3990_erp_compound_path) ||
  2217. (erp->function == dasd_3990_erp_compound_code) ||
  2218. (erp->function == dasd_3990_erp_compound_config))) {
  2219. erp = dasd_3990_erp_compound(erp, sense);
  2220. } else {
  2221. /*
  2222. * No retry left and no additional special handling
  2223. * necessary
  2224. */
  2225. dev_err(&device->cdev->dev,
  2226. "ERP %p has run out of retries and failed\n", erp);
  2227. erp->status = DASD_CQR_FAILED;
  2228. }
  2229. return erp;
  2230. } /* end dasd_3990_erp_further_erp */
  2231. /*
  2232. * DASD_3990_ERP_HANDLE_MATCH_ERP
  2233. *
  2234. * DESCRIPTION
  2235. * An error occurred again and an ERP has been detected which is already
  2236. * used to handle this error (e.g. retries).
  2237. * All prior ERP's are asumed to be successful and therefore removed
  2238. * from queue.
  2239. * If retry counter of matching erp is already 0, it is checked if further
  2240. * action is needed (besides retry) or if the ERP has failed.
  2241. *
  2242. * PARAMETER
  2243. * erp_head first ERP in ERP-chain
  2244. * erp ERP that handles the actual error.
  2245. * (matching erp)
  2246. *
  2247. * RETURN VALUES
  2248. * erp modified/additional ERP
  2249. */
  2250. static struct dasd_ccw_req *
  2251. dasd_3990_erp_handle_match_erp(struct dasd_ccw_req *erp_head,
  2252. struct dasd_ccw_req *erp)
  2253. {
  2254. struct dasd_device *device = erp_head->startdev;
  2255. struct dasd_ccw_req *erp_done = erp_head; /* finished req */
  2256. struct dasd_ccw_req *erp_free = NULL; /* req to be freed */
  2257. /* loop over successful ERPs and remove them from chanq */
  2258. while (erp_done != erp) {
  2259. if (erp_done == NULL) /* end of chain reached */
  2260. panic(PRINTK_HEADER "Programming error in ERP! The "
  2261. "original request was lost\n");
  2262. /* remove the request from the device queue */
  2263. list_del(&erp_done->blocklist);
  2264. erp_free = erp_done;
  2265. erp_done = erp_done->refers;
  2266. /* free the finished erp request */
  2267. dasd_free_erp_request(erp_free, erp_free->memdev);
  2268. } /* end while */
  2269. if (erp->retries > 0) {
  2270. char *sense = dasd_get_sense(&erp->refers->irb);
  2271. /* check for special retries */
  2272. if (sense && erp->function == dasd_3990_erp_action_4) {
  2273. erp = dasd_3990_erp_action_4(erp, sense);
  2274. } else if (sense &&
  2275. erp->function == dasd_3990_erp_action_1B_32) {
  2276. erp = dasd_3990_update_1B(erp, sense);
  2277. } else if (sense && erp->function == dasd_3990_erp_int_req) {
  2278. erp = dasd_3990_erp_int_req(erp);
  2279. } else {
  2280. /* simple retry */
  2281. DBF_DEV_EVENT(DBF_DEBUG, device,
  2282. "%i retries left for erp %p",
  2283. erp->retries, erp);
  2284. /* handle the request again... */
  2285. erp->status = DASD_CQR_FILLED;
  2286. }
  2287. } else {
  2288. /* no retry left - check for further necessary action */
  2289. /* if no further actions, handle rest as permanent error */
  2290. erp = dasd_3990_erp_further_erp(erp);
  2291. }
  2292. return erp;
  2293. } /* end dasd_3990_erp_handle_match_erp */
  2294. /*
  2295. * DASD_3990_ERP_ACTION
  2296. *
  2297. * DESCRIPTION
  2298. * control routine for 3990 erp actions.
  2299. * Has to be called with the queue lock (namely the s390_irq_lock) acquired.
  2300. *
  2301. * PARAMETER
  2302. * cqr failed cqr (either original cqr or already an erp)
  2303. *
  2304. * RETURN VALUES
  2305. * erp erp-pointer to the head of the ERP action chain.
  2306. * This means:
  2307. * - either a ptr to an additional ERP cqr or
  2308. * - the original given cqr (which's status might
  2309. * be modified)
  2310. */
  2311. struct dasd_ccw_req *
  2312. dasd_3990_erp_action(struct dasd_ccw_req * cqr)
  2313. {
  2314. struct dasd_ccw_req *erp = NULL;
  2315. struct dasd_device *device = cqr->startdev;
  2316. struct dasd_ccw_req *temp_erp = NULL;
  2317. if (device->features & DASD_FEATURE_ERPLOG) {
  2318. /* print current erp_chain */
  2319. dev_err(&device->cdev->dev,
  2320. "ERP chain at BEGINNING of ERP-ACTION\n");
  2321. for (temp_erp = cqr;
  2322. temp_erp != NULL; temp_erp = temp_erp->refers) {
  2323. dev_err(&device->cdev->dev,
  2324. "ERP %p (%02x) refers to %p\n",
  2325. temp_erp, temp_erp->status,
  2326. temp_erp->refers);
  2327. }
  2328. }
  2329. /* double-check if current erp/cqr was successful */
  2330. if ((scsw_cstat(&cqr->irb.scsw) == 0x00) &&
  2331. (scsw_dstat(&cqr->irb.scsw) ==
  2332. (DEV_STAT_CHN_END | DEV_STAT_DEV_END))) {
  2333. DBF_DEV_EVENT(DBF_DEBUG, device,
  2334. "ERP called for successful request %p"
  2335. " - NO ERP necessary", cqr);
  2336. cqr->status = DASD_CQR_DONE;
  2337. return cqr;
  2338. }
  2339. /* check if error happened before */
  2340. erp = dasd_3990_erp_in_erp(cqr);
  2341. if (erp == NULL) {
  2342. /* no matching erp found - set up erp */
  2343. erp = dasd_3990_erp_additional_erp(cqr);
  2344. if (IS_ERR(erp))
  2345. return erp;
  2346. } else {
  2347. /* matching erp found - set all leading erp's to DONE */
  2348. erp = dasd_3990_erp_handle_match_erp(cqr, erp);
  2349. }
  2350. if (device->features & DASD_FEATURE_ERPLOG) {
  2351. /* print current erp_chain */
  2352. dev_err(&device->cdev->dev,
  2353. "ERP chain at END of ERP-ACTION\n");
  2354. for (temp_erp = erp;
  2355. temp_erp != NULL; temp_erp = temp_erp->refers) {
  2356. dev_err(&device->cdev->dev,
  2357. "ERP %p (%02x) refers to %p\n",
  2358. temp_erp, temp_erp->status,
  2359. temp_erp->refers);
  2360. }
  2361. }
  2362. /* enqueue ERP request if it's a new one */
  2363. if (list_empty(&erp->blocklist)) {
  2364. cqr->status = DASD_CQR_IN_ERP;
  2365. /* add erp request before the cqr */
  2366. list_add_tail(&erp->blocklist, &cqr->blocklist);
  2367. }
  2368. return erp;
  2369. } /* end dasd_3990_erp_action */