@@ -699,6 +699,7 @@ out:
int ibverbs_init(void)
{
const char *sysfs_path;
+ char *env_value;
int ret;
if (getenv("RDMAV_FORK_SAFE") || getenv("IBV_FORK_SAFE"))
@@ -706,6 +707,11 @@ int ibverbs_init(void)
fprintf(stderr, PFX "Warning: fork()-safety requested "
"but init failed\n");
+ /* Backward compatibility for the mlx4 driver env */
+ env_value = getenv("MLX4_DEVICE_FATAL_CLEANUP");
+ if (env_value)
+ verbs_allow_disassociate_destroy = strcmp(env_value, "0") != 0;
+
if (getenv("RDMAV_ALLOW_DISASSOC_DESTROY"))
verbs_allow_disassociate_destroy = true;
@@ -43,8 +43,6 @@
#include "mlx4.h"
#include "mlx4-abi.h"
-int mlx4_cleanup_upon_device_fatal = 0;
-
#ifndef PCI_VENDOR_ID_MELLANOX
#define PCI_VENDOR_ID_MELLANOX 0x15b3
#endif
@@ -133,15 +131,6 @@ static const struct verbs_context_ops mlx4_ctx_ops = {
.query_rt_values = mlx4_query_rt_values,
};
-static void mlx4_read_env(void)
-{
- char *env_value;
-
- env_value = getenv("MLX4_DEVICE_FATAL_CLEANUP");
- if (env_value)
- mlx4_cleanup_upon_device_fatal = (strcmp(env_value, "0")) ? 1 : 0;
-}
-
static int mlx4_map_internal_clock(struct mlx4_device *mdev,
struct ibv_context *ibv_ctx)
{
@@ -184,7 +173,6 @@ static struct verbs_context *mlx4_alloc_context(struct ibv_device *ibdev,
verbs_ctx = &context->ibv_ctx;
- mlx4_read_env();
if (dev->abi_version <= MLX4_UVERBS_NO_DEV_CAPS_ABI_VERSION) {
if (ibv_cmd_get_context(verbs_ctx, &cmd, sizeof(cmd),
&resp_v3.ibv_resp, sizeof(resp_v3)))
@@ -299,12 +299,6 @@ static inline void mlx4_update_cons_index(struct mlx4_cq *cq)
*cq->set_ci_db = htobe32(cq->cons_index & 0xffffff);
}
-extern int mlx4_cleanup_upon_device_fatal;
-static inline int cleanup_on_fatal(int ret)
-{
- return (ret == EIO && mlx4_cleanup_upon_device_fatal);
-}
-
int mlx4_alloc_buf(struct mlx4_buf *buf, size_t size, int page_size);
void mlx4_free_buf(struct mlx4_buf *buf);
@@ -307,7 +307,7 @@ int mlx4_destroy_xrc_srq(struct ibv_srq *srq)
pthread_spin_unlock(&mcq->lock);
ret = ibv_cmd_destroy_srq(srq);
- if (ret && !cleanup_on_fatal(ret)) {
+ if (ret) {
pthread_spin_lock(&mcq->lock);
mlx4_store_xsrq(&mctx->xsrq_table, msrq->verbs_srq.srq_num, msrq);
pthread_spin_unlock(&mcq->lock);
@@ -232,7 +232,7 @@ int mlx4_free_pd(struct ibv_pd *pd)
int ret;
ret = ibv_cmd_dealloc_pd(pd);
- if (ret && !cleanup_on_fatal(ret))
+ if (ret)
return ret;
free(to_mpd(pd));
@@ -269,7 +269,7 @@ int mlx4_close_xrcd(struct ibv_xrcd *ib_xrcd)
int ret;
ret = ibv_cmd_close_xrcd(xrcd);
- if (ret && !cleanup_on_fatal(ret))
+ if (ret)
return ret;
free(xrcd);
@@ -322,7 +322,7 @@ int mlx4_dereg_mr(struct verbs_mr *vmr)
int ret;
ret = ibv_cmd_dereg_mr(vmr);
- if (ret && !cleanup_on_fatal(ret))
+ if (ret)
return ret;
free(vmr);
@@ -356,7 +356,7 @@ int mlx4_dealloc_mw(struct ibv_mw *mw)
int ret;
ret = ibv_cmd_dealloc_mw(mw);
- if (ret && !cleanup_on_fatal(ret))
+ if (ret)
return ret;
free(mw);
@@ -647,7 +647,7 @@ int mlx4_destroy_cq(struct ibv_cq *cq)
int ret;
ret = ibv_cmd_destroy_cq(cq);
- if (ret && !cleanup_on_fatal(ret))
+ if (ret)
return ret;
mlx4_free_db(to_mctx(cq->context), MLX4_DB_TYPE_CQ, to_mcq(cq)->set_ci_db);
@@ -751,7 +751,7 @@ int mlx4_destroy_srq(struct ibv_srq *srq)
return mlx4_destroy_xrc_srq(srq);
ret = ibv_cmd_destroy_srq(srq);
- if (ret && !cleanup_on_fatal(ret))
+ if (ret)
return ret;
mlx4_free_db(to_mctx(srq->context), MLX4_DB_TYPE_RQ, to_msrq(srq)->db);
@@ -1220,7 +1220,7 @@ static int _mlx4_destroy_qp_rss(struct ibv_qp *ibqp)
int ret;
ret = ibv_cmd_destroy_qp(ibqp);
- if (ret && !cleanup_on_fatal(ret))
+ if (ret)
return ret;
free(qp);
@@ -1238,7 +1238,7 @@ int mlx4_destroy_qp(struct ibv_qp *ibqp)
pthread_mutex_lock(&to_mctx(ibqp->context)->qp_table_mutex);
ret = ibv_cmd_destroy_qp(ibqp);
- if (ret && !cleanup_on_fatal(ret)) {
+ if (ret) {
pthread_mutex_unlock(&to_mctx(ibqp->context)->qp_table_mutex);
return ret;
}
@@ -1567,7 +1567,7 @@ int mlx4_destroy_flow(struct ibv_flow *flow_id)
ret = ibv_cmd_destroy_flow(flow_id);
- if (ret && !cleanup_on_fatal(ret))
+ if (ret)
return ret;
free(flow_id);
@@ -1584,7 +1584,7 @@ int mlx4_destroy_wq(struct ibv_wq *ibwq)
pthread_mutex_lock(&mcontext->qp_table_mutex);
ret = ibv_cmd_destroy_wq(ibwq);
- if (ret && !cleanup_on_fatal(ret)) {
+ if (ret) {
pthread_mutex_unlock(&mcontext->qp_table_mutex);
return ret;
}
@@ -1658,7 +1658,7 @@ int mlx4_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table)
ret = ibv_cmd_destroy_rwq_ind_table(rwq_ind_table);
- if (ret && !cleanup_on_fatal(ret))
+ if (ret)
return ret;
free(rwq_ind_table);
Cleanup the private handling of mlx4 and move to use the generic verbs support for verbs_allow_disassociate_destroy. For backwards compatible support once MLX4_DEVICE_FATAL_CLEANUP is set turn to use the verbs mechanism as well. Signed-off-by: Yishai Hadas <yishaih@mellanox.com> --- libibverbs/init.c | 6 ++++++ providers/mlx4/mlx4.c | 12 ------------ providers/mlx4/mlx4.h | 6 ------ providers/mlx4/srq.c | 2 +- providers/mlx4/verbs.c | 22 +++++++++++----------- 5 files changed, 18 insertions(+), 30 deletions(-)