@@ -648,9 +648,10 @@ static int init_one_port(opal_list_t *btl_list, mca_btl_openib_device_t *device,
648648 sizeof (mca_btl_openib_module ));
649649 ib_selected = OBJ_NEW (mca_btl_base_selected_module_t );
650650 ib_selected -> btl_module = (mca_btl_base_module_t * ) openib_btl ;
651- openib_btl -> device = device ;
652651 openib_btl -> port_num = (uint8_t ) port_num ;
653652 openib_btl -> allowed = false;
653+ openib_btl -> device = NULL ;
654+ openib_btl -> device_name = strdup (ibv_get_device_name (device -> ib_dev ));
654655 OBJ_CONSTRUCT (& openib_btl -> ib_lock , opal_mutex_t );
655656 opal_list_append (btl_list , (opal_list_item_t * ) ib_selected );
656657 opal_pointer_array_add (device -> device_btls , (void * ) openib_btl );
@@ -784,6 +785,7 @@ static int init_one_port(opal_list_t *btl_list, mca_btl_openib_device_t *device,
784785 ib_selected = OBJ_NEW (mca_btl_base_selected_module_t );
785786 ib_selected -> btl_module = (mca_btl_base_module_t * ) openib_btl ;
786787 openib_btl -> device = device ;
788+ openib_btl -> device_name = NULL ;
787789 openib_btl -> port_num = (uint8_t ) port_num ;
788790 openib_btl -> pkey_index = pkey_index ;
789791 openib_btl -> lid = lid ;
@@ -904,6 +906,7 @@ static int init_one_port(opal_list_t *btl_list, mca_btl_openib_device_t *device,
904906 opal_list_append (btl_list , (opal_list_item_t * ) ib_selected );
905907 opal_pointer_array_add (device -> device_btls , (void * ) openib_btl );
906908 ++ device -> btls ;
909+ ++ device -> allowed_btls ;
907910 ++ mca_btl_openib_component .ib_num_btls ;
908911 ++ mca_btl_openib_component .ib_allowed_btls ;
909912 if (-1 != mca_btl_openib_component .ib_max_btls &&
@@ -1933,7 +1936,7 @@ static int init_one_device(opal_list_t *btl_list, struct ibv_device* ib_dev)
19331936 if (ib_port_attr .active_mtu < device -> mtu ){
19341937 device -> mtu = ib_port_attr .active_mtu ;
19351938 }
1936- if (mca_btl_openib_component .apm_ports && device -> btls > 0 ) {
1939+ if (mca_btl_openib_component .apm_ports && device -> allowed_btls > 0 ) {
19371940 init_apm_port (device , i , ib_port_attr .lid );
19381941 break ;
19391942 }
@@ -1969,7 +1972,7 @@ static int init_one_device(opal_list_t *btl_list, struct ibv_device* ib_dev)
19691972
19701973 /* If we made a BTL, check APM status and return. Otherwise, fall
19711974 through and destroy everything */
1972- if (device -> btls > 0 ) {
1975+ if (device -> allowed_btls > 0 ) {
19731976 /* if apm was enabled it should be > 1 */
19741977 if (1 == mca_btl_openib_component .apm_ports ) {
19751978 opal_show_help ("help-mpi-btl-openib.txt" ,
@@ -2290,6 +2293,11 @@ static int init_one_device(opal_list_t *btl_list, struct ibv_device* ib_dev)
22902293 good :
22912294 mca_btl_openib_component .devices_count ++ ;
22922295 return OPAL_SUCCESS ;
2296+ } else if (device -> btls > 0 ) {
2297+ /* no port is allowed to be used by btl/openib,
2298+ * so release the device right away */
2299+ OBJ_RELEASE (device );
2300+ return OPAL_SUCCESS ;
22932301 }
22942302
22952303error :
0 commit comments