scsi: aacraid: Fix command send race condition
[pandora-kernel.git] / drivers / scsi / aacraid / aachba.c
index 409f580..6ebfe8e 100644 (file)
@@ -468,6 +468,7 @@ static int aac_get_container_name(struct scsi_cmnd * scsicmd)
 
        aac_fib_init(cmd_fibcontext);
        dinfo = (struct aac_get_name *) fib_data(cmd_fibcontext);
+       scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
 
        dinfo->command = cpu_to_le32(VM_ContainerConfig);
        dinfo->type = cpu_to_le32(CT_READ_NAME);
@@ -485,10 +486,8 @@ static int aac_get_container_name(struct scsi_cmnd * scsicmd)
        /*
         *      Check that the command queued to the controller
         */
-       if (status == -EINPROGRESS) {
-               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
+       if (status == -EINPROGRESS)
                return 0;
-       }
 
        printk(KERN_WARNING "aac_get_container_name: aac_fib_send failed with status: %d.\n", status);
        aac_fib_complete(cmd_fibcontext);
@@ -577,6 +576,7 @@ static void _aac_probe_container1(void * context, struct fib * fibptr)
        dinfo->command = cpu_to_le32(VM_NameServe64);
        dinfo->count = cpu_to_le32(scmd_id(scsicmd));
        dinfo->type = cpu_to_le32(FT_FILESYS);
+       scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
 
        status = aac_fib_send(ContainerCommand,
                          fibptr,
@@ -588,9 +588,7 @@ static void _aac_probe_container1(void * context, struct fib * fibptr)
        /*
         *      Check that the command queued to the controller
         */
-       if (status == -EINPROGRESS)
-               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
-       else if (status < 0) {
+       if (status < 0 && status != -EINPROGRESS) {
                /* Inherit results from VM_NameServe, if any */
                dresp->status = cpu_to_le32(ST_OK);
                _aac_probe_container2(context, fibptr);
@@ -613,6 +611,7 @@ static int _aac_probe_container(struct scsi_cmnd * scsicmd, int (*callback)(stru
                dinfo->count = cpu_to_le32(scmd_id(scsicmd));
                dinfo->type = cpu_to_le32(FT_FILESYS);
                scsicmd->SCp.ptr = (char *)callback;
+               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
 
                status = aac_fib_send(ContainerCommand,
                          fibptr,
@@ -624,10 +623,9 @@ static int _aac_probe_container(struct scsi_cmnd * scsicmd, int (*callback)(stru
                /*
                 *      Check that the command queued to the controller
                 */
-               if (status == -EINPROGRESS) {
-                       scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
+               if (status == -EINPROGRESS)
                        return 0;
-               }
+
                if (status < 0) {
                        scsicmd->SCp.ptr = NULL;
                        aac_fib_complete(fibptr);
@@ -861,6 +859,7 @@ static int aac_get_container_serial(struct scsi_cmnd * scsicmd)
        dinfo->command = cpu_to_le32(VM_ContainerConfig);
        dinfo->type = cpu_to_le32(CT_CID_TO_32BITS_UID);
        dinfo->cid = cpu_to_le32(scmd_id(scsicmd));
+       scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
 
        status = aac_fib_send(ContainerCommand,
                  cmd_fibcontext,
@@ -873,10 +872,8 @@ static int aac_get_container_serial(struct scsi_cmnd * scsicmd)
        /*
         *      Check that the command queued to the controller
         */
-       if (status == -EINPROGRESS) {
-               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
+       if (status == -EINPROGRESS)
                return 0;
-       }
 
        printk(KERN_WARNING "aac_get_container_serial: aac_fib_send failed with status: %d.\n", status);
        aac_fib_complete(cmd_fibcontext);
@@ -1689,16 +1686,14 @@ static int aac_read(struct scsi_cmnd * scsicmd)
                printk(KERN_WARNING "aac_read: fib allocation failed\n");
                return -1;
        }
-
+       scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
        status = aac_adapter_read(cmd_fibcontext, scsicmd, lba, count);
 
        /*
         *      Check that the command queued to the controller
         */
-       if (status == -EINPROGRESS) {
-               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
+       if (status == -EINPROGRESS)
                return 0;
-       }
 
        printk(KERN_WARNING "aac_read: aac_fib_send failed with status: %d.\n", status);
        /*
@@ -1792,16 +1787,14 @@ static int aac_write(struct scsi_cmnd * scsicmd)
                printk(KERN_WARNING "aac_write: fib allocation failed\n");
                return -1;
        }
-
+       scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
        status = aac_adapter_write(cmd_fibcontext, scsicmd, lba, count, fua);
 
        /*
         *      Check that the command queued to the controller
         */
-       if (status == -EINPROGRESS) {
-               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
+       if (status == -EINPROGRESS)
                return 0;
-       }
 
        printk(KERN_WARNING "aac_write: aac_fib_send failed with status: %d\n", status);
        /*
@@ -1951,6 +1944,7 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
        synchronizecmd->cid = cpu_to_le32(scmd_id(scsicmd));
        synchronizecmd->count =
             cpu_to_le32(sizeof(((struct aac_synchronize_reply *)NULL)->data));
+       scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
 
        /*
         *      Now send the Fib to the adapter
@@ -1966,10 +1960,8 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
        /*
         *      Check that the command queued to the controller
         */
-       if (status == -EINPROGRESS) {
-               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
+       if (status == -EINPROGRESS)
                return 0;
-       }
 
        printk(KERN_WARNING
                "aac_synchronize: aac_fib_send failed with status: %d.\n", status);
@@ -2031,6 +2023,7 @@ static int aac_start_stop(struct scsi_cmnd *scsicmd)
        pmcmd->cid = cpu_to_le32(sdev_id(sdev));
        pmcmd->parm = (scsicmd->cmnd[1] & 1) ?
                cpu_to_le32(CT_PM_UNIT_IMMEDIATE) : 0;
+       scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
 
        /*
         *      Now send the Fib to the adapter
@@ -2046,10 +2039,8 @@ static int aac_start_stop(struct scsi_cmnd *scsicmd)
        /*
         *      Check that the command queued to the controller
         */
-       if (status == -EINPROGRESS) {
-               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
+       if (status == -EINPROGRESS)
                return 0;
-       }
 
        aac_fib_complete(cmd_fibcontext);
        aac_fib_free(cmd_fibcontext);
@@ -2798,15 +2789,14 @@ static int aac_send_srb_fib(struct scsi_cmnd* scsicmd)
        if (!(cmd_fibcontext = aac_fib_alloc(dev))) {
                return -1;
        }
+       scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
        status = aac_adapter_scsi(cmd_fibcontext, scsicmd);
 
        /*
         *      Check that the command queued to the controller
         */
-       if (status == -EINPROGRESS) {
-               scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
+       if (status == -EINPROGRESS)
                return 0;
-       }
 
        printk(KERN_WARNING "aac_srb: aac_fib_send failed with status: %d\n", status);
        aac_fib_complete(cmd_fibcontext);