diff options
| author | Eli Cohen <eli@dev.mellanox.co.il> | 2014-01-14 10:45:20 -0500 |
|---|---|---|
| committer | Roland Dreier <roland@purestorage.com> | 2014-01-23 02:23:52 -0500 |
| commit | 05bdb2ab6b09f2306f0afe0f60f4b9abffa7aba4 (patch) | |
| tree | 526dff83313a9d0b5b136a44cee45e8270db4049 | |
| parent | db81a5c374b5bd650c5e6ae85d026709751db103 (diff) | |
mlx5_core: Fix PowerPC support
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: Eli Cohen <eli@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c | 9 | ||||
| -rw-r--r-- | include/linux/mlx5/device.h | 3 |
2 files changed, 7 insertions, 5 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c index c35c4320225a..d59790a82bc3 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c | |||
| @@ -99,7 +99,7 @@ enum { | |||
| 99 | 99 | ||
| 100 | enum { | 100 | enum { |
| 101 | MLX5_MAX_RECLAIM_TIME_MILI = 5000, | 101 | MLX5_MAX_RECLAIM_TIME_MILI = 5000, |
| 102 | MLX5_NUM_4K_IN_PAGE = PAGE_SIZE / 4096, | 102 | MLX5_NUM_4K_IN_PAGE = PAGE_SIZE / MLX5_ADAPTER_PAGE_SIZE, |
| 103 | }; | 103 | }; |
| 104 | 104 | ||
| 105 | static int insert_page(struct mlx5_core_dev *dev, u64 addr, struct page *page, u16 func_id) | 105 | static int insert_page(struct mlx5_core_dev *dev, u64 addr, struct page *page, u16 func_id) |
| @@ -206,7 +206,7 @@ static int alloc_4k(struct mlx5_core_dev *dev, u64 *addr) | |||
| 206 | if (!fp->free_count) | 206 | if (!fp->free_count) |
| 207 | list_del(&fp->list); | 207 | list_del(&fp->list); |
| 208 | 208 | ||
| 209 | *addr = fp->addr + n * 4096; | 209 | *addr = fp->addr + n * MLX5_ADAPTER_PAGE_SIZE; |
| 210 | 210 | ||
| 211 | return 0; | 211 | return 0; |
| 212 | } | 212 | } |
| @@ -222,14 +222,15 @@ static void free_4k(struct mlx5_core_dev *dev, u64 addr) | |||
| 222 | return; | 222 | return; |
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | n = (addr & ~PAGE_MASK) % 4096; | 225 | n = (addr & ~PAGE_MASK) >> MLX5_ADAPTER_PAGE_SHIFT; |
| 226 | fwp->free_count++; | 226 | fwp->free_count++; |
| 227 | set_bit(n, &fwp->bitmask); | 227 | set_bit(n, &fwp->bitmask); |
| 228 | if (fwp->free_count == MLX5_NUM_4K_IN_PAGE) { | 228 | if (fwp->free_count == MLX5_NUM_4K_IN_PAGE) { |
| 229 | rb_erase(&fwp->rb_node, &dev->priv.page_root); | 229 | rb_erase(&fwp->rb_node, &dev->priv.page_root); |
| 230 | if (fwp->free_count != 1) | 230 | if (fwp->free_count != 1) |
| 231 | list_del(&fwp->list); | 231 | list_del(&fwp->list); |
| 232 | dma_unmap_page(&dev->pdev->dev, addr, PAGE_SIZE, DMA_BIDIRECTIONAL); | 232 | dma_unmap_page(&dev->pdev->dev, addr & PAGE_MASK, PAGE_SIZE, |
| 233 | DMA_BIDIRECTIONAL); | ||
| 233 | __free_page(fwp->page); | 234 | __free_page(fwp->page); |
| 234 | kfree(fwp); | 235 | kfree(fwp); |
| 235 | } else if (fwp->free_count == 1) { | 236 | } else if (fwp->free_count == 1) { |
diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h index 87e23717df70..1d059099226c 100644 --- a/include/linux/mlx5/device.h +++ b/include/linux/mlx5/device.h | |||
| @@ -234,7 +234,8 @@ enum { | |||
| 234 | }; | 234 | }; |
| 235 | 235 | ||
| 236 | enum { | 236 | enum { |
| 237 | MLX5_ADAPTER_PAGE_SHIFT = 12 | 237 | MLX5_ADAPTER_PAGE_SHIFT = 12, |
| 238 | MLX5_ADAPTER_PAGE_SIZE = 1 << MLX5_ADAPTER_PAGE_SHIFT, | ||
| 238 | }; | 239 | }; |
| 239 | 240 | ||
| 240 | enum { | 241 | enum { |
