Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: weh@linux.microsoft.com
Cc: longli@kernel.org, kotaranov@microsoft.com, kuba@kernel.org,
	davem@davemloft.net, pabeni@redhat.com, edumazet@google.com,
	andrew+netdev@lunn.ch, jgg@ziepe.ca, leon@kernel.org,
	haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
	shradhagupta@linux.microsoft.com, horms@kernel.org,
	ernis@linux.microsoft.com, stephen@networkplumber.org,
	netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
	linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
	gargaditya@linux.microsoft.com, kees+treewide@kernel.org,
	kees@kernel.org, mawasthi@linux.microsoft.com, weh@microsoft.com,
	edumazet@kernel.org
Subject: Re: [PATCH net-next v13 4/5] net: mana: support concurrent HWC requests
Date: Sat, 05 Dec 2026 04:36:42 +0000	[thread overview]
Message-ID: <179644540271.3146.18279457892801319193@kernel.org> (raw)
In-Reply-To: <hwc-v13.ab4ca86c3bf24a51ad8a84cc8a0220d1.4@linux.microsoft.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 2

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] Teardown commands now report success with no PF acknowledgment.
- [Low] mana_hwc_submit_request() still rejects with -ENODEV when
  `!hwc->hwc_timeout`.
- [Low] mana_hwc_send_request()
  (drivers/net/ethernet/microsoft/mana/hw_channel.c) mixes goto-based…

--

net: mana: support concurrent HWC requests

This commit replaces the semaphore-based HWC request serialization with
concurrent requests. Message slots are kept until both the sender and
the response are done, SQ posts are serialized under the inflight lock,
and senders are drained before teardown. It also adds per-command
deadlines, an HWC_TIMED_OUT state that stops posting, and a new
mana_gd_send_teardown_request() that treats a timeout as a successful
local teardown for DESTROY_PD, DESTROY_MR and DESTROY_DM.

> diff --git a/drivers/net/ethernet/microsoft/mana/hw_channel.c b/drivers/net/ethernet/microsoft/mana/hw_channel.c
> index a98e58b83f9c7..5c2385c4e1620 100644
> --- a/drivers/net/ethernet/microsoft/mana/hw_channel.c
> +++ b/drivers/net/ethernet/microsoft/mana/hw_channel.c

[ ... ]

> @@ -1039,11 +1115,129 @@ void mana_hwc_free_retained_channel(struct gdma_context *gc)

[ ... ]

> +static int mana_hwc_submit_request(struct hw_channel_context *hwc,
> +				   struct hwc_caller_ctx *ctx,
> +				   struct hwc_work_request *tx_wr)
> +{
> +	struct gdma_resource *r = &hwc->inflight_msg_res;
> +	ktime_t start;
> +	int err;
> +
> +	guard(spinlock_irqsave)(&r->lock);
> +	if (hwc->state == HWC_STOPPED || !hwc->hwc_timeout)
> +		return -ENODEV;

[Severity: Low]

This isn't a bug, but can the !hwc->hwc_timeout check still fire?

This patch removes every writer that stored 0: mana_serv_reset(),
mana_hwc_destroy_channel(), and the old reduce-to-1ms path. The writers
that remain only store non-zero values:

  - mana_hwc_create_channel() stores HW_CHANNEL_WAIT_RESOURCE_TIMEOUT_MS.
  - The HWC_DATA_CFG_HWC_TIMEOUT handler writes only if (val).
  - mana_gd_query_hwc_timeout() writes only if
    (hwc->timeout_query && resp.timeout_ms).

Leaving the check in implies that a zero timeout still means the channel
is stopped, and that is no longer true.

> +
> +	/* Check pending timers before ringing another doorbell, even if
> +	 * their senders haven't been scheduled since the deadlines passed.
> +	 */
> +	mana_hwc_check_timeouts(hwc, ktime_get());
> +	if (hwc->state == HWC_TIMED_OUT)
> +		return HWC_DMA_RETIRED;
> +
> +	start = ktime_get();
> +	err = mana_hwc_post_tx_wqe(hwc->txq, tx_wr, hwc->dest_vrq_id,
> +				   hwc->dest_vrcq_id, false);
> +	if (err)
> +		return err;
> +
> +	ctx->timeout_ms = hwc->hwc_timeout;
> +	ctx->earliest_expiry = ktime_add_ms(start, ctx->timeout_ms);
> +	ctx->posted_at = ktime_get();

[ ... ]

> @@ -1058,108 +1252,87 @@ static int mana_hwc_response_status(struct hw_channel_context *hwc,

[ ... ]

> +	if (err == -ETIMEDOUT) {
> +		dev_err(hwc->dev, "Command 0x%x timed out: %u ms\n",
> +			command, ctx->timeout_ms);
> +		/* A posted destroy's own target predates its timeout, even
> +		 * when an overlapping post precludes retiring the whole HWC.
> +		 */
> +		return HWC_DMA_RETIRED;
> +	}
> +	return mana_hwc_response_result(hwc, command, err, status);
>  }

[Severity: High]

Can a destroy be reported as successful here while the device still has
the object programmed?

Every per-command -ETIMEDOUT becomes HWC_DMA_RETIRED. That includes the
case where mana_hwc_expire() leaves the channel in HWC_READY because a
later post crossed the deadline.

After the channel moves to HWC_TIMED_OUT, mana_hwc_try_get_msg_index()
and mana_hwc_submit_request() also return HWC_DMA_RETIRED without
posting anything. mana_hwc_send_request() then turns this into 0 for
teardown callers.

This patch moves DESTROY_PD, DESTROY_MR and DESTROY_DM onto
mana_gd_send_teardown_request(). mana_ib_dealloc_mw() also reaches
mana_ib_gd_destroy_mr(). In mana_ib_dereg_mr():

	err = mana_ib_gd_destroy_mr(dev, mr->mr_handle);
	if (err)
		return err;

	if (mr->umem)
		ib_umem_release(mr->umem);

	kfree(mr);

With the new 0 return, the user pages are unpinned and given back to the
allocator. The MR may still be reachable through its rkey at that point.

Before this patch the timeout returned -ETIMEDOUT and the umem stayed
pinned. That leaked the pages, but it was DMA safe.

The new behaviour is only safe if the PF retires client DMA and revokes
MRs once the normal response interval has passed. That contract is not
referenced, negotiated or gated on a capability. A few places look like
they could let the VF deadline expire before any PF-side interval does:

  - mana_hwc_submit_request() takes posted_at and earliest_expiry with
    ktime_get() around a posted doorbell write that has no read-back.
    An interval measured from when the device receives the WQE would
    end after the VF's deadline.

  - ctx->timeout_ms is sampled at post time. A later
    HWC_DATA_CFG_HWC_TIMEOUT that raises the interval does not extend
    commands already in flight.

  - Without GDMA_DRV_CAP_FLAG_1_HWC_TIMEOUT_RECONFIG the deadline is
    HW_CHANNEL_WAIT_RESOURCE_TIMEOUT_MS (30000 ms). Nothing ties this
    value to a PF retirement interval.

  - mana_hwc_handle_resp() calls mana_hwc_check_timeouts() in IRQ
    context before it accepts a reply the device has already written.
    Interrupt or vCPU latency alone could then discard a timely reply
    and move the HWC to HWC_TIMED_OUT. For a create command, the device
    would hold a live object that the VF never learns about.

Would it be safer to keep failing these teardowns on timeout, or to
return 0 only when the PF has advertised the retirement semantics?

>  int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len,
> -			  const void *req, u32 resp_len, void *resp)
> +			  const void *req, u32 resp_len, void *resp,
> +			  bool teardown)
>  {

[ ... ]

> +	wait_event(hwc->admission_waitq,
> +		   (err = mana_hwc_try_get_msg_index(hwc, resp, resp_len,
> +						    &ctx)) != -EBUSY);
>  	if (err)
> -		return err;
> -
> -	tx_wr = &txq->msg_buf->reqs[msg_id];
> -	ctx = hwc->caller_ctx + msg_id;
> +		goto out;

[ ... ]

> +	err = mana_hwc_submit_request(hwc, ctx, tx_wr);
> +	if (!err)
> +		err = mana_hwc_wait_for_response(hwc, ctx, command);
> +put:
> +	scoped_guard(spinlock_irqsave, &r->lock) {
>  		ctx->output_buf = NULL;

[ ... ]

> +		ctx->sender = false;
> +		mana_hwc_put_slot(hwc, ctx);
>  	}

[ ... ]

> +out:
> +	if (err == HWC_DMA_RETIRED)
> +		return teardown ? 0 : -ETIMEDOUT;
> +	return err;
>  }

