Skip to content

Commit

Permalink
infiniband: mlx5: no need to check return value of debugfs_create fun…
Browse files Browse the repository at this point in the history
…ctions

When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
Greg Kroah-Hartman authored and Jason Gunthorpe committed Jan 24, 2019
1 parent 0d0336c commit 73eb8f0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 64 deletions.
15 changes: 5 additions & 10 deletions drivers/infiniband/hw/mlx5/cong.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,19 +389,19 @@ void mlx5_ib_cleanup_cong_debugfs(struct mlx5_ib_dev *dev, u8 port_num)
dev->port[port_num].dbg_cc_params = NULL;
}

int mlx5_ib_init_cong_debugfs(struct mlx5_ib_dev *dev, u8 port_num)
void mlx5_ib_init_cong_debugfs(struct mlx5_ib_dev *dev, u8 port_num)
{
struct mlx5_ib_dbg_cc_params *dbg_cc_params;
struct mlx5_core_dev *mdev;
int i;

if (!mlx5_debugfs_root)
goto out;
return;

/* Takes a 1-based port number */
mdev = mlx5_ib_get_native_port_mdev(dev, port_num + 1, NULL);
if (!mdev)
goto out;
return;

if (!MLX5_CAP_GEN(mdev, cc_query_allowed) ||
!MLX5_CAP_GEN(mdev, cc_modify_allowed))
Expand All @@ -415,8 +415,6 @@ int mlx5_ib_init_cong_debugfs(struct mlx5_ib_dev *dev, u8 port_num)

dbg_cc_params->root = debugfs_create_dir("cc_params",
mdev->priv.dbg_root);
if (!dbg_cc_params->root)
goto err;

for (i = 0; i < MLX5_IB_DBG_CC_MAX; i++) {
dbg_cc_params->params[i].offset = i;
Expand All @@ -427,14 +425,11 @@ int mlx5_ib_init_cong_debugfs(struct mlx5_ib_dev *dev, u8 port_num)
0600, dbg_cc_params->root,
&dbg_cc_params->params[i],
&dbg_cc_fops);
if (!dbg_cc_params->params[i].dentry)
goto err;
}

put_mdev:
mlx5_ib_put_native_port_mdev(dev, port_num + 1);
out:
return 0;
return;

