From: Sagi Grimberg Date: Thu, 16 Mar 2017 16:57:00 +0000 (+0200) Subject: IB/cq: Don't process more than the given budget X-Git-Tag: v4.14-rc1~1237^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fedd9e1f75828992ace5833379116f38c66ad7bb;p=platform%2Fkernel%2Flinux-rpi.git IB/cq: Don't process more than the given budget The caller might not want this overhead. Reviewed-by: Bart Van Assche Reviewed-by: Leon Romanovsky Signed-off-by: Sagi Grimberg Reviewed-by: Yuval Shaia Signed-off-by: Doug Ledford --- diff --git a/drivers/infiniband/core/cq.c b/drivers/infiniband/core/cq.c index 2746d2e..f2ae75f 100644 --- a/drivers/infiniband/core/cq.c +++ b/drivers/infiniband/core/cq.c @@ -29,7 +29,13 @@ static int __ib_process_cq(struct ib_cq *cq, int budget) { int i, n, completed = 0; - while ((n = ib_poll_cq(cq, IB_POLL_BATCH, cq->wc)) > 0) { + /* + * budget might be (-1) if the caller does not + * want to bound this call, thus we need unsigned + * minimum here. + */ + while ((n = ib_poll_cq(cq, min_t(u32, IB_POLL_BATCH, + budget - completed), cq->wc)) > 0) { for (i = 0; i < n; i++) { struct ib_wc *wc = &cq->wc[i];