scsi_error.c 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881
  1. /*
  2. * scsi_error.c Copyright (C) 1997 Eric Youngdale
  3. *
  4. * SCSI error/timeout handling
  5. * Initial versions: Eric Youngdale. Based upon conversations with
  6. * Leonard Zubkoff and David Miller at Linux Expo,
  7. * ideas originating from all over the place.
  8. *
  9. * Restructured scsi_unjam_host and associated functions.
  10. * September 04, 2002 Mike Anderson (andmike@us.ibm.com)
  11. *
  12. * Forward port of Russell King's (rmk@arm.linux.org.uk) changes and
  13. * minor cleanups.
  14. * September 30, 2002 Mike Anderson (andmike@us.ibm.com)
  15. */
  16. #include <linux/module.h>
  17. #include <linux/sched.h>
  18. #include <linux/timer.h>
  19. #include <linux/string.h>
  20. #include <linux/slab.h>
  21. #include <linux/kernel.h>
  22. #include <linux/kthread.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/blkdev.h>
  25. #include <linux/delay.h>
  26. #include <scsi/scsi.h>
  27. #include <scsi/scsi_dbg.h>
  28. #include <scsi/scsi_device.h>
  29. #include <scsi/scsi_eh.h>
  30. #include <scsi/scsi_host.h>
  31. #include <scsi/scsi_ioctl.h>
  32. #include <scsi/scsi_request.h>
  33. #include "scsi_priv.h"
  34. #include "scsi_logging.h"
  35. #define SENSE_TIMEOUT (10*HZ)
  36. #define START_UNIT_TIMEOUT (30*HZ)
  37. /*
  38. * These should *probably* be handled by the host itself.
  39. * Since it is allowed to sleep, it probably should.
  40. */
  41. #define BUS_RESET_SETTLE_TIME (10)
  42. #define HOST_RESET_SETTLE_TIME (10)
  43. /* called with shost->host_lock held */
  44. void scsi_eh_wakeup(struct Scsi_Host *shost)
  45. {
  46. if (shost->host_busy == shost->host_failed) {
  47. wake_up_process(shost->ehandler);
  48. SCSI_LOG_ERROR_RECOVERY(5,
  49. printk("Waking error handler thread\n"));
  50. }
  51. }
  52. /**
  53. * scsi_eh_scmd_add - add scsi cmd to error handling.
  54. * @scmd: scmd to run eh on.
  55. * @eh_flag: optional SCSI_EH flag.
  56. *
  57. * Return value:
  58. * 0 on failure.
  59. **/
  60. int scsi_eh_scmd_add(struct scsi_cmnd *scmd, int eh_flag)
  61. {
  62. struct Scsi_Host *shost = scmd->device->host;
  63. unsigned long flags;
  64. int ret = 0;
  65. if (!shost->ehandler)
  66. return 0;
  67. spin_lock_irqsave(shost->host_lock, flags);
  68. if (scsi_host_set_state(shost, SHOST_RECOVERY))
  69. if (scsi_host_set_state(shost, SHOST_CANCEL_RECOVERY))
  70. goto out_unlock;
  71. ret = 1;
  72. scmd->eh_eflags |= eh_flag;
  73. list_add_tail(&scmd->eh_entry, &shost->eh_cmd_q);
  74. shost->host_failed++;
  75. scsi_eh_wakeup(shost);
  76. out_unlock:
  77. spin_unlock_irqrestore(shost->host_lock, flags);
  78. return ret;
  79. }
  80. /**
  81. * scsi_add_timer - Start timeout timer for a single scsi command.
  82. * @scmd: scsi command that is about to start running.
  83. * @timeout: amount of time to allow this command to run.
  84. * @complete: timeout function to call if timer isn't canceled.
  85. *
  86. * Notes:
  87. * This should be turned into an inline function. Each scsi command
  88. * has its own timer, and as it is added to the queue, we set up the
  89. * timer. When the command completes, we cancel the timer.
  90. **/
  91. void scsi_add_timer(struct scsi_cmnd *scmd, int timeout,
  92. void (*complete)(struct scsi_cmnd *))
  93. {
  94. /*
  95. * If the clock was already running for this command, then
  96. * first delete the timer. The timer handling code gets rather
  97. * confused if we don't do this.
  98. */
  99. if (scmd->eh_timeout.function)
  100. del_timer(&scmd->eh_timeout);
  101. scmd->eh_timeout.data = (unsigned long)scmd;
  102. scmd->eh_timeout.expires = jiffies + timeout;
  103. scmd->eh_timeout.function = (void (*)(unsigned long)) complete;
  104. SCSI_LOG_ERROR_RECOVERY(5, printk("%s: scmd: %p, time:"
  105. " %d, (%p)\n", __FUNCTION__,
  106. scmd, timeout, complete));
  107. add_timer(&scmd->eh_timeout);
  108. }
  109. /**
  110. * scsi_delete_timer - Delete/cancel timer for a given function.
  111. * @scmd: Cmd that we are canceling timer for
  112. *
  113. * Notes:
  114. * This should be turned into an inline function.
  115. *
  116. * Return value:
  117. * 1 if we were able to detach the timer. 0 if we blew it, and the
  118. * timer function has already started to run.
  119. **/
  120. int scsi_delete_timer(struct scsi_cmnd *scmd)
  121. {
  122. int rtn;
  123. rtn = del_timer(&scmd->eh_timeout);
  124. SCSI_LOG_ERROR_RECOVERY(5, printk("%s: scmd: %p,"
  125. " rtn: %d\n", __FUNCTION__,
  126. scmd, rtn));
  127. scmd->eh_timeout.data = (unsigned long)NULL;
  128. scmd->eh_timeout.function = NULL;
  129. return rtn;
  130. }
  131. /**
  132. * scsi_times_out - Timeout function for normal scsi commands.
  133. * @scmd: Cmd that is timing out.
  134. *
  135. * Notes:
  136. * We do not need to lock this. There is the potential for a race
  137. * only in that the normal completion handling might run, but if the
  138. * normal completion function determines that the timer has already
  139. * fired, then it mustn't do anything.
  140. **/
  141. void scsi_times_out(struct scsi_cmnd *scmd)
  142. {
  143. scsi_log_completion(scmd, TIMEOUT_ERROR);
  144. if (scmd->device->host->hostt->eh_timed_out)
  145. switch (scmd->device->host->hostt->eh_timed_out(scmd)) {
  146. case EH_HANDLED:
  147. __scsi_done(scmd);
  148. return;
  149. case EH_RESET_TIMER:
  150. /* This allows a single retry even of a command
  151. * with allowed == 0 */
  152. if (scmd->retries++ > scmd->allowed)
  153. break;
  154. scsi_add_timer(scmd, scmd->timeout_per_command,
  155. scsi_times_out);
  156. return;
  157. case EH_NOT_HANDLED:
  158. break;
  159. }
  160. if (unlikely(!scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD))) {
  161. scmd->result |= DID_TIME_OUT << 16;
  162. __scsi_done(scmd);
  163. }
  164. }
  165. /**
  166. * scsi_block_when_processing_errors - Prevent cmds from being queued.
  167. * @sdev: Device on which we are performing recovery.
  168. *
  169. * Description:
  170. * We block until the host is out of error recovery, and then check to
  171. * see whether the host or the device is offline.
  172. *
  173. * Return value:
  174. * 0 when dev was taken offline by error recovery. 1 OK to proceed.
  175. **/
  176. int scsi_block_when_processing_errors(struct scsi_device *sdev)
  177. {
  178. int online;
  179. wait_event(sdev->host->host_wait, !scsi_host_in_recovery(sdev->host));
  180. online = scsi_device_online(sdev);
  181. SCSI_LOG_ERROR_RECOVERY(5, printk("%s: rtn: %d\n", __FUNCTION__,
  182. online));
  183. return online;
  184. }
  185. EXPORT_SYMBOL(scsi_block_when_processing_errors);
  186. #ifdef CONFIG_SCSI_LOGGING
  187. /**
  188. * scsi_eh_prt_fail_stats - Log info on failures.
  189. * @shost: scsi host being recovered.
  190. * @work_q: Queue of scsi cmds to process.
  191. **/
  192. static inline void scsi_eh_prt_fail_stats(struct Scsi_Host *shost,
  193. struct list_head *work_q)
  194. {
  195. struct scsi_cmnd *scmd;
  196. struct scsi_device *sdev;
  197. int total_failures = 0;
  198. int cmd_failed = 0;
  199. int cmd_cancel = 0;
  200. int devices_failed = 0;
  201. shost_for_each_device(sdev, shost) {
  202. list_for_each_entry(scmd, work_q, eh_entry) {
  203. if (scmd->device == sdev) {
  204. ++total_failures;
  205. if (scmd->eh_eflags & SCSI_EH_CANCEL_CMD)
  206. ++cmd_cancel;
  207. else
  208. ++cmd_failed;
  209. }
  210. }
  211. if (cmd_cancel || cmd_failed) {
  212. SCSI_LOG_ERROR_RECOVERY(3,
  213. sdev_printk(KERN_INFO, sdev,
  214. "%s: cmds failed: %d, cancel: %d\n",
  215. __FUNCTION__, cmd_failed,
  216. cmd_cancel));
  217. cmd_cancel = 0;
  218. cmd_failed = 0;
  219. ++devices_failed;
  220. }
  221. }
  222. SCSI_LOG_ERROR_RECOVERY(2, printk("Total of %d commands on %d"
  223. " devices require eh work\n",
  224. total_failures, devices_failed));
  225. }
  226. #endif
  227. /**
  228. * scsi_check_sense - Examine scsi cmd sense
  229. * @scmd: Cmd to have sense checked.
  230. *
  231. * Return value:
  232. * SUCCESS or FAILED or NEEDS_RETRY
  233. *
  234. * Notes:
  235. * When a deferred error is detected the current command has
  236. * not been executed and needs retrying.
  237. **/
  238. static int scsi_check_sense(struct scsi_cmnd *scmd)
  239. {
  240. struct scsi_sense_hdr sshdr;
  241. if (! scsi_command_normalize_sense(scmd, &sshdr))
  242. return FAILED; /* no valid sense data */
  243. if (scsi_sense_is_deferred(&sshdr))
  244. return NEEDS_RETRY;
  245. /*
  246. * Previous logic looked for FILEMARK, EOM or ILI which are
  247. * mainly associated with tapes and returned SUCCESS.
  248. */
  249. if (sshdr.response_code == 0x70) {
  250. /* fixed format */
  251. if (scmd->sense_buffer[2] & 0xe0)
  252. return SUCCESS;
  253. } else {
  254. /*
  255. * descriptor format: look for "stream commands sense data
  256. * descriptor" (see SSC-3). Assume single sense data
  257. * descriptor. Ignore ILI from SBC-2 READ LONG and WRITE LONG.
  258. */
  259. if ((sshdr.additional_length > 3) &&
  260. (scmd->sense_buffer[8] == 0x4) &&
  261. (scmd->sense_buffer[11] & 0xe0))
  262. return SUCCESS;
  263. }
  264. switch (sshdr.sense_key) {
  265. case NO_SENSE:
  266. return SUCCESS;
  267. case RECOVERED_ERROR:
  268. return /* soft_error */ SUCCESS;
  269. case ABORTED_COMMAND:
  270. return NEEDS_RETRY;
  271. case NOT_READY:
  272. case UNIT_ATTENTION:
  273. /*
  274. * if we are expecting a cc/ua because of a bus reset that we
  275. * performed, treat this just as a retry. otherwise this is
  276. * information that we should pass up to the upper-level driver
  277. * so that we can deal with it there.
  278. */
  279. if (scmd->device->expecting_cc_ua) {
  280. scmd->device->expecting_cc_ua = 0;
  281. return NEEDS_RETRY;
  282. }
  283. /*
  284. * if the device is in the process of becoming ready, we
  285. * should retry.
  286. */
  287. if ((sshdr.asc == 0x04) && (sshdr.ascq == 0x01))
  288. return NEEDS_RETRY;
  289. /*
  290. * if the device is not started, we need to wake
  291. * the error handler to start the motor
  292. */
  293. if (scmd->device->allow_restart &&
  294. (sshdr.asc == 0x04) && (sshdr.ascq == 0x02))
  295. return FAILED;
  296. return SUCCESS;
  297. /* these three are not supported */
  298. case COPY_ABORTED:
  299. case VOLUME_OVERFLOW:
  300. case MISCOMPARE:
  301. return SUCCESS;
  302. case MEDIUM_ERROR:
  303. return NEEDS_RETRY;
  304. case HARDWARE_ERROR:
  305. if (scmd->device->retry_hwerror)
  306. return NEEDS_RETRY;
  307. else
  308. return SUCCESS;
  309. case ILLEGAL_REQUEST:
  310. case BLANK_CHECK:
  311. case DATA_PROTECT:
  312. default:
  313. return SUCCESS;
  314. }
  315. }
  316. /**
  317. * scsi_eh_completed_normally - Disposition a eh cmd on return from LLD.
  318. * @scmd: SCSI cmd to examine.
  319. *
  320. * Notes:
  321. * This is *only* called when we are examining the status of commands
  322. * queued during error recovery. the main difference here is that we
  323. * don't allow for the possibility of retries here, and we are a lot
  324. * more restrictive about what we consider acceptable.
  325. **/
  326. static int scsi_eh_completed_normally(struct scsi_cmnd *scmd)
  327. {
  328. /*
  329. * first check the host byte, to see if there is anything in there
  330. * that would indicate what we need to do.
  331. */
  332. if (host_byte(scmd->result) == DID_RESET) {
  333. /*
  334. * rats. we are already in the error handler, so we now
  335. * get to try and figure out what to do next. if the sense
  336. * is valid, we have a pretty good idea of what to do.
  337. * if not, we mark it as FAILED.
  338. */
  339. return scsi_check_sense(scmd);
  340. }
  341. if (host_byte(scmd->result) != DID_OK)
  342. return FAILED;
  343. /*
  344. * next, check the message byte.
  345. */
  346. if (msg_byte(scmd->result) != COMMAND_COMPLETE)
  347. return FAILED;
  348. /*
  349. * now, check the status byte to see if this indicates
  350. * anything special.
  351. */
  352. switch (status_byte(scmd->result)) {
  353. case GOOD:
  354. case COMMAND_TERMINATED:
  355. return SUCCESS;
  356. case CHECK_CONDITION:
  357. return scsi_check_sense(scmd);
  358. case CONDITION_GOOD:
  359. case INTERMEDIATE_GOOD:
  360. case INTERMEDIATE_C_GOOD:
  361. /*
  362. * who knows? FIXME(eric)
  363. */
  364. return SUCCESS;
  365. case BUSY:
  366. case QUEUE_FULL:
  367. case RESERVATION_CONFLICT:
  368. default:
  369. return FAILED;
  370. }
  371. return FAILED;
  372. }
  373. /**
  374. * scsi_eh_done - Completion function for error handling.
  375. * @scmd: Cmd that is done.
  376. **/
  377. static void scsi_eh_done(struct scsi_cmnd *scmd)
  378. {
  379. struct completion *eh_action;
  380. SCSI_LOG_ERROR_RECOVERY(3,
  381. printk("%s scmd: %p result: %x\n",
  382. __FUNCTION__, scmd, scmd->result));
  383. eh_action = scmd->device->host->eh_action;
  384. if (eh_action)
  385. complete(eh_action);
  386. }
  387. /**
  388. * scsi_send_eh_cmnd - send a cmd to a device as part of error recovery.
  389. * @scmd: SCSI Cmd to send.
  390. * @timeout: Timeout for cmd.
  391. *
  392. * Return value:
  393. * SUCCESS or FAILED or NEEDS_RETRY
  394. **/
  395. static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, int timeout)
  396. {
  397. struct scsi_device *sdev = scmd->device;
  398. struct Scsi_Host *shost = sdev->host;
  399. DECLARE_COMPLETION(done);
  400. unsigned long timeleft;
  401. unsigned long flags;
  402. int rtn;
  403. if (sdev->scsi_level <= SCSI_2)
  404. scmd->cmnd[1] = (scmd->cmnd[1] & 0x1f) |
  405. (sdev->lun << 5 & 0xe0);
  406. shost->eh_action = &done;
  407. scmd->request->rq_status = RQ_SCSI_BUSY;
  408. spin_lock_irqsave(shost->host_lock, flags);
  409. scsi_log_send(scmd);
  410. shost->hostt->queuecommand(scmd, scsi_eh_done);
  411. spin_unlock_irqrestore(shost->host_lock, flags);
  412. timeleft = wait_for_completion_timeout(&done, timeout);
  413. scmd->request->rq_status = RQ_SCSI_DONE;
  414. shost->eh_action = NULL;
  415. scsi_log_completion(scmd, SUCCESS);
  416. SCSI_LOG_ERROR_RECOVERY(3,
  417. printk("%s: scmd: %p, timeleft: %ld\n",
  418. __FUNCTION__, scmd, timeleft));
  419. /*
  420. * If there is time left scsi_eh_done got called, and we will
  421. * examine the actual status codes to see whether the command
  422. * actually did complete normally, else tell the host to forget
  423. * about this command.
  424. */
  425. if (timeleft) {
  426. rtn = scsi_eh_completed_normally(scmd);
  427. SCSI_LOG_ERROR_RECOVERY(3,
  428. printk("%s: scsi_eh_completed_normally %x\n",
  429. __FUNCTION__, rtn));
  430. switch (rtn) {
  431. case SUCCESS:
  432. case NEEDS_RETRY:
  433. case FAILED:
  434. break;
  435. default:
  436. rtn = FAILED;
  437. break;
  438. }
  439. } else {
  440. /*
  441. * FIXME(eric) - we are not tracking whether we could
  442. * abort a timed out command or not. not sure how
  443. * we should treat them differently anyways.
  444. */
  445. if (shost->hostt->eh_abort_handler)
  446. shost->hostt->eh_abort_handler(scmd);
  447. rtn = FAILED;
  448. }
  449. return rtn;
  450. }
  451. /**
  452. * scsi_request_sense - Request sense data from a particular target.
  453. * @scmd: SCSI cmd for request sense.
  454. *
  455. * Notes:
  456. * Some hosts automatically obtain this information, others require
  457. * that we obtain it on our own. This function will *not* return until
  458. * the command either times out, or it completes.
  459. **/
  460. static int scsi_request_sense(struct scsi_cmnd *scmd)
  461. {
  462. static unsigned char generic_sense[6] =
  463. {REQUEST_SENSE, 0, 0, 0, 252, 0};
  464. unsigned char *scsi_result;
  465. int saved_result;
  466. int rtn;
  467. memcpy(scmd->cmnd, generic_sense, sizeof(generic_sense));
  468. scsi_result = kmalloc(252, GFP_ATOMIC | ((scmd->device->host->hostt->unchecked_isa_dma) ? __GFP_DMA : 0));
  469. if (unlikely(!scsi_result)) {
  470. printk(KERN_ERR "%s: cannot allocate scsi_result.\n",
  471. __FUNCTION__);
  472. return FAILED;
  473. }
  474. /*
  475. * zero the sense buffer. some host adapters automatically always
  476. * request sense, so it is not a good idea that
  477. * scmd->request_buffer and scmd->sense_buffer point to the same
  478. * address (db). 0 is not a valid sense code.
  479. */
  480. memset(scmd->sense_buffer, 0, sizeof(scmd->sense_buffer));
  481. memset(scsi_result, 0, 252);
  482. saved_result = scmd->result;
  483. scmd->request_buffer = scsi_result;
  484. scmd->request_bufflen = 252;
  485. scmd->use_sg = 0;
  486. scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]);
  487. scmd->sc_data_direction = DMA_FROM_DEVICE;
  488. scmd->underflow = 0;
  489. rtn = scsi_send_eh_cmnd(scmd, SENSE_TIMEOUT);
  490. /* last chance to have valid sense data */
  491. if(!SCSI_SENSE_VALID(scmd)) {
  492. memcpy(scmd->sense_buffer, scmd->request_buffer,
  493. sizeof(scmd->sense_buffer));
  494. }
  495. kfree(scsi_result);
  496. /*
  497. * when we eventually call scsi_finish, we really wish to complete
  498. * the original request, so let's restore the original data. (db)
  499. */
  500. scsi_setup_cmd_retry(scmd);
  501. scmd->result = saved_result;
  502. return rtn;
  503. }
  504. /**
  505. * scsi_eh_finish_cmd - Handle a cmd that eh is finished with.
  506. * @scmd: Original SCSI cmd that eh has finished.
  507. * @done_q: Queue for processed commands.
  508. *
  509. * Notes:
  510. * We don't want to use the normal command completion while we are are
  511. * still handling errors - it may cause other commands to be queued,
  512. * and that would disturb what we are doing. thus we really want to
  513. * keep a list of pending commands for final completion, and once we
  514. * are ready to leave error handling we handle completion for real.
  515. **/
  516. static void scsi_eh_finish_cmd(struct scsi_cmnd *scmd,
  517. struct list_head *done_q)
  518. {
  519. scmd->device->host->host_failed--;
  520. scmd->eh_eflags = 0;
  521. /*
  522. * set this back so that the upper level can correctly free up
  523. * things.
  524. */
  525. scsi_setup_cmd_retry(scmd);
  526. list_move_tail(&scmd->eh_entry, done_q);
  527. }
  528. /**
  529. * scsi_eh_get_sense - Get device sense data.
  530. * @work_q: Queue of commands to process.
  531. * @done_q: Queue of proccessed commands..
  532. *
  533. * Description:
  534. * See if we need to request sense information. if so, then get it
  535. * now, so we have a better idea of what to do.
  536. *
  537. * Notes:
  538. * This has the unfortunate side effect that if a shost adapter does
  539. * not automatically request sense information, that we end up shutting
  540. * it down before we request it.
  541. *
  542. * All drivers should request sense information internally these days,
  543. * so for now all I have to say is tough noogies if you end up in here.
  544. *
  545. * XXX: Long term this code should go away, but that needs an audit of
  546. * all LLDDs first.
  547. **/
  548. static int scsi_eh_get_sense(struct list_head *work_q,
  549. struct list_head *done_q)
  550. {
  551. struct scsi_cmnd *scmd, *next;
  552. int rtn;
  553. list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
  554. if ((scmd->eh_eflags & SCSI_EH_CANCEL_CMD) ||
  555. SCSI_SENSE_VALID(scmd))
  556. continue;
  557. SCSI_LOG_ERROR_RECOVERY(2, scmd_printk(KERN_INFO, scmd,
  558. "%s: requesting sense\n",
  559. current->comm));
  560. rtn = scsi_request_sense(scmd);
  561. if (rtn != SUCCESS)
  562. continue;
  563. SCSI_LOG_ERROR_RECOVERY(3, printk("sense requested for %p"
  564. " result %x\n", scmd,
  565. scmd->result));
  566. SCSI_LOG_ERROR_RECOVERY(3, scsi_print_sense("bh", scmd));
  567. rtn = scsi_decide_disposition(scmd);
  568. /*
  569. * if the result was normal, then just pass it along to the
  570. * upper level.
  571. */
  572. if (rtn == SUCCESS)
  573. /* we don't want this command reissued, just
  574. * finished with the sense data, so set
  575. * retries to the max allowed to ensure it
  576. * won't get reissued */
  577. scmd->retries = scmd->allowed;
  578. else if (rtn != NEEDS_RETRY)
  579. continue;
  580. scsi_eh_finish_cmd(scmd, done_q);
  581. }
  582. return list_empty(work_q);
  583. }
  584. /**
  585. * scsi_try_to_abort_cmd - Ask host to abort a running command.
  586. * @scmd: SCSI cmd to abort from Lower Level.
  587. *
  588. * Notes:
  589. * This function will not return until the user's completion function
  590. * has been called. there is no timeout on this operation. if the
  591. * author of the low-level driver wishes this operation to be timed,
  592. * they can provide this facility themselves. helper functions in
  593. * scsi_error.c can be supplied to make this easier to do.
  594. **/
  595. static int scsi_try_to_abort_cmd(struct scsi_cmnd *scmd)
  596. {
  597. if (!scmd->device->host->hostt->eh_abort_handler)
  598. return FAILED;
  599. /*
  600. * scsi_done was called just after the command timed out and before
  601. * we had a chance to process it. (db)
  602. */
  603. if (scmd->serial_number == 0)
  604. return SUCCESS;
  605. return scmd->device->host->hostt->eh_abort_handler(scmd);
  606. }
  607. /**
  608. * scsi_eh_tur - Send TUR to device.
  609. * @scmd: Scsi cmd to send TUR
  610. *
  611. * Return value:
  612. * 0 - Device is ready. 1 - Device NOT ready.
  613. **/
  614. static int scsi_eh_tur(struct scsi_cmnd *scmd)
  615. {
  616. static unsigned char tur_command[6] = {TEST_UNIT_READY, 0, 0, 0, 0, 0};
  617. int retry_cnt = 1, rtn;
  618. int saved_result;
  619. retry_tur:
  620. memcpy(scmd->cmnd, tur_command, sizeof(tur_command));
  621. /*
  622. * zero the sense buffer. the scsi spec mandates that any
  623. * untransferred sense data should be interpreted as being zero.
  624. */
  625. memset(scmd->sense_buffer, 0, sizeof(scmd->sense_buffer));
  626. saved_result = scmd->result;
  627. scmd->request_buffer = NULL;
  628. scmd->request_bufflen = 0;
  629. scmd->use_sg = 0;
  630. scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]);
  631. scmd->underflow = 0;
  632. scmd->sc_data_direction = DMA_NONE;
  633. rtn = scsi_send_eh_cmnd(scmd, SENSE_TIMEOUT);
  634. /*
  635. * when we eventually call scsi_finish, we really wish to complete
  636. * the original request, so let's restore the original data. (db)
  637. */
  638. scsi_setup_cmd_retry(scmd);
  639. scmd->result = saved_result;
  640. /*
  641. * hey, we are done. let's look to see what happened.
  642. */
  643. SCSI_LOG_ERROR_RECOVERY(3, printk("%s: scmd %p rtn %x\n",
  644. __FUNCTION__, scmd, rtn));
  645. if (rtn == SUCCESS)
  646. return 0;
  647. else if (rtn == NEEDS_RETRY) {
  648. if (retry_cnt--)
  649. goto retry_tur;
  650. return 0;
  651. }
  652. return 1;
  653. }
  654. /**
  655. * scsi_eh_abort_cmds - abort canceled commands.
  656. * @shost: scsi host being recovered.
  657. * @eh_done_q: list_head for processed commands.
  658. *
  659. * Decription:
  660. * Try and see whether or not it makes sense to try and abort the
  661. * running command. this only works out to be the case if we have one
  662. * command that has timed out. if the command simply failed, it makes
  663. * no sense to try and abort the command, since as far as the shost
  664. * adapter is concerned, it isn't running.
  665. **/
  666. static int scsi_eh_abort_cmds(struct list_head *work_q,
  667. struct list_head *done_q)
  668. {
  669. struct scsi_cmnd *scmd, *next;
  670. int rtn;
  671. list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
  672. if (!(scmd->eh_eflags & SCSI_EH_CANCEL_CMD))
  673. continue;
  674. SCSI_LOG_ERROR_RECOVERY(3, printk("%s: aborting cmd:"
  675. "0x%p\n", current->comm,
  676. scmd));
  677. rtn = scsi_try_to_abort_cmd(scmd);
  678. if (rtn == SUCCESS) {
  679. scmd->eh_eflags &= ~SCSI_EH_CANCEL_CMD;
  680. if (!scsi_device_online(scmd->device) ||
  681. !scsi_eh_tur(scmd)) {
  682. scsi_eh_finish_cmd(scmd, done_q);
  683. }
  684. } else
  685. SCSI_LOG_ERROR_RECOVERY(3, printk("%s: aborting"
  686. " cmd failed:"
  687. "0x%p\n",
  688. current->comm,
  689. scmd));
  690. }
  691. return list_empty(work_q);
  692. }
  693. /**
  694. * scsi_try_bus_device_reset - Ask host to perform a BDR on a dev
  695. * @scmd: SCSI cmd used to send BDR
  696. *
  697. * Notes:
  698. * There is no timeout for this operation. if this operation is
  699. * unreliable for a given host, then the host itself needs to put a
  700. * timer on it, and set the host back to a consistent state prior to
  701. * returning.
  702. **/
  703. static int scsi_try_bus_device_reset(struct scsi_cmnd *scmd)
  704. {
  705. int rtn;
  706. if (!scmd->device->host->hostt->eh_device_reset_handler)
  707. return FAILED;
  708. rtn = scmd->device->host->hostt->eh_device_reset_handler(scmd);
  709. if (rtn == SUCCESS) {
  710. scmd->device->was_reset = 1;
  711. scmd->device->expecting_cc_ua = 1;
  712. }
  713. return rtn;
  714. }
  715. /**
  716. * scsi_eh_try_stu - Send START_UNIT to device.
  717. * @scmd: Scsi cmd to send START_UNIT
  718. *
  719. * Return value:
  720. * 0 - Device is ready. 1 - Device NOT ready.
  721. **/
  722. static int scsi_eh_try_stu(struct scsi_cmnd *scmd)
  723. {
  724. static unsigned char stu_command[6] = {START_STOP, 0, 0, 0, 1, 0};
  725. int rtn;
  726. int saved_result;
  727. if (!scmd->device->allow_restart)
  728. return 1;
  729. memcpy(scmd->cmnd, stu_command, sizeof(stu_command));
  730. /*
  731. * zero the sense buffer. the scsi spec mandates that any
  732. * untransferred sense data should be interpreted as being zero.
  733. */
  734. memset(scmd->sense_buffer, 0, sizeof(scmd->sense_buffer));
  735. saved_result = scmd->result;
  736. scmd->request_buffer = NULL;
  737. scmd->request_bufflen = 0;
  738. scmd->use_sg = 0;
  739. scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]);
  740. scmd->underflow = 0;
  741. scmd->sc_data_direction = DMA_NONE;
  742. rtn = scsi_send_eh_cmnd(scmd, START_UNIT_TIMEOUT);
  743. /*
  744. * when we eventually call scsi_finish, we really wish to complete
  745. * the original request, so let's restore the original data. (db)
  746. */
  747. scsi_setup_cmd_retry(scmd);
  748. scmd->result = saved_result;
  749. /*
  750. * hey, we are done. let's look to see what happened.
  751. */
  752. SCSI_LOG_ERROR_RECOVERY(3, printk("%s: scmd %p rtn %x\n",
  753. __FUNCTION__, scmd, rtn));
  754. if (rtn == SUCCESS)
  755. return 0;
  756. return 1;
  757. }
  758. /**
  759. * scsi_eh_stu - send START_UNIT if needed
  760. * @shost: scsi host being recovered.
  761. * @eh_done_q: list_head for processed commands.
  762. *
  763. * Notes:
  764. * If commands are failing due to not ready, initializing command required,
  765. * try revalidating the device, which will end up sending a start unit.
  766. **/
  767. static int scsi_eh_stu(struct Scsi_Host *shost,
  768. struct list_head *work_q,
  769. struct list_head *done_q)
  770. {
  771. struct scsi_cmnd *scmd, *stu_scmd, *next;
  772. struct scsi_device *sdev;
  773. shost_for_each_device(sdev, shost) {
  774. stu_scmd = NULL;
  775. list_for_each_entry(scmd, work_q, eh_entry)
  776. if (scmd->device == sdev && SCSI_SENSE_VALID(scmd) &&
  777. scsi_check_sense(scmd) == FAILED ) {
  778. stu_scmd = scmd;
  779. break;
  780. }
  781. if (!stu_scmd)
  782. continue;
  783. SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Sending START_UNIT to sdev:"
  784. " 0x%p\n", current->comm, sdev));
  785. if (!scsi_eh_try_stu(stu_scmd)) {
  786. if (!scsi_device_online(sdev) ||
  787. !scsi_eh_tur(stu_scmd)) {
  788. list_for_each_entry_safe(scmd, next,
  789. work_q, eh_entry) {
  790. if (scmd->device == sdev)
  791. scsi_eh_finish_cmd(scmd, done_q);
  792. }
  793. }
  794. } else {
  795. SCSI_LOG_ERROR_RECOVERY(3,
  796. printk("%s: START_UNIT failed to sdev:"
  797. " 0x%p\n", current->comm, sdev));
  798. }
  799. }
  800. return list_empty(work_q);
  801. }
  802. /**
  803. * scsi_eh_bus_device_reset - send bdr if needed
  804. * @shost: scsi host being recovered.
  805. * @eh_done_q: list_head for processed commands.
  806. *
  807. * Notes:
  808. * Try a bus device reset. still, look to see whether we have multiple
  809. * devices that are jammed or not - if we have multiple devices, it
  810. * makes no sense to try bus_device_reset - we really would need to try
  811. * a bus_reset instead.
  812. **/
  813. static int scsi_eh_bus_device_reset(struct Scsi_Host *shost,
  814. struct list_head *work_q,
  815. struct list_head *done_q)
  816. {
  817. struct scsi_cmnd *scmd, *bdr_scmd, *next;
  818. struct scsi_device *sdev;
  819. int rtn;
  820. shost_for_each_device(sdev, shost) {
  821. bdr_scmd = NULL;
  822. list_for_each_entry(scmd, work_q, eh_entry)
  823. if (scmd->device == sdev) {
  824. bdr_scmd = scmd;
  825. break;
  826. }
  827. if (!bdr_scmd)
  828. continue;
  829. SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Sending BDR sdev:"
  830. " 0x%p\n", current->comm,
  831. sdev));
  832. rtn = scsi_try_bus_device_reset(bdr_scmd);
  833. if (rtn == SUCCESS) {
  834. if (!scsi_device_online(sdev) ||
  835. !scsi_eh_tur(bdr_scmd)) {
  836. list_for_each_entry_safe(scmd, next,
  837. work_q, eh_entry) {
  838. if (scmd->device == sdev)
  839. scsi_eh_finish_cmd(scmd,
  840. done_q);
  841. }
  842. }
  843. } else {
  844. SCSI_LOG_ERROR_RECOVERY(3, printk("%s: BDR"
  845. " failed sdev:"
  846. "0x%p\n",
  847. current->comm,
  848. sdev));
  849. }
  850. }
  851. return list_empty(work_q);
  852. }
  853. /**
  854. * scsi_try_bus_reset - ask host to perform a bus reset
  855. * @scmd: SCSI cmd to send bus reset.
  856. **/
  857. static int scsi_try_bus_reset(struct scsi_cmnd *scmd)
  858. {
  859. unsigned long flags;
  860. int rtn;
  861. SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Snd Bus RST\n",
  862. __FUNCTION__));
  863. if (!scmd->device->host->hostt->eh_bus_reset_handler)
  864. return FAILED;
  865. rtn = scmd->device->host->hostt->eh_bus_reset_handler(scmd);
  866. if (rtn == SUCCESS) {
  867. if (!scmd->device->host->hostt->skip_settle_delay)
  868. ssleep(BUS_RESET_SETTLE_TIME);
  869. spin_lock_irqsave(scmd->device->host->host_lock, flags);
  870. scsi_report_bus_reset(scmd->device->host,
  871. scmd_channel(scmd));
  872. spin_unlock_irqrestore(scmd->device->host->host_lock, flags);
  873. }
  874. return rtn;
  875. }
  876. /**
  877. * scsi_try_host_reset - ask host adapter to reset itself
  878. * @scmd: SCSI cmd to send hsot reset.
  879. **/
  880. static int scsi_try_host_reset(struct scsi_cmnd *scmd)
  881. {
  882. unsigned long flags;
  883. int rtn;
  884. SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Snd Host RST\n",
  885. __FUNCTION__));
  886. if (!scmd->device->host->hostt->eh_host_reset_handler)
  887. return FAILED;
  888. rtn = scmd->device->host->hostt->eh_host_reset_handler(scmd);
  889. if (rtn == SUCCESS) {
  890. if (!scmd->device->host->hostt->skip_settle_delay)
  891. ssleep(HOST_RESET_SETTLE_TIME);
  892. spin_lock_irqsave(scmd->device->host->host_lock, flags);
  893. scsi_report_bus_reset(scmd->device->host,
  894. scmd_channel(scmd));
  895. spin_unlock_irqrestore(scmd->device->host->host_lock, flags);
  896. }
  897. return rtn;
  898. }
  899. /**
  900. * scsi_eh_bus_reset - send a bus reset
  901. * @shost: scsi host being recovered.
  902. * @eh_done_q: list_head for processed commands.
  903. **/
  904. static int scsi_eh_bus_reset(struct Scsi_Host *shost,
  905. struct list_head *work_q,
  906. struct list_head *done_q)
  907. {
  908. struct scsi_cmnd *scmd, *chan_scmd, *next;
  909. unsigned int channel;
  910. int rtn;
  911. /*
  912. * we really want to loop over the various channels, and do this on
  913. * a channel by channel basis. we should also check to see if any
  914. * of the failed commands are on soft_reset devices, and if so, skip
  915. * the reset.
  916. */
  917. for (channel = 0; channel <= shost->max_channel; channel++) {
  918. chan_scmd = NULL;
  919. list_for_each_entry(scmd, work_q, eh_entry) {
  920. if (channel == scmd_channel(scmd)) {
  921. chan_scmd = scmd;
  922. break;
  923. /*
  924. * FIXME add back in some support for
  925. * soft_reset devices.
  926. */
  927. }
  928. }
  929. if (!chan_scmd)
  930. continue;
  931. SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Sending BRST chan:"
  932. " %d\n", current->comm,
  933. channel));
  934. rtn = scsi_try_bus_reset(chan_scmd);
  935. if (rtn == SUCCESS) {
  936. list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
  937. if (channel == scmd_channel(scmd))
  938. if (!scsi_device_online(scmd->device) ||
  939. !scsi_eh_tur(scmd))
  940. scsi_eh_finish_cmd(scmd,
  941. done_q);
  942. }
  943. } else {
  944. SCSI_LOG_ERROR_RECOVERY(3, printk("%s: BRST"
  945. " failed chan: %d\n",
  946. current->comm,
  947. channel));
  948. }
  949. }
  950. return list_empty(work_q);
  951. }
  952. /**
  953. * scsi_eh_host_reset - send a host reset
  954. * @work_q: list_head for processed commands.
  955. * @done_q: list_head for processed commands.
  956. **/
  957. static int scsi_eh_host_reset(struct list_head *work_q,
  958. struct list_head *done_q)
  959. {
  960. struct scsi_cmnd *scmd, *next;
  961. int rtn;
  962. if (!list_empty(work_q)) {
  963. scmd = list_entry(work_q->next,
  964. struct scsi_cmnd, eh_entry);
  965. SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Sending HRST\n"
  966. , current->comm));
  967. rtn = scsi_try_host_reset(scmd);
  968. if (rtn == SUCCESS) {
  969. list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
  970. if (!scsi_device_online(scmd->device) ||
  971. (!scsi_eh_try_stu(scmd) && !scsi_eh_tur(scmd)) ||
  972. !scsi_eh_tur(scmd))
  973. scsi_eh_finish_cmd(scmd, done_q);
  974. }
  975. } else {
  976. SCSI_LOG_ERROR_RECOVERY(3, printk("%s: HRST"
  977. " failed\n",
  978. current->comm));
  979. }
  980. }
  981. return list_empty(work_q);
  982. }
  983. /**
  984. * scsi_eh_offline_sdevs - offline scsi devices that fail to recover
  985. * @work_q: list_head for processed commands.
  986. * @done_q: list_head for processed commands.
  987. *
  988. **/
  989. static void scsi_eh_offline_sdevs(struct list_head *work_q,
  990. struct list_head *done_q)
  991. {
  992. struct scsi_cmnd *scmd, *next;
  993. list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
  994. sdev_printk(KERN_INFO, scmd->device,
  995. "scsi: Device offlined - not"
  996. " ready after error recovery\n");
  997. scsi_device_set_state(scmd->device, SDEV_OFFLINE);
  998. if (scmd->eh_eflags & SCSI_EH_CANCEL_CMD) {
  999. /*
  1000. * FIXME: Handle lost cmds.
  1001. */
  1002. }
  1003. scsi_eh_finish_cmd(scmd, done_q);
  1004. }
  1005. return;
  1006. }
  1007. /**
  1008. * scsi_decide_disposition - Disposition a cmd on return from LLD.
  1009. * @scmd: SCSI cmd to examine.
  1010. *
  1011. * Notes:
  1012. * This is *only* called when we are examining the status after sending
  1013. * out the actual data command. any commands that are queued for error
  1014. * recovery (e.g. test_unit_ready) do *not* come through here.
  1015. *
  1016. * When this routine returns failed, it means the error handler thread
  1017. * is woken. In cases where the error code indicates an error that
  1018. * doesn't require the error handler read (i.e. we don't need to
  1019. * abort/reset), this function should return SUCCESS.
  1020. **/
  1021. int scsi_decide_disposition(struct scsi_cmnd *scmd)
  1022. {
  1023. int rtn;
  1024. /*
  1025. * if the device is offline, then we clearly just pass the result back
  1026. * up to the top level.
  1027. */
  1028. if (!scsi_device_online(scmd->device)) {
  1029. SCSI_LOG_ERROR_RECOVERY(5, printk("%s: device offline - report"
  1030. " as SUCCESS\n",
  1031. __FUNCTION__));
  1032. return SUCCESS;
  1033. }
  1034. /*
  1035. * first check the host byte, to see if there is anything in there
  1036. * that would indicate what we need to do.
  1037. */
  1038. switch (host_byte(scmd->result)) {
  1039. case DID_PASSTHROUGH:
  1040. /*
  1041. * no matter what, pass this through to the upper layer.
  1042. * nuke this special code so that it looks like we are saying
  1043. * did_ok.
  1044. */
  1045. scmd->result &= 0xff00ffff;
  1046. return SUCCESS;
  1047. case DID_OK:
  1048. /*
  1049. * looks good. drop through, and check the next byte.
  1050. */
  1051. break;
  1052. case DID_NO_CONNECT:
  1053. case DID_BAD_TARGET:
  1054. case DID_ABORT:
  1055. /*
  1056. * note - this means that we just report the status back
  1057. * to the top level driver, not that we actually think
  1058. * that it indicates SUCCESS.
  1059. */
  1060. return SUCCESS;
  1061. /*
  1062. * when the low level driver returns did_soft_error,
  1063. * it is responsible for keeping an internal retry counter
  1064. * in order to avoid endless loops (db)
  1065. *
  1066. * actually this is a bug in this function here. we should
  1067. * be mindful of the maximum number of retries specified
  1068. * and not get stuck in a loop.
  1069. */
  1070. case DID_SOFT_ERROR:
  1071. goto maybe_retry;
  1072. case DID_IMM_RETRY:
  1073. return NEEDS_RETRY;
  1074. case DID_REQUEUE:
  1075. return ADD_TO_MLQUEUE;
  1076. case DID_ERROR:
  1077. if (msg_byte(scmd->result) == COMMAND_COMPLETE &&
  1078. status_byte(scmd->result) == RESERVATION_CONFLICT)
  1079. /*
  1080. * execute reservation conflict processing code
  1081. * lower down
  1082. */
  1083. break;
  1084. /* fallthrough */
  1085. case DID_BUS_BUSY:
  1086. case DID_PARITY:
  1087. goto maybe_retry;
  1088. case DID_TIME_OUT:
  1089. /*
  1090. * when we scan the bus, we get timeout messages for
  1091. * these commands if there is no device available.
  1092. * other hosts report did_no_connect for the same thing.
  1093. */
  1094. if ((scmd->cmnd[0] == TEST_UNIT_READY ||
  1095. scmd->cmnd[0] == INQUIRY)) {
  1096. return SUCCESS;
  1097. } else {
  1098. return FAILED;
  1099. }
  1100. case DID_RESET:
  1101. return SUCCESS;
  1102. default:
  1103. return FAILED;
  1104. }
  1105. /*
  1106. * next, check the message byte.
  1107. */
  1108. if (msg_byte(scmd->result) != COMMAND_COMPLETE)
  1109. return FAILED;
  1110. /*
  1111. * check the status byte to see if this indicates anything special.
  1112. */
  1113. switch (status_byte(scmd->result)) {
  1114. case QUEUE_FULL:
  1115. /*
  1116. * the case of trying to send too many commands to a
  1117. * tagged queueing device.
  1118. */
  1119. case BUSY:
  1120. /*
  1121. * device can't talk to us at the moment. Should only
  1122. * occur (SAM-3) when the task queue is empty, so will cause
  1123. * the empty queue handling to trigger a stall in the
  1124. * device.
  1125. */
  1126. return ADD_TO_MLQUEUE;
  1127. case GOOD:
  1128. case COMMAND_TERMINATED:
  1129. case TASK_ABORTED:
  1130. return SUCCESS;
  1131. case CHECK_CONDITION:
  1132. rtn = scsi_check_sense(scmd);
  1133. if (rtn == NEEDS_RETRY)
  1134. goto maybe_retry;
  1135. /* if rtn == FAILED, we have no sense information;
  1136. * returning FAILED will wake the error handler thread
  1137. * to collect the sense and redo the decide
  1138. * disposition */
  1139. return rtn;
  1140. case CONDITION_GOOD:
  1141. case INTERMEDIATE_GOOD:
  1142. case INTERMEDIATE_C_GOOD:
  1143. case ACA_ACTIVE:
  1144. /*
  1145. * who knows? FIXME(eric)
  1146. */
  1147. return SUCCESS;
  1148. case RESERVATION_CONFLICT:
  1149. sdev_printk(KERN_INFO, scmd->device,
  1150. "reservation conflict\n");
  1151. return SUCCESS; /* causes immediate i/o error */
  1152. default:
  1153. return FAILED;
  1154. }
  1155. return FAILED;
  1156. maybe_retry:
  1157. /* we requeue for retry because the error was retryable, and
  1158. * the request was not marked fast fail. Note that above,
  1159. * even if the request is marked fast fail, we still requeue
  1160. * for queue congestion conditions (QUEUE_FULL or BUSY) */
  1161. if ((++scmd->retries) < scmd->allowed
  1162. && !blk_noretry_request(scmd->request)) {
  1163. return NEEDS_RETRY;
  1164. } else {
  1165. /*
  1166. * no more retries - report this one back to upper level.
  1167. */
  1168. return SUCCESS;
  1169. }
  1170. }
  1171. /**
  1172. * scsi_eh_lock_door - Prevent medium removal for the specified device
  1173. * @sdev: SCSI device to prevent medium removal
  1174. *
  1175. * Locking:
  1176. * We must be called from process context; scsi_allocate_request()
  1177. * may sleep.
  1178. *
  1179. * Notes:
  1180. * We queue up an asynchronous "ALLOW MEDIUM REMOVAL" request on the
  1181. * head of the devices request queue, and continue.
  1182. *
  1183. * Bugs:
  1184. * scsi_allocate_request() may sleep waiting for existing requests to
  1185. * be processed. However, since we haven't kicked off any request
  1186. * processing for this host, this may deadlock.
  1187. *
  1188. * If scsi_allocate_request() fails for what ever reason, we
  1189. * completely forget to lock the door.
  1190. **/
  1191. static void scsi_eh_lock_door(struct scsi_device *sdev)
  1192. {
  1193. unsigned char cmnd[MAX_COMMAND_SIZE];
  1194. cmnd[0] = ALLOW_MEDIUM_REMOVAL;
  1195. cmnd[1] = 0;
  1196. cmnd[2] = 0;
  1197. cmnd[3] = 0;
  1198. cmnd[4] = SCSI_REMOVAL_PREVENT;
  1199. cmnd[5] = 0;
  1200. scsi_execute_async(sdev, cmnd, 6, DMA_NONE, NULL, 0, 0, 10 * HZ,
  1201. 5, NULL, NULL, GFP_KERNEL);
  1202. }
  1203. /**
  1204. * scsi_restart_operations - restart io operations to the specified host.
  1205. * @shost: Host we are restarting.
  1206. *
  1207. * Notes:
  1208. * When we entered the error handler, we blocked all further i/o to
  1209. * this device. we need to 'reverse' this process.
  1210. **/
  1211. static void scsi_restart_operations(struct Scsi_Host *shost)
  1212. {
  1213. struct scsi_device *sdev;
  1214. unsigned long flags;
  1215. /*
  1216. * If the door was locked, we need to insert a door lock request
  1217. * onto the head of the SCSI request queue for the device. There
  1218. * is no point trying to lock the door of an off-line device.
  1219. */
  1220. shost_for_each_device(sdev, shost) {
  1221. if (scsi_device_online(sdev) && sdev->locked)
  1222. scsi_eh_lock_door(sdev);
  1223. }
  1224. /*
  1225. * next free up anything directly waiting upon the host. this
  1226. * will be requests for character device operations, and also for
  1227. * ioctls to queued block devices.
  1228. */
  1229. SCSI_LOG_ERROR_RECOVERY(3, printk("%s: waking up host to restart\n",
  1230. __FUNCTION__));
  1231. spin_lock_irqsave(shost->host_lock, flags);
  1232. if (scsi_host_set_state(shost, SHOST_RUNNING))
  1233. if (scsi_host_set_state(shost, SHOST_CANCEL))
  1234. BUG_ON(scsi_host_set_state(shost, SHOST_DEL));
  1235. spin_unlock_irqrestore(shost->host_lock, flags);
  1236. wake_up(&shost->host_wait);
  1237. /*
  1238. * finally we need to re-initiate requests that may be pending. we will
  1239. * have had everything blocked while error handling is taking place, and
  1240. * now that error recovery is done, we will need to ensure that these
  1241. * requests are started.
  1242. */
  1243. scsi_run_host_queues(shost);
  1244. }
  1245. /**
  1246. * scsi_eh_ready_devs - check device ready state and recover if not.
  1247. * @shost: host to be recovered.
  1248. * @eh_done_q: list_head for processed commands.
  1249. *
  1250. **/
  1251. static void scsi_eh_ready_devs(struct Scsi_Host *shost,
  1252. struct list_head *work_q,
  1253. struct list_head *done_q)
  1254. {
  1255. if (!scsi_eh_stu(shost, work_q, done_q))
  1256. if (!scsi_eh_bus_device_reset(shost, work_q, done_q))
  1257. if (!scsi_eh_bus_reset(shost, work_q, done_q))
  1258. if (!scsi_eh_host_reset(work_q, done_q))
  1259. scsi_eh_offline_sdevs(work_q, done_q);
  1260. }
  1261. /**
  1262. * scsi_eh_flush_done_q - finish processed commands or retry them.
  1263. * @done_q: list_head of processed commands.
  1264. *
  1265. **/
  1266. static void scsi_eh_flush_done_q(struct list_head *done_q)
  1267. {
  1268. struct scsi_cmnd *scmd, *next;
  1269. list_for_each_entry_safe(scmd, next, done_q, eh_entry) {
  1270. list_del_init(&scmd->eh_entry);
  1271. if (scsi_device_online(scmd->device) &&
  1272. !blk_noretry_request(scmd->request) &&
  1273. (++scmd->retries < scmd->allowed)) {
  1274. SCSI_LOG_ERROR_RECOVERY(3, printk("%s: flush"
  1275. " retry cmd: %p\n",
  1276. current->comm,
  1277. scmd));
  1278. scsi_queue_insert(scmd, SCSI_MLQUEUE_EH_RETRY);
  1279. } else {
  1280. /*
  1281. * If just we got sense for the device (called
  1282. * scsi_eh_get_sense), scmd->result is already
  1283. * set, do not set DRIVER_TIMEOUT.
  1284. */
  1285. if (!scmd->result)
  1286. scmd->result |= (DRIVER_TIMEOUT << 24);
  1287. SCSI_LOG_ERROR_RECOVERY(3, printk("%s: flush finish"
  1288. " cmd: %p\n",
  1289. current->comm, scmd));
  1290. scsi_finish_command(scmd);
  1291. }
  1292. }
  1293. }
  1294. /**
  1295. * scsi_unjam_host - Attempt to fix a host which has a cmd that failed.
  1296. * @shost: Host to unjam.
  1297. *
  1298. * Notes:
  1299. * When we come in here, we *know* that all commands on the bus have
  1300. * either completed, failed or timed out. we also know that no further
  1301. * commands are being sent to the host, so things are relatively quiet
  1302. * and we have freedom to fiddle with things as we wish.
  1303. *
  1304. * This is only the *default* implementation. it is possible for
  1305. * individual drivers to supply their own version of this function, and
  1306. * if the maintainer wishes to do this, it is strongly suggested that
  1307. * this function be taken as a template and modified. this function
  1308. * was designed to correctly handle problems for about 95% of the
  1309. * different cases out there, and it should always provide at least a
  1310. * reasonable amount of error recovery.
  1311. *
  1312. * Any command marked 'failed' or 'timeout' must eventually have
  1313. * scsi_finish_cmd() called for it. we do all of the retry stuff
  1314. * here, so when we restart the host after we return it should have an
  1315. * empty queue.
  1316. **/
  1317. static void scsi_unjam_host(struct Scsi_Host *shost)
  1318. {
  1319. unsigned long flags;
  1320. LIST_HEAD(eh_work_q);
  1321. LIST_HEAD(eh_done_q);
  1322. spin_lock_irqsave(shost->host_lock, flags);
  1323. list_splice_init(&shost->eh_cmd_q, &eh_work_q);
  1324. spin_unlock_irqrestore(shost->host_lock, flags);
  1325. SCSI_LOG_ERROR_RECOVERY(1, scsi_eh_prt_fail_stats(shost, &eh_work_q));
  1326. if (!scsi_eh_get_sense(&eh_work_q, &eh_done_q))
  1327. if (!scsi_eh_abort_cmds(&eh_work_q, &eh_done_q))
  1328. scsi_eh_ready_devs(shost, &eh_work_q, &eh_done_q);
  1329. scsi_eh_flush_done_q(&eh_done_q);
  1330. }
  1331. /**
  1332. * scsi_error_handler - SCSI error handler thread
  1333. * @data: Host for which we are running.
  1334. *
  1335. * Notes:
  1336. * This is the main error handling loop. This is run as a kernel thread
  1337. * for every SCSI host and handles all error handling activity.
  1338. **/
  1339. int scsi_error_handler(void *data)
  1340. {
  1341. struct Scsi_Host *shost = data;
  1342. current->flags |= PF_NOFREEZE;
  1343. /*
  1344. * We use TASK_INTERRUPTIBLE so that the thread is not
  1345. * counted against the load average as a running process.
  1346. * We never actually get interrupted because kthread_run
  1347. * disables singal delivery for the created thread.
  1348. */
  1349. set_current_state(TASK_INTERRUPTIBLE);
  1350. while (!kthread_should_stop()) {
  1351. if (shost->host_failed == 0 ||
  1352. shost->host_failed != shost->host_busy) {
  1353. SCSI_LOG_ERROR_RECOVERY(1,
  1354. printk("Error handler scsi_eh_%d sleeping\n",
  1355. shost->host_no));
  1356. schedule();
  1357. set_current_state(TASK_INTERRUPTIBLE);
  1358. continue;
  1359. }
  1360. __set_current_state(TASK_RUNNING);
  1361. SCSI_LOG_ERROR_RECOVERY(1,
  1362. printk("Error handler scsi_eh_%d waking up\n",
  1363. shost->host_no));
  1364. /*
  1365. * We have a host that is failing for some reason. Figure out
  1366. * what we need to do to get it up and online again (if we can).
  1367. * If we fail, we end up taking the thing offline.
  1368. */
  1369. if (shost->hostt->eh_strategy_handler)
  1370. shost->hostt->eh_strategy_handler(shost);
  1371. else
  1372. scsi_unjam_host(shost);
  1373. /*
  1374. * Note - if the above fails completely, the action is to take
  1375. * individual devices offline and flush the queue of any
  1376. * outstanding requests that may have been pending. When we
  1377. * restart, we restart any I/O to any other devices on the bus
  1378. * which are still online.
  1379. */
  1380. scsi_restart_operations(shost);
  1381. set_current_state(TASK_INTERRUPTIBLE);
  1382. }
  1383. __set_current_state(TASK_RUNNING);
  1384. SCSI_LOG_ERROR_RECOVERY(1,
  1385. printk("Error handler scsi_eh_%d exiting\n", shost->host_no));
  1386. shost->ehandler = NULL;
  1387. return 0;
  1388. }
  1389. /*
  1390. * Function: scsi_report_bus_reset()
  1391. *
  1392. * Purpose: Utility function used by low-level drivers to report that
  1393. * they have observed a bus reset on the bus being handled.
  1394. *
  1395. * Arguments: shost - Host in question
  1396. * channel - channel on which reset was observed.
  1397. *
  1398. * Returns: Nothing
  1399. *
  1400. * Lock status: Host lock must be held.
  1401. *
  1402. * Notes: This only needs to be called if the reset is one which
  1403. * originates from an unknown location. Resets originated
  1404. * by the mid-level itself don't need to call this, but there
  1405. * should be no harm.
  1406. *
  1407. * The main purpose of this is to make sure that a CHECK_CONDITION
  1408. * is properly treated.
  1409. */
  1410. void scsi_report_bus_reset(struct Scsi_Host *shost, int channel)
  1411. {
  1412. struct scsi_device *sdev;
  1413. __shost_for_each_device(sdev, shost) {
  1414. if (channel == sdev_channel(sdev)) {
  1415. sdev->was_reset = 1;
  1416. sdev->expecting_cc_ua = 1;
  1417. }
  1418. }
  1419. }
  1420. EXPORT_SYMBOL(scsi_report_bus_reset);
  1421. /*
  1422. * Function: scsi_report_device_reset()
  1423. *
  1424. * Purpose: Utility function used by low-level drivers to report that
  1425. * they have observed a device reset on the device being handled.
  1426. *
  1427. * Arguments: shost - Host in question
  1428. * channel - channel on which reset was observed
  1429. * target - target on which reset was observed
  1430. *
  1431. * Returns: Nothing
  1432. *
  1433. * Lock status: Host lock must be held
  1434. *
  1435. * Notes: This only needs to be called if the reset is one which
  1436. * originates from an unknown location. Resets originated
  1437. * by the mid-level itself don't need to call this, but there
  1438. * should be no harm.
  1439. *
  1440. * The main purpose of this is to make sure that a CHECK_CONDITION
  1441. * is properly treated.
  1442. */
  1443. void scsi_report_device_reset(struct Scsi_Host *shost, int channel, int target)
  1444. {
  1445. struct scsi_device *sdev;
  1446. __shost_for_each_device(sdev, shost) {
  1447. if (channel == sdev_channel(sdev) &&
  1448. target == sdev_id(sdev)) {
  1449. sdev->was_reset = 1;
  1450. sdev->expecting_cc_ua = 1;
  1451. }
  1452. }
  1453. }
  1454. EXPORT_SYMBOL(scsi_report_device_reset);
  1455. static void
  1456. scsi_reset_provider_done_command(struct scsi_cmnd *scmd)
  1457. {
  1458. }
  1459. /*
  1460. * Function: scsi_reset_provider
  1461. *
  1462. * Purpose: Send requested reset to a bus or device at any phase.
  1463. *
  1464. * Arguments: device - device to send reset to
  1465. * flag - reset type (see scsi.h)
  1466. *
  1467. * Returns: SUCCESS/FAILURE.
  1468. *
  1469. * Notes: This is used by the SCSI Generic driver to provide
  1470. * Bus/Device reset capability.
  1471. */
  1472. int
  1473. scsi_reset_provider(struct scsi_device *dev, int flag)
  1474. {
  1475. struct scsi_cmnd *scmd = scsi_get_command(dev, GFP_KERNEL);
  1476. struct request req;
  1477. int rtn;
  1478. scmd->request = &req;
  1479. memset(&scmd->eh_timeout, 0, sizeof(scmd->eh_timeout));
  1480. scmd->request->rq_status = RQ_SCSI_BUSY;
  1481. memset(&scmd->cmnd, '\0', sizeof(scmd->cmnd));
  1482. scmd->scsi_done = scsi_reset_provider_done_command;
  1483. scmd->done = NULL;
  1484. scmd->buffer = NULL;
  1485. scmd->bufflen = 0;
  1486. scmd->request_buffer = NULL;
  1487. scmd->request_bufflen = 0;
  1488. scmd->cmd_len = 0;
  1489. scmd->sc_data_direction = DMA_BIDIRECTIONAL;
  1490. scmd->sc_request = NULL;
  1491. scmd->sc_magic = SCSI_CMND_MAGIC;
  1492. init_timer(&scmd->eh_timeout);
  1493. /*
  1494. * Sometimes the command can get back into the timer chain,
  1495. * so use the pid as an identifier.
  1496. */
  1497. scmd->pid = 0;
  1498. switch (flag) {
  1499. case SCSI_TRY_RESET_DEVICE:
  1500. rtn = scsi_try_bus_device_reset(scmd);
  1501. if (rtn == SUCCESS)
  1502. break;
  1503. /* FALLTHROUGH */
  1504. case SCSI_TRY_RESET_BUS:
  1505. rtn = scsi_try_bus_reset(scmd);
  1506. if (rtn == SUCCESS)
  1507. break;
  1508. /* FALLTHROUGH */
  1509. case SCSI_TRY_RESET_HOST:
  1510. rtn = scsi_try_host_reset(scmd);
  1511. break;
  1512. default:
  1513. rtn = FAILED;
  1514. }
  1515. scsi_next_command(scmd);
  1516. return rtn;
  1517. }
  1518. EXPORT_SYMBOL(scsi_reset_provider);
  1519. /**
  1520. * scsi_normalize_sense - normalize main elements from either fixed or
  1521. * descriptor sense data format into a common format.
  1522. *
  1523. * @sense_buffer: byte array containing sense data returned by device
  1524. * @sb_len: number of valid bytes in sense_buffer
  1525. * @sshdr: pointer to instance of structure that common
  1526. * elements are written to.
  1527. *
  1528. * Notes:
  1529. * The "main elements" from sense data are: response_code, sense_key,
  1530. * asc, ascq and additional_length (only for descriptor format).
  1531. *
  1532. * Typically this function can be called after a device has
  1533. * responded to a SCSI command with the CHECK_CONDITION status.
  1534. *
  1535. * Return value:
  1536. * 1 if valid sense data information found, else 0;
  1537. **/
  1538. int scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
  1539. struct scsi_sense_hdr *sshdr)
  1540. {
  1541. if (!sense_buffer || !sb_len)
  1542. return 0;
  1543. memset(sshdr, 0, sizeof(struct scsi_sense_hdr));
  1544. sshdr->response_code = (sense_buffer[0] & 0x7f);
  1545. if (!scsi_sense_valid(sshdr))
  1546. return 0;
  1547. if (sshdr->response_code >= 0x72) {
  1548. /*
  1549. * descriptor format
  1550. */
  1551. if (sb_len > 1)
  1552. sshdr->sense_key = (sense_buffer[1] & 0xf);
  1553. if (sb_len > 2)
  1554. sshdr->asc = sense_buffer[2];
  1555. if (sb_len > 3)
  1556. sshdr->ascq = sense_buffer[3];
  1557. if (sb_len > 7)
  1558. sshdr->additional_length = sense_buffer[7];
  1559. } else {
  1560. /*
  1561. * fixed format
  1562. */
  1563. if (sb_len > 2)
  1564. sshdr->sense_key = (sense_buffer[2] & 0xf);
  1565. if (sb_len > 7) {
  1566. sb_len = (sb_len < (sense_buffer[7] + 8)) ?
  1567. sb_len : (sense_buffer[7] + 8);
  1568. if (sb_len > 12)
  1569. sshdr->asc = sense_buffer[12];
  1570. if (sb_len > 13)
  1571. sshdr->ascq = sense_buffer[13];
  1572. }
  1573. }
  1574. return 1;
  1575. }
  1576. EXPORT_SYMBOL(scsi_normalize_sense);
  1577. int scsi_request_normalize_sense(struct scsi_request *sreq,
  1578. struct scsi_sense_hdr *sshdr)
  1579. {
  1580. return scsi_normalize_sense(sreq->sr_sense_buffer,
  1581. sizeof(sreq->sr_sense_buffer), sshdr);
  1582. }
  1583. EXPORT_SYMBOL(scsi_request_normalize_sense);
  1584. int scsi_command_normalize_sense(struct scsi_cmnd *cmd,
  1585. struct scsi_sense_hdr *sshdr)
  1586. {
  1587. return scsi_normalize_sense(cmd->sense_buffer,
  1588. sizeof(cmd->sense_buffer), sshdr);
  1589. }
  1590. EXPORT_SYMBOL(scsi_command_normalize_sense);
  1591. /**
  1592. * scsi_sense_desc_find - search for a given descriptor type in
  1593. * descriptor sense data format.
  1594. *
  1595. * @sense_buffer: byte array of descriptor format sense data
  1596. * @sb_len: number of valid bytes in sense_buffer
  1597. * @desc_type: value of descriptor type to find
  1598. * (e.g. 0 -> information)
  1599. *
  1600. * Notes:
  1601. * only valid when sense data is in descriptor format
  1602. *
  1603. * Return value:
  1604. * pointer to start of (first) descriptor if found else NULL
  1605. **/
  1606. const u8 * scsi_sense_desc_find(const u8 * sense_buffer, int sb_len,
  1607. int desc_type)
  1608. {
  1609. int add_sen_len, add_len, desc_len, k;
  1610. const u8 * descp;
  1611. if ((sb_len < 8) || (0 == (add_sen_len = sense_buffer[7])))
  1612. return NULL;
  1613. if ((sense_buffer[0] < 0x72) || (sense_buffer[0] > 0x73))
  1614. return NULL;
  1615. add_sen_len = (add_sen_len < (sb_len - 8)) ?
  1616. add_sen_len : (sb_len - 8);
  1617. descp = &sense_buffer[8];
  1618. for (desc_len = 0, k = 0; k < add_sen_len; k += desc_len) {
  1619. descp += desc_len;
  1620. add_len = (k < (add_sen_len - 1)) ? descp[1]: -1;
  1621. desc_len = add_len + 2;
  1622. if (descp[0] == desc_type)
  1623. return descp;
  1624. if (add_len < 0) // short descriptor ??
  1625. break;
  1626. }
  1627. return NULL;
  1628. }
  1629. EXPORT_SYMBOL(scsi_sense_desc_find);
  1630. /**
  1631. * scsi_get_sense_info_fld - attempts to get information field from
  1632. * sense data (either fixed or descriptor format)
  1633. *
  1634. * @sense_buffer: byte array of sense data
  1635. * @sb_len: number of valid bytes in sense_buffer
  1636. * @info_out: pointer to 64 integer where 8 or 4 byte information
  1637. * field will be placed if found.
  1638. *
  1639. * Return value:
  1640. * 1 if information field found, 0 if not found.
  1641. **/
  1642. int scsi_get_sense_info_fld(const u8 * sense_buffer, int sb_len,
  1643. u64 * info_out)
  1644. {
  1645. int j;
  1646. const u8 * ucp;
  1647. u64 ull;
  1648. if (sb_len < 7)
  1649. return 0;
  1650. switch (sense_buffer[0] & 0x7f) {
  1651. case 0x70:
  1652. case 0x71:
  1653. if (sense_buffer[0] & 0x80) {
  1654. *info_out = (sense_buffer[3] << 24) +
  1655. (sense_buffer[4] << 16) +
  1656. (sense_buffer[5] << 8) + sense_buffer[6];
  1657. return 1;
  1658. } else
  1659. return 0;
  1660. case 0x72:
  1661. case 0x73:
  1662. ucp = scsi_sense_desc_find(sense_buffer, sb_len,
  1663. 0 /* info desc */);
  1664. if (ucp && (0xa == ucp[1])) {
  1665. ull = 0;
  1666. for (j = 0; j < 8; ++j) {
  1667. if (j > 0)
  1668. ull <<= 8;
  1669. ull |= ucp[4 + j];
  1670. }
  1671. *info_out = ull;
  1672. return 1;
  1673. } else
  1674. return 0;
  1675. default:
  1676. return 0;
  1677. }
  1678. }
  1679. EXPORT_SYMBOL(scsi_get_sense_info_fld);