diff options
author | David S. Miller <davem@davemloft.net> | 2019-03-12 18:00:15 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-03-12 18:00:15 -0400 |
commit | 4d09d8d8f91db575cf0f34f35d712fc66655fbe5 (patch) | |
tree | d8197932975c97dfc16f358c65e843105d0867da | |
parent | c7fce569fd954d527643f48f5645ccf8fd51813e (diff) | |
parent | 8511a653e9250ef36b95803c375a7be0e2edb628 (diff) |
Merge branch 'mlx4-fixes'
Tariq Toukan says:
====================
mlx4_core misc fixes
This patchset by Jack contains misc fixes to the mlx4 Core driver.
Patch 1 fixes a use-after-free situation by marking (nullifying) the pointer,
please queue for -stable >= v4.0.
Patch 2 adds a missing lock acquire and release in SRIOV command interface,
please queue for -stable >= v4.9.
Patch 3 avoids calling roundup_pow_of_two when argument is zero,
please queue for -stable >= v3.3.
Series generated against net commit:
a3b1933d34d5 Merge tag 'mlx5-fixes-2019-03-11' of
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/cmd.c | 9 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c index c19e74e6ac94..a5d5d6fc1da0 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c | |||
@@ -2645,6 +2645,8 @@ int mlx4_cmd_use_events(struct mlx4_dev *dev) | |||
2645 | if (!priv->cmd.context) | 2645 | if (!priv->cmd.context) |
2646 | return -ENOMEM; | 2646 | return -ENOMEM; |
2647 | 2647 | ||
2648 | if (mlx4_is_mfunc(dev)) | ||
2649 | mutex_lock(&priv->cmd.slave_cmd_mutex); | ||
2648 | down_write(&priv->cmd.switch_sem); | 2650 | down_write(&priv->cmd.switch_sem); |
2649 | for (i = 0; i < priv->cmd.max_cmds; ++i) { | 2651 | for (i = 0; i < priv->cmd.max_cmds; ++i) { |
2650 | priv->cmd.context[i].token = i; | 2652 | priv->cmd.context[i].token = i; |
@@ -2670,6 +2672,8 @@ int mlx4_cmd_use_events(struct mlx4_dev *dev) | |||
2670 | down(&priv->cmd.poll_sem); | 2672 | down(&priv->cmd.poll_sem); |
2671 | priv->cmd.use_events = 1; | 2673 | priv->cmd.use_events = 1; |
2672 | up_write(&priv->cmd.switch_sem); | 2674 | up_write(&priv->cmd.switch_sem); |
2675 | if (mlx4_is_mfunc(dev)) | ||
2676 | mutex_unlock(&priv->cmd.slave_cmd_mutex); | ||
2673 | 2677 | ||
2674 | return err; | 2678 | return err; |
2675 | } | 2679 | } |
@@ -2682,6 +2686,8 @@ void mlx4_cmd_use_polling(struct mlx4_dev *dev) | |||
2682 | struct mlx4_priv *priv = mlx4_priv(dev); | 2686 | struct mlx4_priv *priv = mlx4_priv(dev); |
2683 | int i; | 2687 | int i; |
2684 | 2688 | ||
2689 | if (mlx4_is_mfunc(dev)) | ||
2690 | mutex_lock(&priv->cmd.slave_cmd_mutex); | ||
2685 | down_write(&priv->cmd.switch_sem); | 2691 | down_write(&priv->cmd.switch_sem); |
2686 | priv->cmd.use_events = 0; | 2692 | priv->cmd.use_events = 0; |
2687 | 2693 | ||
@@ -2689,9 +2695,12 @@ void mlx4_cmd_use_polling(struct mlx4_dev *dev) | |||
2689 | down(&priv->cmd.event_sem); | 2695 | down(&priv->cmd.event_sem); |
2690 | 2696 | ||
2691 | kfree(priv->cmd.context); | 2697 | kfree(priv->cmd.context); |
2698 | priv->cmd.context = NULL; | ||
2692 | 2699 | ||
2693 | up(&priv->cmd.poll_sem); | 2700 | up(&priv->cmd.poll_sem); |
2694 | up_write(&priv->cmd.switch_sem); | 2701 | up_write(&priv->cmd.switch_sem); |
2702 | if (mlx4_is_mfunc(dev)) | ||
2703 | mutex_unlock(&priv->cmd.slave_cmd_mutex); | ||
2695 | } | 2704 | } |
2696 | 2705 | ||
2697 | struct mlx4_cmd_mailbox *mlx4_alloc_cmd_mailbox(struct mlx4_dev *dev) | 2706 | struct mlx4_cmd_mailbox *mlx4_alloc_cmd_mailbox(struct mlx4_dev *dev) |
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c index eb13d3618162..4356f3a58002 100644 --- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | |||
@@ -2719,13 +2719,13 @@ static int qp_get_mtt_size(struct mlx4_qp_context *qpc) | |||
2719 | int total_pages; | 2719 | int total_pages; |
2720 | int total_mem; | 2720 | int total_mem; |
2721 | int page_offset = (be32_to_cpu(qpc->params2) >> 6) & 0x3f; | 2721 | int page_offset = (be32_to_cpu(qpc->params2) >> 6) & 0x3f; |
2722 | int tot; | ||
2722 | 2723 | ||
2723 | sq_size = 1 << (log_sq_size + log_sq_sride + 4); | 2724 | sq_size = 1 << (log_sq_size + log_sq_sride + 4); |
2724 | rq_size = (srq|rss|xrc) ? 0 : (1 << (log_rq_size + log_rq_stride + 4)); | 2725 | rq_size = (srq|rss|xrc) ? 0 : (1 << (log_rq_size + log_rq_stride + 4)); |
2725 | total_mem = sq_size + rq_size; | 2726 | total_mem = sq_size + rq_size; |
2726 | total_pages = | 2727 | tot = (total_mem + (page_offset << 6)) >> page_shift; |
2727 | roundup_pow_of_two((total_mem + (page_offset << 6)) >> | 2728 | total_pages = !tot ? 1 : roundup_pow_of_two(tot); |
2728 | page_shift); | ||
2729 | 2729 | ||
2730 | return total_pages; | 2730 | return total_pages; |
2731 | } | 2731 | } |