]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
scsi: qla2xxx: Fix Management Server NPort handle reservation logic
authorQuinn Tran <quinn.tran@cavium.com>
Thu, 2 Aug 2018 20:16:53 +0000 (13:16 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 2 Aug 2018 20:56:18 +0000 (16:56 -0400)
After selecting the NPort handle/loop_id, set a bit in the loop_id_map to
prevent others from selecting the same NPort handle.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/qla2xxx/qla_gbl.h
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_mid.c
drivers/scsi/qla2xxx/qla_os.c

index f68eb60965592e2539caf409380a753cbe832a4e..00fbd49a9a7ade75ba6e200df055ace18844ed08 100644 (file)
@@ -118,6 +118,7 @@ extern int qla2x00_post_async_prlo_done_work(struct scsi_qla_host *,
     fc_port_t *, uint16_t *);
 int qla_post_iidma_work(struct scsi_qla_host *vha, fc_port_t *fcport);
 void qla_do_iidma_work(struct scsi_qla_host *vha, fc_port_t *fcport);
+int qla2x00_reserve_mgmt_server_loop_id(scsi_qla_host_t *);
 /*
  * Global Data in qla_os.c source file.
  */
index a10a8bb895e9c7cdc6ccce88de1c604de104eeb7..9d1a8b2c41a9b257007ce8c5fbc762b8b607e948 100644 (file)
@@ -5616,6 +5616,34 @@ qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t *dev)
 }
 
 
+/* FW does not set aside Loop id for MGMT Server/FFFFFAh */
+int
+qla2x00_reserve_mgmt_server_loop_id(scsi_qla_host_t *vha)
+{
+       int loop_id = FC_NO_LOOP_ID;
+       int lid = NPH_MGMT_SERVER - vha->vp_idx;
+       unsigned long flags;
+       struct qla_hw_data *ha = vha->hw;
+
+       if (vha->vp_idx == 0) {
+               set_bit(NPH_MGMT_SERVER, ha->loop_id_map);
+               return NPH_MGMT_SERVER;
+       }
+
+       /* pick id from high and work down to low */
+       spin_lock_irqsave(&ha->vport_slock, flags);
+       for (; lid > 0; lid--) {
+               if (!test_bit(lid, vha->hw->loop_id_map)) {
+                       set_bit(lid, vha->hw->loop_id_map);
+                       loop_id = lid;
+                       break;
+               }
+       }
+       spin_unlock_irqrestore(&ha->vport_slock, flags);
+
+       return loop_id;
+}
+
 /*
  * qla2x00_fabric_login
  *     Issue fabric login command.
index f6f0a759a7c248eb403873c01fc9d4d912cced60..14bc88bc4a5a02fc1307acccbd11b40bf0fa2bbc 100644 (file)
@@ -485,7 +485,7 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
                    "Couldn't allocate vp_id.\n");
                goto create_vhost_failed;
        }
-       vha->mgmt_svr_loop_id = NPH_MGMT_SERVER;
+       vha->mgmt_svr_loop_id = qla2x00_reserve_mgmt_server_loop_id(vha);
 
        vha->dpc_flags = 0L;
 
index 04e0c7f51e68ee627a99c2378a5ab4e04a906e10..48d1003c8178b6e3b0718a25914b81f7507b21f9 100644 (file)
@@ -3048,7 +3048,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
        host = base_vha->host;
        base_vha->req = req;
        if (IS_QLA2XXX_MIDTYPE(ha))
-               base_vha->mgmt_svr_loop_id = NPH_MGMT_SERVER;
+               base_vha->mgmt_svr_loop_id =
+                       qla2x00_reserve_mgmt_server_loop_id(base_vha);
        else
                base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER +
                                                base_vha->vp_idx;