diff options
Diffstat (limited to 'net/rds/iw_rdma.c')
-rw-r--r-- | net/rds/iw_rdma.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/net/rds/iw_rdma.c b/net/rds/iw_rdma.c index dcdb37da80f2..de4a1b16bf7b 100644 --- a/net/rds/iw_rdma.c +++ b/net/rds/iw_rdma.c | |||
@@ -263,18 +263,12 @@ static void rds_iw_set_scatterlist(struct rds_iw_scatterlist *sg, | |||
263 | } | 263 | } |
264 | 264 | ||
265 | static u64 *rds_iw_map_scatterlist(struct rds_iw_device *rds_iwdev, | 265 | static u64 *rds_iw_map_scatterlist(struct rds_iw_device *rds_iwdev, |
266 | struct rds_iw_scatterlist *sg, | 266 | struct rds_iw_scatterlist *sg) |
267 | unsigned int dma_page_shift) | ||
268 | { | 267 | { |
269 | struct ib_device *dev = rds_iwdev->dev; | 268 | struct ib_device *dev = rds_iwdev->dev; |
270 | u64 *dma_pages = NULL; | 269 | u64 *dma_pages = NULL; |
271 | u64 dma_mask; | ||
272 | unsigned int dma_page_size; | ||
273 | int i, j, ret; | 270 | int i, j, ret; |
274 | 271 | ||
275 | dma_page_size = 1 << dma_page_shift; | ||
276 | dma_mask = dma_page_size - 1; | ||
277 | |||
278 | WARN_ON(sg->dma_len); | 272 | WARN_ON(sg->dma_len); |
279 | 273 | ||
280 | sg->dma_len = ib_dma_map_sg(dev, sg->list, sg->len, DMA_BIDIRECTIONAL); | 274 | sg->dma_len = ib_dma_map_sg(dev, sg->list, sg->len, DMA_BIDIRECTIONAL); |
@@ -295,18 +289,18 @@ static u64 *rds_iw_map_scatterlist(struct rds_iw_device *rds_iwdev, | |||
295 | sg->bytes += dma_len; | 289 | sg->bytes += dma_len; |
296 | 290 | ||
297 | end_addr = dma_addr + dma_len; | 291 | end_addr = dma_addr + dma_len; |
298 | if (dma_addr & dma_mask) { | 292 | if (dma_addr & PAGE_MASK) { |
299 | if (i > 0) | 293 | if (i > 0) |
300 | goto out_unmap; | 294 | goto out_unmap; |
301 | dma_addr &= ~dma_mask; | 295 | dma_addr &= ~PAGE_MASK; |
302 | } | 296 | } |
303 | if (end_addr & dma_mask) { | 297 | if (end_addr & PAGE_MASK) { |
304 | if (i < sg->dma_len - 1) | 298 | if (i < sg->dma_len - 1) |
305 | goto out_unmap; | 299 | goto out_unmap; |
306 | end_addr = (end_addr + dma_mask) & ~dma_mask; | 300 | end_addr = (end_addr + PAGE_MASK) & ~PAGE_MASK; |
307 | } | 301 | } |
308 | 302 | ||
309 | sg->dma_npages += (end_addr - dma_addr) >> dma_page_shift; | 303 | sg->dma_npages += (end_addr - dma_addr) >> PAGE_SHIFT; |
310 | } | 304 | } |
311 | 305 | ||
312 | /* Now gather the dma addrs into one list */ | 306 | /* Now gather the dma addrs into one list */ |
@@ -325,8 +319,8 @@ static u64 *rds_iw_map_scatterlist(struct rds_iw_device *rds_iwdev, | |||
325 | u64 end_addr; | 319 | u64 end_addr; |
326 | 320 | ||
327 | end_addr = dma_addr + dma_len; | 321 | end_addr = dma_addr + dma_len; |
328 | dma_addr &= ~dma_mask; | 322 | dma_addr &= ~PAGE_MASK; |
329 | for (; dma_addr < end_addr; dma_addr += dma_page_size) | 323 | for (; dma_addr < end_addr; dma_addr += PAGE_SIZE) |
330 | dma_pages[j++] = dma_addr; | 324 | dma_pages[j++] = dma_addr; |
331 | BUG_ON(j > sg->dma_npages); | 325 | BUG_ON(j > sg->dma_npages); |
332 | } | 326 | } |
@@ -727,7 +721,7 @@ static int rds_iw_rdma_build_fastreg(struct rds_iw_mapping *mapping) | |||
727 | f_wr.wr.fast_reg.rkey = mapping->m_rkey; | 721 | f_wr.wr.fast_reg.rkey = mapping->m_rkey; |
728 | f_wr.wr.fast_reg.page_list = ibmr->page_list; | 722 | f_wr.wr.fast_reg.page_list = ibmr->page_list; |
729 | f_wr.wr.fast_reg.page_list_len = mapping->m_sg.dma_len; | 723 | f_wr.wr.fast_reg.page_list_len = mapping->m_sg.dma_len; |
730 | f_wr.wr.fast_reg.page_shift = ibmr->device->page_shift; | 724 | f_wr.wr.fast_reg.page_shift = PAGE_SHIFT; |
731 | f_wr.wr.fast_reg.access_flags = IB_ACCESS_LOCAL_WRITE | | 725 | f_wr.wr.fast_reg.access_flags = IB_ACCESS_LOCAL_WRITE | |
732 | IB_ACCESS_REMOTE_READ | | 726 | IB_ACCESS_REMOTE_READ | |
733 | IB_ACCESS_REMOTE_WRITE; | 727 | IB_ACCESS_REMOTE_WRITE; |
@@ -780,9 +774,7 @@ static int rds_iw_map_fastreg(struct rds_iw_mr_pool *pool, | |||
780 | 774 | ||
781 | rds_iw_set_scatterlist(&mapping->m_sg, sg, sg_len); | 775 | rds_iw_set_scatterlist(&mapping->m_sg, sg, sg_len); |
782 | 776 | ||
783 | dma_pages = rds_iw_map_scatterlist(rds_iwdev, | 777 | dma_pages = rds_iw_map_scatterlist(rds_iwdev, &mapping->m_sg); |
784 | &mapping->m_sg, | ||
785 | rds_iwdev->page_shift); | ||
786 | if (IS_ERR(dma_pages)) { | 778 | if (IS_ERR(dma_pages)) { |
787 | ret = PTR_ERR(dma_pages); | 779 | ret = PTR_ERR(dma_pages); |
788 | dma_pages = NULL; | 780 | dma_pages = NULL; |