Message ID | 20150413003333.GA17193@honli.nay.redhat.com (mailing list archive) |
---|---|
State | Rejected |
Headers | show |
On Mon, Apr 13, 2015 at 08:33:33AM +0800, Honggang LI wrote: > > Yes, replaced all of the PAGE_MASK in the file. Please see attched new > patch. > I think you need to send the new patch inline in your email. > > > > @@ -241,7 +243,7 @@ static void free_4k(struct mlx5_core_dev *dev, u64 addr) static int alloc_system_page(struct mlx5_core_dev *dev, u16 func_id) { > > struct page *page; > > - u64 addr; > > + u64 addr = 0; [Eli] Why is this required? > > For 32bit architectures, if CONFIG_ARCH_DMA_ADDR_T_64BIT disabled and > physical memory is less than 4GB, dma_map_page will return an u32 integer > less than 0xffff_ffff. And if addr had been initialized with random > rubbish in the stack of alloc_system_page, the high four bytes is > unpredictable. The new mask, MLX5_NUM_4K_IN_PAGE, will reserve the high > four bytes. So, free_4k/find_fw_page will randomly failed. > Sorry, I still don't understand the issue here. MLX5_NUM_4K_IN_PAGE is not a mask and will always get the correct value which is fairly small. -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Mon, Apr 13, 2015 at 06:47:11AM +0000, Eli Cohen wrote: > On Mon, Apr 13, 2015 at 08:33:33AM +0800, Honggang LI wrote: > > > > Yes, replaced all of the PAGE_MASK in the file. Please see attched new > > patch. > > > > I think you need to send the new patch inline in your email. > I will resent the patch. > > > > > > @@ -241,7 +243,7 @@ static void free_4k(struct mlx5_core_dev *dev, u64 addr) static int alloc_system_page(struct mlx5_core_dev *dev, u16 func_id) { > > > struct page *page; > > > - u64 addr; > > > + u64 addr = 0; [Eli] Why is this required? > > > > For 32bit architectures, if CONFIG_ARCH_DMA_ADDR_T_64BIT disabled and > > physical memory is less than 4GB, dma_map_page will return an u32 integer > > less than 0xffff_ffff. And if addr had been initialized with random > > rubbish in the stack of alloc_system_page, the high four bytes is > > unpredictable. The new mask, MLX5_NUM_4K_IN_PAGE, will reserve the high > > four bytes. So, free_4k/find_fw_page will randomly failed. > > > > Sorry, I still don't understand the issue here. MLX5_NUM_4K_IN_PAGE is > not a mask and will always get the correct value which is fairly > small. Sorry. It was a typo. It should be MLX5_U64_4K_PAGE_MASK. -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c index df22383..595b507 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) return 0; } +#define MLX5_U64_4K_PAGE_MASK ((~(u64)0U) << PAGE_SHIFT) + static void free_4k(struct mlx5_core_dev *dev, u64 addr) { struct fw_page *fwp; int n; - fwp = find_fw_page(dev, addr & PAGE_MASK); + fwp = find_fw_page(dev, addr & MLX5_U64_4K_PAGE_MASK); if (!fwp) { mlx5_core_warn(dev, "page not found\n"); return; } - n = (addr & ~PAGE_MASK) >> MLX5_ADAPTER_PAGE_SHIFT; + n = (addr & ~MLX5_U64_4K_PAGE_MASK) >> MLX5_ADAPTER_PAGE_SHIFT; fwp->free_count++; set_bit(n, &fwp->bitmask); if (fwp->free_count == MLX5_NUM_4K_IN_PAGE) { rb_erase(&fwp->rb_node, &dev->priv.page_root); if (fwp->free_count != 1) list_del(&fwp->list); - dma_unmap_page(&dev->pdev->dev, addr & PAGE_MASK, PAGE_SIZE, - DMA_BIDIRECTIONAL); + dma_unmap_page(&dev->pdev->dev, addr & MLX5_U64_4K_PAGE_MASK, + PAGE_SIZE, DMA_BIDIRECTIONAL); __free_page(fwp->page); kfree(fwp); } else if (fwp->free_count == 1) { @@ -241,7 +243,7 @@ static void free_4k(struct mlx5_core_dev *dev, u64 addr) static int alloc_system_page(struct mlx5_core_dev *dev, u16 func_id) { struct page *page; - u64 addr; + u64 addr = 0; int err; int nid = dev_to_node(&dev->pdev->dev);