From: Knut Omang <knut.omang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Knut Omang <knut.omang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH 2/9] ib_umem: Add a new, more generic ib_umem_get_attrs
Date: Fri, 2 Sep 2016 02:09:22 +0200 [thread overview]
Message-ID: <1472774969-18997-3-git-send-email-knut.omang@oracle.com> (raw)
In-Reply-To: <1472774969-18997-1-git-send-email-knut.omang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
This call allows a full range of DMA attributes and also
DMA direction to be supplied and is just a refactor of the old ib_umem_get.
Reimplement ib_umem_get using the new generic call,
now a trivial implementation.
Signed-off-by: Knut Omang <knut.omang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
drivers/infiniband/core/umem.c | 23 +++++++++++++++--------
include/rdma/ib_umem.h | 15 ++++++++++++++-
2 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index c68746c..699a0f7 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -52,7 +52,7 @@ static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int d
if (umem->nmap > 0)
ib_dma_unmap_sg(dev, umem->sg_head.sgl,
umem->nmap,
- DMA_BIDIRECTIONAL);
+ umem->dir);
for_each_sg(umem->sg_head.sgl, sg, umem->npages, i) {
@@ -82,6 +82,17 @@ static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int d
struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
size_t size, int access, int dmasync)
{
+ unsigned long dma_attrs = 0;
+ if (dmasync)
+ dma_attrs |= DMA_ATTR_WRITE_BARRIER;
+ return ib_umem_get_attrs(context, addr, size, access, DMA_BIDIRECTIONAL, dma_attrs);
+}
+EXPORT_SYMBOL(ib_umem_get);
+
+struct ib_umem *ib_umem_get_attrs(struct ib_ucontext *context, unsigned long addr,
+ size_t size, int access, enum dma_data_direction dir,
+ unsigned long dma_attrs)
+{
struct ib_umem *umem;
struct page **page_list;
struct vm_area_struct **vma_list;
@@ -91,16 +102,11 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
unsigned long npages;
int ret;
int i;
- unsigned long dma_attrs = 0;
struct scatterlist *sg, *sg_list_start;
int need_release = 0;
- if (dmasync)
- dma_attrs |= DMA_ATTR_WRITE_BARRIER;
-
if (!size)
return ERR_PTR(-EINVAL);
-
/*
* If the combination of the addr and size requested for this memory
* region causes an integer overflow, return error.
@@ -121,6 +127,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
umem->address = addr;
umem->page_size = PAGE_SIZE;
umem->pid = get_task_pid(current, PIDTYPE_PID);
+ umem->dir = dir;
/*
* We ask for writable memory if any of the following
* access flags are set. "Local write" and "remote write"
@@ -213,7 +220,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
umem->nmap = ib_dma_map_sg_attrs(context->device,
umem->sg_head.sgl,
umem->npages,
- DMA_BIDIRECTIONAL,
+ dir,
dma_attrs);
if (umem->nmap <= 0) {
@@ -239,7 +246,7 @@ out:
return ret < 0 ? ERR_PTR(ret) : umem;
}
-EXPORT_SYMBOL(ib_umem_get);
+EXPORT_SYMBOL(ib_umem_get_attrs);
static void ib_umem_account(struct work_struct *work)
{
diff --git a/include/rdma/ib_umem.h b/include/rdma/ib_umem.h
index 2d83cfd..2876679 100644
--- a/include/rdma/ib_umem.h
+++ b/include/rdma/ib_umem.h
@@ -36,6 +36,7 @@
#include <linux/list.h>
#include <linux/scatterlist.h>
#include <linux/workqueue.h>
+#include <linux/dma-direction.h>
struct ib_ucontext;
struct ib_umem_odp;
@@ -47,6 +48,7 @@ struct ib_umem {
int page_size;
int writable;
int hugetlb;
+ enum dma_data_direction dir;
struct work_struct work;
struct pid *pid;
struct mm_struct *mm;
@@ -81,9 +83,12 @@ static inline size_t ib_umem_num_pages(struct ib_umem *umem)
}
#ifdef CONFIG_INFINIBAND_USER_MEM
-
struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
size_t size, int access, int dmasync);
+struct ib_umem *ib_umem_get_attrs(struct ib_ucontext *context, unsigned long addr,
+ size_t size, int access,
+ enum dma_data_direction dir,
+ unsigned long dma_attrs);
void ib_umem_release(struct ib_umem *umem);
int ib_umem_page_count(struct ib_umem *umem);
int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,
@@ -98,6 +103,14 @@ static inline struct ib_umem *ib_umem_get(struct ib_ucontext *context,
int access, int dmasync) {
return ERR_PTR(-EINVAL);
}
+static inline struct ib_umem *ib_umem_get_attrs(struct ib_ucontext *context,
+ unsigned long addr,
+ size_t size, int access,
+ enum dma_data_direction dir,
+ unsigned long dma_attrs)
+{
+ return ERR_PTR(-EINVAL);
+}
static inline void ib_umem_release(struct ib_umem *umem) { }
static inline int ib_umem_page_count(struct ib_umem *umem) { return 0; }
static inline int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,
--
2.5.5
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-09-02 0:09 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-02 0:09 [PATCH 0/9] SIF related verbs patches Knut Omang
[not found] ` <1472774969-18997-1-git-send-email-knut.omang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-02 0:09 ` [PATCH 1/9] ib_mad: incoming sminfo SMPs gets discarded if no process_mad function is registered Knut Omang
[not found] ` <1472774969-18997-2-git-send-email-knut.omang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-06 14:01 ` Hal Rosenstock
[not found] ` <57867d7f-cc9f-5ec2-6632-c552e6469e40-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2016-09-07 11:42 ` Knut Omang
[not found] ` <1473248532.3103.51.camel-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-08 11:33 ` Hal Rosenstock
[not found] ` <098f69ae-6940-589a-e9ad-c65e34c958b7-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2016-09-08 17:22 ` Knut Omang
[not found] ` <1473355350.569.5.camel-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-08 19:02 ` Hal Rosenstock
[not found] ` <2eddf795-71bb-1866-42d9-8a3ba3d512d4-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2016-09-09 2:23 ` Knut Omang
[not found] ` <1473387784.569.17.camel-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-09 14:24 ` Hal Rosenstock
[not found] ` <37195bbc-0db0-8054-2174-8dc0faf7c692-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2016-09-12 9:09 ` Knut Omang
[not found] ` <1473671364.17998.17.camel-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-12 14:03 ` Hal Rosenstock
2016-09-02 0:09 ` Knut Omang [this message]
2016-09-02 0:09 ` [PATCH 3/9] ib_umem: With the new ib_umem_get_attrs, simplify ib_umem_get Knut Omang
2016-09-02 0:09 ` [PATCH 4/9] ib: Add udata argument to create_ah Knut Omang
[not found] ` <1472774969-18997-5-git-send-email-knut.omang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-02 0:38 ` kbuild test robot
2016-09-02 0:39 ` kbuild test robot
[not found] ` <201609020848.QliVPrIS%fengguang.wu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-09-02 8:01 ` Knut Omang
2016-09-02 0:09 ` [PATCH 5/9] ib_uverbs: Add padding to end align ib_uverbs_reg_mr_resp Knut Omang
[not found] ` <1472774969-18997-6-git-send-email-knut.omang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-02 2:09 ` Jason Gunthorpe
[not found] ` <20160902020945.GB30057-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-09-02 7:54 ` Knut Omang
2016-09-02 0:09 ` [PATCH 6/9] ib_uverbs: Avoid vendor specific masking of attributes in query_qp Knut Omang
[not found] ` <1472774969-18997-7-git-send-email-knut.omang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-02 2:13 ` Jason Gunthorpe
[not found] ` <20160902021300.GC30057-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-09-02 4:45 ` Knut Omang
[not found] ` <1472791552.9410.258.camel-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-02 17:10 ` Jason Gunthorpe
[not found] ` <20160902171008.GE24997-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-09-02 17:35 ` Knut Omang
[not found] ` <1472837728.9410.340.camel-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-12 15:05 ` Knut Omang
2016-09-02 0:09 ` [PATCH 7/9] ib_{uverbs/core}: add new ib_create_qp_ex with udata arg Knut Omang
2016-09-02 0:09 ` [PATCH 8/9] ib_uverbs: Support for kernel implementation of XRC Knut Omang
[not found] ` <1472774969-18997-9-git-send-email-knut.omang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-02 2:16 ` Jason Gunthorpe
[not found] ` <20160902021640.GD30057-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-09-02 7:55 ` Knut Omang
2016-09-02 0:09 ` [PATCH 9/9] ib_verbs: Add a new qp create flag to request features for Ethernet over IB Knut Omang
[not found] ` <1472774969-18997-10-git-send-email-knut.omang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-02 2:17 ` Jason Gunthorpe
[not found] ` <20160902021729.GE30057-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-09-02 5:04 ` Knut Omang
[not found] ` <1472792670.9410.276.camel-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-02 11:00 ` Knut Omang
[not found] ` <1472814057.3975.47.camel-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-02 16:19 ` Santosh Shilimkar
[not found] ` <b38c5cf6-4e07-33eb-8704-284498481bb6-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-02 17:11 ` Jason Gunthorpe
[not found] ` <20160902171107.GF24997-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-09-02 17:14 ` Santosh Shilimkar
2016-09-02 16:34 ` Jason Gunthorpe
[not found] ` <20160902163451.GC24997-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-09-07 17:33 ` Knut Omang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1472774969-18997-3-git-send-email-knut.omang@oracle.com \
--to=knut.omang-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).