@@ -198,6 +198,7 @@ static void smc_lgr_free_work(struct work_struct *work)
198198static int smc_lgr_create (struct smc_sock * smc , struct smc_init_info * ini )
199199{
200200 struct smc_link_group * lgr ;
201+ struct list_head * lgr_list ;
201202 struct smc_link * lnk ;
202203 u8 rndvec [3 ];
203204 int rc = 0 ;
@@ -233,6 +234,7 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini)
233234 /* SMC-D specific settings */
234235 lgr -> peer_gid = ini -> ism_gid ;
235236 lgr -> smcd = ini -> ism_dev ;
237+ lgr_list = & ini -> ism_dev -> lgr_list ;
236238 } else {
237239 /* SMC-R specific settings */
238240 lgr -> role = smc -> listen_smc ? SMC_SERV : SMC_CLNT ;
@@ -245,6 +247,7 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini)
245247 lnk -> link_id = SMC_SINGLE_LINK ;
246248 lnk -> smcibdev = ini -> ib_dev ;
247249 lnk -> ibport = ini -> ib_port ;
250+ lgr_list = & smc_lgr_list .list ;
248251 lnk -> path_mtu =
249252 ini -> ib_dev -> pattr [ini -> ib_port - 1 ].active_mtu ;
250253 if (!ini -> ib_dev -> initialized )
@@ -275,7 +278,7 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini)
275278 }
276279 smc -> conn .lgr = lgr ;
277280 spin_lock_bh (& smc_lgr_list .lock );
278- list_add (& lgr -> list , & smc_lgr_list . list );
281+ list_add (& lgr -> list , lgr_list );
279282 spin_unlock_bh (& smc_lgr_list .lock );
280283 return 0 ;
281284
@@ -512,9 +515,8 @@ void smc_smcd_terminate(struct smcd_dev *dev, u64 peer_gid, unsigned short vlan)
512515
513516 /* run common cleanup function and build free list */
514517 spin_lock_bh (& smc_lgr_list .lock );
515- list_for_each_entry_safe (lgr , l , & smc_lgr_list .list , list ) {
516- if (lgr -> is_smcd && lgr -> smcd == dev &&
517- (!peer_gid || lgr -> peer_gid == peer_gid ) &&
518+ list_for_each_entry_safe (lgr , l , & dev -> lgr_list , list ) {
519+ if ((!peer_gid || lgr -> peer_gid == peer_gid ) &&
518520 (vlan == VLAN_VID_MASK || lgr -> vlan_id == vlan )) {
519521 __smc_lgr_terminate (lgr );
520522 list_move (& lgr -> list , & lgr_free_list );
@@ -604,10 +606,12 @@ static bool smcd_lgr_match(struct smc_link_group *lgr,
604606int smc_conn_create (struct smc_sock * smc , struct smc_init_info * ini )
605607{
606608 struct smc_connection * conn = & smc -> conn ;
609+ struct list_head * lgr_list ;
607610 struct smc_link_group * lgr ;
608611 enum smc_lgr_role role ;
609612 int rc = 0 ;
610613
614+ lgr_list = ini -> is_smcd ? & ini -> ism_dev -> lgr_list : & smc_lgr_list .list ;
611615 ini -> cln_first_contact = SMC_FIRST_CONTACT ;
612616 role = smc -> listen_smc ? SMC_SERV : SMC_CLNT ;
613617 if (role == SMC_CLNT && ini -> srv_first_contact )
@@ -616,7 +620,7 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini)
616620
617621 /* determine if an existing link group can be reused */
618622 spin_lock_bh (& smc_lgr_list .lock );
619- list_for_each_entry (lgr , & smc_lgr_list . list , list ) {
623+ list_for_each_entry (lgr , lgr_list , list ) {
620624 write_lock_bh (& lgr -> conns_lock );
621625 if ((ini -> is_smcd ?
622626 smcd_lgr_match (lgr , ini -> ism_dev , ini -> ism_gid ) :
@@ -1029,11 +1033,17 @@ void smc_core_exit(void)
10291033{
10301034 struct smc_link_group * lgr , * lg ;
10311035 LIST_HEAD (lgr_freeing_list );
1036+ struct smcd_dev * smcd ;
10321037
10331038 spin_lock_bh (& smc_lgr_list .lock );
1034- if (!list_empty (& smc_lgr_list .list ))
1035- list_splice_init (& smc_lgr_list .list , & lgr_freeing_list );
1039+ list_splice_init (& smc_lgr_list .list , & lgr_freeing_list );
10361040 spin_unlock_bh (& smc_lgr_list .lock );
1041+
1042+ spin_lock (& smcd_dev_list .lock );
1043+ list_for_each_entry (smcd , & smcd_dev_list .list , list )
1044+ list_splice_init (& smcd -> lgr_list , & lgr_freeing_list );
1045+ spin_unlock (& smcd_dev_list .lock );
1046+
10371047 list_for_each_entry_safe (lgr , lg , & lgr_freeing_list , list ) {
10381048 list_del_init (& lgr -> list );
10391049 if (!lgr -> is_smcd ) {
0 commit comments