/*
  * Returns: QLA_SUCCESS or QLA_FUNCTION_FAILED.
  */
-int
-qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *vha, unsigned int t,
-       uint64_t l, enum nexus_wait_type type)
+static int
+__qla2x00_eh_wait_for_pending_commands(struct qla_qpair *qpair, unsigned int t,
+                                      uint64_t l, enum nexus_wait_type type)
 {
        int cnt, match, status;
        unsigned long flags;
-       struct qla_hw_data *ha = vha->hw;
-       struct req_que *req;
+       scsi_qla_host_t *vha = qpair->vha;
+       struct req_que *req = qpair->req;
        srb_t *sp;
        struct scsi_cmnd *cmd;
 
        status = QLA_SUCCESS;
 
-       spin_lock_irqsave(&ha->hardware_lock, flags);
-       req = vha->req;
+       spin_lock_irqsave(qpair->qp_lock_ptr, flags);
        for (cnt = 1; status == QLA_SUCCESS &&
                cnt < req->num_outstanding_cmds; cnt++) {
                sp = req->outstanding_cmds[cnt];
                if (!match)
                        continue;
 
-               spin_unlock_irqrestore(&ha->hardware_lock, flags);
+               spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
                status = qla2x00_eh_wait_on_command(cmd);
-               spin_lock_irqsave(&ha->hardware_lock, flags);
+               spin_lock_irqsave(qpair->qp_lock_ptr, flags);
        }
-       spin_unlock_irqrestore(&ha->hardware_lock, flags);
+       spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
+
+       return status;
+}
+
+int
+qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *vha, unsigned int t,
+                                    uint64_t l, enum nexus_wait_type type)
+{
+       struct qla_qpair *qpair;
+       struct qla_hw_data *ha = vha->hw;
+       int i, status = QLA_SUCCESS;
 
+       status = __qla2x00_eh_wait_for_pending_commands(ha->base_qpair, t, l,
+                                                       type);
+       for (i = 0; status == QLA_SUCCESS && i < ha->max_qpairs; i++) {
+               qpair = ha->queue_pair_map[i];
+               if (!qpair)
+                       continue;
+               status = __qla2x00_eh_wait_for_pending_commands(qpair, t, l,
+                                                               type);
+       }
        return status;
 }
 
                return err;
 
        if (fcport->deleted)
-               return SUCCESS;
+               return FAILED;
 
        ql_log(ql_log_info, vha, 0x8009,
            "DEVICE RESET ISSUED nexus=%ld:%d:%llu cmd=%p.\n", vha->host_no,
                return err;
 
        if (fcport->deleted)
-               return SUCCESS;
+               return FAILED;
 
        ql_log(ql_log_info, vha, 0x8009,
            "TARGET RESET ISSUED nexus=%ld:%d cmd=%p.\n", vha->host_no,