Commit 4636c5f9 authored by Eli Cohen's avatar Eli Cohen Committed by Kamal Mostafa

mlx5_core: Fix PowerPC support

commit 05bdb2ab upstream.

1. Fix derivation of sub-page index from the dma address in free_4k.
2. Fix the DMA address passed to dma_unmap_page by masking it properly.
Signed-off-by: default avatarEli Cohen <eli@mellanox.com>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent c8bf722e
...@@ -99,7 +99,7 @@ enum { ...@@ -99,7 +99,7 @@ enum {
enum { enum {
MLX5_MAX_RECLAIM_TIME_MILI = 5000, MLX5_MAX_RECLAIM_TIME_MILI = 5000,
MLX5_NUM_4K_IN_PAGE = PAGE_SIZE / 4096, MLX5_NUM_4K_IN_PAGE = PAGE_SIZE / MLX5_ADAPTER_PAGE_SIZE,
}; };
static int insert_page(struct mlx5_core_dev *dev, u64 addr, struct page *page, u16 func_id) static int insert_page(struct mlx5_core_dev *dev, u64 addr, struct page *page, u16 func_id)
...@@ -208,7 +208,7 @@ static int alloc_4k(struct mlx5_core_dev *dev, u64 *addr) ...@@ -208,7 +208,7 @@ static int alloc_4k(struct mlx5_core_dev *dev, u64 *addr)
if (!fp->free_count) if (!fp->free_count)
list_del(&fp->list); list_del(&fp->list);
*addr = fp->addr + n * 4096; *addr = fp->addr + n * MLX5_ADAPTER_PAGE_SIZE;
return 0; return 0;
} }
...@@ -224,14 +224,15 @@ static void free_4k(struct mlx5_core_dev *dev, u64 addr) ...@@ -224,14 +224,15 @@ static void free_4k(struct mlx5_core_dev *dev, u64 addr)
return; return;
} }
n = (addr & ~PAGE_MASK) % 4096; n = (addr & ~PAGE_MASK) >> MLX5_ADAPTER_PAGE_SHIFT;
fwp->free_count++; fwp->free_count++;
set_bit(n, &fwp->bitmask); set_bit(n, &fwp->bitmask);
if (fwp->free_count == MLX5_NUM_4K_IN_PAGE) { if (fwp->free_count == MLX5_NUM_4K_IN_PAGE) {
rb_erase(&fwp->rb_node, &dev->priv.page_root); rb_erase(&fwp->rb_node, &dev->priv.page_root);
if (fwp->free_count != 1) if (fwp->free_count != 1)
list_del(&fwp->list); list_del(&fwp->list);
dma_unmap_page(&dev->pdev->dev, addr, PAGE_SIZE, DMA_BIDIRECTIONAL); dma_unmap_page(&dev->pdev->dev, addr & PAGE_MASK, PAGE_SIZE,
DMA_BIDIRECTIONAL);
__free_page(fwp->page); __free_page(fwp->page);
kfree(fwp); kfree(fwp);
} else if (fwp->free_count == 1) { } else if (fwp->free_count == 1) {
......
...@@ -231,7 +231,8 @@ enum { ...@@ -231,7 +231,8 @@ enum {
}; };
enum { enum {
MLX5_ADAPTER_PAGE_SHIFT = 12 MLX5_ADAPTER_PAGE_SHIFT = 12,
MLX5_ADAPTER_PAGE_SIZE = 1 << MLX5_ADAPTER_PAGE_SHIFT,
}; };
enum { enum {
......
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