All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
To: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 07/10] amso1100: fold c2_reg_phys_mr into c2_get_dma_mr
Date: Fri, 18 Dec 2015 14:55:03 +0100	[thread overview]
Message-ID: <1450446906-10336-8-git-send-email-hch@lst.de> (raw)
In-Reply-To: <1450446906-10336-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>

Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
Reviewed-by: Sagi Grimberg <sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Reviewed-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org> [core]
Reviewed-by: Steve Wise <swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
---
 drivers/staging/rdma/amso1100/c2_provider.c | 71 ++++++-----------------------
 1 file changed, 14 insertions(+), 57 deletions(-)

diff --git a/drivers/staging/rdma/amso1100/c2_provider.c b/drivers/staging/rdma/amso1100/c2_provider.c
index 6c3e9cc..1691fc7 100644
--- a/drivers/staging/rdma/amso1100/c2_provider.c
+++ b/drivers/staging/rdma/amso1100/c2_provider.c
@@ -323,43 +323,21 @@ static inline u32 c2_convert_access(int acc)
 	    C2_ACF_LOCAL_READ | C2_ACF_WINDOW_BIND;
 }
 
-static struct ib_mr *c2_reg_phys_mr(struct ib_pd *ib_pd,
-				    struct ib_phys_buf *buffer_list,
-				    int num_phys_buf, int acc, u64 * iova_start)
+static struct ib_mr *c2_get_dma_mr(struct ib_pd *pd, int acc)
 {
 	struct c2_mr *mr;
 	u64 *page_list;
-	u32 total_len;
-	int err, i, j, k, page_shift, pbl_depth;
+	const u32 total_len = 0xffffffff;	/* AMSO1100 limit */
+	int err, page_shift, pbl_depth, i;
+	u64 kva = 0;
 
-	pbl_depth = 0;
-	total_len = 0;
+	pr_debug("%s:%u\n", __func__, __LINE__);
 
-	page_shift = PAGE_SHIFT;
 	/*
-	 * If there is only 1 buffer we assume this could
-	 * be a map of all phy mem...use a 32k page_shift.
+	 * This is a map of all phy mem...use a 32k page_shift.
 	 */
-	if (num_phys_buf == 1)
-		page_shift += 3;
-
-	for (i = 0; i < num_phys_buf; i++) {
-
-		if (offset_in_page(buffer_list[i].addr)) {
-			pr_debug("Unaligned Memory Buffer: 0x%x\n",
-				(unsigned int) buffer_list[i].addr);
-			return ERR_PTR(-EINVAL);
-		}
-
-		if (!buffer_list[i].size) {
-			pr_debug("Invalid Buffer Size\n");
-			return ERR_PTR(-EINVAL);
-		}
-
-		total_len += buffer_list[i].size;
-		pbl_depth += ALIGN(buffer_list[i].size,
-				   BIT(page_shift)) >> page_shift;
-	}
+	page_shift = PAGE_SHIFT + 3;
+	pbl_depth = ALIGN(total_len, BIT(page_shift)) >> page_shift;
 
 	page_list = vmalloc(sizeof(u64) * pbl_depth);
 	if (!page_list) {
@@ -368,16 +346,8 @@ static struct ib_mr *c2_reg_phys_mr(struct ib_pd *ib_pd,
 		return ERR_PTR(-ENOMEM);
 	}
 
-	for (i = 0, j = 0; i < num_phys_buf; i++) {
-
-		int naddrs;
-
- 		naddrs = ALIGN(buffer_list[i].size,
-			       BIT(page_shift)) >> page_shift;
-		for (k = 0; k < naddrs; k++)
-			page_list[j++] = (buffer_list[i].addr +
-						     (k << page_shift));
-	}
+	for (i = 0; i < pbl_depth; i++)
+		page_list[i] = (i << page_shift);
 
 	mr = kmalloc(sizeof(*mr), GFP_KERNEL);
 	if (!mr) {
@@ -385,17 +355,17 @@ static struct ib_mr *c2_reg_phys_mr(struct ib_pd *ib_pd,
 		return ERR_PTR(-ENOMEM);
 	}
 
-	mr->pd = to_c2pd(ib_pd);
+	mr->pd = to_c2pd(pd);
 	mr->umem = NULL;
 	pr_debug("%s - page shift %d, pbl_depth %d, total_len %u, "
 		"*iova_start %llx, first pa %llx, last pa %llx\n",
 		__func__, page_shift, pbl_depth, total_len,
-		(unsigned long long) *iova_start,
+		(unsigned long long) kva,
 	       	(unsigned long long) page_list[0],
 	       	(unsigned long long) page_list[pbl_depth-1]);
-  	err = c2_nsmr_register_phys_kern(to_c2dev(ib_pd->device), page_list,
+  	err = c2_nsmr_register_phys_kern(to_c2dev(pd->device), page_list,
 					 BIT(page_shift), pbl_depth,
-					 total_len, 0, iova_start,
+					 total_len, 0, &kva,
 					 c2_convert_access(acc), mr);
 	vfree(page_list);
 	if (err) {
@@ -406,19 +376,6 @@ static struct ib_mr *c2_reg_phys_mr(struct ib_pd *ib_pd,
 	return &mr->ibmr;
 }
 
-static struct ib_mr *c2_get_dma_mr(struct ib_pd *pd, int acc)
-{
-	struct ib_phys_buf bl;
-	u64 kva = 0;
-
-	pr_debug("%s:%u\n", __func__, __LINE__);
-
-	/* AMSO1100 limit */
-	bl.size = 0xffffffff;
-	bl.addr = 0;
-	return c2_reg_phys_mr(pd, &bl, 1, acc, &kva);
-}
-
 static struct ib_mr *c2_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
 				    u64 virt, int acc, struct ib_udata *udata)
 {
-- 
1.9.1

--
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

  parent reply	other threads:[~2015-12-18 13:55 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-18 13:54 MR cleanups Christoph Hellwig
     [not found] ` <1450446906-10336-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2015-12-18 13:54   ` [PATCH 01/10] IB: start documenting device capabilities Christoph Hellwig
2015-12-18 13:54   ` [PATCH 02/10] IB: remove ib_query_mr Christoph Hellwig
2015-12-18 13:54   ` [PATCH 03/10] IB: remove support for phys MRs Christoph Hellwig
2015-12-18 13:55   ` [PATCH 04/10] IB: remove in-kernel support for memory windows Christoph Hellwig
2015-12-18 13:55   ` [PATCH 05/10] cxgb3: simplify iwch_get_dma_wr Christoph Hellwig
2015-12-18 13:55   ` [PATCH 06/10] nes: simplify nes_reg_phys_mr calling conventions Christoph Hellwig
2015-12-18 13:55   ` Christoph Hellwig [this message]
2015-12-18 13:55   ` [PATCH 08/10] ehca: stop using struct ib_phys_buf Christoph Hellwig
2015-12-18 13:55   ` [PATCH 09/10] IB: remove the struct ib_phys_buf definition Christoph Hellwig
     [not found]     ` <1450446906-10336-10-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2015-12-20  7:37       ` Or Gerlitz
     [not found]         ` <56765AC2.2010104-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-12-20 15:41           ` Christoph Hellwig
     [not found]             ` <20151220154137.GA10351-jcswGhMUV9g@public.gmane.org>
2015-12-20 16:54               ` Or Gerlitz
2015-12-18 13:55   ` [PATCH 10/10] IB: remove the unused usecnt field from struct ib_mr Christoph Hellwig
     [not found]     ` <1450446906-10336-11-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2015-12-18 14:14       ` Bart Van Assche
     [not found]         ` <567414B0.2050406-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2015-12-20  7:16           ` Or Gerlitz
2015-12-20 15:42           ` Christoph Hellwig
2015-12-20  7:25       ` Or Gerlitz
     [not found]         ` <567657D1.5010700-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-12-20  7:36           ` Or Gerlitz
2015-12-20  9:31           ` Sagi Grimberg
     [not found]             ` <5676756B.6090208-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-12-20 11:27               ` Or Gerlitz
2015-12-20 11:28               ` Or Gerlitz
2015-12-20 11:33               ` Haggai Eran
     [not found]                 ` <56769223.7090308-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-12-20 11:42                   ` Sagi Grimberg
2015-12-23 18:12 MR cleanups / dead code removal V2 Christoph Hellwig
     [not found] ` <1450894374-8241-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2015-12-23 18:12   ` [PATCH 07/10] amso1100: fold c2_reg_phys_mr into c2_get_dma_mr Christoph Hellwig

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=1450446906-10336-8-git-send-email-hch@lst.de \
    --to=hch-jcswghmuv9g@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 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.