err:
mlx5_ib_warn(dev, "cong debugfs failure\n");
Expand All @@ -445,5 +440,5 @@ int mlx5_ib_init_cong_debugfs(struct mlx5_ib_dev *dev, u8 port_num)
* We don't want to fail driver if debugfs failed to initialize,
* so we are not forwarding error to the user.
*/
return 0;
return;
}
9 changes: 4 additions & 5 deletions drivers/infiniband/hw/mlx5/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5530,9 +5530,7 @@ static bool mlx5_ib_bind_slave_port(struct mlx5_ib_dev *ibdev,
mpi->mdev_events.notifier_call = mlx5_ib_event_slave_port;
mlx5_notifier_register(mpi->mdev, &mpi->mdev_events);

err = mlx5_ib_init_cong_debugfs(ibdev, port_num);
if (err)
goto unbind;
mlx5_ib_init_cong_debugfs(ibdev, port_num);

return true;

Expand Down Expand Up @@ -6207,8 +6205,9 @@ void mlx5_ib_stage_counters_cleanup(struct mlx5_ib_dev *dev)

static int mlx5_ib_stage_cong_debugfs_init(struct mlx5_ib_dev *dev)
{
return mlx5_ib_init_cong_debugfs(dev,
mlx5_core_native_port_num(dev->mdev) - 1);
mlx5_ib_init_cong_debugfs(dev,
mlx5_core_native_port_num(dev->mdev) - 1);
return 0;
}

static void mlx5_ib_stage_cong_debugfs_cleanup(struct mlx5_ib_dev *dev)
Expand Down
8 changes: 1 addition & 7 deletions drivers/infiniband/hw/mlx5/mlx5_ib.h
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,6 @@ struct mlx5_cache_ent {
spinlock_t lock;


struct dentry *dir;
char name[4];
u32 order;
u32 xlt;
Expand All @@ -648,11 +647,6 @@ struct mlx5_cache_ent {
u32 miss;
u32 limit;

struct dentry *fsize;
struct dentry *fcur;
struct dentry *fmiss;
struct dentry *flimit;

struct mlx5_ib_dev *dev;
struct work_struct work;
struct delayed_work dwork;
Expand Down Expand Up @@ -1270,7 +1264,7 @@ __be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev,
const struct ib_gid_attr *attr);

void mlx5_ib_cleanup_cong_debugfs(struct mlx5_ib_dev *dev, u8 port_num);
int mlx5_ib_init_cong_debugfs(struct mlx5_ib_dev *dev, u8 port_num);
void mlx5_ib_init_cong_debugfs(struct mlx5_ib_dev *dev, u8 port_num);

/* GSI QP helper functions */
struct ib_qp *mlx5_ib_gsi_create_qp(struct ib_pd *pd,
Expand Down
51 changes: 9 additions & 42 deletions drivers/infiniband/hw/mlx5/mr.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,52 +606,27 @@ static void mlx5_mr_cache_debugfs_cleanup(struct mlx5_ib_dev *dev)
dev->cache.root = NULL;
}

static int mlx5_mr_cache_debugfs_init(struct mlx5_ib_dev *dev)
static void mlx5_mr_cache_debugfs_init(struct mlx5_ib_dev *dev)
{
struct mlx5_mr_cache *cache = &dev->cache;
struct mlx5_cache_ent *ent;
struct dentry *dir;
int i;

if (!mlx5_debugfs_root || dev->rep)
return 0;
return;

cache->root = debugfs_create_dir("mr_cache", dev->mdev->priv.dbg_root);
if (!cache->root)
return -ENOMEM;

for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) {
ent = &cache->ent[i];
sprintf(ent->name, "%d", ent->order);
ent->dir = debugfs_create_dir(ent->name, cache->root);
if (!ent->dir)
goto err;

ent->fsize = debugfs_create_file("size", 0600, ent->dir, ent,
&size_fops);
if (!ent->fsize)
goto err;

ent->flimit = debugfs_create_file("limit", 0600, ent->dir, ent,
&limit_fops);
if (!ent->flimit)
goto err;

ent->fcur = debugfs_create_u32("cur", 0400, ent->dir,
&ent->cur);
if (!ent->fcur)
goto err;

ent->fmiss = debugfs_create_u32("miss", 0600, ent->dir,
&ent->miss);
if (!ent->fmiss)
goto err;
dir = debugfs_create_dir(ent->name, cache->root);
debugfs_create_file("size", 0600, dir, ent, &size_fops);
debugfs_create_file("limit", 0600, dir, ent, &limit_fops);
debugfs_create_u32("cur", 0400, dir, &ent->cur);
debugfs_create_u32("miss", 0600, dir, &ent->miss);
}

return 0;
err:
mlx5_mr_cache_debugfs_cleanup(dev);

return -ENOMEM;
}

static void delay_time_func(struct timer_list *t)
Expand All @@ -665,7 +640,6 @@ int mlx5_mr_cache_init(struct mlx5_ib_dev *dev)
{
struct mlx5_mr_cache *cache = &dev->cache;
struct mlx5_cache_ent *ent;
int err;
int i;

mutex_init(&dev->slow_path_mutex);
Expand Down Expand Up @@ -709,14 +683,7 @@ int mlx5_mr_cache_init(struct mlx5_ib_dev *dev)
queue_work(cache->wq, &ent->work);
}

err = mlx5_mr_cache_debugfs_init(dev);
if (err)
mlx5_ib_warn(dev, "cache debugfs failure\n");

/*
* We don't want to fail driver if debugfs failed to initialize,
* so we are not forwarding error to the user.
*/
mlx5_mr_cache_debugfs_init(dev);

return 0;
}
Expand Down

0 comments on commit 73eb8f0

Please sign in to comment.