From: Konstantin Taranov <kotaranov@linux.microsoft.com>
To: kotaranov@microsoft.com, snsanghvi@microsoft.com,
longli@microsoft.com, jgg@ziepe.ca, leon@kernel.org
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH rdma-next v2 08/10] RDMA/mana_ib: Flush and notify CQs when kernel QPs enter ERR
Date: Fri, 2 Oct 2026 23:40:35 -0700 [thread overview]
Message-ID: <20261003064037.2092669-9-kotaranov@linux.microsoft.com> (raw)
In-Reply-To: <20261003064037.2092669-1-kotaranov@linux.microsoft.com>
From: Konstantin Taranov <kotaranov@microsoft.com>
Complete the RC software flush path by adding a kernel QP to the CQ
error lists when it transitions to the ERR state.
Invoke the CQ handlers after the transition to flush pending work
requests.
Signed-off-by: Konstantin Taranov <kotaranov@microsoft.com>
---
Changes in v2:
- Skip software CQ notifications for IB_POLL_DIRECT.
drivers/infiniband/hw/mana/cq.c | 2 +-
drivers/infiniband/hw/mana/mana_ib.h | 1 +
drivers/infiniband/hw/mana/qp.c | 48 ++++++++++++++++++++++++++--
3 files changed, 47 insertions(+), 4 deletions(-)
diff --git a/drivers/infiniband/hw/mana/cq.c b/drivers/infiniband/hw/mana/cq.c
index 29eb12c1848e..b2fded9fbf40 100644
--- a/drivers/infiniband/hw/mana/cq.c
+++ b/drivers/infiniband/hw/mana/cq.c
@@ -585,7 +585,7 @@ static void mana_drain_gsi_sq(struct mana_ib_qp *qp)
list_add_tail(&qp->send_err_node, &cq->send_err_qp_list);
spin_unlock_irqrestore(&cq->cq_lock, flags);
- if (cq->ibcq.comp_handler)
+ if (cq->ibcq.poll_ctx != IB_POLL_DIRECT && cq->ibcq.comp_handler)
cq->ibcq.comp_handler(&cq->ibcq, cq->ibcq.cq_context);
}
diff --git a/drivers/infiniband/hw/mana/mana_ib.h b/drivers/infiniband/hw/mana/mana_ib.h
index 1fc816792fc6..755fb87bfda1 100644
--- a/drivers/infiniband/hw/mana/mana_ib.h
+++ b/drivers/infiniband/hw/mana/mana_ib.h
@@ -269,6 +269,7 @@ struct mana_ib_qp {
bool pending_mmq_fence;
bool sq_sig_all;
enum ib_mtu mtu;
+ enum ib_qp_state state;
/* Serializes receive WR posting. */
spinlock_t rq_lock;
diff --git a/drivers/infiniband/hw/mana/qp.c b/drivers/infiniband/hw/mana/qp.c
index 65b0ebf4df3f..294f4f885b54 100644
--- a/drivers/infiniband/hw/mana/qp.c
+++ b/drivers/infiniband/hw/mana/qp.c
@@ -735,6 +735,24 @@ destroy_queues:
return err;
}
+static void mana_add_qp_to_error_cqs(struct mana_ib_qp *qp)
+{
+ struct mana_ib_cq *send_cq = container_of(qp->ibqp.send_cq, struct mana_ib_cq, ibcq);
+ struct mana_ib_cq *recv_cq = container_of(qp->ibqp.recv_cq, struct mana_ib_cq, ibcq);
+ unsigned long flags;
+
+ /* Keep ERR QPs linked until reset/destroy, including later drain WRs. */
+ spin_lock_irqsave(&send_cq->cq_lock, flags);
+ if (list_empty(&qp->send_err_node))
+ list_add_tail(&qp->send_err_node, &send_cq->send_err_qp_list);
+ spin_unlock_irqrestore(&send_cq->cq_lock, flags);
+
+ spin_lock_irqsave(&recv_cq->cq_lock, flags);
+ if (list_empty(&qp->recv_err_node))
+ list_add_tail(&qp->recv_err_node, &recv_cq->recv_err_qp_list);
+ spin_unlock_irqrestore(&recv_cq->cq_lock, flags);
+}
+
static void mana_remove_qp_from_cqs(struct mana_ib_qp *qp, bool reset)
{
struct mana_ib_cq *send_cq = container_of(qp->ibqp.send_cq, struct mana_ib_cq, ibcq);
@@ -1027,15 +1045,16 @@ static int mana_ib_gd_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
return 0;
}
-static void mana_ib_modify_qp_state(struct ib_qp *ibqp, struct ib_qp_attr *attr,
+static bool mana_ib_modify_qp_state(struct ib_qp *ibqp, struct ib_qp_attr *attr,
int attr_mask, struct ib_udata *udata)
{
struct mana_ib_dev *mdev = container_of(ibqp->device, struct mana_ib_dev, ib_dev);
struct mana_ib_qp *qp = container_of(ibqp, struct mana_ib_qp, ibqp);
struct gdma_queue *rq;
+ bool notify = false;
if (udata)
- return;
+ return false;
if (attr_mask & IB_QP_PATH_MTU)
qp->mtu = attr->path_mtu;
@@ -1048,6 +1067,11 @@ static void mana_ib_modify_qp_state(struct ib_qp *ibqp, struct ib_qp_attr *attr,
default:
break;
}
+ qp->state = attr->qp_state;
+ if (attr->qp_state == IB_QPS_ERR) {
+ mana_add_qp_to_error_cqs(qp);
+ notify = true;
+ }
}
if (attr_mask & IB_QP_SQ_PSN) {
@@ -1063,12 +1087,27 @@ static void mana_ib_modify_qp_state(struct ib_qp *ibqp, struct ib_qp_attr *attr,
SET_ARM_BIT, MANA_PSN_CLIENT_OFFSET);
}
}
+
+ return notify;
+}
+
+static void mana_ib_notify_error_cqs(struct mana_ib_qp *qp)
+{
+ struct ib_cq *send_cq = qp->ibqp.send_cq;
+ struct ib_cq *recv_cq = qp->ibqp.recv_cq;
+
+ if (send_cq->poll_ctx != IB_POLL_DIRECT && send_cq->comp_handler)
+ send_cq->comp_handler(send_cq, send_cq->cq_context);
+ if (recv_cq != send_cq && recv_cq->poll_ctx != IB_POLL_DIRECT &&
+ recv_cq->comp_handler)
+ recv_cq->comp_handler(recv_cq, recv_cq->cq_context);
}
int mana_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
int attr_mask, struct ib_udata *udata)
{
struct mana_ib_qp *qp = container_of(ibqp, struct mana_ib_qp, ibqp);
+ bool notify = false;
int ret;
mutex_lock(&qp->modify_lock);
@@ -1087,11 +1126,14 @@ int mana_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
goto out_unlock;
}
- mana_ib_modify_qp_state(ibqp, attr, attr_mask, udata);
+ notify = mana_ib_modify_qp_state(ibqp, attr, attr_mask, udata);
out_unlock:
mutex_unlock(&qp->modify_lock);
+ if (notify)
+ mana_ib_notify_error_cqs(qp);
+
return ret;
}
--
2.43.0
next prev parent reply other threads:[~2026-10-03 6:41 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-03 6:40 [PATCH rdma-next v2 00/10] RDMA/mana_ib: Add kernel RC and fast registration support Konstantin Taranov
2026-10-03 6:40 ` [PATCH rdma-next v2 01/10] RDMA/mana_ib: Allocate and map fast-registration MRs Konstantin Taranov
2026-10-03 6:55 ` sashiko-bot
2026-10-03 6:40 ` [PATCH rdma-next v2 02/10] RDMA/mana: Create and destroy kernel RC QPs Konstantin Taranov
2026-10-03 6:55 ` sashiko-bot
2026-10-03 6:40 ` [PATCH rdma-next v2 03/10] net/mana: Extend GDMA encoding for new RDMA WQEs Konstantin Taranov
2026-10-03 6:55 ` sashiko-bot
2026-10-03 6:40 ` [PATCH rdma-next v2 04/10] RDMA/mana_ib: Maintain kernel RC QP state Konstantin Taranov
2026-10-03 6:54 ` sashiko-bot
2026-10-03 6:40 ` [PATCH rdma-next v2 05/10] RDMA/mana_ib: Post receive WRs on kernel RC QPs Konstantin Taranov
2026-10-03 6:51 ` sashiko-bot
2026-10-03 6:40 ` [PATCH rdma-next v2 06/10] RDMA/mana_ib: Post send and memory-management WRs on " Konstantin Taranov
2026-10-03 6:58 ` sashiko-bot
2026-10-03 6:40 ` [PATCH rdma-next v2 07/10] RDMA/mana_ib: Poll RC completions using PSN and FSN progress Konstantin Taranov
2026-10-03 6:54 ` sashiko-bot
2026-10-03 6:40 ` Konstantin Taranov [this message]
2026-10-03 6:58 ` [PATCH rdma-next v2 08/10] RDMA/mana_ib: Flush and notify CQs when kernel QPs enter ERR sashiko-bot
2026-10-03 6:40 ` [PATCH rdma-next v2 09/10] RDMA/mana_ib: Handle error CQEs for RC QPs Konstantin Taranov
2026-10-03 6:53 ` sashiko-bot
2026-10-03 6:40 ` [PATCH rdma-next v2 10/10] RDMA/mana_ib: Drain kernel receive and send queues Konstantin Taranov
2026-10-03 7:01 ` sashiko-bot
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=20261003064037.2092669-9-kotaranov@linux.microsoft.com \
--to=kotaranov@linux.microsoft.com \
--cc=jgg@ziepe.ca \
--cc=kotaranov@microsoft.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=snsanghvi@microsoft.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.