Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cb9fbc5c authored by Arthur Kepner's avatar Arthur Kepner Committed by Linus Torvalds
Browse files

IB: expand ib_umem_get() prototype



Add a new parameter, dmasync, to the ib_umem_get() prototype.  Use dmasync = 1
when mapping user-allocated CQs with ib_umem_get().

Signed-off-by: default avatarArthur Kepner <akepner@sgi.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: Jes Sorensen <jes@sgi.com>
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Roland Dreier <rdreier@cisco.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: David Miller <davem@davemloft.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Grant Grundler <grundler@parisc-linux.org>
Cc: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 309df0c5
Loading
Loading
Loading
Loading
+12 −5
Original line number Original line Diff line number Diff line
@@ -38,6 +38,7 @@
#include <linux/dma-mapping.h>
#include <linux/dma-mapping.h>
#include <linux/sched.h>
#include <linux/sched.h>
#include <linux/hugetlb.h>
#include <linux/hugetlb.h>
#include <linux/dma-attrs.h>


#include "uverbs.h"
#include "uverbs.h"


@@ -72,9 +73,10 @@ static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int d
 * @addr: userspace virtual address to start at
 * @addr: userspace virtual address to start at
 * @size: length of region to pin
 * @size: length of region to pin
 * @access: IB_ACCESS_xxx flags for memory being pinned
 * @access: IB_ACCESS_xxx flags for memory being pinned
 * @dmasync: flush in-flight DMA when the memory region is written
 */
 */
struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
			    size_t size, int access)
			    size_t size, int access, int dmasync)
{
{
	struct ib_umem *umem;
	struct ib_umem *umem;
	struct page **page_list;
	struct page **page_list;
@@ -87,6 +89,10 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
	int ret;
	int ret;
	int off;
	int off;
	int i;
	int i;
	DEFINE_DMA_ATTRS(attrs);

	if (dmasync)
		dma_set_attr(DMA_ATTR_WRITE_BARRIER, &attrs);


	if (!can_do_mlock())
	if (!can_do_mlock())
		return ERR_PTR(-EPERM);
		return ERR_PTR(-EPERM);
@@ -174,10 +180,11 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
				sg_set_page(&chunk->page_list[i], page_list[i + off], PAGE_SIZE, 0);
				sg_set_page(&chunk->page_list[i], page_list[i + off], PAGE_SIZE, 0);
			}
			}


			chunk->nmap = ib_dma_map_sg(context->device,
			chunk->nmap = ib_dma_map_sg_attrs(context->device,
							  &chunk->page_list[0],
							  &chunk->page_list[0],
							  chunk->nents,
							  chunk->nents,
						    DMA_BIDIRECTIONAL);
							  DMA_BIDIRECTIONAL,
							  &attrs);
			if (chunk->nmap <= 0) {
			if (chunk->nmap <= 0) {
				for (i = 0; i < chunk->nents; ++i)
				for (i = 0; i < chunk->nents; ++i)
					put_page(sg_page(&chunk->page_list[i]));
					put_page(sg_page(&chunk->page_list[i]));
+1 −1
Original line number Original line Diff line number Diff line
@@ -452,7 +452,7 @@ static struct ib_mr *c2_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
		return ERR_PTR(-ENOMEM);
		return ERR_PTR(-ENOMEM);
	c2mr->pd = c2pd;
	c2mr->pd = c2pd;


	c2mr->umem = ib_umem_get(pd->uobject->context, start, length, acc);
	c2mr->umem = ib_umem_get(pd->uobject->context, start, length, acc, 0);
	if (IS_ERR(c2mr->umem)) {
	if (IS_ERR(c2mr->umem)) {
		err = PTR_ERR(c2mr->umem);
		err = PTR_ERR(c2mr->umem);
		kfree(c2mr);
		kfree(c2mr);
+1 −1
Original line number Original line Diff line number Diff line
@@ -602,7 +602,7 @@ static struct ib_mr *iwch_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
	if (!mhp)
	if (!mhp)
		return ERR_PTR(-ENOMEM);
		return ERR_PTR(-ENOMEM);


	mhp->umem = ib_umem_get(pd->uobject->context, start, length, acc);
	mhp->umem = ib_umem_get(pd->uobject->context, start, length, acc, 0);
	if (IS_ERR(mhp->umem)) {
	if (IS_ERR(mhp->umem)) {
		err = PTR_ERR(mhp->umem);
		err = PTR_ERR(mhp->umem);
		kfree(mhp);
		kfree(mhp);
+1 −1
Original line number Original line Diff line number Diff line
@@ -323,7 +323,7 @@ struct ib_mr *ehca_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
	}
	}


	e_mr->umem = ib_umem_get(pd->uobject->context, start, length,
	e_mr->umem = ib_umem_get(pd->uobject->context, start, length,
				 mr_access_flags);
				 mr_access_flags, 0);
	if (IS_ERR(e_mr->umem)) {
	if (IS_ERR(e_mr->umem)) {
		ib_mr = (void *)e_mr->umem;
		ib_mr = (void *)e_mr->umem;
		goto reg_user_mr_exit1;
		goto reg_user_mr_exit1;
+2 −1
Original line number Original line Diff line number Diff line
@@ -195,7 +195,8 @@ struct ib_mr *ipath_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
		goto bail;
		goto bail;
	}
	}


	umem = ib_umem_get(pd->uobject->context, start, length, mr_access_flags);
	umem = ib_umem_get(pd->uobject->context, start, length,
			   mr_access_flags, 0);
	if (IS_ERR(umem))
	if (IS_ERR(umem))
		return (void *) umem;
		return (void *) umem;


Loading