Commit 246d8b18 authored by Sagi Grimberg's avatar Sagi Grimberg Committed by Doug Ledford

IB/cq: Don't force IB_POLL_DIRECT poll context for ib_process_cq_direct

polling the completion queue directly does not interfere
with the existing polling logic, hence drop the requirement.
Be aware that running ib_process_cq_direct with non IB_POLL_DIRECT
CQ may trigger concurrent CQ processing.

This can be used for polling mode ULPs.

Cc: Bart Van Assche <bart.vanassche@wdc.com>
Reported-by: default avatarSteve Wise <swise@opengridcomputing.com>
Signed-off-by: default avatarSagi Grimberg <sagi@grimberg.me>
[maxg: added wcs array argument to __ib_process_cq]
Signed-off-by: default avatarMax Gurtovoy <maxg@mellanox.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent aaebd377
...@@ -25,9 +25,10 @@ ...@@ -25,9 +25,10 @@
#define IB_POLL_FLAGS \ #define IB_POLL_FLAGS \
(IB_CQ_NEXT_COMP | IB_CQ_REPORT_MISSED_EVENTS) (IB_CQ_NEXT_COMP | IB_CQ_REPORT_MISSED_EVENTS)
static int __ib_process_cq(struct ib_cq *cq, int budget) static int __ib_process_cq(struct ib_cq *cq, int budget, struct ib_wc *poll_wc)
{ {
int i, n, completed = 0; int i, n, completed = 0;
struct ib_wc *wcs = poll_wc ? : cq->wc;
/* /*
* budget might be (-1) if the caller does not * budget might be (-1) if the caller does not
...@@ -35,9 +36,9 @@ static int __ib_process_cq(struct ib_cq *cq, int budget) ...@@ -35,9 +36,9 @@ static int __ib_process_cq(struct ib_cq *cq, int budget)
* minimum here. * minimum here.
*/ */
while ((n = ib_poll_cq(cq, min_t(u32, IB_POLL_BATCH, while ((n = ib_poll_cq(cq, min_t(u32, IB_POLL_BATCH,
budget - completed), cq->wc)) > 0) { budget - completed), wcs)) > 0) {
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
struct ib_wc *wc = &cq->wc[i]; struct ib_wc *wc = &wcs[i];
if (wc->wr_cqe) if (wc->wr_cqe)
wc->wr_cqe->done(cq, wc); wc->wr_cqe->done(cq, wc);
...@@ -60,18 +61,20 @@ static int __ib_process_cq(struct ib_cq *cq, int budget) ...@@ -60,18 +61,20 @@ static int __ib_process_cq(struct ib_cq *cq, int budget)
* @cq: CQ to process * @cq: CQ to process
* @budget: number of CQEs to poll for * @budget: number of CQEs to poll for
* *
* This function is used to process all outstanding CQ entries on a * This function is used to process all outstanding CQ entries.
* %IB_POLL_DIRECT CQ. It does not offload CQ processing to a different * It does not offload CQ processing to a different context and does
* context and does not ask for completion interrupts from the HCA. * not ask for completion interrupts from the HCA.
* Using direct processing on CQ with non IB_POLL_DIRECT type may trigger
* concurrent processing.
* *
* Note: do not pass -1 as %budget unless it is guaranteed that the number * Note: do not pass -1 as %budget unless it is guaranteed that the number
* of completions that will be processed is small. * of completions that will be processed is small.
*/ */
int ib_process_cq_direct(struct ib_cq *cq, int budget) int ib_process_cq_direct(struct ib_cq *cq, int budget)
{ {
WARN_ON_ONCE(cq->poll_ctx != IB_POLL_DIRECT); struct ib_wc wcs[IB_POLL_BATCH];
return __ib_process_cq(cq, budget); return __ib_process_cq(cq, budget, wcs);
} }
EXPORT_SYMBOL(ib_process_cq_direct); EXPORT_SYMBOL(ib_process_cq_direct);
...@@ -85,7 +88,7 @@ static int ib_poll_handler(struct irq_poll *iop, int budget) ...@@ -85,7 +88,7 @@ static int ib_poll_handler(struct irq_poll *iop, int budget)
struct ib_cq *cq = container_of(iop, struct ib_cq, iop); struct ib_cq *cq = container_of(iop, struct ib_cq, iop);
int completed; int completed;
completed = __ib_process_cq(cq, budget); completed = __ib_process_cq(cq, budget, NULL);
if (completed < budget) { if (completed < budget) {
irq_poll_complete(&cq->iop); irq_poll_complete(&cq->iop);
if (ib_req_notify_cq(cq, IB_POLL_FLAGS) > 0) if (ib_req_notify_cq(cq, IB_POLL_FLAGS) > 0)
...@@ -105,7 +108,7 @@ static void ib_cq_poll_work(struct work_struct *work) ...@@ -105,7 +108,7 @@ static void ib_cq_poll_work(struct work_struct *work)
struct ib_cq *cq = container_of(work, struct ib_cq, work); struct ib_cq *cq = container_of(work, struct ib_cq, work);
int completed; int completed;
completed = __ib_process_cq(cq, IB_POLL_BUDGET_WORKQUEUE); completed = __ib_process_cq(cq, IB_POLL_BUDGET_WORKQUEUE, NULL);
if (completed >= IB_POLL_BUDGET_WORKQUEUE || if (completed >= IB_POLL_BUDGET_WORKQUEUE ||
ib_req_notify_cq(cq, IB_POLL_FLAGS) > 0) ib_req_notify_cq(cq, IB_POLL_FLAGS) > 0)
queue_work(ib_comp_wq, &cq->work); queue_work(ib_comp_wq, &cq->work);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment