From: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Selvin Xavier <selvin.xavier-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Jason Gunthorpe <jgg-uk2M96/98Pc@public.gmane.org>,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH for-rc 4/6] RDMA/bnxt_re: Synchronize destroy_qp with poll_cq
Date: Fri, 16 Feb 2018 17:51:46 +0200 [thread overview]
Message-ID: <20180216155146.GN2197@mtr-leonro.local> (raw)
In-Reply-To: <CA+sbYW1=9G1YHDZQyCKeTfus9FLd-w7FZzHFUnCCPALB3ciw_Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 2896 bytes --]
On Fri, Feb 16, 2018 at 05:09:15PM +0530, Selvin Xavier wrote:
> On Fri, Feb 16, 2018 at 1:08 PM, Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
> > On Thu, Feb 15, 2018 at 09:20:11PM -0800, Selvin Xavier wrote:
> >> Avoid system crash when destroy_qp is invoked while
> >> the driver is processing the poll_cq. Synchronize these
> >> functions using the cq_lock.
> >>
> >> Signed-off-by: Selvin Xavier <selvin.xavier-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
> >> ---
> >> drivers/infiniband/hw/bnxt_re/ib_verbs.c | 39 +++++++++++++++++++++++++++++---
> >> drivers/infiniband/hw/bnxt_re/ib_verbs.h | 2 ++
> >> drivers/infiniband/hw/bnxt_re/qplib_fp.c | 21 +++++------------
> >> drivers/infiniband/hw/bnxt_re/qplib_fp.h | 4 +++-
> >> 4 files changed, 47 insertions(+), 19 deletions(-)
> >>
> >> diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> >> index b7eb104..9cb9928 100644
> >> --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> >> +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> >> @@ -786,20 +786,51 @@ int bnxt_re_query_ah(struct ib_ah *ib_ah, struct rdma_ah_attr *ah_attr)
> >> return 0;
> >> }
> >>
> >> +static unsigned long bnxt_re_lock_cqs(struct bnxt_re_qp *qp)
> >> + __acquires(&qp->scq->cq_lock) __acquires(&qp->rcq->cq_lock)
> >> +{
> >> + unsigned long flags;
> >> +
> >> + spin_lock_irqsave(&qp->scq->cq_lock, flags);
> >> + if (qp->rcq != qp->scq)
> >> + spin_lock(&qp->rcq->cq_lock);
> >> + else
> >> + __acquire(&qp->rcq->cq_lock);
> >
> > Sorry for naive question, why do you need __acquire/__release? And why
> > can't spin_is_locked(&qp->rcq->cq_lock) be used for unlock code?
> >
> I used __acquire and __release for satisfying the sparse. Sparse used to
> give warnings "context imbalance - wrong count at exit" since the locking
> and unlocking happens from two different functions. seen similar implementation
> in other drivers too.
I see, actually I think that sparse complain was right and you went to
far by wrapping standard calls. I see that it is very popular in bnxt_re
code and the problem with that, that it makes very hard to refactor such
code in case of some global change/improvement.
>
> I feel spin_is_locked also can be used.. but it doesn't avoid the RCQ
> != SCQ check.
> Also, if feel the code symmetry is better in this way.
> >
> >> +
> >> + return flags;
> >> +}
> >> +
> >> +static void bnxt_re_unlock_cqs(struct bnxt_re_qp *qp,
> >> + unsigned long flags)
> >> + __releases(&qp->scq->cq_lock) __releases(&qp->rcq->cq_lock)
> >> +{
> >> + if (qp->rcq != qp->scq)
> >> + spin_unlock(&qp->rcq->cq_lock);
> >> + else
> >> + __release(&qp->rcq->cq_lock);
> >> + spin_unlock_irqrestore(&qp->scq->cq_lock, flags);
> >> +}
> >> +
> >
> > Thanks
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2018-02-16 15:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-16 5:20 [PATCH for-rc 0/6] RDMA/bnxt_re: Misc bug fixes Selvin Xavier
[not found] ` <1518758413-20850-1-git-send-email-selvin.xavier-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2018-02-16 5:20 ` [PATCH for-rc 1/6] RDMA/bnxt_re: Disable atomic capability on bnxt_re adapters Selvin Xavier
2018-02-16 5:20 ` [PATCH for-rc 2/6] RDMA/bnxt_re: Maintain GID index mapping between stack and hardware Selvin Xavier
[not found] ` <1518758413-20850-3-git-send-email-selvin.xavier-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2018-02-16 16:07 ` Jason Gunthorpe
[not found] ` <20180216160703.GB22739-uk2M96/98Pc@public.gmane.org>
2018-02-17 6:24 ` Selvin Xavier
2018-02-16 5:20 ` [PATCH for-rc 3/6] RDMA/bnxt_re: Unpin SQ and RQ memory if QP create fails Selvin Xavier
2018-02-16 5:20 ` [PATCH for-rc 4/6] RDMA/bnxt_re: Synchronize destroy_qp with poll_cq Selvin Xavier
[not found] ` <1518758413-20850-5-git-send-email-selvin.xavier-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2018-02-16 7:38 ` Leon Romanovsky
[not found] ` <20180216073802.GM2197-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2018-02-16 11:39 ` Selvin Xavier
[not found] ` <CA+sbYW1=9G1YHDZQyCKeTfus9FLd-w7FZzHFUnCCPALB3ciw_Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-02-16 15:51 ` Leon Romanovsky [this message]
2018-02-16 5:20 ` [PATCH for-rc 5/6] RDMA/bnxt_re: Fix system crash during load/unload Selvin Xavier
2018-02-16 5:20 ` [PATCH for-rc 6/6] RDMA/bnxt_re: Avoid system hang during device un-reg Selvin Xavier
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=20180216155146.GN2197@mtr-leonro.local \
--to=leon-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=jgg-uk2M96/98Pc@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=selvin.xavier-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
/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