[SCSI] wd33c93: cleanups
[safe/jmp/linux-2.6] / drivers / scsi / scsi_error.c
index 918bb60..8a525ab 100644 (file)
 #include <linux/sched.h>
 #include <linux/timer.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/kernel.h>
+#include <linux/freezer.h>
 #include <linux/kthread.h>
 #include <linux/interrupt.h>
 #include <linux/blkdev.h>
 #include <linux/delay.h>
+#include <linux/scatterlist.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
@@ -38,7 +39,6 @@
 #include "scsi_logging.h"
 
 #define SENSE_TIMEOUT          (10*HZ)
-#define START_UNIT_TIMEOUT     (30*HZ)
 
 /*
  * These should *probably* be handled by the host itself.
@@ -184,10 +184,19 @@ int scsi_delete_timer(struct scsi_cmnd *scmd)
  **/
 void scsi_times_out(struct scsi_cmnd *scmd)
 {
+       enum scsi_eh_timer_return (* eh_timed_out)(struct scsi_cmnd *);
+
        scsi_log_completion(scmd, TIMEOUT_ERROR);
 
        if (scmd->device->host->transportt->eh_timed_out)
-               switch (scmd->device->host->transportt->eh_timed_out(scmd)) {
+               eh_timed_out = scmd->device->host->transportt->eh_timed_out;
+       else if (scmd->device->host->hostt->eh_timed_out)
+               eh_timed_out = scmd->device->host->hostt->eh_timed_out;
+       else
+               eh_timed_out = NULL;
+
+       if (eh_timed_out)
+               switch (eh_timed_out(scmd)) {
                case EH_HANDLED:
                        __scsi_done(scmd);
                        return;
@@ -632,16 +641,8 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
        memcpy(scmd->cmnd, cmnd, cmnd_size);
 
        if (copy_sense) {
-               gfp_t gfp_mask = GFP_ATOMIC;
-
-               if (shost->hostt->unchecked_isa_dma)
-                       gfp_mask |= __GFP_DMA;
-
-               sgl.page = alloc_page(gfp_mask);
-               if (!sgl.page)
-                       return FAILED;
-               sgl.offset = 0;
-               sgl.length = 252;
+               sg_init_one(&sgl, scmd->sense_buffer,
+                           sizeof(scmd->sense_buffer));
 
                scmd->sc_data_direction = DMA_FROM_DEVICE;
                scmd->request_bufflen = sgl.length;
@@ -712,18 +713,6 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
 
 
        /*
-        * Last chance to have valid sense data.
-        */
-       if (copy_sense) {
-               if (!SCSI_SENSE_VALID(scmd)) {
-                       memcpy(scmd->sense_buffer, page_address(sgl.page),
-                              sizeof(scmd->sense_buffer));
-               }
-               __free_page(sgl.page);
-       }
-
-
-       /*
         * Restore original data
         */
        scmd->request_buffer = old_buffer;
@@ -923,10 +912,12 @@ static int scsi_eh_try_stu(struct scsi_cmnd *scmd)
        static unsigned char stu_command[6] = {START_STOP, 0, 0, 0, 1, 0};
 
        if (scmd->device->allow_restart) {
-               int rtn;
+               int i, rtn = NEEDS_RETRY;
+
+               for (i = 0; rtn == NEEDS_RETRY && i < 2; i++)
+                       rtn = scsi_send_eh_cmnd(scmd, stu_command, 6,
+                                               scmd->device->timeout, 0);
 
-               rtn = scsi_send_eh_cmnd(scmd, stu_command, 6,
-                                       START_UNIT_TIMEOUT, 0);
                if (rtn == SUCCESS)
                        return 0;
        }
@@ -1526,8 +1517,6 @@ int scsi_error_handler(void *data)
 {
        struct Scsi_Host *shost = data;
 
-       current->flags |= PF_NOFREEZE;
-
        /*
         * We use TASK_INTERRUPTIBLE so that the thread is not
         * counted against the load average as a running process.