aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx/qla_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_init.c')
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c94
1 files changed, 81 insertions, 13 deletions
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index d863ed2619b5..9c383baebe27 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -69,21 +69,29 @@ qla2x00_ctx_sp_free(srb_t *sp)
69{ 69{
70 struct srb_ctx *ctx = sp->ctx; 70 struct srb_ctx *ctx = sp->ctx;
71 struct srb_iocb *iocb = ctx->u.iocb_cmd; 71 struct srb_iocb *iocb = ctx->u.iocb_cmd;
72 struct scsi_qla_host *vha = sp->fcport->vha;
72 73
73 del_timer_sync(&iocb->timer); 74 del_timer_sync(&iocb->timer);
74 kfree(iocb); 75 kfree(iocb);
75 kfree(ctx); 76 kfree(ctx);
76 mempool_free(sp, sp->fcport->vha->hw->srb_mempool); 77 mempool_free(sp, sp->fcport->vha->hw->srb_mempool);
78
79 QLA_VHA_MARK_NOT_BUSY(vha);
77} 80}
78 81
79inline srb_t * 82inline srb_t *
80qla2x00_get_ctx_sp(scsi_qla_host_t *vha, fc_port_t *fcport, size_t size, 83qla2x00_get_ctx_sp(scsi_qla_host_t *vha, fc_port_t *fcport, size_t size,
81 unsigned long tmo) 84 unsigned long tmo)
82{ 85{
83 srb_t *sp; 86 srb_t *sp = NULL;
84 struct qla_hw_data *ha = vha->hw; 87 struct qla_hw_data *ha = vha->hw;
85 struct srb_ctx *ctx; 88 struct srb_ctx *ctx;
86 struct srb_iocb *iocb; 89 struct srb_iocb *iocb;
90 uint8_t bail;
91
92 QLA_VHA_MARK_BUSY(vha, bail);
93 if (bail)
94 return NULL;
87 95
88 sp = mempool_alloc(ha->srb_mempool, GFP_KERNEL); 96 sp = mempool_alloc(ha->srb_mempool, GFP_KERNEL);
89 if (!sp) 97 if (!sp)
@@ -116,6 +124,8 @@ qla2x00_get_ctx_sp(scsi_qla_host_t *vha, fc_port_t *fcport, size_t size,
116 iocb->timer.function = qla2x00_ctx_sp_timeout; 124 iocb->timer.function = qla2x00_ctx_sp_timeout;
117 add_timer(&iocb->timer); 125 add_timer(&iocb->timer);
118done: 126done:
127 if (!sp)
128 QLA_VHA_MARK_NOT_BUSY(vha);
119 return sp; 129 return sp;
120} 130}
121 131
@@ -1777,11 +1787,15 @@ qla2x00_init_rings(scsi_qla_host_t *vha)
1777 qla2x00_init_response_q_entries(rsp); 1787 qla2x00_init_response_q_entries(rsp);
1778 } 1788 }
1779 1789
1790 spin_lock_irqsave(&ha->vport_slock, flags);
1780 /* Clear RSCN queue. */ 1791 /* Clear RSCN queue. */
1781 list_for_each_entry(vp, &ha->vp_list, list) { 1792 list_for_each_entry(vp, &ha->vp_list, list) {
1782 vp->rscn_in_ptr = 0; 1793 vp->rscn_in_ptr = 0;
1783 vp->rscn_out_ptr = 0; 1794 vp->rscn_out_ptr = 0;
1784 } 1795 }
1796
1797 spin_unlock_irqrestore(&ha->vport_slock, flags);
1798
1785 ha->isp_ops->config_rings(vha); 1799 ha->isp_ops->config_rings(vha);
1786 1800
1787 spin_unlock_irqrestore(&ha->hardware_lock, flags); 1801 spin_unlock_irqrestore(&ha->hardware_lock, flags);
@@ -3218,12 +3232,17 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
3218 /* Bypass virtual ports of the same host. */ 3232 /* Bypass virtual ports of the same host. */
3219 found = 0; 3233 found = 0;
3220 if (ha->num_vhosts) { 3234 if (ha->num_vhosts) {
3235 unsigned long flags;
3236
3237 spin_lock_irqsave(&ha->vport_slock, flags);
3221 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) { 3238 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) {
3222 if (new_fcport->d_id.b24 == vp->d_id.b24) { 3239 if (new_fcport->d_id.b24 == vp->d_id.b24) {
3223 found = 1; 3240 found = 1;
3224 break; 3241 break;
3225 } 3242 }
3226 } 3243 }
3244 spin_unlock_irqrestore(&ha->vport_slock, flags);
3245
3227 if (found) 3246 if (found)
3228 continue; 3247 continue;
3229 } 3248 }
@@ -3343,6 +3362,7 @@ qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t *dev)
3343 struct qla_hw_data *ha = vha->hw; 3362 struct qla_hw_data *ha = vha->hw;
3344 struct scsi_qla_host *vp; 3363 struct scsi_qla_host *vp;
3345 struct scsi_qla_host *tvp; 3364 struct scsi_qla_host *tvp;
3365 unsigned long flags = 0;
3346 3366
3347 rval = QLA_SUCCESS; 3367 rval = QLA_SUCCESS;
3348 3368
@@ -3367,6 +3387,8 @@ qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t *dev)
3367 /* Check for loop ID being already in use. */ 3387 /* Check for loop ID being already in use. */
3368 found = 0; 3388 found = 0;
3369 fcport = NULL; 3389 fcport = NULL;
3390
3391 spin_lock_irqsave(&ha->vport_slock, flags);
3370 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) { 3392 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) {
3371 list_for_each_entry(fcport, &vp->vp_fcports, list) { 3393 list_for_each_entry(fcport, &vp->vp_fcports, list) {
3372 if (fcport->loop_id == dev->loop_id && 3394 if (fcport->loop_id == dev->loop_id &&
@@ -3379,6 +3401,7 @@ qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t *dev)
3379 if (found) 3401 if (found)
3380 break; 3402 break;
3381 } 3403 }
3404 spin_unlock_irqrestore(&ha->vport_slock, flags);
3382 3405
3383 /* If not in use then it is free to use. */ 3406 /* If not in use then it is free to use. */
3384 if (!found) { 3407 if (!found) {
@@ -3791,14 +3814,27 @@ void
3791qla2x00_update_fcports(scsi_qla_host_t *base_vha) 3814qla2x00_update_fcports(scsi_qla_host_t *base_vha)
3792{ 3815{
3793 fc_port_t *fcport; 3816 fc_port_t *fcport;
3794 struct scsi_qla_host *tvp, *vha; 3817 struct scsi_qla_host *vha;
3818 struct qla_hw_data *ha = base_vha->hw;
3819 unsigned long flags;
3795 3820
3821 spin_lock_irqsave(&ha->vport_slock, flags);
3796 /* Go with deferred removal of rport references. */ 3822 /* Go with deferred removal of rport references. */
3797 list_for_each_entry_safe(vha, tvp, &base_vha->hw->vp_list, list) 3823 list_for_each_entry(vha, &base_vha->hw->vp_list, list) {
3798 list_for_each_entry(fcport, &vha->vp_fcports, list) 3824 atomic_inc(&vha->vref_count);
3825 list_for_each_entry(fcport, &vha->vp_fcports, list) {
3799 if (fcport && fcport->drport && 3826 if (fcport && fcport->drport &&
3800 atomic_read(&fcport->state) != FCS_UNCONFIGURED) 3827 atomic_read(&fcport->state) != FCS_UNCONFIGURED) {
3828 spin_unlock_irqrestore(&ha->vport_slock, flags);
3829
3801 qla2x00_rport_del(fcport); 3830 qla2x00_rport_del(fcport);
3831
3832 spin_lock_irqsave(&ha->vport_slock, flags);
3833 }
3834 }
3835 atomic_dec(&vha->vref_count);
3836 }
3837 spin_unlock_irqrestore(&ha->vport_slock, flags);
3802} 3838}
3803 3839
3804void 3840void
@@ -3806,7 +3842,7 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha)
3806{ 3842{
3807 struct qla_hw_data *ha = vha->hw; 3843 struct qla_hw_data *ha = vha->hw;
3808 struct scsi_qla_host *vp, *base_vha = pci_get_drvdata(ha->pdev); 3844 struct scsi_qla_host *vp, *base_vha = pci_get_drvdata(ha->pdev);
3809 struct scsi_qla_host *tvp; 3845 unsigned long flags;
3810 3846
3811 vha->flags.online = 0; 3847 vha->flags.online = 0;
3812 ha->flags.chip_reset_done = 0; 3848 ha->flags.chip_reset_done = 0;
@@ -3824,8 +3860,18 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha)
3824 if (atomic_read(&vha->loop_state) != LOOP_DOWN) { 3860 if (atomic_read(&vha->loop_state) != LOOP_DOWN) {
3825 atomic_set(&vha->loop_state, LOOP_DOWN); 3861 atomic_set(&vha->loop_state, LOOP_DOWN);
3826 qla2x00_mark_all_devices_lost(vha, 0); 3862 qla2x00_mark_all_devices_lost(vha, 0);
3827 list_for_each_entry_safe(vp, tvp, &base_vha->hw->vp_list, list) 3863
3864 spin_lock_irqsave(&ha->vport_slock, flags);
3865 list_for_each_entry(vp, &base_vha->hw->vp_list, list) {
3866 atomic_inc(&vp->vref_count);
3867 spin_unlock_irqrestore(&ha->vport_slock, flags);
3868
3828 qla2x00_mark_all_devices_lost(vp, 0); 3869 qla2x00_mark_all_devices_lost(vp, 0);
3870
3871 spin_lock_irqsave(&ha->vport_slock, flags);
3872 atomic_dec(&vp->vref_count);
3873 }
3874 spin_unlock_irqrestore(&ha->vport_slock, flags);
3829 } else { 3875 } else {
3830 if (!atomic_read(&vha->loop_down_timer)) 3876 if (!atomic_read(&vha->loop_down_timer))
3831 atomic_set(&vha->loop_down_timer, 3877 atomic_set(&vha->loop_down_timer,
@@ -3862,8 +3908,8 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
3862 uint8_t status = 0; 3908 uint8_t status = 0;
3863 struct qla_hw_data *ha = vha->hw; 3909 struct qla_hw_data *ha = vha->hw;
3864 struct scsi_qla_host *vp; 3910 struct scsi_qla_host *vp;
3865 struct scsi_qla_host *tvp;
3866 struct req_que *req = ha->req_q_map[0]; 3911 struct req_que *req = ha->req_q_map[0];
3912 unsigned long flags;
3867 3913
3868 if (vha->flags.online) { 3914 if (vha->flags.online) {
3869 qla2x00_abort_isp_cleanup(vha); 3915 qla2x00_abort_isp_cleanup(vha);
@@ -3970,10 +4016,21 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
3970 DEBUG(printk(KERN_INFO 4016 DEBUG(printk(KERN_INFO
3971 "qla2x00_abort_isp(%ld): succeeded.\n", 4017 "qla2x00_abort_isp(%ld): succeeded.\n",
3972 vha->host_no)); 4018 vha->host_no));
3973 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) { 4019
3974 if (vp->vp_idx) 4020 spin_lock_irqsave(&ha->vport_slock, flags);
4021 list_for_each_entry(vp, &ha->vp_list, list) {
4022 if (vp->vp_idx) {
4023 atomic_inc(&vp->vref_count);
4024 spin_unlock_irqrestore(&ha->vport_slock, flags);
4025
3975 qla2x00_vp_abort_isp(vp); 4026 qla2x00_vp_abort_isp(vp);
4027
4028 spin_lock_irqsave(&ha->vport_slock, flags);
4029 atomic_dec(&vp->vref_count);
4030 }
3976 } 4031 }
4032 spin_unlock_irqrestore(&ha->vport_slock, flags);
4033
3977 } else { 4034 } else {
3978 qla_printk(KERN_INFO, ha, 4035 qla_printk(KERN_INFO, ha,
3979 "qla2x00_abort_isp: **** FAILED ****\n"); 4036 "qla2x00_abort_isp: **** FAILED ****\n");
@@ -5185,7 +5242,7 @@ qla82xx_restart_isp(scsi_qla_host_t *vha)
5185 struct req_que *req = ha->req_q_map[0]; 5242 struct req_que *req = ha->req_q_map[0];
5186 struct rsp_que *rsp = ha->rsp_q_map[0]; 5243 struct rsp_que *rsp = ha->rsp_q_map[0];
5187 struct scsi_qla_host *vp; 5244 struct scsi_qla_host *vp;
5188 struct scsi_qla_host *tvp; 5245 unsigned long flags;
5189 5246
5190 status = qla2x00_init_rings(vha); 5247 status = qla2x00_init_rings(vha);
5191 if (!status) { 5248 if (!status) {
@@ -5272,10 +5329,21 @@ qla82xx_restart_isp(scsi_qla_host_t *vha)
5272 DEBUG(printk(KERN_INFO 5329 DEBUG(printk(KERN_INFO
5273 "qla82xx_restart_isp(%ld): succeeded.\n", 5330 "qla82xx_restart_isp(%ld): succeeded.\n",
5274 vha->host_no)); 5331 vha->host_no));
5275 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) { 5332
5276 if (vp->vp_idx) 5333 spin_lock_irqsave(&ha->vport_slock, flags);
5334 list_for_each_entry(vp, &ha->vp_list, list) {
5335 if (vp->vp_idx) {
5336 atomic_inc(&vp->vref_count);
5337 spin_unlock_irqrestore(&ha->vport_slock, flags);
5338
5277 qla2x00_vp_abort_isp(vp); 5339 qla2x00_vp_abort_isp(vp);
5340
5341 spin_lock_irqsave(&ha->vport_slock, flags);
5342 atomic_dec(&vp->vref_count);
5343 }
5278 } 5344 }
5345 spin_unlock_irqrestore(&ha->vport_slock, flags);
5346
5279 } else { 5347 } else {
5280 qla_printk(KERN_INFO, ha, 5348 qla_printk(KERN_INFO, ha,
5281 "qla82xx_restart_isp: **** FAILED ****\n"); 5349 "qla82xx_restart_isp: **** FAILED ****\n");