]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[SCSI] mptfusion : dv performance fix
authorMoore, Eric Dean <Eric.Moore@lsil.com>
Thu, 1 Dec 2005 17:50:32 +0000 (10:50 -0700)
committerJames Bottomley <jejb@mulgrave.(none)>
Thu, 1 Dec 2005 21:59:51 +0000 (15:59 -0600)
Syncronization for Domain Validation workqueue and the initiation of the
alternate controller.  Its possible that dv could be terminated if the
workqueue on the 1st channel doesn complete in time before the 2nd channel
begins initialization.

Signed-off-by: Eric Moore <Eric.Moore@lsil.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/message/fusion/mptbase.c
drivers/message/fusion/mptbase.h
drivers/message/fusion/mptscsih.c

index 74022316fc63403392c7783ac13fc8226e098ceb..cabf35373cfd01311d48e6a0f2462c5ed27758e6 100644 (file)
@@ -1118,6 +1118,65 @@ mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp)
        return -1;
 }
 
+int
+mpt_alt_ioc_wait(MPT_ADAPTER *ioc)
+{
+       int loop_count = 30 * 4;  /* Wait 30 seconds */
+       int status = -1; /* -1 means failed to get board READY */
+
+       do {
+               spin_lock(&ioc->initializing_hba_lock);
+               if (ioc->initializing_hba_lock_flag == 0) {
+                       ioc->initializing_hba_lock_flag=1;
+                       spin_unlock(&ioc->initializing_hba_lock);
+                       status = 0;
+                       break;
+               }
+               spin_unlock(&ioc->initializing_hba_lock);
+               set_current_state(TASK_INTERRUPTIBLE);
+               schedule_timeout(HZ/4);
+       } while (--loop_count);
+
+       return status;
+}
+
+/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
+/*
+ *     mpt_bringup_adapter - This is a wrapper function for mpt_do_ioc_recovery
+ *     @ioc: Pointer to MPT adapter structure
+ *     @sleepFlag: Use schedule if CAN_SLEEP else use udelay.
+ *
+ *     This routine performs all the steps necessary to bring the IOC
+ *     to a OPERATIONAL state.
+ *
+ *      Special Note: This function was added with spin lock's so as to allow
+ *      the dv(domain validation) work thread to succeed on the other channel
+ *      that maybe occuring at the same time when this function is called.
+ *      Without this lock, the dv would fail when message frames were
+ *      requested during hba bringup on the alternate ioc.
+ */
+static int
+mpt_bringup_adapter(MPT_ADAPTER *ioc, int sleepFlag)
+{
+       int r;
+
+       if(ioc->alt_ioc) {
+               if((r=mpt_alt_ioc_wait(ioc->alt_ioc)!=0))
+                       return r;
+       }
+
+       r = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_BRINGUP,
+           CAN_SLEEP);
+
+       if(ioc->alt_ioc) {
+               spin_lock(&ioc->alt_ioc->initializing_hba_lock);
+               ioc->alt_ioc->initializing_hba_lock_flag=0;
+               spin_unlock(&ioc->alt_ioc->initializing_hba_lock);
+       }
+
+return r;
+}
+
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /*
  *     mpt_attach - Install a PCI intelligent MPT adapter.
@@ -1186,6 +1245,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
        ioc->pcidev = pdev;
        ioc->diagPending = 0;
        spin_lock_init(&ioc->diagLock);
+       spin_lock_init(&ioc->initializing_hba_lock);
 
        /* Initialize the event logging.
         */
@@ -1408,8 +1468,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
         */
        mpt_detect_bound_ports(ioc, pdev);
 
-       if ((r = mpt_do_ioc_recovery(ioc,
-         MPT_HOSTEVENT_IOC_BRINGUP, CAN_SLEEP)) != 0) {
+       if ((r = mpt_bringup_adapter(ioc, CAN_SLEEP)) != 0){
                printk(KERN_WARNING MYNAM
                  ": WARNING - %s did not initialize properly! (%d)\n",
                  ioc->name, r);
@@ -6296,6 +6355,7 @@ EXPORT_SYMBOL(mpt_read_ioc_pg_3);
 EXPORT_SYMBOL(mpt_alloc_fw_memory);
 EXPORT_SYMBOL(mpt_free_fw_memory);
 EXPORT_SYMBOL(mptbase_sas_persist_operation);
+EXPORT_SYMBOL(mpt_alt_ioc_wait);
 
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
index 8ad277a9afa16a37906045a522a7b9ca4e21a7f4..a564ae36a2c2ec0b8dfcabd4be77602cbb30147f 100644 (file)
@@ -611,6 +611,8 @@ typedef struct _MPT_ADAPTER
        int                      DoneCtx;
        int                      TaskCtx;
        int                      InternalCtx;
+       spinlock_t               initializing_hba_lock;
+       int                      initializing_hba_lock_flag;
        struct list_head         list;
        struct net_device       *netdev;
        struct list_head         sas_topology;
@@ -1001,6 +1003,7 @@ extern void        mpt_free_fw_memory(MPT_ADAPTER *ioc);
 extern int      mpt_findImVolumes(MPT_ADAPTER *ioc);
 extern int      mpt_read_ioc_pg_3(MPT_ADAPTER *ioc);
 extern int      mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode);
+extern int      mpt_alt_ioc_wait(MPT_ADAPTER *ioc);
 
 /*
  *  Public data decl's...
index 4330ed0cedaaaafbc2a435b73c1b42b4aadc43d9..b7b9846ff3fd960859bd077f2716e95a9ab23dd7 100644 (file)
@@ -4162,6 +4162,12 @@ mptscsih_domainValidation(void *arg)
                                                }
                                        }
 
+                                       if(mpt_alt_ioc_wait(hd->ioc)!=0) {
+                                               ddvprintk((MYIOC_s_WARN_FMT "alt_ioc busy!\n",
+                                                   hd->ioc->name));
+                                               continue;
+                                       }
+
                                        if (mptscsih_doDv(hd, 0, id) == 1) {
                                                /* Untagged device was busy, try again
                                                 */
@@ -4173,6 +4179,10 @@ mptscsih_domainValidation(void *arg)
                                                hd->ioc->spi_data.dvStatus[id] &= ~(MPT_SCSICFG_DV_NOT_DONE | MPT_SCSICFG_DV_PENDING);
                                        }
 
+                                       spin_lock(&hd->ioc->initializing_hba_lock);
+                                       hd->ioc->initializing_hba_lock_flag=0;
+                                       spin_unlock(&hd->ioc->initializing_hba_lock);
+
                                        if (isPhysDisk) {
                                                for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) {
                                                        if (hd->ioc->raid_data.isRaid & (1 << ii)) {