From: Yonatan Nachum <ynachum@amazon.com>
To: <jgg@nvidia.com>, <leon@kernel.org>, <linux-rdma@vger.kernel.org>
Cc: <mrgolin@amazon.com>, <sleybo@amazon.com>, <matua@amazon.com>,
<gal.pressman@linux.dev>, Yonatan Nachum <ynachum@amazon.com>,
Tom Sela <tomsela@amazon.com>
Subject: [PATCH for-rc] RDMA/efa: Fix race between admin command timeout and completion
Date: Tue, 1 Sep 2026 11:30:16 +0000 [thread overview]
Message-ID: <20260901113016.581935-1-ynachum@amazon.com> (raw)
When an admin command times out, there is a potential race between the
interrupt handler processing the completion and the timeout path
releasing the completion context. The interrupt handler may observe the
command as still submitted and attempt to complete it while the timeout
path is concurrently freeing the context.
Fix this by introducing a timed-out state in the completion context. On
timeout, both the polling and interrupt wait paths set the status to
timed-out under the CQ lock before returning. The completion handler
only process commands in submitted state, eliminating the race.
Fixes: 0420e542569b ("RDMA/efa: Implement functions that submit and complete admin commands")
Reviewed-by: Tom Sela <tomsela@amazon.com>
Signed-off-by: Yonatan Nachum <ynachum@amazon.com>
---
drivers/infiniband/hw/efa/efa_com.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/efa/efa_com.c b/drivers/infiniband/hw/efa/efa_com.c
index 583b1cf0d721..a91de9283b6b 100644
--- a/drivers/infiniband/hw/efa/efa_com.c
+++ b/drivers/infiniband/hw/efa/efa_com.c
@@ -41,6 +41,7 @@ enum efa_cmd_status {
EFA_CMD_ALLOCATED,
EFA_CMD_SUBMITTED,
EFA_CMD_COMPLETED,
+ EFA_CMD_TIMED_OUT,
};
struct efa_comp_ctx {
@@ -605,6 +606,10 @@ static int efa_com_wait_and_process_admin_cq_polling(struct efa_comp_ctx *comp_c
break;
if (time_is_before_jiffies(timeout)) {
+ spin_lock_irqsave(&aq->cq.lock, flags);
+ comp_ctx->status = EFA_CMD_TIMED_OUT;
+ spin_unlock_irqrestore(&aq->cq.lock, flags);
+
ibdev_err_ratelimited(
aq->efa_dev,
"Wait for completion (polling) timeout\n");
@@ -639,7 +644,6 @@ static int efa_com_wait_and_process_admin_cq_interrupts(struct efa_comp_ctx *com
if (comp_ctx->status == EFA_CMD_SUBMITTED) {
spin_lock_irqsave(&aq->cq.lock, flags);
efa_com_handle_admin_completion(aq);
- spin_unlock_irqrestore(&aq->cq.lock, flags);
atomic64_inc(&aq->stats.no_completion);
@@ -660,6 +664,9 @@ static int efa_com_wait_and_process_admin_cq_interrupts(struct efa_comp_ctx *com
comp_ctx->cmd_id, aq->sq.pc, aq->sq.cc,
aq->cq.cc);
+ comp_ctx->status = EFA_CMD_TIMED_OUT;
+ spin_unlock_irqrestore(&aq->cq.lock, flags);
+
clear_bit(EFA_AQ_STATE_RUNNING_BIT, &aq->state);
return -ETIME;
}
--
2.50.1
next reply other threads:[~2026-09-01 11:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 11:30 Yonatan Nachum [this message]
2026-09-02 7:58 ` [PATCH for-rc] RDMA/efa: Fix race between admin command timeout and completion Gal Pressman
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=20260901113016.581935-1-ynachum@amazon.com \
--to=ynachum@amazon.com \
--cc=gal.pressman@linux.dev \
--cc=jgg@nvidia.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=matua@amazon.com \
--cc=mrgolin@amazon.com \
--cc=sleybo@amazon.com \
--cc=tomsela@amazon.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox