mirror of
https://github.com/torvalds/linux.git
synced 2026-05-05 15:02:40 -04:00
Merge branch 'sg_nents' into rdma.git for-next
From Maor Gottlieb ==================== Fix the use of nents and orig_nents in the sg table append helpers. The nents should be used by the DMA layer to store the number of DMA mapped sges, the orig_nents is the number of CPU sges. Since the sg append logic doesn't always create a SGL with exactly orig_nents entries store a total_nents as well to allow the table to be properly free'd and reorganize the freeing logic to share across all the use cases. ==================== Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> * 'sg_nents': RDMA: Use the sg_table directly and remove the opencoded version from umem lib/scatterlist: Fix wrong update of orig_nents lib/scatterlist: Provide a dedicated function to support table append
This commit is contained in:
@@ -113,13 +113,14 @@ int rxe_mr_init_user(struct rxe_pd *pd, u64 start, u64 length, u64 iova,
|
||||
int num_buf;
|
||||
void *vaddr;
|
||||
int err;
|
||||
int i;
|
||||
|
||||
umem = ib_umem_get(pd->ibpd.device, start, length, access);
|
||||
if (IS_ERR(umem)) {
|
||||
pr_warn("err %d from rxe_umem_get\n",
|
||||
(int)PTR_ERR(umem));
|
||||
pr_warn("%s: Unable to pin memory region err = %d\n",
|
||||
__func__, (int)PTR_ERR(umem));
|
||||
err = PTR_ERR(umem);
|
||||
goto err1;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
num_buf = ib_umem_num_pages(umem);
|
||||
@@ -128,9 +129,9 @@ int rxe_mr_init_user(struct rxe_pd *pd, u64 start, u64 length, u64 iova,
|
||||
|
||||
err = rxe_mr_alloc(mr, num_buf);
|
||||
if (err) {
|
||||
pr_warn("err %d from rxe_mr_alloc\n", err);
|
||||
ib_umem_release(umem);
|
||||
goto err1;
|
||||
pr_warn("%s: Unable to allocate memory for map\n",
|
||||
__func__);
|
||||
goto err_release_umem;
|
||||
}
|
||||
|
||||
mr->page_shift = PAGE_SHIFT;
|
||||
@@ -141,7 +142,7 @@ int rxe_mr_init_user(struct rxe_pd *pd, u64 start, u64 length, u64 iova,
|
||||
if (length > 0) {
|
||||
buf = map[0]->buf;
|
||||
|
||||
for_each_sg_page(umem->sg_head.sgl, &sg_iter, umem->nmap, 0) {
|
||||
for_each_sgtable_page (&umem->sgt_append.sgt, &sg_iter, 0) {
|
||||
if (num_buf >= RXE_BUF_PER_MAP) {
|
||||
map++;
|
||||
buf = map[0]->buf;
|
||||
@@ -150,10 +151,10 @@ int rxe_mr_init_user(struct rxe_pd *pd, u64 start, u64 length, u64 iova,
|
||||
|
||||
vaddr = page_address(sg_page_iter_page(&sg_iter));
|
||||
if (!vaddr) {
|
||||
pr_warn("null vaddr\n");
|
||||
ib_umem_release(umem);
|
||||
pr_warn("%s: Unable to get virtual address\n",
|
||||
__func__);
|
||||
err = -ENOMEM;
|
||||
goto err1;
|
||||
goto err_cleanup_map;
|
||||
}
|
||||
|
||||
buf->addr = (uintptr_t)vaddr;
|
||||
@@ -176,7 +177,13 @@ int rxe_mr_init_user(struct rxe_pd *pd, u64 start, u64 length, u64 iova,
|
||||
|
||||
return 0;
|
||||
|
||||
err1:
|
||||
err_cleanup_map:
|
||||
for (i = 0; i < mr->num_map; i++)
|
||||
kfree(mr->map[i]);
|
||||
kfree(mr->map);
|
||||
err_release_umem:
|
||||
ib_umem_release(umem);
|
||||
err_out:
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
@@ -259,6 +259,7 @@ static void prepare_ipv4_hdr(struct dst_entry *dst, struct sk_buff *skb,
|
||||
|
||||
iph->version = IPVERSION;
|
||||
iph->ihl = sizeof(struct iphdr) >> 2;
|
||||
iph->tot_len = htons(skb->len);
|
||||
iph->frag_off = df;
|
||||
iph->protocol = proto;
|
||||
iph->tos = tos;
|
||||
|
||||
@@ -318,7 +318,7 @@ static enum resp_states get_srq_wqe(struct rxe_qp *qp)
|
||||
pr_warn("%s: invalid num_sge in SRQ entry\n", __func__);
|
||||
return RESPST_ERR_MALFORMED_WQE;
|
||||
}
|
||||
size = sizeof(wqe) + wqe->dma.num_sge*sizeof(struct rxe_sge);
|
||||
size = sizeof(*wqe) + wqe->dma.num_sge*sizeof(struct rxe_sge);
|
||||
memcpy(&qp->resp.srq_wqe, wqe, size);
|
||||
|
||||
qp->resp.wqe = &qp->resp.srq_wqe.wqe;
|
||||
|
||||
Reference in New Issue
Block a user