[for-next,v3,1/2] RDMA/rxe: Remove unnecessary mr testing

Message ID 1666582315-2-1-git-send-email-lizhijian@fujitsu.com
State New
Headers
Series [for-next,v3,1/2] RDMA/rxe: Remove unnecessary mr testing |

Commit Message

Zhijian Li (Fujitsu) Oct. 24, 2022, 3:31 a.m. UTC
  Before the testing, we already passed it to rxe_mr_copy() where mr could
be dereferenced. so this checking is not needed.

The only way that mr is NULL is when it reaches below line 780 with
 'qp->resp.mr = NULL', which is not possible in Bob's explanation[1].

 778         if (res->state == rdatm_res_state_new) {
 779                 if (!res->replay) {
 780                         mr = qp->resp.mr;
 781                         qp->resp.mr = NULL;
 782                 } else {

[1] https://lore.kernel.org/lkml/30ff25c4-ce66-eac4-eaa2-64c0db203a19@gmail.com/

CC: Bob Pearson <rpearsonhpe@gmail.com>
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
---
V3: remove WARN_ON # Yanjun and Bob
---
 drivers/infiniband/sw/rxe/rxe_resp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Bob Pearson Oct. 24, 2022, 2:10 p.m. UTC | #1
On 10/23/22 22:31, Li Zhijian wrote:
> Before the testing, we already passed it to rxe_mr_copy() where mr could
> be dereferenced. so this checking is not needed.
> 
> The only way that mr is NULL is when it reaches below line 780 with
>  'qp->resp.mr = NULL', which is not possible in Bob's explanation[1].
> 
>  778         if (res->state == rdatm_res_state_new) {
>  779                 if (!res->replay) {
>  780                         mr = qp->resp.mr;
>  781                         qp->resp.mr = NULL;
>  782                 } else {
> 
> [1] https://lore.kernel.org/lkml/30ff25c4-ce66-eac4-eaa2-64c0db203a19@gmail.com/
> 
> CC: Bob Pearson <rpearsonhpe@gmail.com>
> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
> ---
> V3: remove WARN_ON # Yanjun and Bob
> ---
>  drivers/infiniband/sw/rxe/rxe_resp.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c
> index ed5a09e86417..b02639cf8cba 100644
> --- a/drivers/infiniband/sw/rxe/rxe_resp.c
> +++ b/drivers/infiniband/sw/rxe/rxe_resp.c
> @@ -811,8 +811,7 @@ static enum resp_states read_reply(struct rxe_qp *qp,
>  
>  	rxe_mr_copy(mr, res->read.va, payload_addr(&ack_pkt),
>  		    payload, RXE_FROM_MR_OBJ);
> -	if (mr)
> -		rxe_put(mr);
> +	rxe_put(mr);
>  
>  	if (bth_pad(&ack_pkt)) {
>  		u8 *pad = payload_addr(&ack_pkt) + payload;

Reviewed-by: Bob Pearson <rpearsonhpe@gmail.com>
  
Jason Gunthorpe Oct. 24, 2022, 5:16 p.m. UTC | #2
On Mon, Oct 24, 2022 at 03:31:54AM +0000, Li Zhijian wrote:
> Before the testing, we already passed it to rxe_mr_copy() where mr could
> be dereferenced. so this checking is not needed.
> 
> The only way that mr is NULL is when it reaches below line 780 with
>  'qp->resp.mr = NULL', which is not possible in Bob's explanation[1].
> 
>  778         if (res->state == rdatm_res_state_new) {
>  779                 if (!res->replay) {
>  780                         mr = qp->resp.mr;
>  781                         qp->resp.mr = NULL;
>  782                 } else {
> 
> [1] https://lore.kernel.org/lkml/30ff25c4-ce66-eac4-eaa2-64c0db203a19@gmail.com/
> 
> CC: Bob Pearson <rpearsonhpe@gmail.com>
> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
> Reviewed-by: Bob Pearson <rpearsonhpe@gmail.com>
> ---
> V3: remove WARN_ON # Yanjun and Bob
> ---
>  drivers/infiniband/sw/rxe/rxe_resp.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Applied to for-next

Thanks,
Jason
  

Patch

diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c
index ed5a09e86417..b02639cf8cba 100644
--- a/drivers/infiniband/sw/rxe/rxe_resp.c
+++ b/drivers/infiniband/sw/rxe/rxe_resp.c
@@ -811,8 +811,7 @@  static enum resp_states read_reply(struct rxe_qp *qp,
 
 	rxe_mr_copy(mr, res->read.va, payload_addr(&ack_pkt),
 		    payload, RXE_FROM_MR_OBJ);
-	if (mr)
-		rxe_put(mr);
+	rxe_put(mr);
 
 	if (bth_pad(&ack_pkt)) {
 		u8 *pad = payload_addr(&ack_pkt) + payload;