Commit 2fcb92fb authored by Gal Pressman's avatar Gal Pressman Committed by David S. Miller

net/mlx5e: Don't modify CQ before it was created

Calling mlx5e_set_coalesce while the interface is down will result in
modifying CQs that don't exist.

Fixes: f62b8bb8 ('net/mlx5: Extend mlx5_core to support ConnectX-4
Ethernet functionality')
Signed-off-by: default avatarGal Pressman <galp@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7524a5d8
...@@ -423,11 +423,15 @@ static int mlx5e_set_coalesce(struct net_device *netdev, ...@@ -423,11 +423,15 @@ static int mlx5e_set_coalesce(struct net_device *netdev,
if (!MLX5_CAP_GEN(mdev, cq_moderation)) if (!MLX5_CAP_GEN(mdev, cq_moderation))
return -ENOTSUPP; return -ENOTSUPP;
mutex_lock(&priv->state_lock);
priv->params.tx_cq_moderation_usec = coal->tx_coalesce_usecs; priv->params.tx_cq_moderation_usec = coal->tx_coalesce_usecs;
priv->params.tx_cq_moderation_pkts = coal->tx_max_coalesced_frames; priv->params.tx_cq_moderation_pkts = coal->tx_max_coalesced_frames;
priv->params.rx_cq_moderation_usec = coal->rx_coalesce_usecs; priv->params.rx_cq_moderation_usec = coal->rx_coalesce_usecs;
priv->params.rx_cq_moderation_pkts = coal->rx_max_coalesced_frames; priv->params.rx_cq_moderation_pkts = coal->rx_max_coalesced_frames;
if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
goto out;
for (i = 0; i < priv->params.num_channels; ++i) { for (i = 0; i < priv->params.num_channels; ++i) {
c = priv->channel[i]; c = priv->channel[i];
...@@ -443,6 +447,8 @@ static int mlx5e_set_coalesce(struct net_device *netdev, ...@@ -443,6 +447,8 @@ static int mlx5e_set_coalesce(struct net_device *netdev,
coal->rx_max_coalesced_frames); coal->rx_max_coalesced_frames);
} }
out:
mutex_unlock(&priv->state_lock);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment