These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / scsi / megaraid / megaraid_sas_base.c
index 890637f..97a1c1c 100644 (file)
@@ -94,8 +94,8 @@ MODULE_PARM_DESC(smp_affinity_enable, "SMP affinity feature enable/disbale Defau
 
 MODULE_LICENSE("GPL");
 MODULE_VERSION(MEGASAS_VERSION);
-MODULE_AUTHOR("megaraidlinux@lsi.com");
-MODULE_DESCRIPTION("LSI MegaRAID SAS Driver");
+MODULE_AUTHOR("megaraidlinux.pdl@avagotech.com");
+MODULE_DESCRIPTION("Avago MegaRAID SAS Driver");
 
 int megasas_transition_to_ready(struct megasas_instance *instance, int ocr);
 static int megasas_get_pd_list(struct megasas_instance *instance);
@@ -135,6 +135,12 @@ static struct pci_device_id megasas_pci_table[] = {
        /* Invader */
        {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FURY)},
        /* Fury */
+       {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_INTRUDER)},
+       /* Intruder */
+       {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_INTRUDER_24)},
+       /* Intruder 24 port*/
+       {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_CUTLASS_52)},
+       {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_CUTLASS_53)},
        {}
 };
 
@@ -215,9 +221,8 @@ struct megasas_cmd *megasas_get_cmd(struct megasas_instance
                cmd = list_entry((&instance->cmd_pool)->next,
                                 struct megasas_cmd, list);
                list_del_init(&cmd->list);
-               atomic_set(&cmd->mfi_mpt_pthr, MFI_MPT_DETACHED);
        } else {
-               printk(KERN_ERR "megasas: Command pool empty!\n");
+               dev_err(&instance->pdev->dev, "Command pool empty!\n");
        }
 
        spin_unlock_irqrestore(&instance->mfi_pool_lock, flags);
@@ -225,52 +230,101 @@ struct megasas_cmd *megasas_get_cmd(struct megasas_instance
 }
 
 /**
- * __megasas_return_cmd -      Return a cmd to free command pool
+ * megasas_return_cmd -        Return a cmd to free command pool
  * @instance:          Adapter soft state
  * @cmd:               Command packet to be returned to free command pool
  */
 inline void
-__megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd)
+megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd)
 {
-       /*
-        * Don't go ahead and free the MFI frame, if corresponding
-        * MPT frame is not freed(valid for only fusion adapters).
-        * In case of MFI adapters, anyways for any allocated MFI
-        * frame will have cmd->mfi_mpt_mpthr set to MFI_MPT_DETACHED
+       unsigned long flags;
+       u32 blk_tags;
+       struct megasas_cmd_fusion *cmd_fusion;
+       struct fusion_context *fusion = instance->ctrl_context;
+
+       /* This flag is used only for fusion adapter.
+        * Wait for Interrupt for Polled mode DCMD
         */
-       if (atomic_read(&cmd->mfi_mpt_pthr) != MFI_MPT_DETACHED)
+       if (cmd->flags & DRV_DCMD_POLLED_MODE)
                return;
 
+       spin_lock_irqsave(&instance->mfi_pool_lock, flags);
+
+       if (fusion) {
+               blk_tags = instance->max_scsi_cmds + cmd->index;
+               cmd_fusion = fusion->cmd_list[blk_tags];
+               megasas_return_cmd_fusion(instance, cmd_fusion);
+       }
        cmd->scmd = NULL;
        cmd->frame_count = 0;
-       cmd->is_wait_event = 0;
-       cmd->mpt_pthr_cmd_blocked = NULL;
-
-       if ((instance->pdev->device != PCI_DEVICE_ID_LSI_FUSION) &&
-           (instance->pdev->device != PCI_DEVICE_ID_LSI_INVADER) &&
-           (instance->pdev->device != PCI_DEVICE_ID_LSI_FURY) &&
-           (reset_devices))
+       cmd->flags = 0;
+       if (!fusion && reset_devices)
                cmd->frame->hdr.cmd = MFI_CMD_INVALID;
-
-       atomic_set(&cmd->mfi_mpt_pthr, MFI_LIST_ADDED);
        list_add(&cmd->list, (&instance->cmd_pool)->next);
+
+       spin_unlock_irqrestore(&instance->mfi_pool_lock, flags);
+
 }
 
-/**
- * megasas_return_cmd -        Return a cmd to free command pool
- * @instance:          Adapter soft state
- * @cmd:               Command packet to be returned to free command pool
- */
-inline void
-megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd)
+static const char *
+format_timestamp(uint32_t timestamp)
 {
-       unsigned long flags;
+       static char buffer[32];
 
-       spin_lock_irqsave(&instance->mfi_pool_lock, flags);
-       __megasas_return_cmd(instance, cmd);
-       spin_unlock_irqrestore(&instance->mfi_pool_lock, flags);
+       if ((timestamp & 0xff000000) == 0xff000000)
+               snprintf(buffer, sizeof(buffer), "boot + %us", timestamp &
+               0x00ffffff);
+       else
+               snprintf(buffer, sizeof(buffer), "%us", timestamp);
+       return buffer;
+}
+
+static const char *
+format_class(int8_t class)
+{
+       static char buffer[6];
+
+       switch (class) {
+       case MFI_EVT_CLASS_DEBUG:
+               return "debug";
+       case MFI_EVT_CLASS_PROGRESS:
+               return "progress";
+       case MFI_EVT_CLASS_INFO:
+               return "info";
+       case MFI_EVT_CLASS_WARNING:
+               return "WARN";
+       case MFI_EVT_CLASS_CRITICAL:
+               return "CRIT";
+       case MFI_EVT_CLASS_FATAL:
+               return "FATAL";
+       case MFI_EVT_CLASS_DEAD:
+               return "DEAD";
+       default:
+               snprintf(buffer, sizeof(buffer), "%d", class);
+               return buffer;
+       }
 }
 
+/**
+  * megasas_decode_evt: Decode FW AEN event and print critical event
+  * for information.
+  * @instance:                 Adapter soft state
+  */
+static void
+megasas_decode_evt(struct megasas_instance *instance)
+{
+       struct megasas_evt_detail *evt_detail = instance->evt_detail;
+       union megasas_evt_class_locale class_locale;
+       class_locale.word = le32_to_cpu(evt_detail->cl.word);
+
+       if (class_locale.members.class >= MFI_EVT_CLASS_CRITICAL)
+               dev_info(&instance->pdev->dev, "%d (%s/0x%04x/%s) - %s\n",
+                       le32_to_cpu(evt_detail->seq_num),
+                       format_timestamp(le32_to_cpu(evt_detail->time_stamp)),
+                       (class_locale.members.locale),
+                       format_class(class_locale.members.class),
+                       evt_detail->description);
+}
 
 /**
 *      The following functions are defined for xscale
@@ -285,6 +339,7 @@ static inline void
 megasas_enable_intr_xscale(struct megasas_instance *instance)
 {
        struct megasas_register_set __iomem *regs;
+
        regs = instance->reg_set;
        writel(0, &(regs)->outbound_intr_mask);
 
@@ -301,6 +356,7 @@ megasas_disable_intr_xscale(struct megasas_instance *instance)
 {
        struct megasas_register_set __iomem *regs;
        u32 mask = 0x1f;
+
        regs = instance->reg_set;
        writel(mask, &regs->outbound_intr_mask);
        /* Dummy readl to force pci flush */
