diff options
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_provider.c | 18 |
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 | ||
344 | static 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 | |||
343 | static struct ib_pd *mthca_alloc_pd(struct ib_device *ibdev, | 360 | static 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; |