[SCSI] qla2xxx: Additional NPIV corrections.

Minor fixes addressing:
- rport managements during vport deletion.
- acquire proper physical-ha during qla24xx_abort_command() and
qla24xx_queuecommand()
- do not needlessly acquire the pha for non-NPIV capable ISPs.

Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>

authored by

Andrew Vasquez and committed by
James Bottomley
c9c5ced9 bf6583b5

+19 -12
+5
drivers/scsi/qla2xxx/qla_attr.c
··· 1177 qla24xx_vport_delete(struct fc_vport *fc_vport) 1178 { 1179 scsi_qla_host_t *vha = fc_vport->dd_data; 1180 1181 qla24xx_disable_vp(vha); 1182 qla24xx_deallocate_vp_id(vha);
··· 1177 qla24xx_vport_delete(struct fc_vport *fc_vport) 1178 { 1179 scsi_qla_host_t *vha = fc_vport->dd_data; 1180 + scsi_qla_host_t *pha = to_qla_parent(vha); 1181 + 1182 + while (test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags) || 1183 + test_bit(FCPORT_UPDATE_NEEDED, &pha->dpc_flags)) 1184 + msleep(1000); 1185 1186 qla24xx_disable_vp(vha); 1187 qla24xx_deallocate_vp_id(vha);
+2 -1
drivers/scsi/qla2xxx/qla_init.c
··· 3231 3232 /* Go with deferred removal of rport references. */ 3233 list_for_each_entry(fcport, &ha->fcports, list) 3234 - if (fcport->drport) 3235 qla2x00_rport_del(fcport); 3236 } 3237
··· 3231 3232 /* Go with deferred removal of rport references. */ 3233 list_for_each_entry(fcport, &ha->fcports, list) 3234 + if (fcport->drport && 3235 + atomic_read(&fcport->state) != FCS_UNCONFIGURED) 3236 qla2x00_rport_del(fcport); 3237 } 3238
+4 -5
drivers/scsi/qla2xxx/qla_iocb.c
··· 269 { 270 int ret, nseg; 271 unsigned long flags; 272 - scsi_qla_host_t *ha, *pha; 273 struct scsi_cmnd *cmd; 274 uint32_t *clr_ptr; 275 uint32_t index; ··· 283 /* Setup device pointers. */ 284 ret = 0; 285 ha = sp->ha; 286 - pha = to_qla_parent(ha); 287 reg = &ha->iobase->isp; 288 cmd = sp->cmd; 289 /* So we know we haven't pci_map'ed anything yet */ ··· 297 } 298 299 /* Acquire ring specific lock */ 300 - spin_lock_irqsave(&pha->hardware_lock, flags); 301 302 /* Check for room in outstanding command list. */ 303 handle = ha->current_outstanding_cmd; ··· 386 ha->response_ring_ptr->signature != RESPONSE_PROCESSED) 387 qla2x00_process_response_queue(ha); 388 389 - spin_unlock_irqrestore(&pha->hardware_lock, flags); 390 return (QLA_SUCCESS); 391 392 queuing_error: 393 if (tot_dsds) 394 scsi_dma_unmap(cmd); 395 396 - spin_unlock_irqrestore(&pha->hardware_lock, flags); 397 398 return (QLA_FUNCTION_FAILED); 399 }
··· 269 { 270 int ret, nseg; 271 unsigned long flags; 272 + scsi_qla_host_t *ha; 273 struct scsi_cmnd *cmd; 274 uint32_t *clr_ptr; 275 uint32_t index; ··· 283 /* Setup device pointers. */ 284 ret = 0; 285 ha = sp->ha; 286 reg = &ha->iobase->isp; 287 cmd = sp->cmd; 288 /* So we know we haven't pci_map'ed anything yet */ ··· 298 } 299 300 /* Acquire ring specific lock */ 301 + spin_lock_irqsave(&ha->hardware_lock, flags); 302 303 /* Check for room in outstanding command list. */ 304 handle = ha->current_outstanding_cmd; ··· 387 ha->response_ring_ptr->signature != RESPONSE_PROCESSED) 388 qla2x00_process_response_queue(ha); 389 390 + spin_unlock_irqrestore(&ha->hardware_lock, flags); 391 return (QLA_SUCCESS); 392 393 queuing_error: 394 if (tot_dsds) 395 scsi_dma_unmap(cmd); 396 397 + spin_unlock_irqrestore(&ha->hardware_lock, flags); 398 399 return (QLA_FUNCTION_FAILED); 400 }
+3 -4
drivers/scsi/qla2xxx/qla_mbx.c
··· 749 uint32_t handle; 750 mbx_cmd_t mc; 751 mbx_cmd_t *mcp = &mc; 752 - scsi_qla_host_t *pha = to_qla_parent(ha); 753 754 DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", ha->host_no)); 755 756 fcport = sp->fcport; 757 758 - spin_lock_irqsave(&pha->hardware_lock, flags); 759 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { 760 if (ha->outstanding_cmds[handle] == sp) 761 break; 762 } 763 - spin_unlock_irqrestore(&pha->hardware_lock, flags); 764 765 if (handle == MAX_OUTSTANDING_COMMANDS) { 766 /* command not found */ ··· 2171 2172 spin_lock_irqsave(&pha->hardware_lock, flags); 2173 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { 2174 - if (ha->outstanding_cmds[handle] == sp) 2175 break; 2176 } 2177 spin_unlock_irqrestore(&pha->hardware_lock, flags);
··· 749 uint32_t handle; 750 mbx_cmd_t mc; 751 mbx_cmd_t *mcp = &mc; 752 753 DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", ha->host_no)); 754 755 fcport = sp->fcport; 756 757 + spin_lock_irqsave(&ha->hardware_lock, flags); 758 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { 759 if (ha->outstanding_cmds[handle] == sp) 760 break; 761 } 762 + spin_unlock_irqrestore(&ha->hardware_lock, flags); 763 764 if (handle == MAX_OUTSTANDING_COMMANDS) { 765 /* command not found */ ··· 2172 2173 spin_lock_irqsave(&pha->hardware_lock, flags); 2174 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { 2175 + if (pha->outstanding_cmds[handle] == sp) 2176 break; 2177 } 2178 spin_unlock_irqrestore(&pha->hardware_lock, flags);
+1
drivers/scsi/qla2xxx/qla_mid.c
··· 106 vha->host_no, fcport->loop_id, fcport->vp_idx)); 107 108 qla2x00_mark_device_lost(vha, fcport, 0, 0); 109 } 110 } 111
··· 106 vha->host_no, fcport->loop_id, fcport->vp_idx)); 107 108 qla2x00_mark_device_lost(vha, fcport, 0, 0); 109 + atomic_set(&fcport->state, FCS_UNCONFIGURED); 110 } 111 } 112
+4 -2
drivers/scsi/qla2xxx/qla_os.c
··· 449 int rval; 450 scsi_qla_host_t *pha = to_qla_parent(ha); 451 452 - if (unlikely(pci_channel_offline(ha->pdev))) { 453 cmd->result = DID_REQUEUE << 16; 454 goto qc24_fail_command; 455 } ··· 2335 ha->host_no)); 2336 } 2337 2338 - if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags)) 2339 qla2x00_update_fcports(ha); 2340 2341 if (test_and_clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags) && 2342 (!(test_and_set_bit(RESET_ACTIVE, &ha->dpc_flags)))) {
··· 449 int rval; 450 scsi_qla_host_t *pha = to_qla_parent(ha); 451 452 + if (unlikely(pci_channel_offline(pha->pdev))) { 453 cmd->result = DID_REQUEUE << 16; 454 goto qc24_fail_command; 455 } ··· 2335 ha->host_no)); 2336 } 2337 2338 + if (test_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags)) { 2339 qla2x00_update_fcports(ha); 2340 + clear_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags); 2341 + } 2342 2343 if (test_and_clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags) && 2344 (!(test_and_set_bit(RESET_ACTIVE, &ha->dpc_flags)))) {