aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorHonggang LI <honli@redhat.com>2015-04-15 04:36:15 -0400
committerDoug Ledford <dledford@redhat.com>2015-04-15 16:20:51 -0400
commit59d2d18cc4e9ba30b370db18d0e02d792699da96 (patch)
tree8543c0360a369ea37e26b294e040ec2d6df6ee43 /drivers/net
parentcc47d369b51286129aad1735096b1884b8068ad1 (diff)
mlx5: wrong page mask if CONFIG_ARCH_DMA_ADDR_T_64BIT enabled for 32Bit architectures
If CONFIG_ARCH_DMA_ADDR_T_64BIT enabled for x86 systems and physical memory is more than 4GB, dma_map_page may return a valid memory address which greater than 0xffffffff. As a result, the mlx5 device page allocator RB tree will be initialized with valid addresses greater than 0xfffffff. However, (addr & PAGE_MASK) set the high four bytes to zeros. So, it's impossible for the function, free_4k, to release the pages whose addresses greater than 4GB. Memory leaks. And mlx5_ib module can't release the pages when user try to remove the module, as a result, system hang. [root@rdma05 root]# dmesg | grep addr | head addr = 3fe384000 addr & PAGE_MASK = fe384000 [root@rdma05 root]# rmmod mlx5_ib <---- hang on ---------------------- cosnole log ----------------- mlx5_ib 0000:04:00.0: irq 138 for MSI/MSI-X alloc irq_desc for 139 on node -1 alloc kstat_irqs on node -1 mlx5_ib 0000:04:00.0: irq 139 for MSI/MSI-X 0000:04:00.0:free_4k:221:(pid 1519): page not found 0000:04:00.0:free_4k:221:(pid 1519): page not found 0000:04:00.0:free_4k:221:(pid 1519): page not found 0000:04:00.0:free_4k:221:(pid 1519): page not found ---------------------- cosnole log ----------------- Fixes: bf0bf77f6519 ('mlx5: Support communicating arbitrary host page size to firmware') Signed-off-by: Honggang Li <honli@redhat.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
index df2238372ea7..8a64542abc16 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
@@ -211,26 +211,28 @@ static int alloc_4k(struct mlx5_core_dev *dev, u64 *addr)
211 return 0; 211 return 0;
212} 212}
213 213
214#define MLX5_U64_4K_PAGE_MASK ((~(u64)0U) << PAGE_SHIFT)
215
214static void free_4k(struct mlx5_core_dev *dev, u64 addr) 216static void free_4k(struct mlx5_core_dev *dev, u64 addr)
215{ 217{
216 struct fw_page *fwp; 218 struct fw_page *fwp;
217 int n; 219 int n;
218 220
219 fwp = find_fw_page(dev, addr & PAGE_MASK); 221 fwp = find_fw_page(dev, addr & MLX5_U64_4K_PAGE_MASK);
220 if (!fwp) { 222 if (!fwp) {
221 mlx5_core_warn(dev, "page not found\n"); 223 mlx5_core_warn(dev, "page not found\n");
222 return; 224 return;
223 } 225 }
224 226
225 n = (addr & ~PAGE_MASK) >> MLX5_ADAPTER_PAGE_SHIFT; 227 n = (addr & ~MLX5_U64_4K_PAGE_MASK) >> MLX5_ADAPTER_PAGE_SHIFT;
226 fwp->free_count++; 228 fwp->free_count++;
227 set_bit(n, &fwp->bitmask); 229 set_bit(n, &fwp->bitmask);
228 if (fwp->free_count == MLX5_NUM_4K_IN_PAGE) { 230 if (fwp->free_count == MLX5_NUM_4K_IN_PAGE) {
229 rb_erase(&fwp->rb_node, &dev->priv.page_root); 231 rb_erase(&fwp->rb_node, &dev->priv.page_root);
230 if (fwp->free_count != 1) 232 if (fwp->free_count != 1)
231 list_del(&fwp->list); 233 list_del(&fwp->list);
232 dma_unmap_page(&dev->pdev->dev, addr & PAGE_MASK, PAGE_SIZE, 234 dma_unmap_page(&dev->pdev->dev, addr & MLX5_U64_4K_PAGE_MASK,
233 DMA_BIDIRECTIONAL); 235 PAGE_SIZE, DMA_BIDIRECTIONAL);
234 __free_page(fwp->page); 236 __free_page(fwp->page);
235 kfree(fwp); 237 kfree(fwp);
236 } else if (fwp->free_count == 1) { 238 } else if (fwp->free_count == 1) {