mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: YueHaibing <yuehaibing@huawei.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: <liangwenpeng@huawei.com>, <liweihang@huawei.com>,
	<dledford@redhat.com>, <jgg@ziepe.ca>, <chenglang@huawei.com>,
	<linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -next] RDMA/hns: Fix return in hns_roce_rereg_user_mr()
Date: Thu, 5 Aug 2021 10:36:03 +0800	[thread overview]
Message-ID: <f0921aa3-a95d-f7e4-a13b-db15d4a5f259@huawei.com> (raw)
In-Reply-To: <YQqb0U43eQUGK641@unreal>

On 2021/8/4 21:53, Leon Romanovsky wrote:
> On Wed, Aug 04, 2021 at 08:59:39PM +0800, YueHaibing wrote:
>> If re-registering an MR in hns_roce_rereg_user_mr(), we should
>> return NULL instead of pass 0 to ERR_PTR.
>>
>> Fixes: 4e9fc1dae2a9 ("RDMA/hns: Optimize the MR registration process")
>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>> ---
>>  drivers/infiniband/hw/hns/hns_roce_mr.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c
>> index 006c84bb3f9f..7089ac780291 100644
>> --- a/drivers/infiniband/hw/hns/hns_roce_mr.c
>> +++ b/drivers/infiniband/hw/hns/hns_roce_mr.c
>> @@ -352,7 +352,9 @@ struct ib_mr *hns_roce_rereg_user_mr(struct ib_mr *ibmr, int flags, u64 start,
>>  free_cmd_mbox:
>>  	hns_roce_free_cmd_mailbox(hr_dev, mailbox);
>>  
>> -	return ERR_PTR(ret);
>> +	if (ret)
>> +		return ERR_PTR(ret);
>> +	return NULL;
>>  }
> 
> I don't understand this function, it returns or ERR_PTR() or NULL, but
> should return &mr->ibmr in success path. How does it work?

Did you means hns_roce_reg_user_mr()?

hns_roce_rereg_user_mr() returns ERR_PTR() on failure, and return NULL on success,

In ib_uverbs_rereg_mr(), old mr will be used if rereg_user_mr() return NULL, see:

 829         new_mr = ib_dev->ops.rereg_user_mr(mr, cmd.flags, cmd.start, cmd.length,
 830                                            cmd.hca_va, cmd.access_flags, new_pd,
 831                                            &attrs->driver_udata);
 832         if (IS_ERR(new_mr)) {
 833                 ret = PTR_ERR(new_mr);
 834                 goto put_new_uobj;
 835         }
 836         if (new_mr) {
.....
 860                 mr = new_mr;
 861         } else {
 862                 if (cmd.flags & IB_MR_REREG_PD) {
 863                         atomic_dec(&orig_pd->usecnt);
 864                         mr->pd = new_pd;
 865                         atomic_inc(&new_pd->usecnt);
 866                 }
 867                 if (cmd.flags & IB_MR_REREG_TRANS)
 868                         mr->iova = cmd.hca_va;
 869         }


> 
> Thanks
> 
>>  
>>  int hns_roce_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
>> -- 
>> 2.17.1
>>
> .
> 

  reply	other threads:[~2021-08-05  2:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-04 12:59 YueHaibing
2021-08-04 13:53 ` Leon Romanovsky
2021-08-05  2:36   ` YueHaibing [this message]
2021-08-05  3:40     ` Leon Romanovsky
2021-08-05  9:29       ` YueHaibing
2021-08-05 10:58         ` Leon Romanovsky
2021-08-05 12:23           ` Jason Gunthorpe
2021-08-05 12:30             ` Leon Romanovsky
2021-08-19 14:18 ` Jason Gunthorpe

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=f0921aa3-a95d-f7e4-a13b-db15d4a5f259@huawei.com \
    --to=yuehaibing@huawei.com \
    --cc=chenglang@huawei.com \
    --cc=dledford@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=liangwenpeng@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=liweihang@huawei.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®