net/mlx5: cmd: Fix memset with byte count warning
Fix sparse warning: drivers/net/ethernet/mellanox/mlx5/core/cmd.c:1949:15: warning: memset with byte count of 271720 mlx5_cmd_stats array is too big to be held inline in mlx5_cmd. Allocate it separately. Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
This commit is contained in:
parent
9ff2e92c46
commit
2553f421f4
|
@ -1072,7 +1072,7 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in,
|
|||
|
||||
ds = ent->ts2 - ent->ts1;
|
||||
op = MLX5_GET(mbox_in, in->first.data, opcode);
|
||||
if (op < ARRAY_SIZE(cmd->stats)) {
|
||||
if (op < MLX5_CMD_OP_MAX) {
|
||||
stats = &cmd->stats[op];
|
||||
spin_lock_irq(&stats->lock);
|
||||
stats->sum += ds;
|
||||
|
@ -1551,7 +1551,7 @@ static void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool force
|
|||
|
||||
if (ent->callback) {
|
||||
ds = ent->ts2 - ent->ts1;
|
||||
if (ent->op < ARRAY_SIZE(cmd->stats)) {
|
||||
if (ent->op < MLX5_CMD_OP_MAX) {
|
||||
stats = &cmd->stats[ent->op];
|
||||
spin_lock_irqsave(&stats->lock, flags);
|
||||
stats->sum += ds;
|
||||
|
@ -1960,10 +1960,16 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
cmd->pool = dma_pool_create("mlx5_cmd", dev->device, size, align, 0);
|
||||
if (!cmd->pool)
|
||||
cmd->stats = kvzalloc(MLX5_CMD_OP_MAX * sizeof(*cmd->stats), GFP_KERNEL);
|
||||
if (!cmd->stats)
|
||||
return -ENOMEM;
|
||||
|
||||
cmd->pool = dma_pool_create("mlx5_cmd", dev->device, size, align, 0);
|
||||
if (!cmd->pool) {
|
||||
err = -ENOMEM;
|
||||
goto dma_pool_err;
|
||||
}
|
||||
|
||||
err = alloc_cmd_page(dev, cmd);
|
||||
if (err)
|
||||
goto err_free_pool;
|
||||
|
@ -1999,7 +2005,7 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
|
|||
|
||||
spin_lock_init(&cmd->alloc_lock);
|
||||
spin_lock_init(&cmd->token_lock);
|
||||
for (i = 0; i < ARRAY_SIZE(cmd->stats); i++)
|
||||
for (i = 0; i < MLX5_CMD_OP_MAX; i++)
|
||||
spin_lock_init(&cmd->stats[i].lock);
|
||||
|
||||
sema_init(&cmd->sem, cmd->max_reg_cmds);
|
||||
|
@ -2046,7 +2052,8 @@ err_free_page:
|
|||
|
||||
err_free_pool:
|
||||
dma_pool_destroy(cmd->pool);
|
||||
|
||||
dma_pool_err:
|
||||
kvfree(cmd->stats);
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL(mlx5_cmd_init);
|
||||
|
@ -2060,6 +2067,7 @@ void mlx5_cmd_cleanup(struct mlx5_core_dev *dev)
|
|||
destroy_msg_cache(dev);
|
||||
free_cmd_page(dev, cmd);
|
||||
dma_pool_destroy(cmd->pool);
|
||||
kvfree(cmd->stats);
|
||||
}
|
||||
EXPORT_SYMBOL(mlx5_cmd_cleanup);
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ void mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev)
|
|||
cmd = &dev->priv.cmdif_debugfs;
|
||||
*cmd = debugfs_create_dir("commands", dev->priv.dbg_root);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(dev->cmd.stats); i++) {
|
||||
for (i = 0; i < MLX5_CMD_OP_MAX; i++) {
|
||||
stats = &dev->cmd.stats[i];
|
||||
namep = mlx5_command_str(i);
|
||||
if (strcmp(namep, "unknown command opcode")) {
|
||||
|
|
|
@ -298,7 +298,7 @@ struct mlx5_cmd {
|
|||
struct mlx5_cmd_debug dbg;
|
||||
struct cmd_msg_cache cache[MLX5_NUM_COMMAND_CACHES];
|
||||
int checksum_disabled;
|
||||
struct mlx5_cmd_stats stats[MLX5_CMD_OP_MAX];
|
||||
struct mlx5_cmd_stats *stats;
|
||||
};
|
||||
|
||||
struct mlx5_port_caps {
|
||||
|
|
Loading…
Reference in New Issue