@@ -170,17 +170,14 @@ __fnic_set_state_flags(struct fnic *fnic, unsigned long st_flags,
170170 unsigned long clearbits )
171171{
172172 unsigned long flags = 0 ;
173- unsigned long host_lock_flags = 0 ;
174173
175174 spin_lock_irqsave (& fnic -> fnic_lock , flags );
176- spin_lock_irqsave (fnic -> lport -> host -> host_lock , host_lock_flags );
177175
178176 if (clearbits )
179177 fnic -> state_flags &= ~st_flags ;
180178 else
181179 fnic -> state_flags |= st_flags ;
182180
183- spin_unlock_irqrestore (fnic -> lport -> host -> host_lock , host_lock_flags );
184181 spin_unlock_irqrestore (& fnic -> fnic_lock , flags );
185182
186183 return ;
@@ -427,14 +424,27 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
427424 int io_lock_acquired = 0 ;
428425 struct fc_rport_libfc_priv * rp ;
429426
430- if (unlikely (fnic_chk_state_flags_locked (fnic , FNIC_FLAGS_IO_BLOCKED )))
427+ spin_lock_irqsave (& fnic -> fnic_lock , flags );
428+
429+ if (unlikely (fnic_chk_state_flags_locked (fnic , FNIC_FLAGS_IO_BLOCKED ))) {
430+ spin_unlock_irqrestore (& fnic -> fnic_lock , flags );
431+ FNIC_SCSI_DBG (KERN_ERR , fnic -> lport -> host ,
432+ "fnic<%d>: %s: %d: fnic IO blocked flags: 0x%lx. Returning SCSI_MLQUEUE_HOST_BUSY\n" ,
433+ fnic -> fnic_num , __func__ , __LINE__ , fnic -> state_flags );
431434 return SCSI_MLQUEUE_HOST_BUSY ;
435+ }
432436
433- if (unlikely (fnic_chk_state_flags_locked (fnic , FNIC_FLAGS_FWRESET )))
437+ if (unlikely (fnic_chk_state_flags_locked (fnic , FNIC_FLAGS_FWRESET ))) {
438+ spin_unlock_irqrestore (& fnic -> fnic_lock , flags );
439+ FNIC_SCSI_DBG (KERN_ERR , fnic -> lport -> host ,
440+ "fnic<%d>: %s: %d: fnic flags: 0x%lx. Returning SCSI_MLQUEUE_HOST_BUSY\n" ,
441+ fnic -> fnic_num , __func__ , __LINE__ , fnic -> state_flags );
434442 return SCSI_MLQUEUE_HOST_BUSY ;
443+ }
435444
436445 rport = starget_to_rport (scsi_target (sc -> device ));
437446 if (!rport ) {
447+ spin_unlock_irqrestore (& fnic -> fnic_lock , flags );
438448 FNIC_SCSI_DBG (KERN_DEBUG , fnic -> lport -> host ,
439449 "returning DID_NO_CONNECT for IO as rport is NULL\n" );
440450 sc -> result = DID_NO_CONNECT << 16 ;
@@ -444,6 +454,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
444454
445455 ret = fc_remote_port_chkready (rport );
446456 if (ret ) {
457+ spin_unlock_irqrestore (& fnic -> fnic_lock , flags );
447458 FNIC_SCSI_DBG (KERN_DEBUG , fnic -> lport -> host ,
448459 "rport is not ready\n" );
449460 atomic64_inc (& fnic_stats -> misc_stats .rport_not_ready );
@@ -454,6 +465,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
454465
455466 rp = rport -> dd_data ;
456467 if (!rp || rp -> rp_state == RPORT_ST_DELETE ) {
468+ spin_unlock_irqrestore (& fnic -> fnic_lock , flags );
457469 FNIC_SCSI_DBG (KERN_DEBUG , fnic -> lport -> host ,
458470 "rport 0x%x removed, returning DID_NO_CONNECT\n" ,
459471 rport -> port_id );
@@ -465,6 +477,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
465477 }
466478
467479 if (rp -> rp_state != RPORT_ST_READY ) {
480+ spin_unlock_irqrestore (& fnic -> fnic_lock , flags );
468481 FNIC_SCSI_DBG (KERN_DEBUG , fnic -> lport -> host ,
469482 "rport 0x%x in state 0x%x, returning DID_IMM_RETRY\n" ,
470483 rport -> port_id , rp -> rp_state );
@@ -474,17 +487,17 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
474487 return 0 ;
475488 }
476489
477- if (lp -> state != LPORT_ST_READY || !(lp -> link_up ))
490+ if (lp -> state != LPORT_ST_READY || !(lp -> link_up )) {
491+ spin_unlock_irqrestore (& fnic -> fnic_lock , flags );
492+ FNIC_SCSI_DBG (KERN_ERR , fnic -> lport -> host ,
493+ "fnic<%d>: %s: %d: state not ready: %d/link not up: %d Returning HOST_BUSY\n" ,
494+ fnic -> fnic_num , __func__ , __LINE__ , lp -> state , lp -> link_up );
478495 return SCSI_MLQUEUE_HOST_BUSY ;
496+ }
479497
480498 atomic_inc (& fnic -> in_flight );
481499
482- /*
483- * Release host lock, use driver resource specific locks from here.
484- * Don't re-enable interrupts in case they were disabled prior to the
485- * caller disabling them.
486- */
487- spin_unlock (lp -> host -> host_lock );
500+ spin_unlock_irqrestore (& fnic -> fnic_lock , flags );
488501 fnic_priv (sc )-> state = FNIC_IOREQ_NOT_INITED ;
489502 fnic_priv (sc )-> flags = FNIC_NO_FLAGS ;
490503
@@ -569,8 +582,6 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
569582 mempool_free (io_req , fnic -> io_req_pool );
570583 }
571584 atomic_dec (& fnic -> in_flight );
572- /* acquire host lock before returning to SCSI */
573- spin_lock (lp -> host -> host_lock );
574585 return ret ;
575586 } else {
576587 atomic64_inc (& fnic_stats -> io_stats .active_ios );
@@ -598,8 +609,6 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
598609 spin_unlock_irqrestore (io_lock , flags );
599610
600611 atomic_dec (& fnic -> in_flight );
601- /* acquire host lock before returning to SCSI */
602- spin_lock (lp -> host -> host_lock );
603612 return ret ;
604613}
605614
@@ -1493,18 +1502,17 @@ static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag,
14931502 struct fnic_io_req * io_req )
14941503{
14951504 struct vnic_wq_copy * wq = & fnic -> hw_copy_wq [0 ];
1496- struct Scsi_Host * host = fnic -> lport -> host ;
14971505 struct misc_stats * misc_stats = & fnic -> fnic_stats .misc_stats ;
14981506 unsigned long flags ;
14991507
1500- spin_lock_irqsave (host -> host_lock , flags );
1508+ spin_lock_irqsave (& fnic -> fnic_lock , flags );
15011509 if (unlikely (fnic_chk_state_flags_locked (fnic ,
15021510 FNIC_FLAGS_IO_BLOCKED ))) {
1503- spin_unlock_irqrestore (host -> host_lock , flags );
1511+ spin_unlock_irqrestore (& fnic -> fnic_lock , flags );
15041512 return 1 ;
15051513 } else
15061514 atomic_inc (& fnic -> in_flight );
1507- spin_unlock_irqrestore (host -> host_lock , flags );
1515+ spin_unlock_irqrestore (& fnic -> fnic_lock , flags );
15081516
15091517 spin_lock_irqsave (& fnic -> wq_copy_lock [0 ], flags );
15101518
@@ -1939,7 +1947,6 @@ static inline int fnic_queue_dr_io_req(struct fnic *fnic,
19391947 struct fnic_io_req * io_req )
19401948{
19411949 struct vnic_wq_copy * wq = & fnic -> hw_copy_wq [0 ];
1942- struct Scsi_Host * host = fnic -> lport -> host ;
19431950 struct misc_stats * misc_stats = & fnic -> fnic_stats .misc_stats ;
19441951 struct scsi_lun fc_lun ;
19451952 int ret = 0 ;
@@ -1949,14 +1956,14 @@ static inline int fnic_queue_dr_io_req(struct fnic *fnic,
19491956 if (tag == SCSI_NO_TAG )
19501957 tag = io_req -> tag ;
19511958
1952- spin_lock_irqsave (host -> host_lock , intr_flags );
1959+ spin_lock_irqsave (& fnic -> fnic_lock , intr_flags );
19531960 if (unlikely (fnic_chk_state_flags_locked (fnic ,
19541961 FNIC_FLAGS_IO_BLOCKED ))) {
1955- spin_unlock_irqrestore (host -> host_lock , intr_flags );
1962+ spin_unlock_irqrestore (& fnic -> fnic_lock , intr_flags );
19561963 return FAILED ;
19571964 } else
19581965 atomic_inc (& fnic -> in_flight );
1959- spin_unlock_irqrestore (host -> host_lock , intr_flags );
1966+ spin_unlock_irqrestore (& fnic -> fnic_lock , intr_flags );
19601967
19611968 spin_lock_irqsave (& fnic -> wq_copy_lock [0 ], intr_flags );
19621969
0 commit comments