@@ -337,46 +337,39 @@ static void smc_copy_sock_settings_to_smc(struct smc_sock *smc)
337
337
smc_copy_sock_settings (& smc -> sk , smc -> clcsock -> sk , SK_FLAGS_CLC_TO_SMC );
338
338
}
339
339
340
- /* register a new rmb, send confirm_rkey msg to register with peer */
341
- static int smcr_link_reg_rmb (struct smc_link * link ,
342
- struct smc_buf_desc * rmb_desc , bool conf_rkey )
343
- {
344
- if (!rmb_desc -> is_reg_mr [link -> link_idx ]) {
345
- /* register memory region for new rmb */
346
- if (smc_wr_reg_send (link , rmb_desc -> mr_rx [link -> link_idx ])) {
347
- rmb_desc -> is_reg_err = true;
348
- return - EFAULT ;
349
- }
350
- rmb_desc -> is_reg_mr [link -> link_idx ] = true;
351
- }
352
- if (!conf_rkey )
353
- return 0 ;
354
-
355
- /* exchange confirm_rkey msg with peer */
356
- if (!rmb_desc -> is_conf_rkey ) {
357
- if (smc_llc_do_confirm_rkey (link , rmb_desc )) {
358
- rmb_desc -> is_reg_err = true;
359
- return - EFAULT ;
360
- }
361
- rmb_desc -> is_conf_rkey = true;
362
- }
363
- return 0 ;
364
- }
365
-
366
340
/* register the new rmb on all links */
367
- static int smcr_lgr_reg_rmbs (struct smc_link_group * lgr ,
341
+ static int smcr_lgr_reg_rmbs (struct smc_link * link ,
368
342
struct smc_buf_desc * rmb_desc )
369
343
{
370
- int i , rc ;
344
+ struct smc_link_group * lgr = link -> lgr ;
345
+ int i , rc = 0 ;
371
346
347
+ rc = smc_llc_flow_initiate (lgr , SMC_LLC_FLOW_RKEY );
348
+ if (rc )
349
+ return rc ;
350
+ /* protect against parallel smc_llc_cli_rkey_exchange() and
351
+ * parallel smcr_link_reg_rmb()
352
+ */
353
+ mutex_lock (& lgr -> llc_conf_mutex );
372
354
for (i = 0 ; i < SMC_LINKS_PER_LGR_MAX ; i ++ ) {
373
355
if (lgr -> lnk [i ].state != SMC_LNK_ACTIVE )
374
356
continue ;
375
- rc = smcr_link_reg_rmb (& lgr -> lnk [i ], rmb_desc , true );
357
+ rc = smcr_link_reg_rmb (& lgr -> lnk [i ], rmb_desc );
376
358
if (rc )
377
- return rc ;
359
+ goto out ;
378
360
}
379
- return 0 ;
361
+
362
+ /* exchange confirm_rkey msg with peer */
363
+ rc = smc_llc_do_confirm_rkey (link , rmb_desc );
364
+ if (rc ) {
365
+ rc = - EFAULT ;
366
+ goto out ;
367
+ }
368
+ rmb_desc -> is_conf_rkey = true;
369
+ out :
370
+ mutex_unlock (& lgr -> llc_conf_mutex );
371
+ smc_llc_flow_stop (lgr , & lgr -> llc_flow_lcl );
372
+ return rc ;
380
373
}
381
374
382
375
static int smcr_clnt_conf_first_link (struct smc_sock * smc )
@@ -408,7 +401,7 @@ static int smcr_clnt_conf_first_link(struct smc_sock *smc)
408
401
409
402
smc_wr_remember_qp_attr (link );
410
403
411
- if (smcr_link_reg_rmb (link , smc -> conn .rmb_desc , false ))
404
+ if (smcr_link_reg_rmb (link , smc -> conn .rmb_desc ))
412
405
return SMC_CLC_DECL_ERR_REGRMB ;
413
406
414
407
/* confirm_rkey is implicit on 1st contact */
@@ -670,7 +663,7 @@ static int smc_connect_rdma(struct smc_sock *smc,
670
663
return smc_connect_abort (smc , SMC_CLC_DECL_ERR_RDYLNK ,
671
664
ini -> cln_first_contact );
672
665
} else {
673
- if (smcr_lgr_reg_rmbs (smc -> conn . lgr , smc -> conn .rmb_desc ))
666
+ if (smcr_lgr_reg_rmbs (link , smc -> conn .rmb_desc ))
674
667
return smc_connect_abort (smc , SMC_CLC_DECL_ERR_REGRMB ,
675
668
ini -> cln_first_contact );
676
669
}
@@ -1045,7 +1038,7 @@ static int smcr_serv_conf_first_link(struct smc_sock *smc)
1045
1038
1046
1039
link -> lgr -> type = SMC_LGR_SINGLE ;
1047
1040
1048
- if (smcr_link_reg_rmb (link , smc -> conn .rmb_desc , false ))
1041
+ if (smcr_link_reg_rmb (link , smc -> conn .rmb_desc ))
1049
1042
return SMC_CLC_DECL_ERR_REGRMB ;
1050
1043
1051
1044
/* send CONFIRM LINK request to client over the RoCE fabric */
@@ -1220,7 +1213,7 @@ static int smc_listen_rdma_reg(struct smc_sock *new_smc, int local_contact)
1220
1213
struct smc_connection * conn = & new_smc -> conn ;
1221
1214
1222
1215
if (local_contact != SMC_FIRST_CONTACT ) {
1223
- if (smcr_lgr_reg_rmbs (conn -> lgr , conn -> rmb_desc ))
1216
+ if (smcr_lgr_reg_rmbs (conn -> lnk , conn -> rmb_desc ))
1224
1217
return SMC_CLC_DECL_ERR_REGRMB ;
1225
1218
}
1226
1219
smc_rmb_sync_sg_for_device (& new_smc -> conn );
0 commit comments