aacraid: Fix AIF triggered IOP_RESET
authorRaghava Aditya Renukunta <raghavaaditya.renukunta@pmcs.com>
Wed, 3 Feb 2016 23:06:06 +0000 (15:06 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 24 Feb 2016 02:27:02 +0000 (21:27 -0500)
while driver removal is in progress or PCI shutdown is invoked, driver
kills AIF aacraid thread, but IOCTL requests from the management tools
re-start AIF thread leading to IOP_RESET.

Fixed by setting adapter_shutdown flag when PCI shutdown is invoked.

Signed-off-by: Raghava Aditya Renukunta <raghavaaditya.renukunta@pmcs.com>
Reviewed-by: Shane Seymour <shane.seymour@hpe.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/aacraid/commctrl.c
drivers/scsi/aacraid/comminit.c
drivers/scsi/aacraid/linit.c

index ebf214b863a4d77e21ab9121542db495b32b733e..4b3bb52b5108edbabf253d800a083c3f637c9380 100644 (file)
@@ -857,6 +857,11 @@ int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg)
 
        mutex_lock(&dev->ioctl_mutex);
 
+       if (dev->adapter_shutdown) {
+               status = -EACCES;
+               goto cleanup;
+       }
+
        /*
         *      HBA gets first crack
         */
index 0e954e37f0b5f3923980ee684e55ffef5b296510..2b4e75380ae632cf60d392f8517bb8406110d9d4 100644 (file)
@@ -212,8 +212,11 @@ int aac_send_shutdown(struct aac_dev * dev)
                return -ENOMEM;
        aac_fib_init(fibctx);
 
-       cmd = (struct aac_close *) fib_data(fibctx);
+       mutex_lock(&dev->ioctl_mutex);
+       dev->adapter_shutdown = 1;
+       mutex_unlock(&dev->ioctl_mutex);
 
+       cmd = (struct aac_close *) fib_data(fibctx);
        cmd->command = cpu_to_le32(VM_CloseAll);
        cmd->cid = cpu_to_le32(0xfffffffe);
 
@@ -229,7 +232,6 @@ int aac_send_shutdown(struct aac_dev * dev)
        /* FIB should be freed only after getting the response from the F/W */
        if (status != -ERESTARTSYS)
                aac_fib_free(fibctx);
-       dev->adapter_shutdown = 1;
        if ((dev->pdev->device == PMC_DEVICE_S7 ||
             dev->pdev->device == PMC_DEVICE_S8 ||
             dev->pdev->device == PMC_DEVICE_S9) &&
index 3f9c7415bd7e5cce0fd0223436028b952ecfe67b..334f2a602fca98bb4720ac57106e0dc28df903fb 100644 (file)
@@ -705,7 +705,7 @@ static long aac_cfg_ioctl(struct file *file,
 {
        struct aac_dev *aac = (struct aac_dev *)file->private_data;
 
-       if (!capable(CAP_SYS_RAWIO) || aac->adapter_shutdown)
+       if (!capable(CAP_SYS_RAWIO))
                return -EPERM;
 
        return aac_do_ioctl(aac, cmd, (void __user *)arg);
@@ -1072,6 +1072,8 @@ static void __aac_shutdown(struct aac_dev * aac)
        int i;
        int cpu;
 
+       aac_send_shutdown(aac);
+
        if (aac->aif_thread) {
                int i;
                /* Clear out events first */
@@ -1083,7 +1085,6 @@ static void __aac_shutdown(struct aac_dev * aac)
                }
                kthread_stop(aac->thread);
        }
-       aac_send_shutdown(aac);
        aac_adapter_disable_int(aac);
        cpu = cpumask_first(cpu_online_mask);
        if (aac->pdev->device == PMC_DEVICE_S6 ||