]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
scsi: aacraid: Move code to wait for IO completion to shutdown func
authorRaghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Wed, 27 Dec 2017 04:34:29 +0000 (20:34 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 4 Jan 2018 04:26:42 +0000 (23:26 -0500)
Ideally driver needs to wait for IO to be submitted or responded to before
shutdown.

Move code to wait for IO completion into shutdown path

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/aacraid/comminit.c
drivers/scsi/aacraid/commsup.c

index 9eff246ba3a30999683a62e2373d0aff32334abd..0dc7b5a4fea25b98d42342886af30242e5fe1dcf 100644 (file)
@@ -42,6 +42,8 @@
 #include <linux/completion.h>
 #include <linux/mm.h>
 #include <scsi/scsi_host.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_cmnd.h>
 
 #include "aacraid.h"
 
@@ -284,6 +286,38 @@ static void aac_queue_init(struct aac_dev * dev, struct aac_queue * q, u32 *mem,
        q->entries = qsize;
 }
 
+static void aac_wait_for_io_completion(struct aac_dev *aac)
+{
+       unsigned long flagv = 0;
+       int i = 0;
+
+       for (i = 60; i; --i) {
+               struct scsi_device *dev;
+               struct scsi_cmnd *command;
+               int active = 0;
+
+               __shost_for_each_device(dev, aac->scsi_host_ptr) {
+                       spin_lock_irqsave(&dev->list_lock, flagv);
+                       list_for_each_entry(command, &dev->cmd_list, list) {
+                               if (command->SCp.phase == AAC_OWNER_FIRMWARE) {
+                                       active++;
+                                       break;
+                               }
+                       }
+                       spin_unlock_irqrestore(&dev->list_lock, flagv);
+                       if (active)
+                               break;
+
+               }
+               /*
+                * We can exit If all the commands are complete
+                */
+               if (active == 0)
+                       break;
+               ssleep(1);
+       }
+}
+
 /**
  *     aac_send_shutdown               -       shutdown an adapter
  *     @dev: Adapter to shutdown
@@ -306,6 +340,8 @@ int aac_send_shutdown(struct aac_dev * dev)
                mutex_unlock(&dev->ioctl_mutex);
        }
 
+       aac_wait_for_io_completion(dev);
+
        fibctx = aac_fib_alloc(dev);
        if (!fibctx)
                return -ENOMEM;
index 32b8bdb97c18dd71ec2ae3895bf6439e3cf5b87e..9840bd3aee6c973c3f07a92c13fd980685fc2502 100644 (file)
@@ -1701,31 +1701,6 @@ int aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type)
         */
        host = aac->scsi_host_ptr;
        scsi_block_requests(host);
-       if (forced < 2) for (retval = 60; retval; --retval) {
-               struct scsi_device * dev;
-               struct scsi_cmnd * command;
-               int active = 0;
-
-               __shost_for_each_device(dev, host) {
-                       spin_lock_irqsave(&dev->list_lock, flagv);
-                       list_for_each_entry(command, &dev->cmd_list, list) {
-                               if (command->SCp.phase == AAC_OWNER_FIRMWARE) {
-                                       active++;
-                                       break;
-                               }
-                       }
-                       spin_unlock_irqrestore(&dev->list_lock, flagv);
-                       if (active)
-                               break;
-
-               }
-               /*
-                * We can exit If all the commands are complete
-                */
-               if (active == 0)
-                       break;
-               ssleep(1);
-       }
 
        /* Quiesce build, flush cache, write through mode */
        if (forced < 2)