Skip to content

Commit

Permalink
net/mlx5: Fix wrong address reclaim when command interface is down
Browse files Browse the repository at this point in the history
[ Upstream commit 1d2bb5a ]

When command interface is down, driver to reclaim all 4K page chucks that
were hold by the Firmeware. Fix a bug for 64K page size systems, where
driver repeatedly released only the first chunk of the page.

Define helper function to fill 4K chunks for a given Firmware pages.
Iterate over all unreleased Firmware pages and call the hepler per each.

Fixes: 5adff6a ("net/mlx5: Fix incorrect page count when in internal error")
Signed-off-by: Eran Ben Elisha <eranbe@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Eran Ben Elisha authored and Greg Kroah-Hartman committed Dec 8, 2020
1 parent 2598dd8 commit 8cd76da
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
Original file line number Diff line number Diff line change
@@ -339,6 +339,24 @@ static int give_pages(struct mlx5_core_dev *dev, u16 func_id, int npages,
return err;
}

static u32 fwp_fill_manage_pages_out(struct fw_page *fwp, u32 *out, u32 index,
u32 npages)
{
u32 pages_set = 0;
unsigned int n;

for_each_clear_bit(n, &fwp->bitmask, MLX5_NUM_4K_IN_PAGE) {
MLX5_ARRAY_SET64(manage_pages_out, out, pas, index + pages_set,
fwp->addr + (n * MLX5_ADAPTER_PAGE_SIZE));
pages_set++;

if (!--npages)
break;
}

return pages_set;
}

static int reclaim_pages_cmd(struct mlx5_core_dev *dev,
u32 *in, int in_size, u32 *out, int out_size)
{
@@ -362,8 +380,7 @@ static int reclaim_pages_cmd(struct mlx5_core_dev *dev,
if (fwp->func_id != func_id)
continue;

MLX5_ARRAY_SET64(manage_pages_out, out, pas, i, fwp->addr);
i++;
i += fwp_fill_manage_pages_out(fwp, out, i, npages - i);
}

MLX5_SET(manage_pages_out, out, output_num_entries, i);

0 comments on commit 8cd76da

Please sign in to comment.