]> err.no Git - linux-2.6/blobdiff - drivers/scsi/qla2xxx/qla_mid.c
Merge branches 'at91', 'dyntick', 'ep93xx', 'iop', 'ixp', 'misc', 'orion', 'omap...
[linux-2.6] / drivers / scsi / qla2xxx / qla_mid.c
index dea37689b7d407c65eb9adfb42be6813c1854f92..62a3ad6e8ecb0d1a0c457e3617019b39298344ba 100644 (file)
@@ -1,20 +1,8 @@
 /*
- *                  QLOGIC LINUX SOFTWARE
- *
- * QLogic ISP2x00 device driver for Linux 2.6.x
- * Copyright (C) 2003-2005 QLogic Corporation
- * (www.qlogic.com)
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
+ * QLogic Fibre Channel HBA Driver
+ * Copyright (c)  2003-2008 QLogic Corporation
  *
+ * See LICENSE.qla2xxx for copyright and licensing details.
  */
 #include "qla_def.h"
 
@@ -28,8 +16,6 @@
 #include <scsi/scsicam.h>
 #include <linux/delay.h>
 
-void qla2x00_vp_stop_timer(scsi_qla_host_t *);
-
 void
 qla2x00_vp_stop_timer(scsi_qla_host_t *vha)
 {
@@ -39,19 +25,19 @@ qla2x00_vp_stop_timer(scsi_qla_host_t *vha)
        }
 }
 
-uint32_t
+static uint32_t
 qla24xx_allocate_vp_id(scsi_qla_host_t *vha)
 {
        uint32_t vp_id;
        scsi_qla_host_t *ha = vha->parent;
 
        /* Find an empty slot and assign an vp_id */
-       down(&ha->vport_sem);
+       mutex_lock(&ha->vport_lock);
        vp_id = find_first_zero_bit(ha->vp_idx_map, ha->max_npiv_vports + 1);
        if (vp_id > ha->max_npiv_vports) {
                DEBUG15(printk ("vp_id %d is bigger than max-supported %d.\n",
                    vp_id, ha->max_npiv_vports));
-               up(&ha->vport_sem);
+               mutex_unlock(&ha->vport_lock);
                return vp_id;
        }
 
@@ -59,7 +45,7 @@ qla24xx_allocate_vp_id(scsi_qla_host_t *vha)
        ha->num_vhosts++;
        vha->vp_idx = vp_id;
        list_add_tail(&vha->vp_list, &ha->vp_list);
-       up(&ha->vport_sem);
+       mutex_unlock(&ha->vport_lock);
        return vp_id;
 }
 
@@ -69,15 +55,15 @@ qla24xx_deallocate_vp_id(scsi_qla_host_t *vha)
        uint16_t vp_id;
        scsi_qla_host_t *ha = vha->parent;
 
-       down(&ha->vport_sem);
+       mutex_lock(&ha->vport_lock);
        vp_id = vha->vp_idx;
        ha->num_vhosts--;
        clear_bit(vp_id, ha->vp_idx_map);
        list_del(&vha->vp_list);
-       up(&ha->vport_sem);
+       mutex_unlock(&ha->vport_lock);
 }
 
-scsi_qla_host_t *
+static scsi_qla_host_t *
 qla24xx_find_vhost_by_name(scsi_qla_host_t *ha, uint8_t *port_name)
 {
        scsi_qla_host_t *vha;
@@ -159,9 +145,9 @@ qla24xx_enable_vp(scsi_qla_host_t *vha)
        }
 
        /* Initialize the new vport unless it is a persistent port */
-       down(&ha->vport_sem);
+       mutex_lock(&ha->vport_lock);
        ret = qla24xx_modify_vp_config(vha);
-       up(&ha->vport_sem);
+       mutex_unlock(&ha->vport_lock);
 
        if (ret != QLA_SUCCESS) {
                fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED);
@@ -265,12 +251,20 @@ qla2x00_vp_abort_isp(scsi_qla_host_t *vha)
        qla24xx_enable_vp(vha);
 }
 
-int
+static int
 qla2x00_do_dpc_vp(scsi_qla_host_t *vha)
 {
+       scsi_qla_host_t *ha = vha->parent;
+
        if (test_and_clear_bit(VP_IDX_ACQUIRED, &vha->vp_flags)) {
                /* VP acquired. complete port configuration */
-               qla24xx_configure_vp(vha);
+               if (atomic_read(&ha->loop_state) == LOOP_READY) {
+                       qla24xx_configure_vp(vha);
+               } else {
+                       set_bit(VP_IDX_ACQUIRED, &vha->vp_flags);
+                       set_bit(VP_DPC_NEEDED, &ha->dpc_flags);
+               }
+
                return 0;
        }
 
@@ -412,6 +406,7 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
        INIT_LIST_HEAD(&vha->list);
        INIT_LIST_HEAD(&vha->fcports);
        INIT_LIST_HEAD(&vha->vp_fcports);
+       INIT_LIST_HEAD(&vha->work_list);
 
        vha->dpc_flags = 0L;
        set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags);
@@ -443,10 +438,10 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
        vha->flags.init_done = 1;
        num_hosts++;
 
-       down(&ha->vport_sem);
+       mutex_lock(&ha->vport_lock);
        set_bit(vha->vp_idx, ha->vp_idx_map);
        ha->cur_vport_count++;
-       up(&ha->vport_sem);
+       mutex_unlock(&ha->vport_lock);
 
        return vha;