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,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Hal Rosenstock
<hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>,
Hans-Christian Noren Egtvedt
<egtvedt-BrfabpQBY5qlHtIdYg32fQ@public.gmane.org>,
Vineet Gupta <vgupta-HKixBCOQz3hWk0Htik3J/w@public.gmane.org>,
Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>,
Gerald Schaefer
<gerald.schaefer-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>,
Krzysztof Kozlowski
<k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
Dave Hansen <dave.hansen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Subject: Re: [PATCH v2 2/8] ib_umem: Add a new, more generic ib_umem_get_attrs
Date: Wed, 05 Apr 2017 17:20:38 +0200 [thread overview]
Message-ID: <1491405638.5830.209.camel@oracle.com> (raw)
In-Reply-To: <53550a232af32c5c97ba9fb70faacc2c64d8fceb.1474049924.git-series.knut.omang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Dough,
This patch and the next in this set is IMHO together a generic enhancement/cleanup,
is it something you would consider to take just as that?
I am looking at suggesting a simplified, less target specific version of this set
to get it off my chest,
Thanks,
Knut
On Fri, 2016-09-16 at 20:31 +0200, Knut Omang wrote:
> 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.
> ---
> 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,
--
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
WARNING: multiple messages have this Message-ID (diff)
From: Knut Omang <knut.omang@oracle.com>
To: Doug Ledford <dledford@redhat.com>
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
Sean Hefty <sean.hefty@intel.com>,
Hal Rosenstock <hal.rosenstock@gmail.com>,
Robin Murphy <robin.murphy@arm.com>,
Hans-Christian Noren Egtvedt <egtvedt@samfundet.no>,
Vineet Gupta <vgupta@synopsys.com>,
Joerg Roedel <jroedel@suse.de>,
Gerald Schaefer <gerald.schaefer@de.ibm.com>,
Krzysztof Kozlowski <k.kozlowski@samsung.com>,
Dave Hansen <dave.hansen@linux.intel.com>
Subject: Re: [PATCH v2 2/8] ib_umem: Add a new, more generic ib_umem_get_attrs
Date: Wed, 05 Apr 2017 17:20:38 +0200 [thread overview]
Message-ID: <1491405638.5830.209.camel@oracle.com> (raw)
In-Reply-To: <53550a232af32c5c97ba9fb70faacc2c64d8fceb.1474049924.git-series.knut.omang@oracle.com>
Dough,
This patch and the next in this set is IMHO together a generic enhancement/cleanup,
is it something you would consider to take just as that?
I am looking at suggesting a simplified, less target specific version of this set
to get it off my chest,
Thanks,
Knut
On Fri, 2016-09-16 at 20:31 +0200, Knut Omang wrote:
> 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.
> ---
> 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,
next prev parent reply other threads:[~2017-04-05 15:20 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-16 18:31 [PATCH v2 0/8] SIF related verbs patches Knut Omang
2016-09-16 18:31 ` [PATCH v2 1/8] ib_mad: incoming sminfo SMPs gets discarded if no process_mad function is registered Knut Omang
[not found] ` <66d69383a3376018d99c025cd188150f6673b209.1474049924.git-series.knut.omang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-16 20:28 ` Santosh Shilimkar
2016-09-16 20:28 ` Santosh Shilimkar
[not found] ` <b57491e1-e36b-c331-8360-557310d15002-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-16 20:40 ` Knut Omang
2016-09-16 20:40 ` Knut Omang
2016-09-16 18:31 ` [PATCH v2 5/8] ib_uverbs: Add padding to end align ib_uverbs_reg_mr_resp Knut Omang
2016-09-20 10:45 ` Yishai Hadas
2016-09-20 11:02 ` Knut Omang
2016-09-16 18:31 ` [PATCH v2 8/8] ib_uverbs: Support for kernel implementation of XRC Knut Omang
[not found] ` <88ffb8c9407a71069b52e155dde308a36dfaf247.1474049924.git-series.knut.omang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-16 19:31 ` Jason Gunthorpe
2016-09-16 19:31 ` Jason Gunthorpe
[not found] ` <20160916193102.GB28859-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-09-16 19:49 ` Knut Omang
2016-09-16 19:49 ` Knut Omang
[not found] ` <cover.15d71ac2c57534f1170c2c48374d3841ed75e676.1474049924.git-series.knut.omang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-09-16 18:31 ` [PATCH v2 2/8] ib_umem: Add a new, more generic ib_umem_get_attrs Knut Omang
2016-09-16 18:31 ` Knut Omang
[not found] ` <53550a232af32c5c97ba9fb70faacc2c64d8fceb.1474049924.git-series.knut.omang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2017-04-05 15:20 ` Knut Omang [this message]
2017-04-05 15:20 ` Knut Omang
2016-09-16 18:31 ` [PATCH v2 3/8] ib_umem: With the new ib_umem_get_attrs, simplify ib_umem_get Knut Omang
2016-09-16 18:31 ` Knut Omang
2016-09-16 18:31 ` [PATCH v2 4/8] ib: Add udata argument to create_ah Knut Omang
2016-09-16 18:31 ` Knut Omang
2016-09-16 18:31 ` [PATCH v2 6/8] ib_uverbs: Avoid vendor specific masking of attributes in query_qp Knut Omang
2016-09-16 18:31 ` Knut Omang
2016-09-16 18:31 ` [PATCH v2 7/8] ib_{uverbs/core}: add new ib_create_qp_ex with udata arg Knut Omang
2016-09-16 18:31 ` Knut Omang
2016-09-16 20:30 ` [PATCH v2 0/8] SIF related verbs patches Santosh Shilimkar
2016-09-16 20:30 ` Santosh Shilimkar
2016-09-16 20:42 ` 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=1491405638.5830.209.camel@oracle.com \
--to=knut.omang-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
--cc=dave.hansen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=egtvedt-BrfabpQBY5qlHtIdYg32fQ@public.gmane.org \
--cc=gerald.schaefer-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org \
--cc=hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=jroedel-l3A5Bk7waGM@public.gmane.org \
--cc=k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=robin.murphy-5wv7dgnIgG8@public.gmane.org \
--cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=vgupta-HKixBCOQz3hWk0Htik3J/w@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.