From: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
To: Sagi Grimberg <sagig-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
Cc: Sagi Grimberg <sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
"linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"Nicholas A. Bellinger"
<nab-IzHhD5pYlfBP7FQvKIMDCQ@public.gmane.org>
Subject: Re: [PATCH v1 00/24] New fast registration API
Date: Tue, 6 Oct 2015 11:49:29 -0700 [thread overview]
Message-ID: <561417B9.2080505@sandisk.com> (raw)
In-Reply-To: <56138854.4040209-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
On 10/06/2015 01:37 AM, Sagi Grimberg wrote:
> I see now the error you are referring to.
>
> The issue is that the device requires the MR page array to have
> an alignment (0x40 for mlx4 and 0x400 for mlx5). When I modified the
> page array allocation to be non-coherent I didn't take care of
> alignment.
>
> Taking care of this alignment may result in a higher order allocation
> as we'd need to add (alignment - 1) to the allocation size.
>
> e.g. a 512 pages on mlx4 will become:
> 512 * 8 + 0x40 - 1 = 4159
>
> I'm leaning towards this approach. Any preference?
>
> I think this patch should take care of mlx4:
> [ ... ]
Hello Sagi,
Thanks for the patch. But since the patch included in the previous
e-mail mapped a memory range that could be outside the bounds of the
allocated memory I have been testing the patch below:
---
drivers/infiniband/hw/mlx4/mlx4_ib.h | 3 +++
drivers/infiniband/hw/mlx4/mr.c | 19 ++++++++++++-------
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index de6eab3..864d595 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -129,6 +129,8 @@ struct mlx4_ib_cq {
struct list_head recv_qp_list;
};
+#define MLX4_MR_PAGES_ALIGN 0x40
+
struct mlx4_ib_mr {
struct ib_mr ibmr;
__be64 *pages;
@@ -137,6 +139,7 @@ struct mlx4_ib_mr {
u32 max_pages;
struct mlx4_mr mmr;
struct ib_umem *umem;
+ void *pages_alloc;
};
struct mlx4_ib_mw {
diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c
index fa01f75..8121c1c 100644
--- a/drivers/infiniband/hw/mlx4/mr.c
+++ b/drivers/infiniband/hw/mlx4/mr.c
@@ -277,12 +277,17 @@ mlx4_alloc_priv_pages(struct ib_device *device,
int max_pages)
{
int size = max_pages * sizeof(u64);
+ int add_size;
int ret;
- mr->pages = kzalloc(size, GFP_KERNEL);
- if (!mr->pages)
+ add_size = max_t(int, MLX4_MR_PAGES_ALIGN - ARCH_KMALLOC_MINALIGN, 0);
+
+ mr->pages_alloc = kzalloc(size + add_size, GFP_KERNEL);
+ if (!mr->pages_alloc)
return -ENOMEM;
+ mr->pages = PTR_ALIGN(mr->pages_alloc, MLX4_MR_PAGES_ALIGN);
+
mr->page_map = dma_map_single(device->dma_device, mr->pages,
size, DMA_TO_DEVICE);
@@ -293,20 +298,20 @@ mlx4_alloc_priv_pages(struct ib_device *device,
return 0;
err:
- kfree(mr->pages);
+ kfree(mr->pages_alloc);
return ret;
}
static void
mlx4_free_priv_pages(struct mlx4_ib_mr *mr)
{
- struct ib_device *device = mr->ibmr.device;
- int size = mr->max_pages * sizeof(u64);
-
if (mr->pages) {
+ struct ib_device *device = mr->ibmr.device;
+ int size = mr->max_pages * sizeof(u64);
+
dma_unmap_single(device->dma_device, mr->page_map,
size, DMA_TO_DEVICE);
- kfree(mr->pages);
+ kfree(mr->pages_alloc);
mr->pages = NULL;
}
}
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" 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:[~2015-10-06 18:49 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-17 9:42 [PATCH v1 00/24] New fast registration API Sagi Grimberg
[not found] ` <1442482947-27785-1-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-09-17 9:42 ` [PATCH v1 01/24] IB/core: Introduce new " Sagi Grimberg
[not found] ` <1442482947-27785-2-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-09-22 21:21 ` Bart Van Assche
[not found] ` <5601C65F.8060403-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-09-24 7:37 ` Sagi Grimberg
[not found] ` <5603A841.70509-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-09-28 20:57 ` Bart Van Assche
[not found] ` <5609A9D0.8030607-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-09-29 5:59 ` Christoph Hellwig
[not found] ` <20150929055907.GA29758-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2015-09-29 6:47 ` Sagi Grimberg
[not found] ` <560A341F.7030108-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-09-29 6:49 ` Sagi Grimberg
2015-09-29 6:42 ` Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 02/24] IB/mlx5: Remove dead fmr code Sagi Grimberg
[not found] ` <1442482947-27785-3-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-09-22 21:24 ` Bart Van Assche
2015-09-17 9:42 ` [PATCH v1 03/24] IB/mlx5: Support the new memory registration API Sagi Grimberg
[not found] ` <1442482947-27785-4-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-09-22 21:27 ` Bart Van Assche
[not found] ` <5601C7A4.5030302-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-09-24 7:39 ` Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 04/24] IB/mlx4: " Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 05/24] RDMA/ocrdma: " Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 06/24] RDMA/cxgb3: " Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 07/24] iw_cxgb4: " Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 08/24] IB/qib: " Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 09/24] RDMA/nes: " Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 10/24] IB/iser: Port to new fast " Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 11/24] iser-target: Port to new memory " Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 12/24] xprtrdma: " Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 13/24] svcrdma: " Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 14/24] RDS/IW: Convert " Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 15/24] IB/srp: " Sagi Grimberg
[not found] ` <1442482947-27785-16-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-09-22 21:58 ` Bart Van Assche
[not found] ` <5601CF20.3040102-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-09-24 9:06 ` Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 16/24] IB/mlx5: Remove old FRWR API support Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 17/24] IB/mlx4: " Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 18/24] RDMA/ocrdma: Remove old FRWR API Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 19/24] RDMA/cxgb3: " Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 20/24] iw_cxgb4: " Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 21/24] IB/qib: " Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 22/24] RDMA/nes: " Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 23/24] IB/hfi1: Remove Old fast registraion API support Sagi Grimberg
2015-09-17 9:42 ` [PATCH v1 24/24] IB/core: Remove old fast registration API Sagi Grimberg
2015-09-19 22:45 ` [PATCH v1 00/24] New " Christoph Hellwig
[not found] ` <20150919224518.GA23027-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2015-09-24 6:53 ` Sagi Grimberg
[not found] ` <56039DE9.1010300-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-09-24 13:39 ` Christoph Hellwig
2015-09-19 23:20 ` santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA
[not found] ` <55FDEDD5.1090105-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2015-09-20 9:36 ` Sagi Grimberg
[not found] ` <55FE7E24.20300-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-09-21 23:28 ` santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA
[not found] ` <5600928A.7070202-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2015-09-22 7:19 ` Sagi Grimberg
[not found] ` <560100EA.8080302-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-09-22 7:56 ` Sagi Grimberg
[not found] ` <560109B7.8070005-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-09-22 18:23 ` santosh shilimkar
2015-09-22 21:22 ` Bart Van Assche
[not found] ` <5601C698.4000509-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-09-24 7:40 ` Sagi Grimberg
2015-09-29 19:03 ` Bart Van Assche
[not found] ` <560AE099.2080004-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-09-29 20:58 ` Sagi Grimberg
[not found] ` <560AFB71.3010003-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-09-30 6:47 ` Sagi Grimberg
2015-09-30 18:59 ` Bart Van Assche
[not found] ` <560C30F4.50900-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-09-30 20:15 ` Bart Van Assche
[not found] ` <560C42CE.6090000-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-10-01 7:16 ` Sagi Grimberg
[not found] ` <560CDDBC.8000400-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-10-01 17:53 ` Bart Van Assche
[not found] ` <560D730C.9000302-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-10-01 20:58 ` Bart Van Assche
[not found] ` <35618B90-4D6E-4036-A69B-4405F020D440@dev.mellanox.co.il>
[not found] ` <35618B90-4D6E-4036-A69B-4405F020D440-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-10-02 15:37 ` Bart Van Assche
[not found] ` <560EA4A1.3080709-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-10-06 8:37 ` Sagi Grimberg
[not found] ` <56138854.4040209-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-10-06 18:49 ` Bart Van Assche [this message]
[not found] ` <561417B9.2080505-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-10-07 6:42 ` Sagi Grimberg
[not found] ` <5614BECF.9030907-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-10-07 15:46 ` Bart Van Assche
[not found] ` <56153E41.10607-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-10-07 15:48 ` Sagi Grimberg
2015-10-07 9:20 ` Christoph Hellwig
[not found] ` <20151007092024.GA18020-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2015-10-07 9:25 ` Sagi Grimberg
[not found] ` <5614E505.7090808-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-10-07 9:36 ` Christoph Hellwig
[not found] ` <20151007093645.GA6940-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2015-10-07 10:00 ` Sagi Grimberg
2015-10-07 16:30 ` Bart Van Assche
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=561417B9.2080505@sandisk.com \
--to=bart.vanassche-xdaiopvojttbdgjk7y7tuq@public.gmane.org \
--cc=linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=nab-IzHhD5pYlfBP7FQvKIMDCQ@public.gmane.org \
--cc=sagig-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org \
--cc=sagig-VPRAkNaXOzVWk0Htik3J/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 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).