IB/mlx4: For 64-bit systems, use large virtually contiguous queue buffers 
(rather than 2-layer).

Since kernel virtual memory is not a problem on 64-bit systems, there is no
reason to use a 2-layer page mapping scheme on such systems. Instead,
map the page list to a single virtually contiguous buffer, so that
can access buffer memory via direct indexing.

Signed-off-by: Michael S. Tsirkin <[EMAIL PROTECTED]>
Signed-off-by: Jack Morgenstein <[EMAIL PROTECTED]>

---

Roland, this 2-patch series is based on your for-2.6.25 tree,
commit 9b73e76f3cf63379dcf45fcd4f112f5812418d0a

Index: infiniband/drivers/net/mlx4/alloc.c
===================================================================
--- infiniband.orig/drivers/net/mlx4/alloc.c    2008-01-22 18:41:14.000000000 
+0200
+++ infiniband/drivers/net/mlx4/alloc.c 2008-01-27 10:52:21.000000000 +0200
@@ -151,6 +151,19 @@ int mlx4_buf_alloc(struct mlx4_dev *dev,
 
                        memset(buf->u.page_list[i].buf, 0, PAGE_SIZE);
                }
+
+               if (BITS_PER_LONG == 64) {
+                       struct page **pages;
+                       pages = kmalloc(sizeof *pages * buf->nbufs, GFP_KERNEL);
+                       if (!pages)
+                               goto err_free;
+                       for (i = 0; i < buf->nbufs; ++i)
+                               pages[i] = 
virt_to_page(buf->u.page_list[i].buf);
+                       buf->u.direct.buf = vmap(pages, buf->nbufs, VM_MAP, 
PAGE_KERNEL);
+                       kfree(pages);
+                       if (!buf->u.direct.buf)
+                               goto err_free;
+               }
        }
 
        return 0;
@@ -170,6 +183,9 @@ void mlx4_buf_free(struct mlx4_dev *dev,
                dma_free_coherent(&dev->pdev->dev, size, buf->u.direct.buf,
                                  buf->u.direct.map);
        else {
+               if (BITS_PER_LONG == 64)
+                       vunmap(buf->u.direct.buf);
+
                for (i = 0; i < buf->nbufs; ++i)
                        if (buf->u.page_list[i].buf)
                                dma_free_coherent(&dev->pdev->dev, PAGE_SIZE,
Index: infiniband/include/linux/mlx4/device.h
===================================================================
--- infiniband.orig/include/linux/mlx4/device.h 2008-01-27 10:44:25.000000000 
+0200
+++ infiniband/include/linux/mlx4/device.h      2008-01-27 10:52:21.000000000 
+0200
@@ -189,7 +189,7 @@ struct mlx4_buf_list {
 };
 
 struct mlx4_buf {
-       union {
+       struct {
                struct mlx4_buf_list    direct;
                struct mlx4_buf_list   *page_list;
        } u;
Index: infiniband/drivers/infiniband/hw/mlx4/qp.c
===================================================================
--- infiniband.orig/drivers/infiniband/hw/mlx4/qp.c     2008-01-27 
10:44:25.000000000 +0200
+++ infiniband/drivers/infiniband/hw/mlx4/qp.c  2008-01-27 10:52:21.000000000 
+0200
@@ -96,7 +96,7 @@ static int is_qp0(struct mlx4_ib_dev *de
 
 static void *get_wqe(struct mlx4_ib_qp *qp, int offset)
 {
-       if (qp->buf.nbufs == 1)
+       if (BITS_PER_LONG == 64 || qp->buf.nbufs == 1)
                return qp->buf.u.direct.buf + offset;
        else
                return qp->buf.u.page_list[offset >> PAGE_SHIFT].buf +
_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to