@@ -325,6 +381,7 @@ megasas_clear_intr_xscale(struct megasas_register_set __iomem * regs)
 {
        u32 status;
        u32 mfiStatus = 0;
+
        /*
         * Check if it is our interrupt
         */
@@ -360,6 +417,7 @@ megasas_fire_cmd_xscale(struct megasas_instance *instance,
                struct megasas_register_set __iomem *regs)
 {
        unsigned long flags;
+
        spin_lock_irqsave(&instance->hba_lock, flags);
        writel((frame_phys_addr >> 3)|(frame_count),
               &(regs)->inbound_queue_port);
@@ -376,15 +434,16 @@ megasas_adp_reset_xscale(struct megasas_instance *instance,
 {
        u32 i;
        u32 pcidata;
+
        writel(MFI_ADP_RESET, &regs->inbound_doorbell);
 
        for (i = 0; i < 3; i++)
                msleep(1000); /* sleep for 3 secs */
        pcidata  = 0;
        pci_read_config_dword(instance->pdev, MFI_1068_PCSR_OFFSET, &pcidata);
-       printk(KERN_NOTICE "pcidata = %x\n", pcidata);
+       dev_notice(&instance->pdev->dev, "pcidata = %x\n", pcidata);
        if (pcidata & 0x2) {
-               printk(KERN_NOTICE "mfi 1068 offset read=%x\n", pcidata);
+               dev_notice(&instance->pdev->dev, "mfi 1068 offset read=%x\n", pcidata);
                pcidata &= ~0x2;
                pci_write_config_dword(instance->pdev,
                                MFI_1068_PCSR_OFFSET, pcidata);
@@ -395,9 +454,9 @@ megasas_adp_reset_xscale(struct megasas_instance *instance,
                pcidata  = 0;
                pci_read_config_dword(instance->pdev,
                                MFI_1068_FW_HANDSHAKE_OFFSET, &pcidata);
-               printk(KERN_NOTICE "1068 offset handshake read=%x\n", pcidata);
+               dev_notice(&instance->pdev->dev, "1068 offset handshake read=%x\n", pcidata);
                if ((pcidata & 0xffff0000) == MFI_1068_FW_READY) {
-                       printk(KERN_NOTICE "1068 offset pcidt=%x\n", pcidata);
+                       dev_notice(&instance->pdev->dev, "1068 offset pcidt=%x\n", pcidata);
                        pcidata = 0;
                        pci_write_config_dword(instance->pdev,
                                MFI_1068_FW_HANDSHAKE_OFFSET, pcidata);
@@ -414,7 +473,6 @@ static int
 megasas_check_reset_xscale(struct megasas_instance *instance,
                struct megasas_register_set __iomem *regs)
 {
-
        if ((instance->adprecovery != MEGASAS_HBA_OPERATIONAL) &&
            (le32_to_cpu(*instance->consumer) ==
                MEGASAS_ADPRESET_INPROG_SIGN))
@@ -445,7 +503,7 @@ static struct megasas_instance_template megasas_instance_template_xscale = {
 
 /**
 *      The following functions are defined for ppc (deviceid : 0x60)
-*      controllers
+*      controllers
 */
 
 /**
@@ -456,6 +514,7 @@ static inline void
 megasas_enable_intr_ppc(struct megasas_instance *instance)
 {
        struct megasas_register_set __iomem *regs;
+
        regs = instance->reg_set;
        writel(0xFFFFFFFF, &(regs)->outbound_doorbell_clear);
 
@@ -474,6 +533,7 @@ megasas_disable_intr_ppc(struct megasas_instance *instance)
 {
        struct megasas_register_set __iomem *regs;
        u32 mask = 0xFFFFFFFF;
+
        regs = instance->reg_set;
        writel(mask, &regs->outbound_intr_mask);
        /* Dummy readl to force pci flush */
@@ -534,6 +594,7 @@ megasas_fire_cmd_ppc(struct megasas_instance *instance,
                struct megasas_register_set __iomem *regs)
 {
        unsigned long flags;
+
        spin_lock_irqsave(&instance->hba_lock, flags);
        writel((frame_phys_addr | (frame_count<<1))|1,
                        &(regs)->inbound_queue_port);
@@ -578,6 +639,7 @@ static inline void
 megasas_enable_intr_skinny(struct megasas_instance *instance)
 {
        struct megasas_register_set __iomem *regs;
+
        regs = instance->reg_set;
        writel(0xFFFFFFFF, &(regs)->outbound_intr_mask);
 
@@ -596,6 +658,7 @@ megasas_disable_intr_skinny(struct megasas_instance *instance)
 {
        struct megasas_register_set __iomem *regs;
        u32 mask = 0xFFFFFFFF;
+
        regs = instance->reg_set;
        writel(mask, &regs->outbound_intr_mask);
        /* Dummy readl to force pci flush */
@@ -646,8 +709,8 @@ megasas_clear_intr_skinny(struct megasas_register_set __iomem *regs)
        writel(status, &regs->outbound_intr_status);
 
        /*
-       * dummy read to flush PCI
-       */
+        * dummy read to flush PCI
+        */
        readl(&regs->outbound_intr_status);
 
        return mfiStatus;
@@ -666,6 +729,7 @@ megasas_fire_cmd_skinny(struct megasas_instance *instance,
                        struct megasas_register_set __iomem *regs)
 {
        unsigned long flags;
+
        spin_lock_irqsave(&instance->hba_lock, flags);
        writel(upper_32_bits(frame_phys_addr),
               &(regs)->inbound_high_queue_port);
@@ -718,6 +782,7 @@ static inline void
 megasas_enable_intr_gen2(struct megasas_instance *instance)
 {
        struct megasas_register_set __iomem *regs;
+
        regs = instance->reg_set;
        writel(0xFFFFFFFF, &(regs)->outbound_doorbell_clear);
 
@@ -737,6 +802,7 @@ megasas_disable_intr_gen2(struct megasas_instance *instance)
 {
        struct megasas_register_set __iomem *regs;
        u32 mask = 0xFFFFFFFF;
+
        regs = instance->reg_set;
        writel(mask, &regs->outbound_intr_mask);
        /* Dummy readl to force pci flush */
@@ -762,6 +828,7 @@ megasas_clear_intr_gen2(struct megasas_register_set __iomem *regs)
 {
        u32 status;
        u32 mfiStatus = 0;
+
        /*
         * Check if it is our interrupt
         */
@@ -798,6 +865,7 @@ megasas_fire_cmd_gen2(struct megasas_instance *instance,
                        struct megasas_register_set __iomem *regs)
 {
        unsigned long flags;
+
        spin_lock_irqsave(&instance->hba_lock, flags);
        writel((frame_phys_addr | (frame_count<<1))|1,
                        &(regs)->inbound_queue_port);
@@ -812,10 +880,10 @@ static int
 megasas_adp_reset_gen2(struct megasas_instance *instance,
                        struct megasas_register_set __iomem *reg_set)
 {
-       u32                     retry = 0 ;
-       u32                     HostDiag;
-       u32                     *seq_offset = &reg_set->seq_offset;
-       u32                     *hostdiag_offset = &reg_set->host_diag;
+       u32 retry = 0 ;
+       u32 HostDiag;
+       u32 __iomem *seq_offset = &reg_set->seq_offset;
+       u32 __iomem *hostdiag_offset = &reg_set->host_diag;
 
        if (instance->instancet == &megasas_instance_template_skinny) {
                seq_offset = &reg_set->fusion_seq_offset;
@@ -833,10 +901,10 @@ megasas_adp_reset_gen2(struct megasas_instance *instance,
 
        HostDiag = (u32)readl(hostdiag_offset);
 
-       while ( !( HostDiag & DIAG_WRITE_ENABLE) ) {
+       while (!(HostDiag & DIAG_WRITE_ENABLE)) {
                msleep(100);
                HostDiag = (u32)readl(hostdiag_offset);
-               printk(KERN_NOTICE "RESETGEN2: retry=%x, hostdiag=%x\n",
+               dev_notice(&instance->pdev->dev, "RESETGEN2: retry=%x, hostdiag=%x\n",
                                        retry, HostDiag);
 
                if (retry++ >= 100)
@@ -844,17 +912,17 @@ megasas_adp_reset_gen2(struct megasas_instance *instance,
 
        }
 
-       printk(KERN_NOTICE "ADP_RESET_GEN2: HostDiag=%x\n", HostDiag);
+       dev_notice(&instance->pdev->dev, "ADP_RESET_GEN2: HostDiag=%x\n", HostDiag);
 
        writel((HostDiag | DIAG_RESET_ADAPTER), hostdiag_offset);
 
        ssleep(10);
 
        HostDiag = (u32)readl(hostdiag_offset);
-       while ( ( HostDiag & DIAG_RESET_ADAPTER) ) {
+       while (HostDiag & DIAG_RESET_ADAPTER) {
                msleep(100);
                HostDiag = (u32)readl(hostdiag_offset);
-               printk(KERN_NOTICE "RESET_GEN2: retry=%x, hostdiag=%x\n",
+               dev_notice(&instance->pdev->dev, "RESET_GEN2: retry=%x, hostdiag=%x\n",
                                retry, HostDiag);
 
                if (retry++ >= 1000)
@@ -910,13 +978,12 @@ extern struct megasas_instance_template megasas_instance_template_fusion;
  * @instance:                  Adapter soft state
  * @cmd:                       Command packet to be issued
  *
- * For polling, MFI requires the cmd_status to be set to 0xFF before posting.
+ * For polling, MFI requires the cmd_status to be set to MFI_STAT_INVALID_STATUS before posting.
  */
 int
 megasas_issue_polled(struct megasas_instance *instance, struct megasas_cmd *cmd)
 {
        int seconds;
-
        struct megasas_header *frame_hdr = &cmd->frame->hdr;
 
        frame_hdr->cmd_status = MFI_CMD_STATUS_POLL_MODE;
@@ -952,20 +1019,21 @@ megasas_issue_blocked_cmd(struct megasas_instance *instance,
                          struct megasas_cmd *cmd, int timeout)
 {
        int ret = 0;
-       cmd->cmd_status = ENODATA;
 
-       cmd->is_wait_event = 1;
+       cmd->cmd_status_drv = MFI_STAT_INVALID_STATUS;
+
        instance->instancet->issue_dcmd(instance, cmd);
        if (timeout) {
                ret = wait_event_timeout(instance->int_cmd_wait_q,
-                               cmd->cmd_status != ENODATA, timeout * HZ);
+                               cmd->cmd_status_drv != MFI_STAT_INVALID_STATUS, timeout * HZ);
                if (!ret)
                        return 1;
        } else
                wait_event(instance->int_cmd_wait_q,
-                               cmd->cmd_status != ENODATA);
+                               cmd->cmd_status_drv != MFI_STAT_INVALID_STATUS);
 
-       return 0;
+       return (cmd->cmd_status_drv == MFI_STAT_OK) ?
+               0 : 1;
 }
 
 /**
@@ -998,7 +1066,7 @@ megasas_issue_blocked_abort_cmd(struct megasas_instance *instance,
         * Prepare and issue the abort frame
         */
        abort_fr->cmd = MFI_CMD_ABORT;
-       abort_fr->cmd_status = 0xFF;
+       abort_fr->cmd_status = MFI_STAT_INVALID_STATUS;
        abort_fr->flags = cpu_to_le16(0);
        abort_fr->abort_context = cpu_to_le32(cmd_to_abort->index);
        abort_fr->abort_mfi_phys_addr_lo =
@@ -1007,13 +1075,13 @@ megasas_issue_blocked_abort_cmd(struct megasas_instance *instance,
                cpu_to_le32(upper_32_bits(cmd_to_abort->frame_phys_addr));
 
        cmd->sync_cmd = 1;
-       cmd->cmd_status = ENODATA;
+       cmd->cmd_status_drv = MFI_STAT_INVALID_STATUS;
 
        instance->instancet->issue_dcmd(instance, cmd);
 
        if (timeout) {
                ret = wait_event_timeout(instance->abort_cmd_wait_q,
-                               cmd->cmd_status != ENODATA, timeout * HZ);
+                               cmd->cmd_status_drv != MFI_STAT_INVALID_STATUS, timeout * HZ);
                if (!ret) {
                        dev_err(&instance->pdev->dev, "Command timedout"
                                "from %s\n", __func__);
@@ -1021,7 +1089,7 @@ megasas_issue_blocked_abort_cmd(struct megasas_instance *instance,
                }
        } else
                wait_event(instance->abort_cmd_wait_q,
-                               cmd->cmd_status != ENODATA);
+                               cmd->cmd_status_drv != MFI_STAT_INVALID_STATUS);
 
        cmd->sync_cmd = 0;
 
@@ -1132,7 +1200,7 @@ static u32 megasas_get_frame_count(struct megasas_instance *instance,
        int num_cnt;
        int sge_bytes;
        u32 sge_sz;
-       u32 frame_count=0;
+       u32 frame_count = 0;
 
        sge_sz = (IS_DMA64) ? sizeof(struct megasas_sge64) :
            sizeof(struct megasas_sge32);
@@ -1163,14 +1231,14 @@ static u32 megasas_get_frame_count(struct megasas_instance *instance,
                        num_cnt = sge_count - 3;
        }
 
-       if(num_cnt>0){
+       if (num_cnt > 0) {
                sge_bytes = sge_sz * num_cnt;
 
                frame_count = (sge_bytes / MEGAMFI_FRAME_SIZE) +
                    ((sge_bytes % MEGAMFI_FRAME_SIZE) ? 1 : 0) ;
        }
        /* Main frame */
-       frame_count +=1;
+       frame_count += 1;
 
        if (frame_count > 7)
                frame_count = 8;
@@ -1196,7 +1264,7 @@ megasas_build_dcdb(struct megasas_instance *instance, struct scsi_cmnd *scp,
        struct megasas_pthru_frame *pthru;
 
        is_logical = MEGASAS_IS_LOGICAL(scp);
-       device_id = MEGASAS_DEV_INDEX(instance, scp);
+       device_id = MEGASAS_DEV_INDEX(scp);
        pthru = (struct megasas_pthru_frame *)cmd->frame;
 
        if (scp->sc_data_direction == PCI_DMA_TODEVICE)
@@ -1227,12 +1295,12 @@ megasas_build_dcdb(struct megasas_instance *instance, struct scsi_cmnd *scp,
        memcpy(pthru->cdb, scp->cmnd, scp->cmd_len);
 
        /*
-       * If the command is for the tape device, set the
-       * pthru timeout to the os layer timeout value.
-       */
+        * If the command is for the tape device, set the
+        * pthru timeout to the os layer timeout value.
+        */
        if (scp->device->type == TYPE_TAPE) {
                if ((scp->request->timeout / HZ) > 0xFFFF)
-                       pthru->timeout = 0xFFFF;
+                       pthru->timeout = cpu_to_le16(0xFFFF);
                else
                        pthru->timeout = cpu_to_le16(scp->request->timeout / HZ);
        }
@@ -1253,7 +1321,7 @@ megasas_build_dcdb(struct megasas_instance *instance, struct scsi_cmnd *scp,
                                                      &pthru->sgl);
 
        if (pthru->sge_count > instance->max_num_sge) {
-               printk(KERN_ERR "megasas: DCDB two many SGE NUM=%x\n",
+               dev_err(&instance->pdev->dev, "DCDB too many SGE NUM=%x\n",
                        pthru->sge_count);
                return 0;
        }
@@ -1294,7 +1362,7 @@ megasas_build_ldio(struct megasas_instance *instance, struct scsi_cmnd *scp,
        u16 flags = 0;
        struct megasas_io_frame *ldio;
 
-       device_id = MEGASAS_DEV_INDEX(instance, scp);
+       device_id = MEGASAS_DEV_INDEX(scp);
        ldio = (struct megasas_io_frame *)cmd->frame;
 
        if (scp->sc_data_direction == PCI_DMA_TODEVICE)
@@ -1394,7 +1462,7 @@ megasas_build_ldio(struct megasas_instance *instance, struct scsi_cmnd *scp,
                ldio->sge_count = megasas_make_sgl32(instance, scp, &ldio->sgl);
 
        if (ldio->sge_count > instance->max_num_sge) {
-               printk(KERN_ERR "megasas: build_ld_io: sge_count = %x\n",
+               dev_err(&instance->pdev->dev, "build_ld_io: sge_count = %x\n",
                        ldio->sge_count);
                return 0;
        }
@@ -1447,7 +1515,7 @@ inline int megasas_cmd_type(struct scsi_cmnd *cmd)
 
  /**
  * megasas_dump_pending_frames -       Dumps the frame address of all pending cmds
- *                                     in FW
+ *                                     in FW
  * @instance:                          Adapter soft state
  */
 static inline void
@@ -1461,63 +1529,60 @@ megasas_dump_pending_frames(struct megasas_instance *instance)
        u32 sgcount;
        u32 max_cmd = instance->max_fw_cmds;
 
-       printk(KERN_ERR "\nmegasas[%d]: Dumping Frame Phys Address of all pending cmds in FW\n",instance->host->host_no);
-       printk(KERN_ERR "megasas[%d]: Total OS Pending cmds : %d\n",instance->host->host_no,atomic_read(&instance->fw_outstanding));
+       dev_err(&instance->pdev->dev, "[%d]: Dumping Frame Phys Address of all pending cmds in FW\n",instance->host->host_no);
+       dev_err(&instance->pdev->dev, "[%d]: Total OS Pending cmds : %d\n",instance->host->host_no,atomic_read(&instance->fw_outstanding));
        if (IS_DMA64)
-               printk(KERN_ERR "\nmegasas[%d]: 64 bit SGLs were sent to FW\n",instance->host->host_no);
+               dev_err(&instance->pdev->dev, "[%d]: 64 bit SGLs were sent to FW\n",instance->host->host_no);
        else
-               printk(KERN_ERR "\nmegasas[%d]: 32 bit SGLs were sent to FW\n",instance->host->host_no);
+               dev_err(&instance->pdev->dev, "[%d]: 32 bit SGLs were sent to FW\n",instance->host->host_no);
 
-       printk(KERN_ERR "megasas[%d]: Pending OS cmds in FW : \n",instance->host->host_no);
+       dev_err(&instance->pdev->dev, "[%d]: Pending OS cmds in FW : \n",instance->host->host_no);
        for (i = 0; i < max_cmd; i++) {
                cmd = instance->cmd_list[i];
-               if(!cmd->scmd)
+               if (!cmd->scmd)
                        continue;
-               printk(KERN_ERR "megasas[%d]: Frame addr :0x%08lx : ",instance->host->host_no,(unsigned long)cmd->frame_phys_addr);
+               dev_err(&instance->pdev->dev, "[%d]: Frame addr :0x%08lx : ",instance->host->host_no,(unsigned long)cmd->frame_phys_addr);
                if (megasas_cmd_type(cmd->scmd) == READ_WRITE_LDIO) {
                        ldio = (struct megasas_io_frame *)cmd->frame;
                        mfi_sgl = &ldio->sgl;
                        sgcount = ldio->sge_count;
-                       printk(KERN_ERR "megasas[%d]: frame count : 0x%x, Cmd : 0x%x, Tgt id : 0x%x,"
+                       dev_err(&instance->pdev->dev, "[%d]: frame count : 0x%x, Cmd : 0x%x, Tgt id : 0x%x,"
                        " lba lo : 0x%x, lba_hi : 0x%x, sense_buf addr : 0x%x,sge count : 0x%x\n",
                        instance->host->host_no, cmd->frame_count, ldio->cmd, ldio->target_id,
                        le32_to_cpu(ldio->start_lba_lo), le32_to_cpu(ldio->start_lba_hi),
                        le32_to_cpu(ldio->sense_buf_phys_addr_lo), sgcount);
-               }
-               else {
+               } else {
                        pthru = (struct megasas_pthru_frame *) cmd->frame;
                        mfi_sgl = &pthru->sgl;
                        sgcount = pthru->sge_count;
-                       printk(KERN_ERR "megasas[%d]: frame count : 0x%x, Cmd : 0x%x, Tgt id : 0x%x, "
+                       dev_err(&instance->pdev->dev, "[%d]: frame count : 0x%x, Cmd : 0x%x, Tgt id : 0x%x, "
                        "lun : 0x%x, cdb_len : 0x%x, data xfer len : 0x%x, sense_buf addr : 0x%x,sge count : 0x%x\n",
                        instance->host->host_no, cmd->frame_count, pthru->cmd, pthru->target_id,
                        pthru->lun, pthru->cdb_len, le32_to_cpu(pthru->data_xfer_len),
                        le32_to_cpu(pthru->sense_buf_phys_addr_lo), sgcount);
                }
-       if(megasas_dbg_lvl & MEGASAS_DBG_LVL){
-               for (n = 0; n < sgcount; n++){
-                       if (IS_DMA64)
-                               printk(KERN_ERR "megasas: sgl len : 0x%x, sgl addr : 0x%llx ",
-                                       le32_to_cpu(mfi_sgl->sge64[n].length),
-                                       le64_to_cpu(mfi_sgl->sge64[n].phys_addr));
-                       else
-                               printk(KERN_ERR "megasas: sgl len : 0x%x, sgl addr : 0x%x ",
-                                       le32_to_cpu(mfi_sgl->sge32[n].length),
-                                       le32_to_cpu(mfi_sgl->sge32[n].phys_addr));
+               if (megasas_dbg_lvl & MEGASAS_DBG_LVL) {
+                       for (n = 0; n < sgcount; n++) {
+                               if (IS_DMA64)
+                                       dev_err(&instance->pdev->dev, "sgl len : 0x%x, sgl addr : 0x%llx\n",
+                                               le32_to_cpu(mfi_sgl->sge64[n].length),
+                                               le64_to_cpu(mfi_sgl->sge64[n].phys_addr));
+                               else
+                                       dev_err(&instance->pdev->dev, "sgl len : 0x%x, sgl addr : 0x%x\n",
+                                               le32_to_cpu(mfi_sgl->sge32[n].length),
+                                               le32_to_cpu(mfi_sgl->sge32[n].phys_addr));
                        }
                }
-               printk(KERN_ERR "\n");
        } /*for max_cmd*/
-       printk(KERN_ERR "\nmegasas[%d]: Pending Internal cmds in FW : \n",instance->host->host_no);
+       dev_err(&instance->pdev->dev, "[%d]: Pending Internal cmds in FW : \n",instance->host->host_no);
        for (i = 0; i < max_cmd; i++) {
 
                cmd = instance->cmd_list[i];
 
-               if(cmd->sync_cmd == 1){
-                       printk(KERN_ERR "0x%08lx : ", (unsigned long)cmd->frame_phys_addr);
-               }
+               if (cmd->sync_cmd == 1)
+                       dev_err(&instance->pdev->dev, "0x%08lx : ", (unsigned long)cmd->frame_phys_addr);
        }
-       printk(KERN_ERR "megasas[%d]: Dumping Done.\n\n",instance->host->host_no);
+       dev_err(&instance->pdev->dev, "[%d]: Dumping Done\n\n",instance->host->host_no);
 }
 
 u32
@@ -1635,7 +1700,7 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
        }
 
        if (instance->instancet->build_and_issue_cmd(instance, scmd)) {
-               printk(KERN_ERR "megasas: Err returned from build_and_issue_cmd\n");
+               dev_err(&instance->pdev->dev, "Err returned from build_and_issue_cmd\n");
                return SCSI_MLQUEUE_HOST_BUSY;
        }
 
@@ -1660,11 +1725,59 @@ static struct megasas_instance *megasas_lookup_instance(u16 host_no)
        return NULL;
 }
 
+/*
+* megasas_set_dma_alignment - Set DMA alignment for PI enabled VD
+*
+* @sdev: OS provided scsi device
+*
+* Returns void
+*/
+static void megasas_set_dma_alignment(struct scsi_device *sdev)
+{
+       u32 device_id, ld;
+       struct megasas_instance *instance;
+       struct fusion_context *fusion;
+       struct MR_LD_RAID *raid;
+       struct MR_DRV_RAID_MAP_ALL *local_map_ptr;
+
+       instance = megasas_lookup_instance(sdev->host->host_no);
+       fusion = instance->ctrl_context;
+
+       if (!fusion)
+               return;
+
+       if (sdev->channel >= MEGASAS_MAX_PD_CHANNELS) {
+               device_id = ((sdev->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL)
+                                       + sdev->id;
+               local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)];
+               ld = MR_TargetIdToLdGet(device_id, local_map_ptr);
+               raid = MR_LdRaidGet(ld, local_map_ptr);
+
+               if (raid->capability.ldPiMode == MR_PROT_INFO_TYPE_CONTROLLER)
+                       blk_queue_update_dma_alignment(sdev->request_queue, 0x7);
+       }
+}
+
 static int megasas_slave_configure(struct scsi_device *sdev)
 {
+       u16 pd_index = 0;
+       struct megasas_instance *instance;
+
+       instance = megasas_lookup_instance(sdev->host->host_no);
+       if (instance->allow_fw_scan) {
+               if (sdev->channel < MEGASAS_MAX_PD_CHANNELS &&
+                       sdev->type == TYPE_DISK) {
+                       pd_index = (sdev->channel * MEGASAS_MAX_DEV_PER_CHANNEL) +
+                               sdev->id;
+                       if (instance->pd_list[pd_index].driveState !=
+                               MR_PD_STATE_SYSTEM)
+                               return -ENXIO;
+               }
+       }
+       megasas_set_dma_alignment(sdev);
        /*
-       * The RAID firmware may require extended timeouts.
-       */
+        * The RAID firmware may require extended timeouts.
+        */
        blk_queue_rq_timeout(sdev->request_queue,
                MEGASAS_DEFAULT_CMD_TIMEOUT * HZ);
 
@@ -1673,8 +1786,9 @@ static int megasas_slave_configure(struct scsi_device *sdev)
 
 static int megasas_slave_alloc(struct scsi_device *sdev)
 {
-       u16             pd_index = 0;
+       u16 pd_index = 0;
        struct megasas_instance *instance ;
+
        instance = megasas_lookup_instance(sdev->host->host_no);
        if (sdev->channel < MEGASAS_MAX_PD_CHANNELS) {
                /*
@@ -1683,8 +1797,8 @@ static int megasas_slave_alloc(struct scsi_device *sdev)
                pd_index =
                        (sdev->channel * MEGASAS_MAX_DEV_PER_CHANNEL) +
                        sdev->id;
-               if (instance->pd_list[pd_index].driveState ==
-                                       MR_PD_STATE_SYSTEM) {
+               if ((instance->allow_fw_scan || instance->pd_list[pd_index].driveState ==
+                       MR_PD_STATE_SYSTEM)) {
                        return 0;
                }
                return -ENXIO;
@@ -1698,7 +1812,7 @@ static int megasas_slave_alloc(struct scsi_device *sdev)
 * @instance:                           Adapter soft state
 *
 */
-void megasas_complete_outstanding_ioctls(struct megasas_instance *instance)
+static void megasas_complete_outstanding_ioctls(struct megasas_instance *instance)
 {
        int i;
        struct megasas_cmd *cmd_mfi;
@@ -1736,12 +1850,8 @@ void megaraid_sas_kill_hba(struct megasas_instance *instance)
        msleep(1000);
        if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
                (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY) ||
-               (instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) ||
-               (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) ||
-               (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) ||
-               (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) {
-               writel(MFI_STOP_ADP,
-                       &instance->reg_set->doorbell);
+               (instance->ctrl_context)) {
+               writel(MFI_STOP_ADP, &instance->reg_set->doorbell);
                /* Flush */
                readl(&instance->reg_set->doorbell);
                if (instance->mpio && instance->requestorId)
@@ -1795,7 +1905,7 @@ static void megasas_complete_cmd_dpc(unsigned long instance_addr)
        unsigned long flags;
 
        /* If we have already declared adapter dead, donot complete cmds */
-       if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR )
+       if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR)
                return;
 
        spin_lock_irqsave(&instance->completion_lock, flags);
@@ -1806,7 +1916,7 @@ static void megasas_complete_cmd_dpc(unsigned long instance_addr)
        while (consumer != producer) {
                context = le32_to_cpu(instance->reply_queue[consumer]);
                if (context >= instance->max_fw_cmds) {
-                       printk(KERN_ERR "Unexpected context value %x\n",
+                       dev_err(&instance->pdev->dev, "Unexpected context value %x\n",
                                context);
                        BUG();
                }
@@ -1885,8 +1995,8 @@ static int megasas_get_ld_vf_affiliation_111(struct megasas_instance *instance,
        cmd = megasas_get_cmd(instance);
 
        if (!cmd) {
-               printk(KERN_DEBUG "megasas: megasas_get_ld_vf_affiliation_111:"
-                      "Failed to get cmd for scsi%d.\n",
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "megasas_get_ld_vf_affiliation_111:"
+                      "Failed to get cmd for scsi%d\n",
                        instance->host->host_no);
                return -ENOMEM;
        }
@@ -1894,8 +2004,8 @@ static int megasas_get_ld_vf_affiliation_111(struct megasas_instance *instance,
        dcmd = &cmd->frame->dcmd;
 
        if (!instance->vf_affiliation_111) {
-               printk(KERN_WARNING "megasas: SR-IOV: Couldn't get LD/VF "
-                      "affiliation for scsi%d.\n", instance->host->host_no);
+               dev_warn(&instance->pdev->dev, "SR-IOV: Couldn't get LD/VF "
+                      "affiliation for scsi%d\n", instance->host->host_no);
                megasas_return_cmd(instance, cmd);
                return -ENOMEM;
        }
@@ -1909,8 +2019,8 @@ static int megasas_get_ld_vf_affiliation_111(struct megasas_instance *instance,
                                             sizeof(struct MR_LD_VF_AFFILIATION_111),
                                             &new_affiliation_111_h);
                if (!new_affiliation_111) {
-                       printk(KERN_DEBUG "megasas: SR-IOV: Couldn't allocate "
-                              "memory for new affiliation for scsi%d.\n",
+                       dev_printk(KERN_DEBUG, &instance->pdev->dev, "SR-IOV: Couldn't allocate "
+                              "memory for new affiliation for scsi%d\n",
                               instance->host->host_no);
                        megasas_return_cmd(instance, cmd);
                        return -ENOMEM;
@@ -1922,31 +2032,33 @@ static int megasas_get_ld_vf_affiliation_111(struct megasas_instance *instance,
        memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
 
        dcmd->cmd = MFI_CMD_DCMD;
-       dcmd->cmd_status = 0xFF;
+       dcmd->cmd_status = MFI_STAT_INVALID_STATUS;
        dcmd->sge_count = 1;
-       dcmd->flags = MFI_FRAME_DIR_BOTH;
+       dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_BOTH);
        dcmd->timeout = 0;
        dcmd->pad_0 = 0;
-       dcmd->data_xfer_len = sizeof(struct MR_LD_VF_AFFILIATION_111);
-       dcmd->opcode = MR_DCMD_LD_VF_MAP_GET_ALL_LDS_111;
+       dcmd->data_xfer_len =
+               cpu_to_le32(sizeof(struct MR_LD_VF_AFFILIATION_111));
+       dcmd->opcode = cpu_to_le32(MR_DCMD_LD_VF_MAP_GET_ALL_LDS_111);
 
        if (initial)
                dcmd->sgl.sge32[0].phys_addr =
-                       instance->vf_affiliation_111_h;
+                       cpu_to_le32(instance->vf_affiliation_111_h);
        else
-               dcmd->sgl.sge32[0].phys_addr = new_affiliation_111_h;
+               dcmd->sgl.sge32[0].phys_addr =
+                       cpu_to_le32(new_affiliation_111_h);
 
-       dcmd->sgl.sge32[0].length =
-               sizeof(struct MR_LD_VF_AFFILIATION_111);
+       dcmd->sgl.sge32[0].length = cpu_to_le32(
+               sizeof(struct MR_LD_VF_AFFILIATION_111));
 
-       printk(KERN_WARNING "megasas: SR-IOV: Getting LD/VF affiliation for "
+       dev_warn(&instance->pdev->dev, "SR-IOV: Getting LD/VF affiliation for "
               "scsi%d\n", instance->host->host_no);
 
        megasas_issue_blocked_cmd(instance, cmd, 0);
 
        if (dcmd->cmd_status) {
-               printk(KERN_WARNING "megasas: SR-IOV: LD/VF affiliation DCMD"
-                      " failed with status 0x%x for scsi%d.\n",
+               dev_warn(&instance->pdev->dev, "SR-IOV: LD/VF affiliation DCMD"
+                      " failed with status 0x%x for scsi%d\n",
                       dcmd->cmd_status, instance->host->host_no);
                retval = 1; /* Do a scan if we couldn't get affiliation */
                goto out;
@@ -1957,9 +2069,8 @@ static int megasas_get_ld_vf_affiliation_111(struct megasas_instance *instance,
                for (ld = 0 ; ld < new_affiliation_111->vdCount; ld++)
                        if (instance->vf_affiliation_111->map[ld].policy[thisVf] !=
                            new_affiliation_111->map[ld].policy[thisVf]) {
-                               printk(KERN_WARNING "megasas: SR-IOV: "
-                                      "Got new LD/VF affiliation "
-                                      "for scsi%d.\n",
+                               dev_warn(&instance->pdev->dev, "SR-IOV: "
+                                      "Got new LD/VF affiliation for scsi%d\n",
                                       instance->host->host_no);
                                memcpy(instance->vf_affiliation_111,
                                       new_affiliation_111,
@@ -1976,11 +2087,7 @@ out:
                                    new_affiliation_111_h);
        }
 
-       if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked)
-               megasas_return_mfi_mpt_pthr(instance, cmd,
-                       cmd->mpt_pthr_cmd_blocked);
-       else
-               megasas_return_cmd(instance, cmd);
+       megasas_return_cmd(instance, cmd);
 
        return retval;
 }
@@ -1999,8 +2106,8 @@ static int megasas_get_ld_vf_affiliation_12(struct megasas_instance *instance,
        cmd = megasas_get_cmd(instance);
 
        if (!cmd) {
-               printk(KERN_DEBUG "megasas: megasas_get_ld_vf_affiliation12: "
-                      "Failed to get cmd for scsi%d.\n",
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "megasas_get_ld_vf_affiliation12: "
+                      "Failed to get cmd for scsi%d\n",
                       instance->host->host_no);
                return -ENOMEM;
        }
@@ -2008,8 +2115,8 @@ static int megasas_get_ld_vf_affiliation_12(struct megasas_instance *instance,
        dcmd = &cmd->frame->dcmd;
 
        if (!instance->vf_affiliation) {
-               printk(KERN_WARNING "megasas: SR-IOV: Couldn't get LD/VF "
-                      "affiliation for scsi%d.\n", instance->host->host_no);
+               dev_warn(&instance->pdev->dev, "SR-IOV: Couldn't get LD/VF "
+                      "affiliation for scsi%d\n", instance->host->host_no);
                megasas_return_cmd(instance, cmd);
                return -ENOMEM;
        }
@@ -2024,8 +2131,8 @@ static int megasas_get_ld_vf_affiliation_12(struct megasas_instance *instance,
                                             sizeof(struct MR_LD_VF_AFFILIATION),
                                             &new_affiliation_h);
                if (!new_affiliation) {
-                       printk(KERN_DEBUG "megasas: SR-IOV: Couldn't allocate "
-                              "memory for new affiliation for scsi%d.\n",
+                       dev_printk(KERN_DEBUG, &instance->pdev->dev, "SR-IOV: Couldn't allocate "
+                              "memory for new affiliation for scsi%d\n",
                               instance->host->host_no);
                        megasas_return_cmd(instance, cmd);
                        return -ENOMEM;
@@ -2037,31 +2144,33 @@ static int megasas_get_ld_vf_affiliation_12(struct megasas_instance *instance,
        memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
 
        dcmd->cmd = MFI_CMD_DCMD;
-       dcmd->cmd_status = 0xFF;
+       dcmd->cmd_status = MFI_STAT_INVALID_STATUS;
        dcmd->sge_count = 1;
-       dcmd->flags = MFI_FRAME_DIR_BOTH;
+       dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_BOTH);
        dcmd->timeout = 0;
        dcmd->pad_0 = 0;
-       dcmd->data_xfer_len = (MAX_LOGICAL_DRIVES + 1) *
-               sizeof(struct MR_LD_VF_AFFILIATION);
-       dcmd->opcode = MR_DCMD_LD_VF_MAP_GET_ALL_LDS;
+       dcmd->data_xfer_len = cpu_to_le32((MAX_LOGICAL_DRIVES + 1) *
+               sizeof(struct MR_LD_VF_AFFILIATION));
+       dcmd->opcode = cpu_to_le32(MR_DCMD_LD_VF_MAP_GET_ALL_LDS);
 
        if (initial)
-               dcmd->sgl.sge32[0].phys_addr = instance->vf_affiliation_h;
+               dcmd->sgl.sge32[0].phys_addr =
+                       cpu_to_le32(instance->vf_affiliation_h);
        else
-               dcmd->sgl.sge32[0].phys_addr = new_affiliation_h;
+               dcmd->sgl.sge32[0].phys_addr =
+                       cpu_to_le32(new_affiliation_h);
 
-       dcmd->sgl.sge32[0].length = (MAX_LOGICAL_DRIVES + 1) *
-               sizeof(struct MR_LD_VF_AFFILIATION);
+       dcmd->sgl.sge32[0].length = cpu_to_le32((MAX_LOGICAL_DRIVES + 1) *
+               sizeof(struct MR_LD_VF_AFFILIATION));
 
-       printk(KERN_WARNING "megasas: SR-IOV: Getting LD/VF affiliation for "
+       dev_warn(&instance->pdev->dev, "SR-IOV: Getting LD/VF affiliation for "
               "scsi%d\n", instance->host->host_no);
 
        megasas_issue_blocked_cmd(instance, cmd, 0);
 
        if (dcmd->cmd_status) {
-               printk(KERN_WARNING "megasas: SR-IOV: LD/VF affiliation DCMD"
-                      " failed with status 0x%x for scsi%d.\n",
+               dev_warn(&instance->pdev->dev, "SR-IOV: LD/VF affiliation DCMD"
+                      " failed with status 0x%x for scsi%d\n",
                       dcmd->cmd_status, instance->host->host_no);
                retval = 1; /* Do a scan if we couldn't get affiliation */
                goto out;
@@ -2069,8 +2178,8 @@ static int megasas_get_ld_vf_affiliation_12(struct megasas_instance *instance,
 
        if (!initial) {
                if (!new_affiliation->ldCount) {
-                       printk(KERN_WARNING "megasas: SR-IOV: Got new LD/VF "
-                              "affiliation for passive path for scsi%d.\n",
+                       dev_warn(&instance->pdev->dev, "SR-IOV: Got new LD/VF "
+                              "affiliation for passive path for scsi%d\n",
                               instance->host->host_no);
                        retval = 1;
                        goto out;
@@ -2135,8 +2244,8 @@ static int megasas_get_ld_vf_affiliation_12(struct megasas_instance *instance,
        }
 out:
        if (doscan) {
-               printk(KERN_WARNING "megasas: SR-IOV: Got new LD/VF "
-                      "affiliation for scsi%d.\n", instance->host->host_no);
+               dev_warn(&instance->pdev->dev, "SR-IOV: Got new LD/VF "
+                      "affiliation for scsi%d\n", instance->host->host_no);
                memcpy(instance->vf_affiliation, new_affiliation,
                       new_affiliation->size);
                retval = 1;
@@ -2147,11 +2256,7 @@ out:
                                    (MAX_LOGICAL_DRIVES + 1) *
                                    sizeof(struct MR_LD_VF_AFFILIATION),
                                    new_affiliation, new_affiliation_h);
-       if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked)
-               megasas_return_mfi_mpt_pthr(instance, cmd,
-                       cmd->mpt_pthr_cmd_blocked);
-       else
-               megasas_return_cmd(instance, cmd);
+       megasas_return_cmd(instance, cmd);
 
        return retval;
 }
@@ -2180,8 +2285,8 @@ int megasas_sriov_start_heartbeat(struct megasas_instance *instance,
        cmd = megasas_get_cmd(instance);
 
        if (!cmd) {
-               printk(KERN_DEBUG "megasas: megasas_sriov_start_heartbeat: "
-                      "Failed to get cmd for scsi%d.\n",
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "megasas_sriov_start_heartbeat: "
+                      "Failed to get cmd for scsi%d\n",
                       instance->host->host_no);
                return -ENOMEM;
        }
@@ -2194,9 +2299,9 @@ int megasas_sriov_start_heartbeat(struct megasas_instance *instance,
                                              sizeof(struct MR_CTRL_HB_HOST_MEM),
                                              &instance->hb_host_mem_h);
                if (!instance->hb_host_mem) {
-                       printk(KERN_DEBUG "megasas: SR-IOV: Couldn't allocate"
-                              " memory for heartbeat host memory for "
-                              "scsi%d.\n", instance->host->host_no);
+                       dev_printk(KERN_DEBUG, &instance->pdev->dev, "SR-IOV: Couldn't allocate"
+                              " memory for heartbeat host memory for scsi%d\n",
+                              instance->host->host_no);
                        retval = -ENOMEM;
                        goto out;
                }
@@ -2204,39 +2309,33 @@ int megasas_sriov_start_heartbeat(struct megasas_instance *instance,
 
        memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
 
-       dcmd->mbox.s[0] = sizeof(struct MR_CTRL_HB_HOST_MEM);
+       dcmd->mbox.s[0] = cpu_to_le16(sizeof(struct MR_CTRL_HB_HOST_MEM));
        dcmd->cmd = MFI_CMD_DCMD;
-       dcmd->cmd_status = 0xFF;
+       dcmd->cmd_status = MFI_STAT_INVALID_STATUS;
        dcmd->sge_count = 1;
-       dcmd->flags = MFI_FRAME_DIR_BOTH;
+       dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_BOTH);
        dcmd->timeout = 0;
        dcmd->pad_0 = 0;
-       dcmd->data_xfer_len = sizeof(struct MR_CTRL_HB_HOST_MEM);
-       dcmd->opcode = MR_DCMD_CTRL_SHARED_HOST_MEM_ALLOC;
-       dcmd->sgl.sge32[0].phys_addr = instance->hb_host_mem_h;
-       dcmd->sgl.sge32[0].length = sizeof(struct MR_CTRL_HB_HOST_MEM);
+       dcmd->data_xfer_len = cpu_to_le32(sizeof(struct MR_CTRL_HB_HOST_MEM));
+       dcmd->opcode = cpu_to_le32(MR_DCMD_CTRL_SHARED_HOST_MEM_ALLOC);
+       dcmd->sgl.sge32[0].phys_addr = cpu_to_le32(instance->hb_host_mem_h);
+       dcmd->sgl.sge32[0].length = cpu_to_le32(sizeof(struct MR_CTRL_HB_HOST_MEM));
 
-       printk(KERN_WARNING "megasas: SR-IOV: Starting heartbeat for scsi%d\n",
+       dev_warn(&instance->pdev->dev, "SR-IOV: Starting heartbeat for scsi%d\n",
               instance->host->host_no);
 
-       if (!megasas_issue_polled(instance, cmd)) {
-               retval = 0;
-       } else {
-               printk(KERN_WARNING "megasas: SR-IOV: MR_DCMD_CTRL_SHARED_HOST"
-                      "_MEM_ALLOC DCMD timed out for scsi%d\n",
-                      instance->host->host_no);
-               retval = 1;
-               goto out;
-       }
-
+       if (instance->ctrl_context && !instance->mask_interrupts)
+               retval = megasas_issue_blocked_cmd(instance, cmd,
+                       MEGASAS_ROUTINE_WAIT_TIME_VF);
+       else
+               retval = megasas_issue_polled(instance, cmd);
 
-       if (dcmd->cmd_status) {
-               printk(KERN_WARNING "megasas: SR-IOV: MR_DCMD_CTRL_SHARED_HOST"
-                      "_MEM_ALLOC DCMD failed with status 0x%x for scsi%d\n",
-                      dcmd->cmd_status,
-                      instance->host->host_no);
+       if (retval) {
+               dev_warn(&instance->pdev->dev, "SR-IOV: MR_DCMD_CTRL_SHARED_HOST"
+                       "_MEM_ALLOC DCMD %s for scsi%d\n",
+                       (dcmd->cmd_status == MFI_STAT_INVALID_STATUS) ?
+                       "timed out" : "failed", instance->host->host_no);
                retval = 1;
-               goto out;
        }
 
 out:
@@ -2258,7 +2357,7 @@ void megasas_sriov_heartbeat_handler(unsigned long instance_addr)
                mod_timer(&instance->sriov_heartbeat_timer,
                          jiffies + MEGASAS_SRIOV_HEARTBEAT_INTERVAL_VF);
        } else {
-               printk(KERN_WARNING "megasas: SR-IOV: Heartbeat never "
+               dev_warn(&instance->pdev->dev, "SR-IOV: Heartbeat never "
                       "completed for scsi%d\n", instance->host->host_no);
                schedule_work(&instance->work_init);
        }
@@ -2296,7 +2395,7 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
                                &clist_local);
                spin_unlock_irqrestore(&instance->hba_lock, flags);
 
-               printk(KERN_NOTICE "megasas: HBA reset wait ...\n");
+               dev_notice(&instance->pdev->dev, "HBA reset wait ...\n");
                for (i = 0; i < wait_time; i++) {
                        msleep(1000);
                        spin_lock_irqsave(&instance->hba_lock, flags);
@@ -2307,37 +2406,37 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
                }
 
                if (adprecovery != MEGASAS_HBA_OPERATIONAL) {
-                       printk(KERN_NOTICE "megasas: reset: Stopping HBA.\n");
+                       dev_notice(&instance->pdev->dev, "reset: Stopping HBA.\n");
                        spin_lock_irqsave(&instance->hba_lock, flags);
-                       instance->adprecovery   = MEGASAS_HW_CRITICAL_ERROR;
+                       instance->adprecovery = MEGASAS_HW_CRITICAL_ERROR;
                        spin_unlock_irqrestore(&instance->hba_lock, flags);
                        return FAILED;
                }
 
-               reset_index     = 0;
+               reset_index = 0;
                while (!list_empty(&clist_local)) {
-                       reset_cmd       = list_entry((&clist_local)->next,
+                       reset_cmd = list_entry((&clist_local)->next,
                                                struct megasas_cmd, list);
                        list_del_init(&reset_cmd->list);
                        if (reset_cmd->scmd) {
                                reset_cmd->scmd->result = DID_RESET << 16;
-                               printk(KERN_NOTICE "%d:%p reset [%02x]\n",
+                               dev_notice(&instance->pdev->dev, "%d:%p reset [%02x]\n",
                                        reset_index, reset_cmd,
                                        reset_cmd->scmd->cmnd[0]);
 
                                reset_cmd->scmd->scsi_done(reset_cmd->scmd);
                                megasas_return_cmd(instance, reset_cmd);
                        } else if (reset_cmd->sync_cmd) {
-                               printk(KERN_NOTICE "megasas:%p synch cmds"
+                               dev_notice(&instance->pdev->dev, "%p synch cmds"
                                                "reset queue\n",
                                                reset_cmd);
 
-                               reset_cmd->cmd_status = ENODATA;
+                               reset_cmd->cmd_status_drv = MFI_STAT_INVALID_STATUS;
                                instance->instancet->fire_cmd(instance,
                                                reset_cmd->frame_phys_addr,
                                                0, instance->reg_set);
                        } else {
-                               printk(KERN_NOTICE "megasas: %p unexpected"
+                               dev_notice(&instance->pdev->dev, "%p unexpected"
                                        "cmds lst\n",
                                        reset_cmd);
                        }
@@ -2348,14 +2447,13 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
        }
 
        for (i = 0; i < resetwaittime; i++) {
-
                int outstanding = atomic_read(&instance->fw_outstanding);
 
                if (!outstanding)
                        break;
 
                if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) {
-                       printk(KERN_NOTICE "megasas: [%2d]waiting for %d "
+                       dev_notice(&instance->pdev->dev, "[%2d]waiting for %d "
                               "commands to complete\n",i,outstanding);
                        /*
                         * Call cmd completion routine. Cmd to be
@@ -2387,10 +2485,8 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
                i++;
        } while (i <= 3);
 
-       if (atomic_read(&instance->fw_outstanding) &&
-                                       !kill_adapter_flag) {
+       if (atomic_read(&instance->fw_outstanding) && !kill_adapter_flag) {
                if (instance->disableOnlineCtrlReset == 0) {
-
                        megasas_do_ocr(instance);
 
                        /* wait for 5 secs to let FW finish the pending cmds */
@@ -2406,11 +2502,11 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
 
        if (atomic_read(&instance->fw_outstanding) ||
                                        (kill_adapter_flag == 2)) {
-               printk(KERN_NOTICE "megaraid_sas: pending cmds after reset\n");
+               dev_notice(&instance->pdev->dev, "pending cmds after reset\n");
                /*
-               * Send signal to FW to stop processing any pending cmds.
-               * The controller will be taken offline by the OS now.
-               */
+                * Send signal to FW to stop processing any pending cmds.
+                * The controller will be taken offline by the OS now.
+                */
                if ((instance->pdev->device ==
                        PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
                        (instance->pdev->device ==
@@ -2423,12 +2519,12 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
                }
                megasas_dump_pending_frames(instance);
                spin_lock_irqsave(&instance->hba_lock, flags);
-               instance->adprecovery   = MEGASAS_HW_CRITICAL_ERROR;
+               instance->adprecovery = MEGASAS_HW_CRITICAL_ERROR;
                spin_unlock_irqrestore(&instance->hba_lock, flags);
                return FAILED;
        }
 
-       printk(KERN_NOTICE "megaraid_sas: no pending cmds after reset\n");
+       dev_notice(&instance->pdev->dev, "no pending cmds after reset\n");
 
        return SUCCESS;
 }
@@ -2452,16 +2548,15 @@ static int megasas_generic_reset(struct scsi_cmnd *scmd)
                 scmd->cmnd[0], scmd->retries);
 
        if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) {
-               printk(KERN_ERR "megasas: cannot recover from previous reset "
-                      "failures\n");
+               dev_err(&instance->pdev->dev, "cannot recover from previous reset failures\n");
                return FAILED;
        }
 
        ret_val = megasas_wait_for_outstanding(instance);
        if (ret_val == SUCCESS)
-               printk(KERN_NOTICE "megasas: reset successful \n");
+               dev_notice(&instance->pdev->dev, "reset successful\n");
        else
-               printk(KERN_ERR "megasas: failed to do reset\n");
+               dev_err(&instance->pdev->dev, "failed to do reset\n");
 
        return ret_val;
 }
@@ -2503,14 +2598,10 @@ blk_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd)
  */
 static int megasas_reset_device(struct scsi_cmnd *scmd)
 {
-       int ret;
-
        /*
         * First wait for all commands to complete
         */
-       ret = megasas_generic_reset(scmd);
-
-       return ret;
+       return megasas_generic_reset(scmd);
 }
 
 /**
@@ -2520,15 +2611,13 @@ static int megasas_reset_bus_host(struct scsi_cmnd *scmd)
 {
        int ret;
        struct megasas_instance *instance;
+
        instance = (struct megasas_instance *)scmd->device->host->hostdata;
 
        /*
         * First wait for all commands to complete
         */
-       if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) ||
-           (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) ||
-           (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) ||
-           (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY))
+       if (instance->ctrl_context)
                ret = megasas_reset_fusion(scmd->device->host, 1);
        else
                ret = megasas_generic_reset(scmd);
@@ -2538,7 +2627,7 @@ static int megasas_reset_bus_host(struct scsi_cmnd *scmd)
 
 /**
  * megasas_bios_param - Returns disk geometry for a disk
- * @sdev:              device handle
+ * @sdev:              device handle
  * @bdev:              block device
  * @capacity:          drive capacity
  * @geom:              geometry parameters
@@ -2551,6 +2640,7 @@ megasas_bios_param(struct scsi_device *sdev, struct block_device *bdev,
        int sectors;
        sector_t cylinders;
        unsigned long tmp;
+
        /* Default heads (64) & sectors (32) */
        heads = 64;
        sectors = 32;
@@ -2597,6 +2687,7 @@ static void
 megasas_service_aen(struct megasas_instance *instance, struct megasas_cmd *cmd)
 {
        unsigned long flags;
+
        /*
         * Don't signal app if it is just an aborted previously registered aen
         */
@@ -2612,18 +2703,15 @@ megasas_service_aen(struct megasas_instance *instance, struct megasas_cmd *cmd)
 
        instance->aen_cmd = NULL;
 
-       if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked)
-               megasas_return_mfi_mpt_pthr(instance, cmd,
-                       cmd->mpt_pthr_cmd_blocked);
-       else
-               megasas_return_cmd(instance, cmd);
+       megasas_return_cmd(instance, cmd);
 
        if ((instance->unload == 0) &&
                ((instance->issuepend_done == 1))) {
                struct megasas_aen_event *ev;
+
                ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
                if (!ev) {
-                       printk(KERN_ERR "megasas_service_aen: out of memory\n");
+                       dev_err(&instance->pdev->dev, "megasas_service_aen: out of memory\n");
                } else {
                        ev->instance = instance;
                        instance->ev = ev;
@@ -2680,8 +2768,7 @@ megasas_fw_crash_buffer_show(struct device *cdev,
 
        buff_addr = (unsigned long) buf;
 
-       if (buff_offset >
-               (instance->fw_crash_buffer_size * dmachunk)) {
+       if (buff_offset > (instance->fw_crash_buffer_size * dmachunk)) {
                dev_err(&instance->pdev->dev,
                        "Firmware crash dump offset is out of range\n");
                spin_unlock_irqrestore(&instance->crashdump_lock, flags);
@@ -2693,7 +2780,7 @@ megasas_fw_crash_buffer_show(struct device *cdev,
 
        src_addr = (unsigned long)instance->crash_buf[buff_offset / dmachunk] +
                (buff_offset % dmachunk);
-       memcpy(buf, (void *)src_addr,  size);
+       memcpy(buf, (void *)src_addr, size);
        spin_unlock_irqrestore(&instance->crashdump_lock, flags);
 
        return size;
@@ -2753,6 +2840,7 @@ megasas_fw_crash_state_show(struct device *cdev,
        struct Scsi_Host *shost = class_to_shost(cdev);
        struct megasas_instance *instance =
                (struct megasas_instance *) shost->hostdata;
+
        return snprintf(buf, PAGE_SIZE, "%d\n", instance->fw_crash_state);
 }
 
@@ -2786,7 +2874,7 @@ struct device_attribute *megaraid_host_attrs[] = {
 static struct scsi_host_template megasas_template = {
 
        .module = THIS_MODULE,
-       .name = "LSI SAS based MegaRAID driver",
+       .name = "Avago SAS based MegaRAID driver",
        .proc_name = "megaraid_sas",
        .slave_configure = megasas_slave_configure,
        .slave_alloc = megasas_slave_alloc,
@@ -2815,11 +2903,7 @@ static void
 megasas_complete_int_cmd(struct megasas_instance *instance,
                         struct megasas_cmd *cmd)
 {
-       cmd->cmd_status = cmd->frame->io.cmd_status;
-
-       if (cmd->cmd_status == ENODATA) {
-               cmd->cmd_status = 0;
-       }
+       cmd->cmd_status_drv = cmd->frame->io.cmd_status;
        wake_up(&instance->int_cmd_wait_q);
 }
 
@@ -2838,11 +2922,9 @@ megasas_complete_abort(struct megasas_instance *instance,
 {
        if (cmd->sync_cmd) {
                cmd->sync_cmd = 0;
-               cmd->cmd_status = 0;
+               cmd->cmd_status_drv = 0;
                wake_up(&instance->abort_cmd_wait_q);
        }
-
-       return;
 }
 
 /**
@@ -2850,10 +2932,10 @@ megasas_complete_abort(struct megasas_instance *instance,
  * @instance:                  Adapter soft state
  * @cmd:                       Command to be completed
  * @alt_status:                        If non-zero, use this value as status to
- *                             SCSI mid-layer instead of the value returned
- *                             by the FW. This should be used if caller wants
- *                             an alternate status (as in the case of aborted
- *                             commands)
+ *                             SCSI mid-layer instead of the value returned
+ *                             by the FW. This should be used if caller wants
+ *                             an alternate status (as in the case of aborted
+ *                             commands)
  */
 void
 megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
@@ -2863,7 +2945,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
        struct megasas_header *hdr = &cmd->frame->hdr;
        unsigned long flags;
        struct fusion_context *fusion = instance->ctrl_context;
-       u32 opcode;
+       u32 opcode, status;
 
        /* flag for the retry reset */
        cmd->retry_for_fw_reset = 0;
@@ -2877,10 +2959,10 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
                   MR_DCMD_CTRL_EVENT_GET_INFO left over from the main kernel
                   when booting the kdump kernel.  Ignore this command to
                   prevent a kernel panic on shutdown of the kdump kernel. */
-               printk(KERN_WARNING "megaraid_sas: MFI_CMD_INVALID command "
-                      "completed.\n");
-               printk(KERN_WARNING "megaraid_sas: If you have a controller "
-                      "other than PERC5, please upgrade your firmware.\n");
+               dev_warn(&instance->pdev->dev, "MFI_CMD_INVALID command "
+                      "completed\n");
+               dev_warn(&instance->pdev->dev, "If you have a controller "
+                      "other than PERC5, please upgrade your firmware\n");
                break;
        case MFI_CMD_PD_SCSI_IO:
        case MFI_CMD_LD_SCSI_IO:
@@ -2948,7 +3030,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
                        break;
 
                default:
-                       printk(KERN_DEBUG "megasas: MFI FW status %#x\n",
+                       dev_printk(KERN_DEBUG, &instance->pdev->dev, "MFI FW status %#x\n",
                               hdr->cmd_status);
                        cmd->scmd->result = DID_ERROR << 16;
                        break;
@@ -2971,15 +3053,14 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
                        && (cmd->frame->dcmd.mbox.b[1] == 1)) {
                        fusion->fast_path_io = 0;
                        spin_lock_irqsave(instance->host->host_lock, flags);
+                       instance->map_update_cmd = NULL;
                        if (cmd->frame->hdr.cmd_status != 0) {
                                if (cmd->frame->hdr.cmd_status !=
                                    MFI_STAT_NOT_FOUND)
-                                       printk(KERN_WARNING "megasas: map sync"
-                                              "failed, status = 0x%x.\n",
+                                       dev_warn(&instance->pdev->dev, "map syncfailed, status = 0x%x\n",
                                               cmd->frame->hdr.cmd_status);
                                else {
-                                       megasas_return_mfi_mpt_pthr(instance,
-                                               cmd, cmd->mpt_pthr_cmd_blocked);
+                                       megasas_return_cmd(instance, cmd);
                                        spin_unlock_irqrestore(
                                                instance->host->host_lock,
                                                flags);
@@ -2987,8 +3068,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
                                }
                        } else
                                instance->map_id++;
-                       megasas_return_mfi_mpt_pthr(instance, cmd,
-                               cmd->mpt_pthr_cmd_blocked);
+                       megasas_return_cmd(instance, cmd);
 
                        /*
                         * Set fast path IO to ZERO.
@@ -3011,6 +3091,27 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
                        spin_unlock_irqrestore(&poll_aen_lock, flags);
                }
 
+               /* FW has an updated PD sequence */
+               if ((opcode == MR_DCMD_SYSTEM_PD_MAP_GET_INFO) &&
+                       (cmd->frame->dcmd.mbox.b[0] == 1)) {
+
+                       spin_lock_irqsave(instance->host->host_lock, flags);
+                       status = cmd->frame->hdr.cmd_status;
+                       instance->jbod_seq_cmd = NULL;
+                       megasas_return_cmd(instance, cmd);
+
+                       if (status == MFI_STAT_OK) {
+                               instance->pd_seq_map_id++;
+                               /* Re-register a pd sync seq num cmd */
+                               if (megasas_sync_pd_seq_num(instance, true))
+                                       instance->use_seqnum_jbod_fp = false;
+                       } else
+                               instance->use_seqnum_jbod_fp = false;
+
+                       spin_unlock_irqrestore(instance->host->host_lock, flags);
+                       break;
+               }
+
                /*
                 * See if got an event notification
                 */
@@ -3029,7 +3130,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
                break;
 
        default:
-               printk("megasas: Unknown command completed! [0x%X]\n",
+               dev_info(&instance->pdev->dev, "Unknown command completed! [0x%X]\n",
                       hdr->cmd);
                break;
        }
@@ -3037,7 +3138,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
 
 /**
  * megasas_issue_pending_cmds_again -  issue all pending cmds
- *                                     in FW again because of the fw reset
+ *                                     in FW again because of the fw reset
  * @instance:                          Adapter soft state
  */
 static inline void
@@ -3055,19 +3156,19 @@ megasas_issue_pending_cmds_again(struct megasas_instance *instance)
        spin_unlock_irqrestore(&instance->hba_lock, flags);
 
        while (!list_empty(&clist_local)) {
-               cmd     = list_entry((&clist_local)->next,
+               cmd = list_entry((&clist_local)->next,
                                        struct megasas_cmd, list);
                list_del_init(&cmd->list);
 
                if (cmd->sync_cmd || cmd->scmd) {
-                       printk(KERN_NOTICE "megaraid_sas: command %p, %p:%d"
-                               "detected to be pending while HBA reset.\n",
+                       dev_notice(&instance->pdev->dev, "command %p, %p:%d"
+                               "detected to be pending while HBA reset\n",
                                        cmd, cmd->scmd, cmd->sync_cmd);
 
                        cmd->retry_for_fw_reset++;
 
                        if (cmd->retry_for_fw_reset == 3) {
-                               printk(KERN_NOTICE "megaraid_sas: cmd %p, %p:%d"
+                               dev_notice(&instance->pdev->dev, "cmd %p, %p:%d"
                                        "was tried multiple times during reset."
                                        "Shutting down the HBA\n",
                                        cmd, cmd->scmd, cmd->sync_cmd);
@@ -3080,18 +3181,18 @@ megasas_issue_pending_cmds_again(struct megasas_instance *instance)
 
                if (cmd->sync_cmd == 1) {
                        if (cmd->scmd) {
-                               printk(KERN_NOTICE "megaraid_sas: unexpected"
+                               dev_notice(&instance->pdev->dev, "unexpected"
                                        "cmd attached to internal command!\n");
                        }
-                       printk(KERN_NOTICE "megasas: %p synchronous cmd"
+                       dev_notice(&instance->pdev->dev, "%p synchronous cmd"
                                                "on the internal reset queue,"
                                                "issue it again.\n", cmd);
-                       cmd->cmd_status = ENODATA;
+                       cmd->cmd_status_drv = MFI_STAT_INVALID_STATUS;
                        instance->instancet->fire_cmd(instance,
-                                                       cmd->frame_phys_addr ,
+                                                       cmd->frame_phys_addr,
                                                        0, instance->reg_set);
                } else if (cmd->scmd) {
-                       printk(KERN_NOTICE "megasas: %p scsi cmd [%02x]"
+                       dev_notice(&instance->pdev->dev, "%p scsi cmd [%02x]"
                        "detected on the internal queue, issue again.\n",
                        cmd, cmd->scmd->cmnd[0]);
 
@@ -3100,22 +3201,22 @@ megasas_issue_pending_cmds_again(struct megasas_instance *instance)
                                        cmd->frame_phys_addr,
                                        cmd->frame_count-1, instance->reg_set);
                } else {
-                       printk(KERN_NOTICE "megasas: %p unexpected cmd on the"
+                       dev_notice(&instance->pdev->dev, "%p unexpected cmd on the"
                                "internal reset defer list while re-issue!!\n",
                                cmd);
                }
        }
 
        if (instance->aen_cmd) {
-               printk(KERN_NOTICE "megaraid_sas: aen_cmd in def process\n");
+               dev_notice(&instance->pdev->dev, "aen_cmd in def process\n");
                megasas_return_cmd(instance, instance->aen_cmd);
 
-               instance->aen_cmd       = NULL;
+               instance->aen_cmd = NULL;
        }
 
        /*
-       * Initiate AEN (Asynchronous Event Notification)
-       */
+        * Initiate AEN (Asynchronous Event Notification)
+        */
        seq_num = instance->last_seq_num;
        class_locale.members.reserved = 0;
        class_locale.members.locale = MR_EVT_LOCALE_ALL;
@@ -3142,17 +3243,17 @@ megasas_internal_reset_defer_cmds(struct megasas_instance *instance)
        u32 defer_index;
        unsigned long flags;
 
-       defer_index     = 0;
+       defer_index = 0;
        spin_lock_irqsave(&instance->mfi_pool_lock, flags);
        for (i = 0; i < max_cmd; i++) {
                cmd = instance->cmd_list[i];
                if (cmd->sync_cmd == 1 || cmd->scmd) {
-                       printk(KERN_NOTICE "megasas: moving cmd[%d]:%p:%d:%p"
+                       dev_notice(&instance->pdev->dev, "moving cmd[%d]:%p:%d:%p"
                                        "on the defer queue as internal\n",
                                defer_index, cmd, cmd->sync_cmd, cmd->scmd);
 
                        if (!list_empty(&cmd->list)) {
-                               printk(KERN_NOTICE "megaraid_sas: ERROR while"
+                               dev_notice(&instance->pdev->dev, "ERROR while"
                                        " moving this cmd:%p, %d %p, it was"
                                        "discovered on some list?\n",
                                        cmd, cmd->sync_cmd, cmd->scmd);
@@ -3177,13 +3278,13 @@ process_fw_state_change_wq(struct work_struct *work)
        unsigned long flags;
 
        if (instance->adprecovery != MEGASAS_ADPRESET_SM_INFAULT) {
-               printk(KERN_NOTICE "megaraid_sas: error, recovery st %x \n",
+               dev_notice(&instance->pdev->dev, "error, recovery st %x\n",
                                instance->adprecovery);
                return ;
        }
 
        if (instance->adprecovery == MEGASAS_ADPRESET_SM_INFAULT) {
-               printk(KERN_NOTICE "megaraid_sas: FW detected to be in fault"
+               dev_notice(&instance->pdev->dev, "FW detected to be in fault"
                                        "state, restarting it...\n");
 
                instance->instancet->disable_intr(instance);
@@ -3191,21 +3292,21 @@ process_fw_state_change_wq(struct work_struct *work)
 
                atomic_set(&instance->fw_reset_no_pci_access, 1);
                instance->instancet->adp_reset(instance, instance->reg_set);
-               atomic_set(&instance->fw_reset_no_pci_access, 0 );
+               atomic_set(&instance->fw_reset_no_pci_access, 0);
 
-               printk(KERN_NOTICE "megaraid_sas: FW restarted successfully,"
+               dev_notice(&instance->pdev->dev, "FW restarted successfully,"
                                        "initiating next stage...\n");
 
-               printk(KERN_NOTICE "megaraid_sas: HBA recovery state machine,"
+               dev_notice(&instance->pdev->dev, "HBA recovery state machine,"
                                        "state 2 starting...\n");
 
-               /*waitting for about 20 second before start the second init*/
+               /* waiting for about 20 second before start the second init */
                for (wait = 0; wait < 30; wait++) {
                        msleep(1000);
                }
 
                if (megasas_transition_to_ready(instance, 1)) {
-                       printk(KERN_NOTICE "megaraid_sas:adapter not ready\n");
+                       dev_notice(&instance->pdev->dev, "adapter not ready\n");
 
                        atomic_set(&instance->fw_reset_no_pci_access, 1);
                        megaraid_sas_kill_hba(instance);
@@ -3232,15 +3333,14 @@ process_fw_state_change_wq(struct work_struct *work)
                megasas_issue_pending_cmds_again(instance);
                instance->issuepend_done = 1;
        }
-       return ;
 }
 
 /**
  * megasas_deplete_reply_queue -       Processes all completed commands
  * @instance:                          Adapter soft state
  * @alt_status:                                Alternate status to be returned to
- *                                     SCSI mid-layer instead of the status
- *                                     returned by the FW
+ *                                     SCSI mid-layer instead of the status
+ *                                     returned by the FW
  * Note: this must be called with hba lock held
  */
 static int
@@ -3270,13 +3370,13 @@ megasas_deplete_reply_queue(struct megasas_instance *instance,
                                instance->reg_set) & MFI_STATE_MASK;
 
                if (fw_state != MFI_STATE_FAULT) {
-                       printk(KERN_NOTICE "megaraid_sas: fw state:%x\n",
+                       dev_notice(&instance->pdev->dev, "fw state:%x\n",
                                                fw_state);
                }
 
                if ((fw_state == MFI_STATE_FAULT) &&
                                (instance->disableOnlineCtrlReset == 0)) {
-                       printk(KERN_NOTICE "megaraid_sas: wait adp restart\n");
+                       dev_notice(&instance->pdev->dev, "wait adp restart\n");
 
                        if ((instance->pdev->device ==
                                        PCI_DEVICE_ID_LSI_SAS1064R) ||
@@ -3297,14 +3397,14 @@ megasas_deplete_reply_queue(struct megasas_instance *instance,
                        atomic_set(&instance->fw_outstanding, 0);
                        megasas_internal_reset_defer_cmds(instance);
 
-                       printk(KERN_NOTICE "megasas: fwState=%x, stage:%d\n",
+                       dev_notice(&instance->pdev->dev, "fwState=%x, stage:%d\n",
                                        fw_state, instance->adprecovery);
 
                        schedule_work(&instance->work_init);
                        return IRQ_HANDLED;
 
                } else {
-                       printk(KERN_NOTICE "megasas: fwstate:%x, dis_OCR=%x\n",
+                       dev_notice(&instance->pdev->dev, "fwstate:%x, dis_OCR=%x\n",
                                fw_state, instance->disableOnlineCtrlReset);
                }
        }
@@ -3320,13 +3420,13 @@ static irqreturn_t megasas_isr(int irq, void *devp)
        struct megasas_irq_context *irq_context = devp;
        struct megasas_instance *instance = irq_context->instance;
        unsigned long flags;
-       irqreturn_t     rc;
+       irqreturn_t rc;
 
        if (atomic_read(&instance->fw_reset_no_pci_access))
                return IRQ_HANDLED;
 
        spin_lock_irqsave(&instance->hba_lock, flags);
-       rc =  megasas_deplete_reply_queue(instance, DID_OK);
+       rc = megasas_deplete_reply_queue(instance, DID_OK);
        spin_unlock_irqrestore(&instance->hba_lock, flags);
 
        return rc;
@@ -3354,7 +3454,7 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
        fw_state = abs_state & MFI_STATE_MASK;
 
        if (fw_state != MFI_STATE_READY)
-               printk(KERN_INFO "megasas: Waiting for FW to come to ready"
+               dev_info(&instance->pdev->dev, "Waiting for FW to come to ready"
                       " state\n");
 
        while (fw_state != MFI_STATE_READY) {
@@ -3362,7 +3462,7 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
                switch (fw_state) {
 
                case MFI_STATE_FAULT:
-                       printk(KERN_DEBUG "megasas: FW in FAULT state!!\n");
+                       dev_printk(KERN_DEBUG, &instance->pdev->dev, "FW in FAULT state!!\n");
                        if (ocr) {
                                max_wait = MEGASAS_RESET_WAIT_TIME;
                                cur_state = MFI_STATE_FAULT;
@@ -3378,22 +3478,14 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
                                PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
                                (instance->pdev->device ==
                                 PCI_DEVICE_ID_LSI_SAS0071SKINNY) ||
-                               (instance->pdev->device ==
-                               PCI_DEVICE_ID_LSI_FUSION) ||
-                               (instance->pdev->device ==
-                               PCI_DEVICE_ID_LSI_PLASMA) ||
-                               (instance->pdev->device ==
-                               PCI_DEVICE_ID_LSI_INVADER) ||
-                               (instance->pdev->device ==
-                               PCI_DEVICE_ID_LSI_FURY)) {
+                               (instance->ctrl_context))
                                writel(
                                  MFI_INIT_CLEAR_HANDSHAKE|MFI_INIT_HOTPLUG,
                                  &instance->reg_set->doorbell);
-                       } else {
+                       else
                                writel(
                                    MFI_INIT_CLEAR_HANDSHAKE|MFI_INIT_HOTPLUG,
                                        &instance->reg_set->inbound_doorbell);
-                       }
 
                        max_wait = MEGASAS_RESET_WAIT_TIME;
                        cur_state = MFI_STATE_WAIT_HANDSHAKE;
@@ -3404,17 +3496,10 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
                             PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
                                (instance->pdev->device ==
                                 PCI_DEVICE_ID_LSI_SAS0071SKINNY) ||
-                           (instance->pdev->device ==
-                            PCI_DEVICE_ID_LSI_FUSION) ||
-                           (instance->pdev->device ==
-                            PCI_DEVICE_ID_LSI_PLASMA) ||
-                           (instance->pdev->device ==
-                            PCI_DEVICE_ID_LSI_INVADER) ||
-                           (instance->pdev->device ==
-                            PCI_DEVICE_ID_LSI_FURY)) {
+                               (instance->ctrl_context))
                                writel(MFI_INIT_HOTPLUG,
                                       &instance->reg_set->doorbell);
-                       else
+                       else
                                writel(MFI_INIT_HOTPLUG,
                                        &instance->reg_set->inbound_doorbell);
 
@@ -3431,24 +3516,11 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
                                PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
                                (instance->pdev->device ==
                                PCI_DEVICE_ID_LSI_SAS0071SKINNY)  ||
-                               (instance->pdev->device
-                                       == PCI_DEVICE_ID_LSI_FUSION) ||
-                               (instance->pdev->device
-                                       == PCI_DEVICE_ID_LSI_PLASMA) ||
-                               (instance->pdev->device
-                                       == PCI_DEVICE_ID_LSI_INVADER) ||
-                               (instance->pdev->device
-                                       == PCI_DEVICE_ID_LSI_FURY)) {
+                               (instance->ctrl_context)) {
                                writel(MFI_RESET_FLAGS,
                                        &instance->reg_set->doorbell);
-                               if ((instance->pdev->device ==
-                                       PCI_DEVICE_ID_LSI_FUSION) ||
-                                       (instance->pdev->device ==
-                                       PCI_DEVICE_ID_LSI_PLASMA) ||
-                                       (instance->pdev->device ==
-                                       PCI_DEVICE_ID_LSI_INVADER) ||
-                                       (instance->pdev->device ==
-                                       PCI_DEVICE_ID_LSI_FURY)) {
+
+                               if (instance->ctrl_context) {
                                        for (i = 0; i < (10 * 1000); i += 20) {
                                                if (readl(
                                                            &instance->
@@ -3501,7 +3573,7 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
                        break;
 
                default:
-                       printk(KERN_DEBUG "megasas: Unknown state 0x%x\n",
+                       dev_printk(KERN_DEBUG, &instance->pdev->dev, "Unknown state 0x%x\n",
                               fw_state);
                        return -ENODEV;
                }
@@ -3523,7 +3595,7 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
                 * Return error if fw_state hasn't changed after max_wait
                 */
                if (curr_abs_state == abs_state) {
-                       printk(KERN_DEBUG "FW state [%d] hasn't changed "
+                       dev_printk(KERN_DEBUG, &instance->pdev->dev, "FW state [%d] hasn't changed "
                               "in %d secs\n", fw_state, max_wait);
                        return -ENODEV;
                }
@@ -3531,7 +3603,7 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
                abs_state = curr_abs_state;
                fw_state = curr_abs_state & MFI_STATE_MASK;
        }
-       printk(KERN_INFO "megasas: FW now in Ready state\n");
+       dev_info(&instance->pdev->dev, "FW now in Ready state\n");
 
        return 0;
 }
@@ -3602,9 +3674,8 @@ static int megasas_create_frame_pool(struct megasas_instance *instance)
        sge_sz = (IS_DMA64) ? sizeof(struct megasas_sge64) :
            sizeof(struct megasas_sge32);
 
-       if (instance->flag_ieee) {
+       if (instance->flag_ieee)
                sge_sz = sizeof(struct megasas_sge_skinny);
-       }
 
        /*
         * For MFI controllers.
@@ -3626,7 +3697,7 @@ static int megasas_create_frame_pool(struct megasas_instance *instance)
                                        instance->pdev, total_sz, 256, 0);
 
        if (!instance->frame_dma_pool) {
-               printk(KERN_DEBUG "megasas: failed to setup frame pool\n");
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "failed to setup frame pool\n");
                return -ENOMEM;
        }
 
@@ -3634,7 +3705,7 @@ static int megasas_create_frame_pool(struct megasas_instance *instance)
                                                   instance->pdev, 128, 4, 0);
 
        if (!instance->sense_dma_pool) {
-               printk(KERN_DEBUG "megasas: failed to setup sense pool\n");
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "failed to setup sense pool\n");
 
                pci_pool_destroy(instance->frame_dma_pool);
                instance->frame_dma_pool = NULL;
@@ -3662,7 +3733,7 @@ static int megasas_create_frame_pool(struct megasas_instance *instance)
                 * whatever has been allocated
                 */
                if (!cmd->frame || !cmd->sense) {
-                       printk(KERN_DEBUG "megasas: pci_pool_alloc failed \n");
+                       dev_printk(KERN_DEBUG, &instance->pdev->dev, "pci_pool_alloc failed\n");
                        megasas_teardown_frame_pool(instance);
                        return -ENOMEM;
                }
@@ -3670,11 +3741,7 @@ static int megasas_create_frame_pool(struct megasas_instance *instance)
                memset(cmd->frame, 0, total_sz);
                cmd->frame->io.context = cpu_to_le32(cmd->index);
                cmd->frame->io.pad_0 = 0;
-               if ((instance->pdev->device != PCI_DEVICE_ID_LSI_FUSION) &&
-                   (instance->pdev->device != PCI_DEVICE_ID_LSI_PLASMA) &&
-                   (instance->pdev->device != PCI_DEVICE_ID_LSI_INVADER) &&
-                       (instance->pdev->device != PCI_DEVICE_ID_LSI_FURY) &&
-                   (reset_devices))
+               if (!instance->ctrl_context && reset_devices)
                        cmd->frame->hdr.cmd = MFI_CMD_INVALID;
        }
 
@@ -3688,6 +3755,7 @@ static int megasas_create_frame_pool(struct megasas_instance *instance)
 void megasas_free_cmds(struct megasas_instance *instance)
 {
        int i;
+
        /* First free the MFI frame pool */
        megasas_teardown_frame_pool(instance);
 
@@ -3740,7 +3808,7 @@ int megasas_alloc_cmds(struct megasas_instance *instance)
        instance->cmd_list = kcalloc(max_cmd, sizeof(struct megasas_cmd*), GFP_KERNEL);
 
        if (!instance->cmd_list) {
-               printk(KERN_DEBUG "megasas: out of memory\n");
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "out of memory\n");
                return -ENOMEM;
        }
 
@@ -3766,7 +3834,6 @@ int megasas_alloc_cmds(struct megasas_instance *instance)
                cmd = instance->cmd_list[i];
                memset(cmd, 0, sizeof(struct megasas_cmd));
                cmd->index = i;
-               atomic_set(&cmd->mfi_mpt_pthr, MFI_LIST_ADDED);
                cmd->scmd = NULL;
                cmd->instance = instance;
 
@@ -3777,7 +3844,7 @@ int megasas_alloc_cmds(struct megasas_instance *instance)
         * Create a frame pool and assign one frame to each cmd
         */
        if (megasas_create_frame_pool(instance)) {
-               printk(KERN_DEBUG "megasas: Error creating frame DMA pool\n");
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "Error creating frame DMA pool\n");
                megasas_free_cmds(instance);
        }
 
@@ -3806,7 +3873,7 @@ megasas_get_pd_list(struct megasas_instance *instance)
        cmd = megasas_get_cmd(instance);
 
        if (!cmd) {
-               printk(KERN_DEBUG "megasas (get_pd_list): Failed to get cmd\n");
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "(get_pd_list): Failed to get cmd\n");
                return -ENOMEM;
        }
 
@@ -3816,7 +3883,7 @@ megasas_get_pd_list(struct megasas_instance *instance)
                  MEGASAS_MAX_PD * sizeof(struct MR_PD_LIST), &ci_h);
 
        if (!ci) {
-               printk(KERN_DEBUG "Failed to alloc mem for pd_list\n");
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to alloc mem for pd_list\n");
                megasas_return_cmd(instance, cmd);
                return -ENOMEM;
        }
@@ -3827,7 +3894,7 @@ megasas_get_pd_list(struct megasas_instance *instance)
        dcmd->mbox.b[0] = MR_PD_QUERY_TYPE_EXPOSED_TO_HOST;
        dcmd->mbox.b[1] = 0;
        dcmd->cmd = MFI_CMD_DCMD;
-       dcmd->cmd_status = 0xFF;
+       dcmd->cmd_status = MFI_STAT_INVALID_STATUS;
        dcmd->sge_count = 1;
        dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_READ);
        dcmd->timeout = 0;
@@ -3844,12 +3911,12 @@ megasas_get_pd_list(struct megasas_instance *instance)
                ret = megasas_issue_polled(instance, cmd);
 
        /*
-       * the following function will get the instance PD LIST.
-       */
+        * the following function will get the instance PD LIST.
+        */
 
        pd_addr = ci->addr;
 
-       if ( ret == 0 &&
+       if (ret == 0 &&
             (le32_to_cpu(ci->count) <
                  (MEGASAS_MAX_PD_CHANNELS * MEGASAS_MAX_DEV_PER_CHANNEL))) {
 
@@ -3874,11 +3941,7 @@ megasas_get_pd_list(struct megasas_instance *instance)
                                MEGASAS_MAX_PD * sizeof(struct MR_PD_LIST),
                                ci, ci_h);
 
-       if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked)
-               megasas_return_mfi_mpt_pthr(instance, cmd,
-                       cmd->mpt_pthr_cmd_blocked);
-       else
-               megasas_return_cmd(instance, cmd);
+       megasas_return_cmd(instance, cmd);
 
        return ret;
 }
@@ -3905,7 +3968,7 @@ megasas_get_ld_list(struct megasas_instance *instance)
        cmd = megasas_get_cmd(instance);
 
        if (!cmd) {
-               printk(KERN_DEBUG "megasas_get_ld_list: Failed to get cmd\n");
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "megasas_get_ld_list: Failed to get cmd\n");
                return -ENOMEM;
        }
 
@@ -3916,7 +3979,7 @@ megasas_get_ld_list(struct megasas_instance *instance)
                                &ci_h);
 
        if (!ci) {
-               printk(KERN_DEBUG "Failed to alloc mem in get_ld_list\n");
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to alloc mem in get_ld_list\n");
                megasas_return_cmd(instance, cmd);
                return -ENOMEM;
        }
@@ -3927,7 +3990,7 @@ megasas_get_ld_list(struct megasas_instance *instance)
        if (instance->supportmax256vd)
                dcmd->mbox.b[0] = 1;
        dcmd->cmd = MFI_CMD_DCMD;
-       dcmd->cmd_status = 0xFF;
+       dcmd->cmd_status = MFI_STAT_INVALID_STATUS;
        dcmd->sge_count = 1;
        dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_READ);
        dcmd->timeout = 0;
@@ -3965,11 +4028,7 @@ megasas_get_ld_list(struct megasas_instance *instance)
                                ci,
                                ci_h);
 
-       if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked)
-               megasas_return_mfi_mpt_pthr(instance, cmd,
-                       cmd->mpt_pthr_cmd_blocked);
-       else
-               megasas_return_cmd(instance, cmd);
+       megasas_return_cmd(instance, cmd);
        return ret;
 }
 
@@ -3995,8 +4054,8 @@ megasas_ld_list_query(struct megasas_instance *instance, u8 query_type)
        cmd = megasas_get_cmd(instance);
 
        if (!cmd) {
-               printk(KERN_WARNING
-                      "megasas:(megasas_ld_list_query): Failed to get cmd\n");
+               dev_warn(&instance->pdev->dev,
+                        "megasas_ld_list_query: Failed to get cmd\n");
                return -ENOMEM;
        }
 
@@ -4006,8 +4065,8 @@ megasas_ld_list_query(struct megasas_instance *instance, u8 query_type)
                                  sizeof(struct MR_LD_TARGETID_LIST), &ci_h);
 
        if (!ci) {
-               printk(KERN_WARNING
-                      "megasas: Failed to alloc mem for ld_list_query\n");
+               dev_warn(&instance->pdev->dev,
+                        "Failed to alloc mem for ld_list_query\n");
                megasas_return_cmd(instance, cmd);
                return -ENOMEM;
        }
@@ -4020,7 +4079,7 @@ megasas_ld_list_query(struct megasas_instance *instance, u8 query_type)
                dcmd->mbox.b[2] = 1;
 
        dcmd->cmd = MFI_CMD_DCMD;
-       dcmd->cmd_status = 0xFF;
+       dcmd->cmd_status = MFI_STAT_INVALID_STATUS;
        dcmd->sge_count = 1;
        dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_READ);
        dcmd->timeout = 0;
@@ -4050,11 +4109,7 @@ megasas_ld_list_query(struct megasas_instance *instance, u8 query_type)
        pci_free_consistent(instance->pdev, sizeof(struct MR_LD_TARGETID_LIST),
                            ci, ci_h);
 
-       if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked)
-               megasas_return_mfi_mpt_pthr(instance, cmd,
-                       cmd->mpt_pthr_cmd_blocked);
-       else
-               megasas_return_cmd(instance, cmd);
+       megasas_return_cmd(instance, cmd);
 
        return ret;
 }
@@ -4091,18 +4146,17 @@ static void megasas_update_ext_vd_details(struct megasas_instance *instance)
                instance->fw_supported_vd_count = MAX_LOGICAL_DRIVES;
                instance->fw_supported_pd_count = MAX_PHYSICAL_DEVICES;
        }
-       dev_info(&instance->pdev->dev, "Firmware supports %d VD %d PD\n",
-               instance->fw_supported_vd_count,
-               instance->fw_supported_pd_count);
-       dev_info(&instance->pdev->dev, "Driver supports %d VD  %d PD\n",
-               instance->drv_supported_vd_count,
-               instance->drv_supported_pd_count);
 
-       old_map_sz =  sizeof(struct MR_FW_RAID_MAP) +
+       dev_info(&instance->pdev->dev,
+               "firmware type\t: %s\n",
+               instance->supportmax256vd ? "Extended VD(240 VD)firmware" :
+               "Legacy(64 VD) firmware");
+
+       old_map_sz = sizeof(struct MR_FW_RAID_MAP) +
                                (sizeof(struct MR_LD_SPAN_MAP) *
                                (instance->fw_supported_vd_count - 1));
-       new_map_sz =  sizeof(struct MR_FW_RAID_MAP_EXT);
-       fusion->drv_map_sz =  sizeof(struct MR_DRV_RAID_MAP) +
+       new_map_sz = sizeof(struct MR_FW_RAID_MAP_EXT);
+       fusion->drv_map_sz = sizeof(struct MR_DRV_RAID_MAP) +
                                (sizeof(struct MR_LD_SPAN_MAP) *
                                (instance->drv_supported_vd_count - 1));
 
@@ -4113,7 +4167,6 @@ static void megasas_update_ext_vd_details(struct megasas_instance *instance)
                fusion->current_map_sz = new_map_sz;
        else
                fusion->current_map_sz = old_map_sz;
-
 }
 
 /**
@@ -4139,7 +4192,7 @@ megasas_get_ctrl_info(struct megasas_instance *instance)
        cmd = megasas_get_cmd(instance);
 
        if (!cmd) {
-               printk(KERN_DEBUG "megasas: Failed to get a free cmd\n");
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to get a free cmd\n");
                return -ENOMEM;
        }
 
@@ -4149,7 +4202,7 @@ megasas_get_ctrl_info(struct megasas_instance *instance)
                                  sizeof(struct megasas_ctrl_info), &ci_h);
 
        if (!ci) {
-               printk(KERN_DEBUG "Failed to alloc mem for ctrl info\n");
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to alloc mem for ctrl info\n");
                megasas_return_cmd(instance, cmd);
                return -ENOMEM;
        }
@@ -4158,7 +4211,7 @@ megasas_get_ctrl_info(struct megasas_instance *instance)
        memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
 
        dcmd->cmd = MFI_CMD_DCMD;
-       dcmd->cmd_status = 0xFF;
+       dcmd->cmd_status = MFI_STAT_INVALID_STATUS;
        dcmd->sge_count = 1;
        dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_READ);
        dcmd->timeout = 0;
@@ -4181,16 +4234,27 @@ megasas_get_ctrl_info(struct megasas_instance *instance)
                le32_to_cpus((u32 *)&ctrl_info->adapterOperations2);
                le32_to_cpus((u32 *)&ctrl_info->adapterOperations3);
                megasas_update_ext_vd_details(instance);
+               instance->use_seqnum_jbod_fp =
+                       ctrl_info->adapterOperations3.useSeqNumJbodFP;
+               instance->is_imr = (ctrl_info->memory_size ? 0 : 1);
+               dev_info(&instance->pdev->dev,
+                               "controller type\t: %s(%dMB)\n",
+                               instance->is_imr ? "iMR" : "MR",
+                               le16_to_cpu(ctrl_info->memory_size));
+               instance->disableOnlineCtrlReset =
+                       ctrl_info->properties.OnOffProperties.disableOnlineCtrlReset;
+               dev_info(&instance->pdev->dev, "Online Controller Reset(OCR)\t: %s\n",
+                       instance->disableOnlineCtrlReset ? "Disabled" : "Enabled");
+               instance->secure_jbod_support =
+                       ctrl_info->adapterOperations3.supportSecurityonJBOD;
+               dev_info(&instance->pdev->dev, "Secure JBOD support\t: %s\n",
+                       instance->secure_jbod_support ? "Yes" : "No");
        }
 
        pci_free_consistent(instance->pdev, sizeof(struct megasas_ctrl_info),
                            ci, ci_h);
 
-       if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked)
-               megasas_return_mfi_mpt_pthr(instance, cmd,
-                       cmd->mpt_pthr_cmd_blocked);
-       else
-               megasas_return_cmd(instance, cmd);
+       megasas_return_cmd(instance, cmd);
        return ret;
 }
 
@@ -4229,7 +4293,7 @@ int megasas_set_crash_dump_params(struct megasas_instance *instance,
        memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
        dcmd->mbox.b[0] = crash_buf_state;
        dcmd->cmd = MFI_CMD_DCMD;
-       dcmd->cmd_status = 0xFF;
+       dcmd->cmd_status = MFI_STAT_INVALID_STATUS;
        dcmd->sge_count = 1;
        dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_NONE);
        dcmd->timeout = 0;
@@ -4245,11 +4309,7 @@ int megasas_set_crash_dump_params(struct megasas_instance *instance,
        else
                ret = megasas_issue_polled(instance, cmd);
 
-       if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked)
-               megasas_return_mfi_mpt_pthr(instance, cmd,
-                       cmd->mpt_pthr_cmd_blocked);
-       else
-               megasas_return_cmd(instance, cmd);
+       megasas_return_cmd(instance, cmd);
        return ret;
 }
 
@@ -4262,10 +4322,8 @@ int megasas_set_crash_dump_params(struct megasas_instance *instance,
 static int
 megasas_issue_init_mfi(struct megasas_instance *instance)
 {
-       u32 context;
-
+       __le32 context;
        struct megasas_cmd *cmd;
-
        struct megasas_init_frame *init_frame;
        struct megasas_init_queue_info *initq_info;
        dma_addr_t init_frame_h;
@@ -4300,7 +4358,7 @@ megasas_issue_init_mfi(struct megasas_instance *instance)
        initq_info->consumer_index_phys_addr_lo = cpu_to_le32(instance->consumer_h);
 
        init_frame->cmd = MFI_CMD_INIT;
-       init_frame->cmd_status = 0xFF;
+       init_frame->cmd_status = MFI_STAT_INVALID_STATUS;
        init_frame->queue_info_new_phys_addr_lo =
                cpu_to_le32(lower_32_bits(initq_info_h));
        init_frame->queue_info_new_phys_addr_hi =
@@ -4318,7 +4376,7 @@ megasas_issue_init_mfi(struct megasas_instance *instance)
         */
 
        if (megasas_issue_polled(instance, cmd)) {
-               printk(KERN_ERR "megasas: Failed to init firmware\n");
+               dev_err(&instance->pdev->dev, "Failed to init firmware\n");
                megasas_return_cmd(instance, cmd);
                goto fail_fw_init;
        }
@@ -4353,6 +4411,21 @@ megasas_init_adapter_mfi(struct megasas_instance *instance)
        instance->max_mfi_cmds = instance->max_fw_cmds;
        instance->max_num_sge = (instance->instancet->read_fw_status_reg(reg_set) & 0xFF0000) >>
                                        0x10;
+       /*
+        * For MFI skinny adapters, MEGASAS_SKINNY_INT_CMDS commands
+        * are reserved for IOCTL + driver's internal DCMDs.
+        */
+       if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
+               (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY)) {
+               instance->max_scsi_cmds = (instance->max_fw_cmds -
+                       MEGASAS_SKINNY_INT_CMDS);
+               sema_init(&instance->ioctl_sem, MEGASAS_SKINNY_INT_CMDS);
+       } else {
+               instance->max_scsi_cmds = (instance->max_fw_cmds -
+                       MEGASAS_INT_CMDS);
+               sema_init(&instance->ioctl_sem, (MEGASAS_MFI_IOCTL_CMDS));
+       }
+
        /*
         * Create a pool of commands
         */
@@ -4376,7 +4449,7 @@ megasas_init_adapter_mfi(struct megasas_instance *instance)
                                                     &instance->reply_queue_h);
 
        if (!instance->reply_queue) {
-               printk(KERN_DEBUG "megasas: Out of DMA mem for reply queue\n");
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "Out of DMA mem for reply queue\n");
                goto fail_reply_queue;
        }
 
@@ -4395,7 +4468,7 @@ megasas_init_adapter_mfi(struct megasas_instance *instance)
                (instance->instancet->read_fw_status_reg(reg_set) &
                0x04000000);
 
-       printk(KERN_NOTICE "megasas_init_mfi: fw_support_ieee=%d",
+       dev_notice(&instance->pdev->dev, "megasas_init_mfi: fw_support_ieee=%d",
                        instance->fw_support_ieee);
 
        if (instance->fw_support_ieee)
@@ -4414,6 +4487,163 @@ fail_alloc_cmds:
        return 1;
 }
 
+/*
+ * megasas_setup_irqs_msix -           register legacy interrupts.
+ * @instance:                          Adapter soft state
+ *
+ * Do not enable interrupt, only setup ISRs.
+ *
+ * Return 0 on success.
+ */
+static int
+megasas_setup_irqs_ioapic(struct megasas_instance *instance)
+{
+       struct pci_dev *pdev;
+
+       pdev = instance->pdev;
+       instance->irq_context[0].instance = instance;
+       instance->irq_context[0].MSIxIndex = 0;
+       if (request_irq(pdev->irq, instance->instancet->service_isr,
+               IRQF_SHARED, "megasas", &instance->irq_context[0])) {
+               dev_err(&instance->pdev->dev,
+                               "Failed to register IRQ from %s %d\n",
+                               __func__, __LINE__);
+               return -1;
+       }
+       return 0;
+}
+
+/**
+ * megasas_setup_irqs_msix -           register MSI-x interrupts.
+ * @instance:                          Adapter soft state
+ * @is_probe:                          Driver probe check
+ *
+ * Do not enable interrupt, only setup ISRs.
+ *
+ * Return 0 on success.
+ */
+static int
+megasas_setup_irqs_msix(struct megasas_instance *instance, u8 is_probe)
+{
+       int i, j, cpu;
+       struct pci_dev *pdev;
+
+       pdev = instance->pdev;
+
+       /* Try MSI-x */
+       cpu = cpumask_first(cpu_online_mask);
+       for (i = 0; i < instance->msix_vectors; i++) {
+               instance->irq_context[i].instance = instance;
+               instance->irq_context[i].MSIxIndex = i;
+               if (request_irq(instance->msixentry[i].vector,
+                       instance->instancet->service_isr, 0, "megasas",
+                       &instance->irq_context[i])) {
+                       dev_err(&instance->pdev->dev,
+                               "Failed to register IRQ for vector %d.\n", i);
+                       for (j = 0; j < i; j++) {
+                               if (smp_affinity_enable)
+                                       irq_set_affinity_hint(
+                                               instance->msixentry[j].vector, NULL);
+                               free_irq(instance->msixentry[j].vector,
+                                       &instance->irq_context[j]);
+                       }
+                       /* Retry irq register for IO_APIC*/
+                       instance->msix_vectors = 0;
+                       if (is_probe)
+                               return megasas_setup_irqs_ioapic(instance);
+                       else
+                               return -1;
+               }
+               if (smp_affinity_enable) {
+                       if (irq_set_affinity_hint(instance->msixentry[i].vector,
+                               get_cpu_mask(cpu)))
+                               dev_err(&instance->pdev->dev,
+                                       "Failed to set affinity hint"
+                                       " for cpu %d\n", cpu);
+                       cpu = cpumask_next(cpu, cpu_online_mask);
+               }
+       }
+       return 0;
+}
+
+/*
+ * megasas_destroy_irqs-               unregister interrupts.
+ * @instance:                          Adapter soft state
+ * return:                             void
+ */
+static void
+megasas_destroy_irqs(struct megasas_instance *instance) {
+
+       int i;
+
+       if (instance->msix_vectors)
+               for (i = 0; i < instance->msix_vectors; i++) {
+                       if (smp_affinity_enable)
+                               irq_set_affinity_hint(
+                                       instance->msixentry[i].vector, NULL);
+                       free_irq(instance->msixentry[i].vector,
+                                &instance->irq_context[i]);
+               }
+       else
+               free_irq(instance->pdev->irq, &instance->irq_context[0]);
+}
+
+/**
+ * megasas_setup_jbod_map -    setup jbod map for FP seq_number.
+ * @instance:                          Adapter soft state
+ * @is_probe:                          Driver probe check
+ *
+ * Return 0 on success.
+ */
+void
+megasas_setup_jbod_map(struct megasas_instance *instance)
+{
+       int i;
+       struct fusion_context *fusion = instance->ctrl_context;
+       u32 pd_seq_map_sz;
+
+       pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) +
+               (sizeof(struct MR_PD_CFG_SEQ) * (MAX_PHYSICAL_DEVICES - 1));
+
+       if (reset_devices || !fusion ||
+               !instance->ctrl_info->adapterOperations3.useSeqNumJbodFP) {
+               dev_info(&instance->pdev->dev,
+                       "Jbod map is not supported %s %d\n",
+                       __func__, __LINE__);
+               instance->use_seqnum_jbod_fp = false;
+               return;
+       }
+
+       if (fusion->pd_seq_sync[0])
+               goto skip_alloc;
+
+       for (i = 0; i < JBOD_MAPS_COUNT; i++) {
+               fusion->pd_seq_sync[i] = dma_alloc_coherent
+                       (&instance->pdev->dev, pd_seq_map_sz,
+                       &fusion->pd_seq_phys[i], GFP_KERNEL);
+               if (!fusion->pd_seq_sync[i]) {
+                       dev_err(&instance->pdev->dev,
+                               "Failed to allocate memory from %s %d\n",
+                               __func__, __LINE__);
+                       if (i == 1) {
+                               dma_free_coherent(&instance->pdev->dev,
+                                       pd_seq_map_sz, fusion->pd_seq_sync[0],
+                                       fusion->pd_seq_phys[0]);
+                               fusion->pd_seq_sync[0] = NULL;
+                       }
+                       instance->use_seqnum_jbod_fp = false;
+                       return;
+               }
+       }
+
+skip_alloc:
+       if (!megasas_sync_pd_seq_num(instance, false) &&
+               !megasas_sync_pd_seq_num(instance, true))
+               instance->use_seqnum_jbod_fp = true;
+       else
+               instance->use_seqnum_jbod_fp = false;
+}
+
 /**
  * megasas_init_fw -   Initializes the FW
  * @instance:          Adapter soft state
@@ -4432,13 +4662,16 @@ static int megasas_init_fw(struct megasas_instance *instance)
        unsigned long bar_list;
        int i, loop, fw_msix_count = 0;
        struct IOV_111 *iovPtr;
+       struct fusion_context *fusion;
+
+       fusion = instance->ctrl_context;
 
        /* Find first memory bar */
        bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM);
        instance->bar = find_first_bit(&bar_list, sizeof(unsigned long));
        if (pci_request_selected_regions(instance->pdev, instance->bar,
                                         "megasas: LSI")) {
-               printk(KERN_DEBUG "megasas: IO memory region busy!\n");
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "IO memory region busy!\n");
                return -EBUSY;
        }
 
@@ -4446,7 +4679,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
        instance->reg_set = ioremap_nocache(base_addr, 8192);
 
        if (!instance->reg_set) {
-               printk(KERN_DEBUG "megasas: Failed to map IO mem\n");
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to map IO mem\n");
                goto fail_ioremap;
        }
 
@@ -4457,6 +4690,10 @@ static int megasas_init_fw(struct megasas_instance *instance)
        case PCI_DEVICE_ID_LSI_PLASMA:
        case PCI_DEVICE_ID_LSI_INVADER:
        case PCI_DEVICE_ID_LSI_FURY:
+       case PCI_DEVICE_ID_LSI_INTRUDER:
+       case PCI_DEVICE_ID_LSI_INTRUDER_24:
+       case PCI_DEVICE_ID_LSI_CUTLASS_52:
+       case PCI_DEVICE_ID_LSI_CUTLASS_53:
                instance->instancet = &megasas_instance_template_fusion;
                break;
        case PCI_DEVICE_ID_LSI_SAS1078R:
@@ -4475,6 +4712,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
        case PCI_DEVICE_ID_DELL_PERC5:
        default:
                instance->instancet = &megasas_instance_template_xscale;
+               instance->allow_fw_scan = 1;
                break;
        }
 
@@ -4484,7 +4722,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
                        (instance, instance->reg_set);
                atomic_set(&instance->fw_reset_no_pci_access, 0);
                dev_info(&instance->pdev->dev,
-                       "megasas: FW restarted successfully from %s!\n",
+                       "FW restarted successfully from %s!\n",
                        __func__);
 
                /*waitting for about 30 second before retry*/
@@ -4499,7 +4737,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
         * It is used for all MPT based Adapters.
         */
        instance->reply_post_host_index_addr[0] =
-               (u32 *)((u8 *)instance->reg_set +
+               (u32 __iomem *)((u8 __iomem *)instance->reg_set +
                MPI2_REPLY_POST_HOST_INDEX_OFFSET);
 
        /* Check if MSI-X is supported while in ready state */
@@ -4509,36 +4747,32 @@ static int megasas_init_fw(struct megasas_instance *instance)
                scratch_pad_2 = readl
                        (&instance->reg_set->outbound_scratch_pad_2);
                /* Check max MSI-X vectors */
-               if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) ||
-                   (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA)) {
-                       instance->msix_vectors = (scratch_pad_2
-                               & MR_MAX_REPLY_QUEUES_OFFSET) + 1;
-                       fw_msix_count = instance->msix_vectors;
-                       if (msix_vectors)
-                               instance->msix_vectors =
-                                       min(msix_vectors,
-                                           instance->msix_vectors);
-               } else if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER)
-                       || (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) {
-                       /* Invader/Fury supports more than 8 MSI-X */
-                       instance->msix_vectors = ((scratch_pad_2
-                               & MR_MAX_REPLY_QUEUES_EXT_OFFSET)
-                               >> MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT) + 1;
-                       fw_msix_count = instance->msix_vectors;
-                       /* Save 1-15 reply post index address to local memory
-                        * Index 0 is already saved from reg offset
-                        * MPI2_REPLY_POST_HOST_INDEX_OFFSET
-                        */
-                       for (loop = 1; loop < MR_MAX_MSIX_REG_ARRAY; loop++) {
-                               instance->reply_post_host_index_addr[loop] =
-                                       (u32 *)((u8 *)instance->reg_set +
-                                       MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET
-                                       + (loop * 0x10));
+               if (fusion) {
+                       if (fusion->adapter_type == THUNDERBOLT_SERIES) { /* Thunderbolt Series*/
+                               instance->msix_vectors = (scratch_pad_2
+                                       & MR_MAX_REPLY_QUEUES_OFFSET) + 1;
+                               fw_msix_count = instance->msix_vectors;
+                       } else { /* Invader series supports more than 8 MSI-x vectors*/
+                               instance->msix_vectors = ((scratch_pad_2
+                                       & MR_MAX_REPLY_QUEUES_EXT_OFFSET)
+                                       >> MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT) + 1;
+                               fw_msix_count = instance->msix_vectors;
+                               /* Save 1-15 reply post index address to local memory
+                                * Index 0 is already saved from reg offset
+                                * MPI2_REPLY_POST_HOST_INDEX_OFFSET
+                                */
+                               for (loop = 1; loop < MR_MAX_MSIX_REG_ARRAY; loop++) {
+                                       instance->reply_post_host_index_addr[loop] =
+                                               (u32 __iomem *)
+                                               ((u8 __iomem *)instance->reg_set +
+                                               MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET
+                                               + (loop * 0x10));
+                               }
                        }
                        if (msix_vectors)
                                instance->msix_vectors = min(msix_vectors,
                                        instance->msix_vectors);
-               } else
+               } else /* MFI adapters */
                        instance->msix_vectors = 1;
                /* Don't bother allocating more MSI-X vectors than cpus */
                instance->msix_vectors = min(instance->msix_vectors,
@@ -4551,14 +4785,22 @@ static int megasas_init_fw(struct megasas_instance *instance)
                        instance->msix_vectors = i;
                else
                        instance->msix_vectors = 0;
-
-               dev_info(&instance->pdev->dev, "[scsi%d]: FW supports"
-                       "<%d> MSIX vector,Online CPUs: <%d>,"
-                       "Current MSIX <%d>\n", instance->host->host_no,
-                       fw_msix_count, (unsigned int)num_online_cpus(),
-                       instance->msix_vectors);
        }
 
+       dev_info(&instance->pdev->dev,
+               "firmware supports msix\t: (%d)", fw_msix_count);
+       dev_info(&instance->pdev->dev,
+               "current msix/online cpus\t: (%d/%d)\n",
+               instance->msix_vectors, (unsigned int)num_online_cpus());
+
+       tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet,
+               (unsigned long)instance);
+
+       if (instance->msix_vectors ?
+               megasas_setup_irqs_msix(instance, 1) :
+               megasas_setup_irqs_ioapic(instance))
+               goto fail_setup_irqs;
+
        instance->ctrl_info = kzalloc(sizeof(struct megasas_ctrl_info),
                                GFP_KERNEL);
        if (instance->ctrl_info == NULL)
@@ -4574,17 +4816,21 @@ static int megasas_init_fw(struct megasas_instance *instance)
        if (instance->instancet->init_adapter(instance))
                goto fail_init_adapter;
 
-       printk(KERN_ERR "megasas: INIT adapter done\n");
 
-       /** for passthrough
-       * the following function will get the PD LIST.
-       */
+       instance->instancet->enable_intr(instance);
+
+       dev_err(&instance->pdev->dev, "INIT adapter done\n");
 
-       memset(instance->pd_list, 0 ,
+       megasas_setup_jbod_map(instance);
+
+       /** for passthrough
+        * the following function will get the PD LIST.
+        */
+       memset(instance->pd_list, 0,
                (MEGASAS_MAX_PD * sizeof(struct megasas_pd_list)));
        if (megasas_get_pd_list(instance) < 0) {
-               printk(KERN_ERR "megasas: failed to get PD list\n");
-               goto fail_init_adapter;
+               dev_err(&instance->pdev->dev, "failed to get PD list\n");
+               goto fail_get_pd_list;
        }
 
        memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS);
@@ -4608,29 +4854,13 @@ static int megasas_init_fw(struct megasas_instance *instance)
                le16_to_cpu(ctrl_info->max_strips_per_io);
        max_sectors_2 = le32_to_cpu(ctrl_info->max_request_size);
 
-       tmp_sectors = min_t(u32, max_sectors_1 , max_sectors_2);
+       tmp_sectors = min_t(u32, max_sectors_1, max_sectors_2);
 
-       /*Check whether controller is iMR or MR */
-       if (ctrl_info->memory_size) {
-               instance->is_imr = 0;
-               dev_info(&instance->pdev->dev, "Controller type: MR,"
-                       "Memory size is: %dMB\n",
-                       le16_to_cpu(ctrl_info->memory_size));
-       } else {
-               instance->is_imr = 1;
-               dev_info(&instance->pdev->dev,
-                       "Controller type: iMR\n");
-       }
-       instance->disableOnlineCtrlReset =
-       ctrl_info->properties.OnOffProperties.disableOnlineCtrlReset;
        instance->mpio = ctrl_info->adapterOperations2.mpio;
        instance->UnevenSpanSupport =
                ctrl_info->adapterOperations2.supportUnevenSpans;
        if (instance->UnevenSpanSupport) {
                struct fusion_context *fusion = instance->ctrl_context;
-
-               dev_info(&instance->pdev->dev, "FW supports: "
-               "UnevenSpanSupport=%x\n", instance->UnevenSpanSupport);
                if (MR_ValidateMapInfo(instance))
                        fusion->fast_path_io = 1;
                else
@@ -4638,18 +4868,22 @@ static int megasas_init_fw(struct megasas_instance *instance)
 
        }
        if (ctrl_info->host_interface.SRIOV) {
-               if (!ctrl_info->adapterOperations2.activePassive)
-                       instance->PlasmaFW111 = 1;
-
-               if (!instance->PlasmaFW111)
-                       instance->requestorId =
-                               ctrl_info->iov.requestorId;
-               else {
-                       iovPtr = (struct IOV_111 *)((unsigned char *)ctrl_info + IOV_111_OFFSET);
-                       instance->requestorId = iovPtr->requestorId;
+               instance->requestorId = ctrl_info->iov.requestorId;
+               if (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) {
+                       if (!ctrl_info->adapterOperations2.activePassive)
+                           instance->PlasmaFW111 = 1;
+
+                       dev_info(&instance->pdev->dev, "SR-IOV: firmware type: %s\n",
+                           instance->PlasmaFW111 ? "1.11" : "new");
+
+                       if (instance->PlasmaFW111) {
+                           iovPtr = (struct IOV_111 *)
+                               ((unsigned char *)ctrl_info + IOV_111_OFFSET);
+                           instance->requestorId = iovPtr->requestorId;
+                       }
                }
-               dev_warn(&instance->pdev->dev, "I am VF "
-                      "requestorId %d\n", instance->requestorId);
+               dev_info(&instance->pdev->dev, "SRIOV: VF requestorId %d\n",
+                       instance->requestorId);
        }
 
        instance->crash_dump_fw_support =
@@ -4657,13 +4891,11 @@ static int megasas_init_fw(struct megasas_instance *instance)
        instance->crash_dump_drv_support =
                (instance->crash_dump_fw_support &&
                instance->crash_dump_buf);
-       if (instance->crash_dump_drv_support) {
-               dev_info(&instance->pdev->dev, "Firmware Crash dump "
-                       "feature is supported\n");
+       if (instance->crash_dump_drv_support)
                megasas_set_crash_dump_params(instance,
                        MR_CRASH_BUF_TURN_OFF);
 
-       else {
+       else {
                if (instance->crash_dump_buf)
                        pci_free_consistent(instance->pdev,
                                CRASH_DMA_BUF_SIZE,
@@ -4672,39 +4904,26 @@ static int megasas_init_fw(struct megasas_instance *instance)
                instance->crash_dump_buf = NULL;
        }
 
-       instance->secure_jbod_support =
-               ctrl_info->adapterOperations3.supportSecurityonJBOD;
-       if (instance->secure_jbod_support)
-               dev_info(&instance->pdev->dev, "Firmware supports Secure JBOD\n");
+
+       dev_info(&instance->pdev->dev,
+               "pci id\t\t: (0x%04x)/(0x%04x)/(0x%04x)/(0x%04x)\n",
+               le16_to_cpu(ctrl_info->pci.vendor_id),
+               le16_to_cpu(ctrl_info->pci.device_id),
+               le16_to_cpu(ctrl_info->pci.sub_vendor_id),
+               le16_to_cpu(ctrl_info->pci.sub_device_id));
+       dev_info(&instance->pdev->dev, "unevenspan support      : %s\n",
+               instance->UnevenSpanSupport ? "yes" : "no");
+       dev_info(&instance->pdev->dev, "firmware crash dump     : %s\n",
+               instance->crash_dump_drv_support ? "yes" : "no");
+       dev_info(&instance->pdev->dev, "jbod sync map           : %s\n",
+               instance->use_seqnum_jbod_fp ? "yes" : "no");
+
+
        instance->max_sectors_per_req = instance->max_num_sge *
-                                               PAGE_SIZE / 512;
+                                               SGE_BUFFER_SIZE / 512;
        if (tmp_sectors && (instance->max_sectors_per_req > tmp_sectors))
                instance->max_sectors_per_req = tmp_sectors;
 
-       /*
-        * 1. For fusion adapters, 3 commands for IOCTL and 5 commands
-        *    for driver's internal DCMDs.
-        * 2. For MFI skinny adapters, 5 commands for IOCTL + driver's
-        *    internal DCMDs.
-        * 3. For rest of MFI adapters, 27 commands reserved for IOCTLs
-        *    and 5 commands for drivers's internal DCMD.
-        */
-       if (instance->ctrl_context) {
-               instance->max_scsi_cmds = instance->max_fw_cmds -
-                                       (MEGASAS_FUSION_INTERNAL_CMDS +
-                                       MEGASAS_FUSION_IOCTL_CMDS);
-               sema_init(&instance->ioctl_sem, MEGASAS_FUSION_IOCTL_CMDS);
-       } else if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
-               (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY)) {
-               instance->max_scsi_cmds = instance->max_fw_cmds -
-                                               MEGASAS_SKINNY_INT_CMDS;
-               sema_init(&instance->ioctl_sem, MEGASAS_SKINNY_INT_CMDS);
-       } else {
-               instance->max_scsi_cmds = instance->max_fw_cmds -
-                                               MEGASAS_INT_CMDS;
-               sema_init(&instance->ioctl_sem, (MEGASAS_INT_CMDS - 5));
-       }
-
        /* Check for valid throttlequeuedepth module parameter */
        if (throttlequeuedepth &&
                        throttlequeuedepth <= instance->max_scsi_cmds)
@@ -4713,12 +4932,6 @@ static int megasas_init_fw(struct megasas_instance *instance)
                instance->throttlequeuedepth =
                                MEGASAS_THROTTLE_QUEUE_DEPTH;
 
-        /*
-       * Setup tasklet for cmd completion
-       */
-
-       tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet,
-               (unsigned long)instance);
 
        /* Launch SR-IOV heartbeat timer */
        if (instance->requestorId) {
@@ -4733,7 +4946,14 @@ static int megasas_init_fw(struct megasas_instance *instance)
 
        return 0;
 
+fail_get_pd_list:
+       instance->instancet->disable_intr(instance);
 fail_init_adapter:
+       megasas_destroy_irqs(instance);
+fail_setup_irqs:
+       if (instance->msix_vectors)
+               pci_disable_msix(instance->pdev);
+       instance->msix_vectors = 0;
 fail_ready_state:
        kfree(instance->ctrl_info);
        instance->ctrl_info = NULL;
@@ -4747,7 +4967,7 @@ fail_ready_state:
 
 /**
  * megasas_release_mfi -       Reverses the FW initialization
- * @intance:                   Adapter soft state
+ * @instance:                  Adapter soft state
  */
 static void megasas_release_mfi(struct megasas_instance *instance)
 {
@@ -4822,21 +5042,17 @@ megasas_get_seq_num(struct megasas_instance *instance,
                /*
                 * Copy the data back into callers buffer
                 */
-               eli->newest_seq_num = le32_to_cpu(el_info->newest_seq_num);
-               eli->oldest_seq_num = le32_to_cpu(el_info->oldest_seq_num);
-               eli->clear_seq_num = le32_to_cpu(el_info->clear_seq_num);
-               eli->shutdown_seq_num = le32_to_cpu(el_info->shutdown_seq_num);
-               eli->boot_seq_num = le32_to_cpu(el_info->boot_seq_num);
+               eli->newest_seq_num = el_info->newest_seq_num;
+               eli->oldest_seq_num = el_info->oldest_seq_num;
+               eli->clear_seq_num = el_info->clear_seq_num;
+               eli->shutdown_seq_num = el_info->shutdown_seq_num;
+               eli->boot_seq_num = el_info->boot_seq_num;
        }
 
        pci_free_consistent(instance->pdev, sizeof(struct megasas_evt_log_info),
                            el_info, el_info_h);
 
-       if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked)
-               megasas_return_mfi_mpt_pthr(instance, cmd,
-                       cmd->mpt_pthr_cmd_blocked);
-       else
-               megasas_return_cmd(instance, cmd);
+       megasas_return_cmd(instance, cmd);
 
        return 0;
 }
@@ -4877,8 +5093,8 @@ megasas_register_aen(struct megasas_instance *instance, u32 seq_num,
 
        if (instance->aen_cmd) {
 
-               prev_aen.word = instance->aen_cmd->frame->dcmd.mbox.w[1];
-               prev_aen.members.locale = le16_to_cpu(prev_aen.members.locale);
+               prev_aen.word =
+                       le32_to_cpu(instance->aen_cmd->frame->dcmd.mbox.w[1]);
 
                /*
                 * A class whose enum value is smaller is inclusive of all
@@ -4910,7 +5126,7 @@ megasas_register_aen(struct megasas_instance *instance, u32 seq_num,
                                                                  aen_cmd, 30);
 
                        if (ret_val) {
-                               printk(KERN_DEBUG "megasas: Failed to abort "
+                               dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to abort "
                                       "previous AEN command\n");
                                return ret_val;
                        }
@@ -4990,7 +5206,7 @@ static int megasas_start_aen(struct megasas_instance *instance)
        class_locale.members.class = MR_EVT_CLASS_DEBUG;
 
        return megasas_register_aen(instance,
-                       eli.newest_seq_num + 1,
+                       le32_to_cpu(eli.newest_seq_num) + 1,
                        class_locale.word);
 }
 
@@ -5028,7 +5244,7 @@ static int megasas_io_attach(struct megasas_instance *instance)
                                (max_sectors <= MEGASAS_MAX_SECTORS)) {
                                instance->max_sectors_per_req = max_sectors;
                        } else {
-                       printk(KERN_INFO "megasas: max_sectors should be > 0"
+                       dev_info(&instance->pdev->dev, "max_sectors should be > 0"
                                "and <= %d (or < 1MB for GEN2 controller)\n",
                                instance->max_sectors_per_req);
                        }
@@ -5043,10 +5259,7 @@ static int megasas_io_attach(struct megasas_instance *instance)
        host->max_cmd_len = 16;
 
        /* Fusion only supports host reset */
-       if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) ||
-           (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) ||
-           (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) ||
-           (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) {
+       if (instance->ctrl_context) {
                host->hostt->eh_device_reset_handler = NULL;
                host->hostt->eh_bus_reset_handler = NULL;
        }
@@ -5055,7 +5268,9 @@ static int megasas_io_attach(struct megasas_instance *instance)
         * Notify the mid-layer about the new controller
         */
        if (scsi_add_host(host, &instance->pdev->dev)) {
-               printk(KERN_DEBUG "megasas: scsi_add_host failed\n");
+               dev_err(&instance->pdev->dev,
+                       "Failed to add host from %s %d\n",
+                       __func__, __LINE__);
                return -ENODEV;
        }
 
@@ -5066,7 +5281,7 @@ static int
 megasas_set_dma_mask(struct pci_dev *pdev)
 {
        /*
-        * All our contollers are capable of performing 64-bit DMA
+        * All our controllers are capable of performing 64-bit DMA
         */
        if (IS_DMA64) {
                if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) != 0) {
@@ -5106,7 +5321,7 @@ fail_set_dma_mask:
 static int megasas_probe_one(struct pci_dev *pdev,
                             const struct pci_device_id *id)
 {
-       int rval, pos, i, j, cpu;
+       int rval, pos;
        struct Scsi_Host *host;
        struct megasas_instance *instance;
        u16 control = 0;
@@ -5128,16 +5343,6 @@ static int megasas_probe_one(struct pci_dev *pdev,
                }
        }
 
-       /*
-        * Announce PCI information
-        */
-       printk(KERN_INFO "megasas: %#4.04x:%#4.04x:%#4.04x:%#4.04x: ",
-              pdev->vendor, pdev->device, pdev->subsystem_vendor,
-              pdev->subsystem_device);
-
-       printk("bus %d:slot %d:func %d\n",
-              pdev->bus->number, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
-
        /*
         * PCI prepping: enable device set bus mastering and dma mask
         */
@@ -5156,13 +5361,13 @@ static int megasas_probe_one(struct pci_dev *pdev,
                               sizeof(struct megasas_instance));
 
        if (!host) {
-               printk(KERN_DEBUG "megasas: scsi_host_alloc failed\n");
+               dev_printk(KERN_DEBUG, &pdev->dev, "scsi_host_alloc failed\n");
                goto fail_alloc_instance;
        }
 
        instance = (struct megasas_instance *)host->hostdata;
        memset(instance, 0, sizeof(*instance));
-       atomic_set( &instance->fw_reset_no_pci_access, 0 );
+       atomic_set(&instance->fw_reset_no_pci_access, 0);
        instance->pdev = pdev;
 
        switch (instance->pdev->device) {
@@ -5170,21 +5375,28 @@ static int megasas_probe_one(struct pci_dev *pdev,
        case PCI_DEVICE_ID_LSI_PLASMA:
        case PCI_DEVICE_ID_LSI_INVADER:
        case PCI_DEVICE_ID_LSI_FURY:
+       case PCI_DEVICE_ID_LSI_INTRUDER:
+       case PCI_DEVICE_ID_LSI_INTRUDER_24:
+       case PCI_DEVICE_ID_LSI_CUTLASS_52:
+       case PCI_DEVICE_ID_LSI_CUTLASS_53:
        {
                instance->ctrl_context_pages =
                        get_order(sizeof(struct fusion_context));
                instance->ctrl_context = (void *)__get_free_pages(GFP_KERNEL,
                                instance->ctrl_context_pages);
                if (!instance->ctrl_context) {
-                       printk(KERN_DEBUG "megasas: Failed to allocate "
+                       dev_printk(KERN_DEBUG, &pdev->dev, "Failed to allocate "
                               "memory for Fusion context info\n");
                        goto fail_alloc_dma_buf;
                }
                fusion = instance->ctrl_context;
                memset(fusion, 0,
                        ((1 << PAGE_SHIFT) << instance->ctrl_context_pages));
-               INIT_LIST_HEAD(&fusion->cmd_pool);
-               spin_lock_init(&fusion->mpt_pool_lock);
+               if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) ||
+                       (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA))
+                       fusion->adapter_type = THUNDERBOLT_SERIES;
+               else
+                       fusion->adapter_type = INVADER_SERIES;
        }
        break;
        default: /* For all other supported controllers */
@@ -5197,7 +5409,7 @@ static int megasas_probe_one(struct pci_dev *pdev,
                                             &instance->consumer_h);
 
                if (!instance->producer || !instance->consumer) {
-                       printk(KERN_DEBUG "megasas: Failed to allocate"
+                       dev_printk(KERN_DEBUG, &pdev->dev, "Failed to allocate"
                               "memory for producer, consumer\n");
                        goto fail_alloc_dma_buf;
                }
@@ -5207,6 +5419,13 @@ static int megasas_probe_one(struct pci_dev *pdev,
                break;
        }
 
+       instance->system_info_buf = pci_zalloc_consistent(pdev,
+                                       sizeof(struct MR_DRV_SYSTEM_INFO),
+                                       &instance->system_info_h);
+
+       if (!instance->system_info_buf)
+               dev_info(&instance->pdev->dev, "Can't allocate system info buffer\n");
+
        /* Crash dump feature related initialisation*/
        instance->drv_buf_index = 0;
        instance->drv_buf_alloc = 0;
@@ -5221,7 +5440,7 @@ static int megasas_probe_one(struct pci_dev *pdev,
                                                CRASH_DMA_BUF_SIZE,
                                                &instance->crash_dump_h);
        if (!instance->crash_dump_buf)
-               dev_err(&instance->pdev->dev, "Can't allocate Firmware "
+               dev_err(&pdev->dev, "Can't allocate Firmware "
                        "crash dump DMA buffer\n");
 
        megasas_poll_wait_aen = 0;
@@ -5237,7 +5456,7 @@ static int megasas_probe_one(struct pci_dev *pdev,
                                                    &instance->evt_detail_h);
 
        if (!instance->evt_detail) {
-               printk(KERN_DEBUG "megasas: Failed to allocate memory for "
+               dev_printk(KERN_DEBUG, &pdev->dev, "Failed to allocate memory for "
                       "event detail structure\n");
                goto fail_alloc_dma_buf;
        }
@@ -5280,10 +5499,7 @@ static int megasas_probe_one(struct pci_dev *pdev,
        instance->disableOnlineCtrlReset = 1;
        instance->UnevenSpanSupport = 0;
 
-       if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) ||
-           (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) ||
-           (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) ||
-           (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) {
+       if (instance->ctrl_context) {
                INIT_WORK(&instance->work_init, megasas_fusion_ocr_wq);
                INIT_WORK(&instance->crash_init, megasas_fusion_crash_dump_wq);
        } else
@@ -5301,7 +5517,7 @@ static int megasas_probe_one(struct pci_dev *pdev,
                                pci_alloc_consistent(pdev, sizeof(struct MR_LD_VF_AFFILIATION_111),
                                                     &instance->vf_affiliation_111_h);
                        if (!instance->vf_affiliation_111)
-                               printk(KERN_WARNING "megasas: Can't allocate "
+                               dev_warn(&pdev->dev, "Can't allocate "
                                       "memory for VF affiliation buffer\n");
                } else {
                        instance->vf_affiliation =
@@ -5310,60 +5526,11 @@ static int megasas_probe_one(struct pci_dev *pdev,
                                                     sizeof(struct MR_LD_VF_AFFILIATION),
                                                     &instance->vf_affiliation_h);
                        if (!instance->vf_affiliation)
-                               printk(KERN_WARNING "megasas: Can't allocate "
+                               dev_warn(&pdev->dev, "Can't allocate "
                                       "memory for VF affiliation buffer\n");
                }
        }
 
-retry_irq_register:
-       /*
-        * Register IRQ
-        */
-       if (instance->msix_vectors) {
-               cpu = cpumask_first(cpu_online_mask);
-               for (i = 0; i < instance->msix_vectors; i++) {
-                       instance->irq_context[i].instance = instance;
-                       instance->irq_context[i].MSIxIndex = i;
-                       if (request_irq(instance->msixentry[i].vector,
-                                       instance->instancet->service_isr, 0,
-                                       "megasas",
-                                       &instance->irq_context[i])) {
-                               printk(KERN_DEBUG "megasas: Failed to "
-                                      "register IRQ for vector %d.\n", i);
-                               for (j = 0; j < i; j++) {
-                                       if (smp_affinity_enable)
-                                               irq_set_affinity_hint(
-                                                       instance->msixentry[j].vector, NULL);
-                                       free_irq(
-                                               instance->msixentry[j].vector,
-                                               &instance->irq_context[j]);
-                               }
-                               /* Retry irq register for IO_APIC */
-                               instance->msix_vectors = 0;
-                               goto retry_irq_register;
-                       }
-                       if (smp_affinity_enable) {
-                               if (irq_set_affinity_hint(instance->msixentry[i].vector,
-                                       get_cpu_mask(cpu)))
-                                       dev_err(&instance->pdev->dev,
-                                               "Error setting affinity hint "
-                                               "for cpu %d\n", cpu);
-                               cpu = cpumask_next(cpu, cpu_online_mask);
-                       }
-               }
-       } else {
-               instance->irq_context[0].instance = instance;
-               instance->irq_context[0].MSIxIndex = 0;
-               if (request_irq(pdev->irq, instance->instancet->service_isr,
-                               IRQF_SHARED, "megasas",
-                               &instance->irq_context[0])) {
-                       printk(KERN_DEBUG "megasas: Failed to register IRQ\n");
-                       goto fail_irq;
-               }
-       }
-
-       instance->instancet->enable_intr(instance);
-
        /*
         * Store instance in PCI softstate
         */
@@ -5393,7 +5560,7 @@ retry_irq_register:
         * Initiate AEN (Asynchronous Event Notification)
         */
        if (megasas_start_aen(instance)) {
-               printk(KERN_DEBUG "megasas: start aen failed\n");
+               dev_printk(KERN_DEBUG, &pdev->dev, "start aen failed\n");
                goto fail_start_aen;
        }
 
@@ -5403,35 +5570,23 @@ retry_irq_register:
 
        return 0;
 
-      fail_start_aen:
-      fail_io_attach:
+fail_start_aen:
+fail_io_attach:
        megasas_mgmt_info.count--;
        megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = NULL;
        megasas_mgmt_info.max_index--;
 
        instance->instancet->disable_intr(instance);
-       if (instance->msix_vectors)
-               for (i = 0; i < instance->msix_vectors; i++) {
-                       if (smp_affinity_enable)
-                               irq_set_affinity_hint(
-                                       instance->msixentry[i].vector, NULL);
-                       free_irq(instance->msixentry[i].vector,
-                                &instance->irq_context[i]);
-               }
-       else
-               free_irq(instance->pdev->irq, &instance->irq_context[0]);
-fail_irq:
-       if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) ||
-           (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) ||
-           (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) ||
-           (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY))
+       megasas_destroy_irqs(instance);
+
+       if (instance->ctrl_context)
                megasas_release_fusion(instance);
        else
                megasas_release_mfi(instance);
-      fail_init_mfi:
        if (instance->msix_vectors)
                pci_disable_msix(instance->pdev);
-      fail_alloc_dma_buf:
+fail_init_mfi:
+fail_alloc_dma_buf:
        if (instance->evt_detail)
                pci_free_consistent(pdev, sizeof(struct megasas_evt_detail),
                                    instance->evt_detail,
@@ -5445,8 +5600,8 @@ fail_irq:
                                    instance->consumer_h);
        scsi_host_put(host);
 
-      fail_alloc_instance:
-      fail_set_dma_mask:
+fail_alloc_instance:
+fail_set_dma_mask:
        pci_disable_device(pdev);
 
        return -ENODEV;
@@ -5487,13 +5642,7 @@ static void megasas_flush_cache(struct megasas_instance *instance)
                dev_err(&instance->pdev->dev, "Command timedout"
                        " from %s\n", __func__);
 
-       if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked)
-               megasas_return_mfi_mpt_pthr(instance, cmd,
-                       cmd->mpt_pthr_cmd_blocked);
-       else
-               megasas_return_cmd(instance, cmd);
-
-       return;
+       megasas_return_cmd(instance, cmd);
 }
 
 /**
@@ -5517,10 +5666,14 @@ static void megasas_shutdown_controller(struct megasas_instance *instance,
 
        if (instance->aen_cmd)
                megasas_issue_blocked_abort_cmd(instance,
-                       instance->aen_cmd, 30);
+                       instance->aen_cmd, MEGASAS_BLOCKED_CMD_TIMEOUT);
        if (instance->map_update_cmd)
                megasas_issue_blocked_abort_cmd(instance,
-                       instance->map_update_cmd, 30);
+                       instance->map_update_cmd, MEGASAS_BLOCKED_CMD_TIMEOUT);
+       if (instance->jbod_seq_cmd)
+               megasas_issue_blocked_abort_cmd(instance,
+                       instance->jbod_seq_cmd, MEGASAS_BLOCKED_CMD_TIMEOUT);
+
        dcmd = &cmd->frame->dcmd;
 
        memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
@@ -5538,13 +5691,7 @@ static void megasas_shutdown_controller(struct megasas_instance *instance,
                dev_err(&instance->pdev->dev, "Command timedout"
                        "from %s\n", __func__);
 
-       if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked)
-               megasas_return_mfi_mpt_pthr(instance, cmd,
-                       cmd->mpt_pthr_cmd_blocked);
-       else
-               megasas_return_cmd(instance, cmd);
-
-       return;
+       megasas_return_cmd(instance, cmd);
 }
 
 #ifdef CONFIG_PM
@@ -5558,7 +5705,6 @@ megasas_suspend(struct pci_dev *pdev, pm_message_t state)
 {
        struct Scsi_Host *host;
        struct megasas_instance *instance;
-       int i;
 
        instance = pci_get_drvdata(pdev);
        host = instance->host;
@@ -5583,16 +5729,8 @@ megasas_suspend(struct pci_dev *pdev, pm_message_t state)
        pci_set_drvdata(instance->pdev, instance);
        instance->instancet->disable_intr(instance);
 
-       if (instance->msix_vectors)
-               for (i = 0; i < instance->msix_vectors; i++) {
-                       if (smp_affinity_enable)
-                               irq_set_affinity_hint(
-                                       instance->msixentry[i].vector, NULL);
-                       free_irq(instance->msixentry[i].vector,
-                                &instance->irq_context[i]);
-               }
-       else
-               free_irq(instance->pdev->irq, &instance->irq_context[0]);
+       megasas_destroy_irqs(instance);
+
        if (instance->msix_vectors)
                pci_disable_msix(instance->pdev);
 
@@ -5611,7 +5749,7 @@ megasas_suspend(struct pci_dev *pdev, pm_message_t state)
 static int
 megasas_resume(struct pci_dev *pdev)
 {
-       int rval, i, j, cpu;
+       int rval;
        struct Scsi_Host *host;
        struct megasas_instance *instance;
 
@@ -5627,7 +5765,7 @@ megasas_resume(struct pci_dev *pdev)
        rval = pci_enable_device_mem(pdev);
 
        if (rval) {
-               printk(KERN_ERR "megasas: Enable device failed\n");
+               dev_err(&pdev->dev, "Enable device failed\n");
                return rval;
        }
 
@@ -5654,12 +5792,7 @@ megasas_resume(struct pci_dev *pdev)
                                  instance->msix_vectors))
                goto fail_reenable_msix;
 
-       switch (instance->pdev->device) {
-       case PCI_DEVICE_ID_LSI_FUSION:
-       case PCI_DEVICE_ID_LSI_PLASMA:
-       case PCI_DEVICE_ID_LSI_INVADER:
-       case PCI_DEVICE_ID_LSI_FURY:
-       {
+       if (instance->ctrl_context) {
                megasas_reset_reply_desc(instance);
                if (megasas_ioc_init_fusion(instance)) {
                        megasas_free_cmds(instance);
@@ -5668,63 +5801,20 @@ megasas_resume(struct pci_dev *pdev)
                }
                if (!megasas_get_map_info(instance))
                        megasas_sync_map_info(instance);
-       }
-       break;
-       default:
+       } else {
                *instance->producer = 0;
                *instance->consumer = 0;
                if (megasas_issue_init_mfi(instance))
                        goto fail_init_mfi;
-               break;
        }
 
        tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet,
                     (unsigned long)instance);
 
-       /*
-        * Register IRQ
-        */
-       if (instance->msix_vectors) {
-               cpu = cpumask_first(cpu_online_mask);
-               for (i = 0 ; i < instance->msix_vectors; i++) {
-                       instance->irq_context[i].instance = instance;
-                       instance->irq_context[i].MSIxIndex = i;
-                       if (request_irq(instance->msixentry[i].vector,
-                                       instance->instancet->service_isr, 0,
-                                       "megasas",
-                                       &instance->irq_context[i])) {
-                               printk(KERN_DEBUG "megasas: Failed to "
-                                      "register IRQ for vector %d.\n", i);
-                               for (j = 0; j < i; j++) {
-                                       if (smp_affinity_enable)
-                                               irq_set_affinity_hint(
-                                                       instance->msixentry[j].vector, NULL);
-                                       free_irq(
-                                               instance->msixentry[j].vector,
-                                               &instance->irq_context[j]);
-                               }
-                               goto fail_irq;
-                       }
-
-                       if (smp_affinity_enable) {
-                               if (irq_set_affinity_hint(instance->msixentry[i].vector,
-                                       get_cpu_mask(cpu)))
-                                       dev_err(&instance->pdev->dev, "Error "
-                                               "setting affinity hint for cpu "
-                                               "%d\n", cpu);
-                               cpu = cpumask_next(cpu, cpu_online_mask);
-                       }
-               }
-       } else {
-               instance->irq_context[0].instance = instance;
-               instance->irq_context[0].MSIxIndex = 0;
-               if (request_irq(pdev->irq, instance->instancet->service_isr,
-                               IRQF_SHARED, "megasas",
-                               &instance->irq_context[0])) {
-                       printk(KERN_DEBUG "megasas: Failed to register IRQ\n");
-                       goto fail_irq;
-               }
-       }
+       if (instance->msix_vectors ?
+                       megasas_setup_irqs_msix(instance, 0) :
+                       megasas_setup_irqs_ioapic(instance))
+               goto fail_init_mfi;
 
        /* Re-launch SR-IOV heartbeat timer */
        if (instance->requestorId) {
@@ -5733,22 +5823,24 @@ megasas_resume(struct pci_dev *pdev)
                                            &instance->sriov_heartbeat_timer,
                                            megasas_sriov_heartbeat_handler,
                                            MEGASAS_SRIOV_HEARTBEAT_INTERVAL_VF);
-               else
+               else {
                        instance->skip_heartbeat_timer_del = 1;
+                       goto fail_init_mfi;
+               }
        }
 
        instance->instancet->enable_intr(instance);
+       megasas_setup_jbod_map(instance);
        instance->unload = 0;
 
        /*
         * Initiate AEN (Asynchronous Event Notification)
         */
        if (megasas_start_aen(instance))
-               printk(KERN_ERR "megasas: Start AEN failed\n");
+               dev_err(&instance->pdev->dev, "Start AEN failed\n");
 
        return 0;
 
-fail_irq:
 fail_init_mfi:
        if (instance->evt_detail)
                pci_free_consistent(pdev, sizeof(struct megasas_evt_detail),
@@ -5786,6 +5878,7 @@ static void megasas_detach_one(struct pci_dev *pdev)
        struct Scsi_Host *host;
        struct megasas_instance *instance;
        struct fusion_context *fusion;
+       u32 pd_seq_map_sz;
 
        instance = pci_get_drvdata(pdev);
        instance->unload = 1;
@@ -5829,25 +5922,16 @@ static void megasas_detach_one(struct pci_dev *pdev)
 
        instance->instancet->disable_intr(instance);
 
-       if (instance->msix_vectors)
-               for (i = 0; i < instance->msix_vectors; i++) {
-                       if (smp_affinity_enable)
-                               irq_set_affinity_hint(
-                                       instance->msixentry[i].vector, NULL);
-                       free_irq(instance->msixentry[i].vector,
-                                &instance->irq_context[i]);
-               }
-       else
-               free_irq(instance->pdev->irq, &instance->irq_context[0]);
+       megasas_destroy_irqs(instance);
+
        if (instance->msix_vectors)
                pci_disable_msix(instance->pdev);
 
-       switch (instance->pdev->device) {
-       case PCI_DEVICE_ID_LSI_FUSION:
-       case PCI_DEVICE_ID_LSI_PLASMA:
-       case PCI_DEVICE_ID_LSI_INVADER:
-       case PCI_DEVICE_ID_LSI_FURY:
+       if (instance->ctrl_context) {
                megasas_release_fusion(instance);
+                       pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) +
+                               (sizeof(struct MR_PD_CFG_SEQ) *
+                                       (MAX_PHYSICAL_DEVICES - 1));
                for (i = 0; i < 2 ; i++) {
                        if (fusion->ld_map[i])
                                dma_free_coherent(&instance->pdev->dev,
@@ -5857,11 +5941,15 @@ static void megasas_detach_one(struct pci_dev *pdev)
                        if (fusion->ld_drv_map[i])
                                free_pages((ulong)fusion->ld_drv_map[i],
                                        fusion->drv_map_pages);
+                               if (fusion->pd_seq_sync)
+                                       dma_free_coherent(&instance->pdev->dev,
+                                               pd_seq_map_sz,
+                                               fusion->pd_seq_sync[i],
+                                               fusion->pd_seq_phys[i]);
                }
                free_pages((ulong)instance->ctrl_context,
                        instance->ctrl_context_pages);
-               break;
-       default:
+       } else {
                megasas_release_mfi(instance);
                pci_free_consistent(pdev, sizeof(u32),
                                    instance->producer,
@@ -5869,7 +5957,6 @@ static void megasas_detach_one(struct pci_dev *pdev)
                pci_free_consistent(pdev, sizeof(u32),
                                    instance->consumer,
                                    instance->consumer_h);
-               break;
        }
 
        kfree(instance->ctrl_info);
@@ -5899,11 +5986,13 @@ static void megasas_detach_one(struct pci_dev *pdev)
                pci_free_consistent(pdev, CRASH_DMA_BUF_SIZE,
                            instance->crash_dump_buf, instance->crash_dump_h);
 
+       if (instance->system_info_buf)
+               pci_free_consistent(pdev, sizeof(struct MR_DRV_SYSTEM_INFO),
+                                   instance->system_info_buf, instance->system_info_h);
+
        scsi_host_put(host);
 
        pci_disable_device(pdev);
-
-       return;
 }
 
 /**
@@ -5912,23 +6001,14 @@ static void megasas_detach_one(struct pci_dev *pdev)
  */
 static void megasas_shutdown(struct pci_dev *pdev)
 {
-       int i;
        struct megasas_instance *instance = pci_get_drvdata(pdev);
 
        instance->unload = 1;
        megasas_flush_cache(instance);
        megasas_shutdown_controller(instance, MR_DCMD_CTRL_SHUTDOWN);
        instance->instancet->disable_intr(instance);
-       if (instance->msix_vectors)
-               for (i = 0; i < instance->msix_vectors; i++) {
-                       if (smp_affinity_enable)
-                               irq_set_affinity_hint(
-                                       instance->msixentry[i].vector, NULL);
-                       free_irq(instance->msixentry[i].vector,
-                                &instance->irq_context[i]);
-               }
-       else
-               free_irq(instance->pdev->irq, &instance->irq_context[0]);
+       megasas_destroy_irqs(instance);
+
        if (instance->msix_vectors)
                pci_disable_msix(instance->pdev);
 }
@@ -5981,11 +6061,11 @@ static unsigned int megasas_mgmt_poll(struct file *file, poll_table *wait)
 {
        unsigned int mask;
        unsigned long flags;
+
        poll_wait(file, &megasas_poll_wait, wait);
        spin_lock_irqsave(&poll_aen_lock, flags);
        if (megasas_poll_wait_aen)
-               mask =   (POLLIN | POLLRDNORM);
-
+               mask = (POLLIN | POLLRDNORM);
        else
                mask = 0;
        megasas_poll_wait_aen = 0;
@@ -5999,8 +6079,7 @@ static unsigned int megasas_mgmt_poll(struct file *file, poll_table *wait)
  * @cmd:       MFI command frame
  */
 
-static int megasas_set_crash_dump_params_ioctl(
-       struct megasas_cmd *cmd)
+static int megasas_set_crash_dump_params_ioctl(struct megasas_cmd *cmd)
 {
        struct megasas_instance *local_instance;
        int i, error = 0;
@@ -6054,14 +6133,14 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance,
        memset(kbuff_arr, 0, sizeof(kbuff_arr));
 
        if (ioc->sge_count > MAX_IOCTL_SGE) {
-               printk(KERN_DEBUG "megasas: SGE count [%d] >  max limit [%d]\n",
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "SGE count [%d] >  max limit [%d]\n",
                       ioc->sge_count, MAX_IOCTL_SGE);
                return -EINVAL;
        }
 
        cmd = megasas_get_cmd(instance);
        if (!cmd) {
-               printk(KERN_DEBUG "megasas: Failed to get a cmd packet\n");
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to get a cmd packet\n");
                return -ENOMEM;
        }
 
@@ -6106,8 +6185,8 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance,
                                                    ioc->sgl[i].iov_len,
                                                    &buf_handle, GFP_KERNEL);
                if (!kbuff_arr[i]) {
-                       printk(KERN_DEBUG "megasas: Failed to alloc "
-                              "kernel SGL buffer for IOCTL \n");
+                       dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to alloc "
+                              "kernel SGL buffer for IOCTL\n");
                        error = -ENOMEM;
                        goto out;
                }
@@ -6180,7 +6259,7 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance,
 
                if (copy_to_user((void __user *)((unsigned long)(*sense_ptr)),
                                 sense, ioc->sense_len)) {
-                       printk(KERN_ERR "megasas: Failed to copy out to user "
+                       dev_err(&instance->pdev->dev, "Failed to copy out to user "
                                        "sense data\n");
                        error = -EFAULT;
                        goto out;
@@ -6192,11 +6271,11 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance,
         */
        if (copy_to_user(&user_ioc->frame.hdr.cmd_status,
                         &cmd->frame->hdr.cmd_status, sizeof(u8))) {
-               printk(KERN_DEBUG "megasas: Error copying out cmd_status\n");
+               dev_printk(KERN_DEBUG, &instance->pdev->dev, "Error copying out cmd_status\n");
                error = -EFAULT;
        }
 
-      out:
+out:
        if (sense) {
                dma_free_coherent(&instance->pdev->dev, ioc->sense_len,
                                    sense, sense_handle);
@@ -6211,11 +6290,7 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance,
                        kbuff_arr[i] = NULL;
        }
 
-       if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked)
-               megasas_return_mfi_mpt_pthr(instance, cmd,
-                       cmd->mpt_pthr_cmd_blocked);
-       else
-               megasas_return_cmd(instance, cmd);
+       megasas_return_cmd(instance, cmd);
        return error;
 }
 
@@ -6256,7 +6331,7 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg)
        }
 
        if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) {
-               printk(KERN_ERR "Controller in crit error\n");
+               dev_err(&instance->pdev->dev, "Controller in crit error\n");
                error = -ENODEV;
                goto out_kfree_ioc;
        }
@@ -6281,7 +6356,7 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg)
                spin_unlock_irqrestore(&instance->hba_lock, flags);
 
                if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) {
-                       printk(KERN_NOTICE "megasas: waiting"
+                       dev_notice(&instance->pdev->dev, "waiting"
                                "for controller reset to finish\n");
                }
 
@@ -6292,7 +6367,7 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg)
        if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) {
                spin_unlock_irqrestore(&instance->hba_lock, flags);
 
-               printk(KERN_ERR "megaraid_sas: timed out while"
+               dev_err(&instance->pdev->dev, "timed out while"
                        "waiting for HBA to recover\n");
                error = -ENODEV;
                goto out_up;
@@ -6300,10 +6375,10 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg)
        spin_unlock_irqrestore(&instance->hba_lock, flags);
 
        error = megasas_mgmt_fw_ioctl(instance, user_ioc, ioc);
-      out_up:
+out_up:
        up(&instance->ioctl_sem);
 
-      out_kfree_ioc:
+out_kfree_ioc:
        kfree(ioc);
        return error;
 }
@@ -6351,7 +6426,7 @@ static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg)
                spin_unlock_irqrestore(&instance->hba_lock, flags);
 
                if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) {
-                       printk(KERN_NOTICE "megasas: waiting for"
+                       dev_notice(&instance->pdev->dev, "waiting for"
                                "controller reset to finish\n");
                }
 
@@ -6361,8 +6436,8 @@ static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg)
        spin_lock_irqsave(&instance->hba_lock, flags);
        if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) {
                spin_unlock_irqrestore(&instance->hba_lock, flags);
-               printk(KERN_ERR "megaraid_sas: timed out while waiting"
-                               "for HBA to recover.\n");
+               dev_err(&instance->pdev->dev, "timed out while waiting"
+                               "for HBA to recover\n");
                return -ENODEV;
        }
        spin_unlock_irqrestore(&instance->hba_lock, flags);
@@ -6401,6 +6476,9 @@ static int megasas_mgmt_compat_ioctl_fw(struct file *file, unsigned long arg)
        int i;
        int error = 0;
        compat_uptr_t ptr;
+       unsigned long local_raw_ptr;
+       u32 local_sense_off;
+       u32 local_sense_len;
 
        if (clear_user(ioc, sizeof(*ioc)))
                return -EFAULT;
@@ -6418,9 +6496,15 @@ static int megasas_mgmt_compat_ioctl_fw(struct file *file, unsigned long arg)
         * sense_len is not null, so prepare the 64bit value under
         * the same condition.
         */
-       if (ioc->sense_len) {
+       if (get_user(local_raw_ptr, ioc->frame.raw) ||
+               get_user(local_sense_off, &ioc->sense_off) ||
+               get_user(local_sense_len, &ioc->sense_len))
+               return -EFAULT;
+
+
+       if (local_sense_len) {
                void __user **sense_ioc_ptr =
-                       (void __user **)(ioc->frame.raw + ioc->sense_off);
+                       (void __user **)((u8*)local_raw_ptr + local_sense_off);
                compat_uptr_t *sense_cioc_ptr =
                        (compat_uptr_t *)(cioc->frame.raw + cioc->sense_off);
                if (get_user(ptr, sense_cioc_ptr) ||
@@ -6501,6 +6585,15 @@ static ssize_t megasas_sysfs_show_version(struct device_driver *dd, char *buf)
 
 static DRIVER_ATTR(version, S_IRUGO, megasas_sysfs_show_version, NULL);
 
+static ssize_t
+megasas_sysfs_show_release_date(struct device_driver *dd, char *buf)
+{
+       return snprintf(buf, strlen(MEGASAS_RELDATE) + 2, "%s\n",
+               MEGASAS_RELDATE);
+}
+
+static DRIVER_ATTR(release_date, S_IRUGO, megasas_sysfs_show_release_date, NULL);
+
 static ssize_t
 megasas_sysfs_show_support_poll_for_event(struct device_driver *dd, char *buf)
 {
@@ -6529,7 +6622,8 @@ static ssize_t
 megasas_sysfs_set_dbg_lvl(struct device_driver *dd, const char *buf, size_t count)
 {
        int retval = count;
-       if(sscanf(buf,"%u",&megasas_dbg_lvl)<1){
+
+       if (sscanf(buf, "%u", &megasas_dbg_lvl) < 1) {
                printk(KERN_ERR "megasas: could not set dbg_lvl\n");
                retval = -EINVAL;
        }
@@ -6569,7 +6663,7 @@ megasas_aen_polling(struct work_struct *work)
                if (instance->adprecovery == MEGASAS_HBA_OPERATIONAL)
                        break;
                if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) {
-                       printk(KERN_NOTICE "megasas: %s waiting for "
+                       dev_notice(&instance->pdev->dev, "%s waiting for "
                               "controller reset to finish for scsi%d\n",
                               __func__, instance->host->host_no);
                }
@@ -6579,6 +6673,7 @@ megasas_aen_polling(struct work_struct *work)
        instance->ev = NULL;
        host = instance->host;
        if (instance->evt_detail) {
+               megasas_decode_evt(instance);
 
                switch (le32_to_cpu(instance->evt_detail->code)) {
                case MR_EVT_PD_INSERTED:
@@ -6591,14 +6686,12 @@ megasas_aen_polling(struct work_struct *work)
                                pd_index =
                                (i * MEGASAS_MAX_DEV_PER_CHANNEL) + j;
 
-                               sdev1 =
-                               scsi_device_lookup(host, i, j, 0);
+                               sdev1 = scsi_device_lookup(host, i, j, 0);
 
                                if (instance->pd_list[pd_index].driveState
                                                == MR_PD_STATE_SYSTEM) {
-                                               if (!sdev1) {
+                                       if (!sdev1)
                                                scsi_add_device(host, i, j, 0);
-                                               }
 
                                        if (sdev1)
                                                scsi_device_put(sdev1);
@@ -6619,14 +6712,12 @@ megasas_aen_polling(struct work_struct *work)
                                pd_index =
                                (i * MEGASAS_MAX_DEV_PER_CHANNEL) + j;
 
-                               sdev1 =
-                               scsi_device_lookup(host, i, j, 0);
+                               sdev1 = scsi_device_lookup(host, i, j, 0);
 
                                if (instance->pd_list[pd_index].driveState
                                        == MR_PD_STATE_SYSTEM) {
-                                       if (sdev1) {
+                                       if (sdev1)
                                                scsi_device_put(sdev1);
-                                       }
                                } else {
                                        if (sdev1) {
                                                scsi_remove_device(sdev1);
@@ -6643,8 +6734,7 @@ megasas_aen_polling(struct work_struct *work)
                case MR_EVT_CFG_CLEARED:
                case MR_EVT_LD_DELETED:
                        if (!instance->requestorId ||
-                           (instance->requestorId &&
-                            megasas_get_ld_vf_affiliation(instance, 0))) {
+                           megasas_get_ld_vf_affiliation(instance, 0)) {
                                if (megasas_ld_list_query(instance,
                                                          MR_LD_QUERY_TYPE_EXPOSED_TO_HOST))
                                        megasas_get_ld_list(instance);
@@ -6675,8 +6765,7 @@ megasas_aen_polling(struct work_struct *work)
                        break;
                case MR_EVT_LD_CREATED:
                        if (!instance->requestorId ||
-                           (instance->requestorId &&
-                            megasas_get_ld_vf_affiliation(instance, 0))) {
+                           megasas_get_ld_vf_affiliation(instance, 0)) {
                                if (megasas_ld_list_query(instance,
                                                          MR_LD_QUERY_TYPE_EXPOSED_TO_HOST))
                                        megasas_get_ld_list(instance);
@@ -6706,18 +6795,21 @@ megasas_aen_polling(struct work_struct *work)
                case MR_EVT_LD_STATE_CHANGE:
                        doscan = 1;
                        break;
+               case MR_EVT_CTRL_PROP_CHANGED:
+                       megasas_get_ctrl_info(instance);
+                       break;
                default:
                        doscan = 0;
                        break;
                }
        } else {
-               printk(KERN_ERR "invalid evt_detail!\n");
+               dev_err(&instance->pdev->dev, "invalid evt_detail!\n");
                kfree(ev);
                return;
        }
 
        if (doscan) {
-               printk(KERN_INFO "megaraid_sas: scanning for scsi%d...\n",
+               dev_info(&instance->pdev->dev, "scanning for scsi%d...\n",
                       instance->host->host_no);
                if (megasas_get_pd_list(instance) == 0) {
                        for (i = 0; i < MEGASAS_MAX_PD_CHANNELS; i++) {
@@ -6742,8 +6834,7 @@ megasas_aen_polling(struct work_struct *work)
                }
 
                if (!instance->requestorId ||
-                   (instance->requestorId &&
-                    megasas_get_ld_vf_affiliation(instance, 0))) {
+                   megasas_get_ld_vf_affiliation(instance, 0)) {
                        if (megasas_ld_list_query(instance,
                                                  MR_LD_QUERY_TYPE_EXPOSED_TO_HOST))
                                megasas_get_ld_list(instance);
@@ -6772,7 +6863,7 @@ megasas_aen_polling(struct work_struct *work)
                }
        }
 
-       if ( instance->aen_cmd != NULL ) {
+       if (instance->aen_cmd != NULL) {
                kfree(ev);
                return ;
        }
@@ -6789,7 +6880,7 @@ megasas_aen_polling(struct work_struct *work)
        mutex_unlock(&instance->aen_mutex);
 
        if (error)
-               printk(KERN_ERR "register aen failed error %x\n", error);
+               dev_err(&instance->pdev->dev, "register aen failed error %x\n", error);
 
        kfree(ev);
 }
@@ -6840,6 +6931,11 @@ static int __init megasas_init(void)
        if (rval)
                goto err_dcf_attr_ver;
 
+       rval = driver_create_file(&megasas_pci_driver.driver,
+                                 &driver_attr_release_date);
+       if (rval)
+               goto err_dcf_rel_date;
+
        rval = driver_create_file(&megasas_pci_driver.driver,
                                &driver_attr_support_poll_for_event);
        if (rval)
@@ -6863,6 +6959,9 @@ err_dcf_dbg_lvl:
        driver_remove_file(&megasas_pci_driver.driver,
                        &driver_attr_support_poll_for_event);
 err_dcf_support_poll_for_event:
+       driver_remove_file(&megasas_pci_driver.driver,
+                          &driver_attr_release_date);
+err_dcf_rel_date:
        driver_remove_file(&megasas_pci_driver.driver, &driver_attr_version);
 err_dcf_attr_ver:
        pci_unregister_driver(&megasas_pci_driver);
@@ -6882,6 +6981,8 @@ static void __exit megasas_exit(void)
                        &driver_attr_support_poll_for_event);
        driver_remove_file(&megasas_pci_driver.driver,
                        &driver_attr_support_device_change);
+       driver_remove_file(&megasas_pci_driver.driver,
+                          &driver_attr_release_date);
        driver_remove_file(&megasas_pci_driver.driver, &driver_attr_version);
 
        pci_unregister_driver(&megasas_pci_driver);