diff mbox series

[v2,2/2] RDMA/rw: map P2P memory correctly for signature operations

Message ID 20200220100819.41860-2-maxg@mellanox.com (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show
Series [v2,1/2] RDMA/rw: fix error flow during RDMA context initialization | expand

Commit Message

Max Gurtovoy Feb. 20, 2020, 10:08 a.m. UTC
Since RDMA rw API support operations with P2P memory sg list, make sure
to map/unmap the scatter list for signature operation correctly.

Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
---
 drivers/infiniband/core/rw.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Logan Gunthorpe Feb. 20, 2020, 4:51 p.m. UTC | #1
On 2020-02-20 3:08 a.m., Max Gurtovoy wrote:
> Since RDMA rw API support operations with P2P memory sg list, make sure
> to map/unmap the scatter list for signature operation correctly.

Does anyone actually use P2P pages with rdma_rw_ctx_signature_init()?

Logan

> Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
> ---
>  drivers/infiniband/core/rw.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/infiniband/core/rw.c b/drivers/infiniband/core/rw.c
> index 69513b484507..6eba8453f206 100644
> --- a/drivers/infiniband/core/rw.c
> +++ b/drivers/infiniband/core/rw.c
> @@ -392,13 +392,13 @@ int rdma_rw_ctx_signature_init(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
>  		return -EINVAL;
>  	}
>  
> -	ret = ib_dma_map_sg(dev, sg, sg_cnt, dir);
> +	ret = rdma_rw_map_sg(dev, sg, sg_cnt, dir);
>  	if (!ret)
>  		return -ENOMEM;
>  	sg_cnt = ret;
>  
>  	if (prot_sg_cnt) {
> -		ret = ib_dma_map_sg(dev, prot_sg, prot_sg_cnt, dir);
> +		ret = rdma_rw_map_sg(dev, prot_sg, prot_sg_cnt, dir);
>  		if (!ret) {
>  			ret = -ENOMEM;
>  			goto out_unmap_sg;
> @@ -467,9 +467,9 @@ int rdma_rw_ctx_signature_init(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
>  	kfree(ctx->reg);
>  out_unmap_prot_sg:
>  	if (prot_sg_cnt)
> -		ib_dma_unmap_sg(dev, prot_sg, prot_sg_cnt, dir);
> +		rdma_rw_unmap_sg(dev, prot_sg, prot_sg_cnt, dir);
>  out_unmap_sg:
> -	ib_dma_unmap_sg(dev, sg, sg_cnt, dir);
> +	rdma_rw_unmap_sg(dev, sg, sg_cnt, dir);
>  	return ret;
>  }
>  EXPORT_SYMBOL(rdma_rw_ctx_signature_init);
> @@ -629,9 +629,9 @@ void rdma_rw_ctx_destroy_signature(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
>  	ib_mr_pool_put(qp, &qp->sig_mrs, ctx->reg->mr);
>  	kfree(ctx->reg);
>  
> -	ib_dma_unmap_sg(qp->pd->device, sg, sg_cnt, dir);
>  	if (prot_sg_cnt)
> -		ib_dma_unmap_sg(qp->pd->device, prot_sg, prot_sg_cnt, dir);
> +		rdma_rw_unmap_sg(qp->pd->device, prot_sg, prot_sg_cnt, dir);
> +	rdma_rw_unmap_sg(qp->pd->device, sg, sg_cnt, dir);
>  }
>  EXPORT_SYMBOL(rdma_rw_ctx_destroy_signature);
>  
>
Max Gurtovoy Feb. 20, 2020, 4:57 p.m. UTC | #2
On 2/20/2020 6:51 PM, Logan Gunthorpe wrote:
>
> On 2020-02-20 3:08 a.m., Max Gurtovoy wrote:
>> Since RDMA rw API support operations with P2P memory sg list, make sure
>> to map/unmap the scatter list for signature operation correctly.
> Does anyone actually use P2P pages with rdma_rw_ctx_signature_init()?

We're adding support for NVMf/target in these days.

Nevertheless, the RW API defined as an API that might use P2P pages.

>
> Logan
>
>> Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
>> ---
>>   drivers/infiniband/core/rw.c | 12 ++++++------
>>   1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/infiniband/core/rw.c b/drivers/infiniband/core/rw.c
>> index 69513b484507..6eba8453f206 100644
>> --- a/drivers/infiniband/core/rw.c
>> +++ b/drivers/infiniband/core/rw.c
>> @@ -392,13 +392,13 @@ int rdma_rw_ctx_signature_init(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
>>   		return -EINVAL;
>>   	}
>>   
>> -	ret = ib_dma_map_sg(dev, sg, sg_cnt, dir);
>> +	ret = rdma_rw_map_sg(dev, sg, sg_cnt, dir);
>>   	if (!ret)
>>   		return -ENOMEM;
>>   	sg_cnt = ret;
>>   
>>   	if (prot_sg_cnt) {
>> -		ret = ib_dma_map_sg(dev, prot_sg, prot_sg_cnt, dir);
>> +		ret = rdma_rw_map_sg(dev, prot_sg, prot_sg_cnt, dir);
>>   		if (!ret) {
>>   			ret = -ENOMEM;
>>   			goto out_unmap_sg;
>> @@ -467,9 +467,9 @@ int rdma_rw_ctx_signature_init(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
>>   	kfree(ctx->reg);
>>   out_unmap_prot_sg:
>>   	if (prot_sg_cnt)
>> -		ib_dma_unmap_sg(dev, prot_sg, prot_sg_cnt, dir);
>> +		rdma_rw_unmap_sg(dev, prot_sg, prot_sg_cnt, dir);
>>   out_unmap_sg:
>> -	ib_dma_unmap_sg(dev, sg, sg_cnt, dir);
>> +	rdma_rw_unmap_sg(dev, sg, sg_cnt, dir);
>>   	return ret;
>>   }
>>   EXPORT_SYMBOL(rdma_rw_ctx_signature_init);
>> @@ -629,9 +629,9 @@ void rdma_rw_ctx_destroy_signature(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
>>   	ib_mr_pool_put(qp, &qp->sig_mrs, ctx->reg->mr);
>>   	kfree(ctx->reg);
>>   
>> -	ib_dma_unmap_sg(qp->pd->device, sg, sg_cnt, dir);
>>   	if (prot_sg_cnt)
>> -		ib_dma_unmap_sg(qp->pd->device, prot_sg, prot_sg_cnt, dir);
>> +		rdma_rw_unmap_sg(qp->pd->device, prot_sg, prot_sg_cnt, dir);
>> +	rdma_rw_unmap_sg(qp->pd->device, sg, sg_cnt, dir);
>>   }
>>   EXPORT_SYMBOL(rdma_rw_ctx_destroy_signature);
>>   
>>
Jason Gunthorpe March 10, 2020, 4:02 p.m. UTC | #3
On Thu, Feb 20, 2020 at 12:08:19PM +0200, Max Gurtovoy wrote:
> Since RDMA rw API support operations with P2P memory sg list, make sure
> to map/unmap the scatter list for signature operation correctly.
> 
> Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
> ---
>  drivers/infiniband/core/rw.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)

Applied to for-next

Thanks,
Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/core/rw.c b/drivers/infiniband/core/rw.c
index 69513b484507..6eba8453f206 100644
--- a/drivers/infiniband/core/rw.c
+++ b/drivers/infiniband/core/rw.c
@@ -392,13 +392,13 @@  int rdma_rw_ctx_signature_init(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
 		return -EINVAL;
 	}
 
-	ret = ib_dma_map_sg(dev, sg, sg_cnt, dir);
+	ret = rdma_rw_map_sg(dev, sg, sg_cnt, dir);
 	if (!ret)
 		return -ENOMEM;
 	sg_cnt = ret;
 
 	if (prot_sg_cnt) {
-		ret = ib_dma_map_sg(dev, prot_sg, prot_sg_cnt, dir);
+		ret = rdma_rw_map_sg(dev, prot_sg, prot_sg_cnt, dir);
 		if (!ret) {
 			ret = -ENOMEM;
 			goto out_unmap_sg;
@@ -467,9 +467,9 @@  int rdma_rw_ctx_signature_init(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
 	kfree(ctx->reg);
 out_unmap_prot_sg:
 	if (prot_sg_cnt)
-		ib_dma_unmap_sg(dev, prot_sg, prot_sg_cnt, dir);
+		rdma_rw_unmap_sg(dev, prot_sg, prot_sg_cnt, dir);
 out_unmap_sg:
-	ib_dma_unmap_sg(dev, sg, sg_cnt, dir);
+	rdma_rw_unmap_sg(dev, sg, sg_cnt, dir);
 	return ret;
 }
 EXPORT_SYMBOL(rdma_rw_ctx_signature_init);
@@ -629,9 +629,9 @@  void rdma_rw_ctx_destroy_signature(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
 	ib_mr_pool_put(qp, &qp->sig_mrs, ctx->reg->mr);
 	kfree(ctx->reg);
 
-	ib_dma_unmap_sg(qp->pd->device, sg, sg_cnt, dir);
 	if (prot_sg_cnt)
-		ib_dma_unmap_sg(qp->pd->device, prot_sg, prot_sg_cnt, dir);
+		rdma_rw_unmap_sg(qp->pd->device, prot_sg, prot_sg_cnt, dir);
+	rdma_rw_unmap_sg(qp->pd->device, sg, sg_cnt, dir);
 }
 EXPORT_SYMBOL(rdma_rw_ctx_destroy_signature);