Skip to content

Commit 4ab39e2

Browse files
KAGA-KOKOjgunthorpe
authored andcommitted
RDMA/cxgb4: Make c4iw_poll_cq_one() easier to analyze
Introduce the function __c4iw_poll_cq_one() such that c4iw_poll_cq_one() becomes easier to analyze for static source code analyzers. This patch avoids that sparse reports the following: drivers/infiniband/hw/cxgb4/cq.c:401:36: warning: context imbalance in 'c4iw_flush_hw_cq' - unexpected unlock drivers/infiniband/hw/cxgb4/cq.c:824:9: warning: context imbalance in 'c4iw_poll_cq_one' - different lock contexts for basic block Compile-tested only. Signed-off-by: Bart Van Assche <[email protected]> Cc: Steve Wise <[email protected]> Acked-by: Steve Wise <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent cbd8e98 commit 4ab39e2

File tree

1 file changed

+35
-27
lines changed
  • drivers/infiniband/hw/cxgb4

1 file changed

+35
-27
lines changed

drivers/infiniband/hw/cxgb4/cq.c

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -668,43 +668,22 @@ static int poll_cq(struct t4_wq *wq, struct t4_cq *cq, struct t4_cqe *cqe,
668668
return ret;
669669
}
670670

671-
/*
672-
* Get one cq entry from c4iw and map it to openib.
673-
*
674-
* Returns:
675-
* 0 cqe returned
676-
* -ENODATA EMPTY;
677-
* -EAGAIN caller must try again
678-
* any other -errno fatal error
679-
*/
680-
static int c4iw_poll_cq_one(struct c4iw_cq *chp, struct ib_wc *wc)
671+
static int __c4iw_poll_cq_one(struct c4iw_cq *chp, struct c4iw_qp *qhp,
672+
struct ib_wc *wc)
681673
{
682-
struct c4iw_qp *qhp = NULL;
683-
struct t4_cqe uninitialized_var(cqe), *rd_cqe;
684-
struct t4_wq *wq;
674+
struct t4_cqe cqe;
675+
struct t4_wq *wq = qhp ? &qhp->wq : NULL;
685676
u32 credit = 0;
686677
u8 cqe_flushed;
687678
u64 cookie = 0;
688679
int ret;
689680

690-
ret = t4_next_cqe(&chp->cq, &rd_cqe);
691-
692-
if (ret)
693-
return ret;
694-
695-
qhp = get_qhp(chp->rhp, CQE_QPID(rd_cqe));
696-
if (!qhp)
697-
wq = NULL;
698-
else {
699-
spin_lock(&qhp->lock);
700-
wq = &(qhp->wq);
701-
}
702681
ret = poll_cq(wq, &(chp->cq), &cqe, &cqe_flushed, &cookie, &credit);
703682
if (ret)
704683
goto out;
705684

706685
wc->wr_id = cookie;
707-
wc->qp = &qhp->ibqp;
686+
wc->qp = qhp ? &qhp->ibqp : NULL;
708687
wc->vendor_err = CQE_STATUS(&cqe);
709688
wc->wc_flags = 0;
710689

@@ -819,8 +798,37 @@ static int c4iw_poll_cq_one(struct c4iw_cq *chp, struct ib_wc *wc)
819798
}
820799
}
821800
out:
822-
if (wq)
801+
return ret;
802+
}
803+
804+
/*
805+
* Get one cq entry from c4iw and map it to openib.
806+
*
807+
* Returns:
808+
* 0 cqe returned
809+
* -ENODATA EMPTY;
810+
* -EAGAIN caller must try again
811+
* any other -errno fatal error
812+
*/
813+
static int c4iw_poll_cq_one(struct c4iw_cq *chp, struct ib_wc *wc)
814+
{
815+
struct c4iw_qp *qhp = NULL;
816+
struct t4_cqe *rd_cqe;
817+
int ret;
818+
819+
ret = t4_next_cqe(&chp->cq, &rd_cqe);
820+
821+
if (ret)
822+
return ret;
823+
824+
qhp = get_qhp(chp->rhp, CQE_QPID(rd_cqe));
825+
if (qhp) {
826+
spin_lock(&qhp->lock);
827+
ret = __c4iw_poll_cq_one(chp, qhp, wc);
823828
spin_unlock(&qhp->lock);
829+
} else {
830+
ret = __c4iw_poll_cq_one(chp, NULL, wc);
831+
}
824832
return ret;
825833
}
826834

0 commit comments

Comments
 (0)