@@ -318,11 +318,18 @@ static struct fc_seq *qedf_elsct_send(struct fc_lport *lport, u32 did,
318318 */
319319 if (resp == fc_lport_flogi_resp ) {
320320 qedf -> flogi_cnt ++ ;
321+ qedf -> flogi_pending ++ ;
322+
323+ if (test_bit (QEDF_UNLOADING , & qedf -> flags )) {
324+ QEDF_ERR (& qedf -> dbg_ctx , "Driver unloading\n" );
325+ qedf -> flogi_pending = 0 ;
326+ }
327+
321328 if (qedf -> flogi_pending >= QEDF_FLOGI_RETRY_CNT ) {
322329 schedule_delayed_work (& qedf -> stag_work , 2 );
323330 return NULL ;
324331 }
325- qedf -> flogi_pending ++ ;
332+
326333 return fc_elsct_send (lport , did , fp , op , qedf_flogi_resp ,
327334 arg , timeout );
328335 }
@@ -912,13 +919,14 @@ void qedf_ctx_soft_reset(struct fc_lport *lport)
912919 struct qedf_ctx * qedf ;
913920 struct qed_link_output if_link ;
914921
922+ qedf = lport_priv (lport );
923+
915924 if (lport -> vport ) {
925+ clear_bit (QEDF_STAG_IN_PROGRESS , & qedf -> flags );
916926 printk_ratelimited ("Cannot issue host reset on NPIV port.\n" );
917927 return ;
918928 }
919929
920- qedf = lport_priv (lport );
921-
922930 qedf -> flogi_pending = 0 ;
923931 /* For host reset, essentially do a soft link up/down */
924932 atomic_set (& qedf -> link_state , QEDF_LINK_DOWN );
@@ -938,6 +946,7 @@ void qedf_ctx_soft_reset(struct fc_lport *lport)
938946 if (!if_link .link_up ) {
939947 QEDF_INFO (& qedf -> dbg_ctx , QEDF_LOG_DISC ,
940948 "Physical link is not up.\n" );
949+ clear_bit (QEDF_STAG_IN_PROGRESS , & qedf -> flags );
941950 return ;
942951 }
943952 /* Flush and wait to make sure link down is processed */
@@ -950,6 +959,7 @@ void qedf_ctx_soft_reset(struct fc_lport *lport)
950959 "Queue link up work.\n" );
951960 queue_delayed_work (qedf -> link_update_wq , & qedf -> link_update ,
952961 0 );
962+ clear_bit (QEDF_STAG_IN_PROGRESS , & qedf -> flags );
953963}
954964
955965/* Reset the host by gracefully logging out and then logging back in */
@@ -3463,6 +3473,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
34633473 }
34643474
34653475 /* Start the Slowpath-process */
3476+ memset (& slowpath_params , 0 , sizeof (struct qed_slowpath_params ));
34663477 slowpath_params .int_mode = QED_INT_MODE_MSIX ;
34673478 slowpath_params .drv_major = QEDF_DRIVER_MAJOR_VER ;
34683479 slowpath_params .drv_minor = QEDF_DRIVER_MINOR_VER ;
@@ -3721,6 +3732,7 @@ static void __qedf_remove(struct pci_dev *pdev, int mode)
37213732{
37223733 struct qedf_ctx * qedf ;
37233734 int rc ;
3735+ int cnt = 0 ;
37243736
37253737 if (!pdev ) {
37263738 QEDF_ERR (NULL , "pdev is NULL.\n" );
@@ -3738,6 +3750,17 @@ static void __qedf_remove(struct pci_dev *pdev, int mode)
37383750 return ;
37393751 }
37403752
3753+ stag_in_prog :
3754+ if (test_bit (QEDF_STAG_IN_PROGRESS , & qedf -> flags )) {
3755+ QEDF_ERR (& qedf -> dbg_ctx , "Stag in progress, cnt=%d.\n" , cnt );
3756+ cnt ++ ;
3757+
3758+ if (cnt < 5 ) {
3759+ msleep (500 );
3760+ goto stag_in_prog ;
3761+ }
3762+ }
3763+
37413764 if (mode != QEDF_MODE_RECOVERY )
37423765 set_bit (QEDF_UNLOADING , & qedf -> flags );
37433766
@@ -3997,6 +4020,24 @@ void qedf_stag_change_work(struct work_struct *work)
39974020 struct qedf_ctx * qedf =
39984021 container_of (work , struct qedf_ctx , stag_work .work );
39994022
4023+ if (!qedf ) {
4024+ QEDF_ERR (& qedf -> dbg_ctx , "qedf is NULL" );
4025+ return ;
4026+ }
4027+
4028+ if (test_bit (QEDF_IN_RECOVERY , & qedf -> flags )) {
4029+ QEDF_ERR (& qedf -> dbg_ctx ,
4030+ "Already is in recovery, hence not calling software context reset.\n" );
4031+ return ;
4032+ }
4033+
4034+ if (test_bit (QEDF_UNLOADING , & qedf -> flags )) {
4035+ QEDF_ERR (& qedf -> dbg_ctx , "Driver unloading\n" );
4036+ return ;
4037+ }
4038+
4039+ set_bit (QEDF_STAG_IN_PROGRESS , & qedf -> flags );
4040+
40004041 printk_ratelimited ("[%s]:[%s:%d]:%d: Performing software context reset." ,
40014042 dev_name (& qedf -> pdev -> dev ), __func__ , __LINE__ ,
40024043 qedf -> dbg_ctx .host_no );
0 commit comments