@@ -75,8 +75,6 @@ int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport)
7575
7676 fcport -> nvme_remote_port -> private = fcport ;
7777 fcport -> nvme_flag |= NVME_FLAG_REGISTERED ;
78- atomic_set (& fcport -> nvme_ref_count , 1 );
79- init_waitqueue_head (& fcport -> nvme_waitq );
8078 rport -> fcport = fcport ;
8179 list_add_tail (& rport -> list , & vha -> nvme_rport_list );
8280 return 0 ;
@@ -233,7 +231,6 @@ static int qla_nvme_ls_req(struct nvme_fc_local_port *lport,
233231 sp -> name = "nvme_ls" ;
234232 sp -> done = qla_nvme_sp_ls_done ;
235233 atomic_set (& sp -> ref_count , 1 );
236- init_waitqueue_head (& sp -> nvme_ls_waitq );
237234 nvme = & sp -> u .iocb_cmd ;
238235 priv -> sp = sp ;
239236 priv -> fd = fd ;
@@ -540,12 +537,10 @@ static void qla_nvme_localport_delete(struct nvme_fc_local_port *lport)
540537{
541538 struct scsi_qla_host * vha = lport -> private ;
542539
543- atomic_dec (& vha -> nvme_ref_count );
544- wake_up_all (& vha -> nvme_waitq );
545-
546540 ql_log (ql_log_info , vha , 0x210f ,
547541 "localport delete of %p completed.\n" , vha -> nvme_local_port );
548542 vha -> nvme_local_port = NULL ;
543+ complete (& vha -> nvme_del_done );
549544}
550545
551546static void qla_nvme_remoteport_delete (struct nvme_fc_remote_port * rport )
@@ -556,8 +551,6 @@ static void qla_nvme_remoteport_delete(struct nvme_fc_remote_port *rport)
556551 fcport = rport -> private ;
557552 fcport -> nvme_remote_port = NULL ;
558553 fcport -> nvme_flag &= ~NVME_FLAG_REGISTERED ;
559- atomic_dec (& fcport -> nvme_ref_count );
560- wake_up_all (& fcport -> nvme_waitq );
561554
562555 list_for_each_entry_safe (r_port , trport ,
563556 & fcport -> vha -> nvme_rport_list , list ) {
@@ -567,6 +560,7 @@ static void qla_nvme_remoteport_delete(struct nvme_fc_remote_port *rport)
567560 }
568561 }
569562 kfree (r_port );
563+ complete (& fcport -> nvme_del_done );
570564
571565 ql_log (ql_log_info , fcport -> vha , 0x2110 ,
572566 "remoteport_delete of %p completed.\n" , fcport );
@@ -609,12 +603,11 @@ static int qla_nvme_wait_on_command(srb_t *sp)
609603static int qla_nvme_wait_on_rport_del (fc_port_t * fcport )
610604{
611605 int ret = QLA_SUCCESS ;
606+ int timeout ;
612607
613- wait_event_timeout (fcport -> nvme_waitq ,
614- atomic_read (& fcport -> nvme_ref_count ),
615- NVME_ABORT_POLLING_PERIOD * HZ );
616-
617- if (atomic_read (& fcport -> nvme_ref_count )) {
608+ timeout = wait_for_completion_timeout (& fcport -> nvme_del_done ,
609+ msecs_to_jiffies (2000 ));
610+ if (!timeout ) {
618611 ret = QLA_FUNCTION_FAILED ;
619612 ql_log (ql_log_info , fcport -> vha , 0x2111 ,
620613 "timed out waiting for fcport=%p to delete\n" , fcport );
@@ -633,39 +626,6 @@ void qla_nvme_abort(struct qla_hw_data *ha, struct srb *sp)
633626 "nvme_wait_on_comand timed out waiting on sp=%p\n" , sp );
634627}
635628
636- static void qla_nvme_abort_all (fc_port_t * fcport )
637- {
638- int que , cnt ;
639- unsigned long flags ;
640- srb_t * sp ;
641- struct qla_hw_data * ha = fcport -> vha -> hw ;
642- struct req_que * req ;
643-
644- spin_lock_irqsave (& ha -> hardware_lock , flags );
645- for (que = 0 ; que < ha -> max_req_queues ; que ++ ) {
646- req = ha -> req_q_map [que ];
647- if (!req )
648- continue ;
649- if (!req -> outstanding_cmds )
650- continue ;
651- for (cnt = 1 ; cnt < req -> num_outstanding_cmds ; cnt ++ ) {
652- sp = req -> outstanding_cmds [cnt ];
653- if ((sp ) && ((sp -> type == SRB_NVME_CMD ) ||
654- (sp -> type == SRB_NVME_LS )) &&
655- (sp -> fcport == fcport )) {
656- atomic_inc (& sp -> ref_count );
657- spin_unlock_irqrestore (& ha -> hardware_lock ,
658- flags );
659- qla_nvme_abort (ha , sp );
660- spin_lock_irqsave (& ha -> hardware_lock , flags );
661- req -> outstanding_cmds [cnt ] = NULL ;
662- sp -> done (sp , 1 );
663- }
664- }
665- }
666- spin_unlock_irqrestore (& ha -> hardware_lock , flags );
667- }
668-
669629static void qla_nvme_unregister_remote_port (struct work_struct * work )
670630{
671631 struct fc_port * fcport = container_of (work , struct fc_port ,
@@ -701,12 +661,13 @@ void qla_nvme_delete(struct scsi_qla_host *vha)
701661 ql_log (ql_log_info , fcport -> vha , 0x2114 , "%s: fcport=%p\n" ,
702662 __func__ , fcport );
703663
664+ init_completion (& fcport -> nvme_del_done );
704665 nvme_fc_unregister_remoteport (fcport -> nvme_remote_port );
705666 qla_nvme_wait_on_rport_del (fcport );
706- qla_nvme_abort_all (fcport );
707667 }
708668
709669 if (vha -> nvme_local_port ) {
670+ init_completion (& vha -> nvme_del_done );
710671 nv_ret = nvme_fc_unregister_localport (vha -> nvme_local_port );
711672 if (nv_ret == 0 )
712673 ql_log (ql_log_info , vha , 0x2116 ,
@@ -715,6 +676,8 @@ void qla_nvme_delete(struct scsi_qla_host *vha)
715676 else
716677 ql_log (ql_log_info , vha , 0x2115 ,
717678 "Unregister of localport failed\n" );
679+ wait_for_completion_timeout (& vha -> nvme_del_done ,
680+ msecs_to_jiffies (5000 ));
718681 }
719682}
720683
@@ -755,7 +718,5 @@ void qla_nvme_register_hba(struct scsi_qla_host *vha)
755718 "register_localport failed: ret=%x\n" , ret );
756719 return ;
757720 }
758- atomic_set (& vha -> nvme_ref_count , 1 );
759721 vha -> nvme_local_port -> private = vha ;
760- init_waitqueue_head (& vha -> nvme_waitq );
761722}
0 commit comments