dasd_3990_erp.c 72 KB

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