mlx4_core: For 64-bit systems, vmap() kernel queue buffers

Since kernel virtual memory is not a problem on 64-bit systems, there
is no reason to use our own 2-layer page mapping scheme for large
kernel queue buffers on such systems. Instead, map the page list to a
single virtually contiguous buffer with vmap(), so that can we access
buffer memory via direct indexing.

Signed-off-by: Michael S. Tsirkin <mst@dev.mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>

authored by Jack Morgenstein and committed by Roland Dreier 313abe55 1c69fc2a

+18 -2
+16
drivers/net/mlx4/alloc.c
··· 151 151 152 152 memset(buf->u.page_list[i].buf, 0, PAGE_SIZE); 153 153 } 154 + 155 + if (BITS_PER_LONG == 64) { 156 + struct page **pages; 157 + pages = kmalloc(sizeof *pages * buf->nbufs, GFP_KERNEL); 158 + if (!pages) 159 + goto err_free; 160 + for (i = 0; i < buf->nbufs; ++i) 161 + pages[i] = virt_to_page(buf->u.page_list[i].buf); 162 + buf->u.direct.buf = vmap(pages, buf->nbufs, VM_MAP, PAGE_KERNEL); 163 + kfree(pages); 164 + if (!buf->u.direct.buf) 165 + goto err_free; 166 + } 154 167 } 155 168 156 169 return 0; ··· 183 170 dma_free_coherent(&dev->pdev->dev, size, buf->u.direct.buf, 184 171 buf->u.direct.map); 185 172 else { 173 + if (BITS_PER_LONG == 64) 174 + vunmap(buf->u.direct.buf); 175 + 186 176 for (i = 0; i < buf->nbufs; ++i) 187 177 if (buf->u.page_list[i].buf) 188 178 dma_free_coherent(&dev->pdev->dev, PAGE_SIZE,
+2 -2
include/linux/mlx4/device.h
··· 189 189 }; 190 190 191 191 struct mlx4_buf { 192 - union { 192 + struct { 193 193 struct mlx4_buf_list direct; 194 194 struct mlx4_buf_list *page_list; 195 195 } u; ··· 310 310 void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf); 311 311 static inline void *mlx4_buf_offset(struct mlx4_buf *buf, int offset) 312 312 { 313 - if (buf->nbufs == 1) 313 + if (BITS_PER_LONG == 64 || buf->nbufs == 1) 314 314 return buf->u.direct.buf + offset; 315 315 else 316 316 return buf->u.page_list[offset >> PAGE_SHIFT].buf +