aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2005-07-07 20:57:17 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-07 21:23:49 -0400
commit53b8b3ffd5e0b10f3c683096a663d0cc22179c43 (patch)
tree9cc09804e388e8febba6fd8d565dfdd633efe04b
parent5e0b537c7d94efe3fea0fee8e2533c3231a8af75 (diff)
[PATCH] IB uverbs: add mthca mmap support
Add support for mmap() method to mthca, so that userspace can get access to doorbell registers. This allows userspace to get direct access to the HCA for data path operations. Each userspace context gets its own copy of the doorbell registers and is only allowed to use resources that the kernel has given it access to. In other words, this is safe. Signed-off-by: Roland Dreier <rolandd@cisco.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index bfd33a470020..9acb8c54ce4f 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -35,6 +35,7 @@
35 */ 35 */
36 36
37#include <ib_smi.h> 37#include <ib_smi.h>
38#include <linux/mm.h>
38 39
39#include "mthca_dev.h" 40#include "mthca_dev.h"
40#include "mthca_cmd.h" 41#include "mthca_cmd.h"
@@ -340,6 +341,22 @@ static int mthca_dealloc_ucontext(struct ib_ucontext *context)
340 return 0; 341 return 0;
341} 342}
342 343
344static int mthca_mmap_uar(struct ib_ucontext *context,
345 struct vm_area_struct *vma)
346{
347 if (vma->vm_end - vma->vm_start != PAGE_SIZE)
348 return -EINVAL;
349
350 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
351
352 if (remap_pfn_range(vma, vma->vm_start,
353 to_mucontext(context)->uar.pfn,
354 PAGE_SIZE, vma->vm_page_prot))
355 return -EAGAIN;
356
357 return 0;
358}
359
343static struct ib_pd *mthca_alloc_pd(struct ib_device *ibdev, 360static struct ib_pd *mthca_alloc_pd(struct ib_device *ibdev,
344 struct ib_ucontext *context, 361 struct ib_ucontext *context,
345 struct ib_udata *udata) 362 struct ib_udata *udata)
@@ -766,6 +783,7 @@ int mthca_register_device(struct mthca_dev *dev)
766 dev->ib_dev.query_gid = mthca_query_gid; 783 dev->ib_dev.query_gid = mthca_query_gid;
767 dev->ib_dev.alloc_ucontext = mthca_alloc_ucontext; 784 dev->ib_dev.alloc_ucontext = mthca_alloc_ucontext;
768 dev->ib_dev.dealloc_ucontext = mthca_dealloc_ucontext; 785 dev->ib_dev.dealloc_ucontext = mthca_dealloc_ucontext;
786 dev->ib_dev.mmap = mthca_mmap_uar;
769 dev->ib_dev.alloc_pd = mthca_alloc_pd; 787 dev->ib_dev.alloc_pd = mthca_alloc_pd;
770 dev->ib_dev.dealloc_pd = mthca_dealloc_pd; 788 dev->ib_dev.dealloc_pd = mthca_dealloc_pd;
771 dev->ib_dev.create_ah = mthca_ah_create; 789 dev->ib_dev.create_ah = mthca_ah_create;