[Severity: Low]

This isn't a bug, but mana_hwc_send_request() now mixes the goto put and
goto out labels with a scoped_guard() block. include/linux/cleanup.h
expects goto-based and scope-based cleanup not to be mixed in the same
routine.

The forward gotos don't jump into or out of the scoped_guard() statement,
so the locking is correct today. Could the slot release move into a
helper, or the gotos be dropped, so the function uses a single cleanup
style?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/hwc-v13.ab4ca86c3bf24a51ad8a84cc8a0220d1.0%40linux.microsoft.com

  reply	other threads:[~2026-12-05  4:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  4:03 [PATCH net-next v13 0/5] net: mana: concurrent HWC requests Wei Hu
2026-12-01  4:03 ` [PATCH net-next v13 1/5] net: mana: validate the HWC doorbell before ringing it Wei Hu
2026-12-01  4:03 ` [PATCH net-next v13 2/5] net: mana: keep HWC queues until the PF acknowledges teardown Wei Hu
2026-12-05  4:36   ` netdev-bot+sashiko
2026-12-01  4:03 ` [PATCH net-next v13 3/5] net: mana: protect the HWC response buffer until the sender returns Wei Hu
2026-12-01  4:04 ` [PATCH net-next v13 4/5] net: mana: support concurrent HWC requests Wei Hu
2026-12-05  4:36   ` netdev-bot+sashiko [this message]
2026-12-01  4:04 ` [PATCH net-next v13 5/5] net: mana: use the reported HWC queue depth Wei Hu
2026-12-05  4:36   ` netdev-bot+sashiko
2026-12-01  4:08 ` [PATCH net-next v13 0/5] net: mana: concurrent HWC requests netdev-bot+sinfo
2026-12-01  6:51   ` [EXTERNAL] " Wei Hu
2026-12-01  4:18 ` 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=179644540271.3146.18279457892801319193@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=decui@microsoft.com \
    --cc=edumazet@google.com \
    --cc=edumazet@kernel.org \
    --cc=ernis@linux.microsoft.com \
    --cc=gargaditya@linux.microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=horms@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=kees+treewide@kernel.org \
    --cc=kees@kernel.org \
    --cc=kotaranov@microsoft.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=longli@kernel.org \
    --cc=mawasthi@linux.microsoft.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shradhagupta@linux.microsoft.com \
    --cc=stephen@networkplumber.org \
    --cc=weh@linux.microsoft.com \
    --cc=weh@microsoft.com \
    --cc=wei.liu@kernel.org \
    /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