Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Gal Pressman <gal.pressman@linux.dev>
To: Yonatan Nachum <ynachum@amazon.com>,
	jgg@nvidia.com, leon@kernel.org, linux-rdma@vger.kernel.org
Cc: mrgolin@amazon.com, sleybo@amazon.com, matua@amazon.com,
	Tom Sela <tomsela@amazon.com>
Subject: Re: [PATCH for-rc] RDMA/efa: Fix race between admin command timeout and completion
Date: Wed, 2 Sep 2026 10:58:39 +0300	[thread overview]
Message-ID: <2e005595-3761-4a29-9c62-e7f935c8691e@linux.dev> (raw)
In-Reply-To: <20260901113016.581935-1-ynachum@amazon.com>

On 01/09/2026 14:30, Yonatan Nachum wrote:
> 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);

This smells bad, a few lines above 'comp_ctx->status' is being read
without a lock. Can't it change during this window?

      reply	other threads:[~2026-09-02  7:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 11:30 [PATCH for-rc] RDMA/efa: Fix race between admin command timeout and completion Yonatan Nachum
2026-09-02  7:58 ` Gal Pressman [this message]

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=2e005595-3761-4a29-9c62-e7f935c8691e@linux.dev \
    --to=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 \
    --cc=ynachum@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