🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27246

Re: [PATCH net-next v13 4/5] net: mana: support concurrent HWC requests

#27246
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 04:36
219 lines
15914 bytes
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
Technical Details
Message-ID: <179644540271.3146.18279457892801319193@kernel.org>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377833-linux-kernel-netdev=dewy.ru
References: <hwc-v13.ab4ca86c3bf24a51ad8a84cc8a0220d1.4@linux.microsoft.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377833-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v13 4/5] net: mana: support concurrent HWC requests
Date: Sat, 05 Dec 2026 04:36:42 +0000
Organization: Usenet Network
Message-ID: <179644540271.3146.18279457892801319193@kernel.org>
References: <hwc-v13.ab4ca86c3bf24a51ad8a84cc8a0220d1.4@linux.microsoft.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="2954243"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:mzUSG1U/jBXn8W55M4DvRpUlbGU= sha256:KvPJY4vewsXIysTIrQw5lbE/kKc61vVtpGbhxZoq0Zk= sha1:SBsIzoQ9LFAijUuJ7m7+ceMVgdU= sha256:6w2C0bhL9F6O65dZMRms8bPRd61b3KBRUFUWTUdPRAU=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 6662A117D71; Sat,  5 Dec 2026 07:37:08 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.642
X-Spam-Status: No, score=-3.642 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hIOhfPAAam82; Sat,  5 Dec 2026 07:37:05 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-377833-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id D761D117D6D; Sat,  5 Dec 2026 07:36:54 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id CF87D2845C; Sat,  5 Dec 2026 04:36:49 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796445405; b=xhwiPWt5iP8sIeN0v9SB5W2OFvFiTFgqZTp8TtcbcA9EeFYSW01keoL5XB0ASIcwPb9s +88EQPDJV3Bjcu/GIYGgfgLoofz9yR2Kgb1MEX2PhEPq+OqYC/BgUqSLaOgFRQlmPvWiV S3lzvc2x66pgE8iv4EHxQqKZrljp4914RcBPvAke7CH8tfMssRrsrdzhwh8heds5sCXmI UdRMErgWYFMe1rQ2Ls1c2DXiXndLUmqbuwldE+ojm3CrpuOVzA3iZT+YJH3dC9FoUiijj rWFPnAGGbYwUJ0Iq7dco9lV0LEkopeqWLcUVyph+ryB7/kmOIX0Go/56/yKIImP6Rrg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796445405; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=GtWUNkFCbfWv2PvHL/M1EcDldQFdCRKWNuPyQaHkCDQ=; b=dF/AWSYDtJa5Hd6QZLn8fJjfsasYlVDdyx0Y6CfSvLWDcBo9OcJ/i3SCdt9XKnnu0Qld 5suvkr3Uf2Md1vRNb2jLy8aqBsPDUSrtDyYbjOvHEd2mxZLKGHtJXqCPrmUmKrSN0ALvC nfqtq/sQC70oJHlSa/Zmgj2S0dHO22PxW6vbhtpGK7IHT3xYIKz+m45eX1xVVgWMvhSaS ImOgs0/qRhwnhKWv1oXtzuBK0/BU1WnSOCofXVmYdilerMlKOCzO7mApR3rP4rOpaCqPK dddPZ6MoEqqKZZx5to+/wN4nlyqMfSBsu6liiftJ++qeDeqFBZeseIvsgV36gPHz/aQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=N0Te2cxf; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B2225606A695; Sat,  5 Dec 2026 04:36:45 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=N0Te2cxf
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796445404; b=YGHQ66yVeu6rDb/WT4jvSa7wEcsRFzv1SEOMNjUxBAcSNwGVEw1LeA2gG3bntyI2ICx7 OCTBbxWkG1IZctqHkpxwQ30HA5EQq1NxcqSHUby+yflePeCwdWzJNbmGFFjb3QY22vHQa 4NUOT9/Hy3AFjMuEpZoKDF4imCHFnwwNH4zYAOLJ+l3r2EFJ+2kkeebEluZdp3urxMZcI VeazQQowwX4jil6m4mW2pGUkmngcKqYqxcg4xvEGGJQZOQs0TmX+xYUwJAir0tbXwahkr qEoXuAvXa7wuLQRMx/OlaGOmh5Vh40b1x1ZC4ua3wZj1ktt8ljyum8KOMzkJTC3RTOQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796445404; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=GtWUNkFCbfWv2PvHL/M1EcDldQFdCRKWNuPyQaHkCDQ=; b=32JXsKhE1DGf9EWJQbkacXy551SSlO87/HanE29la4xVRTYr3BmFuA0Ql2UoW/FZ/NO4 IQvCHRt4lAgiAOqkR/sxTrbTgXirZIa9jXY7uCCPVAhvW2f6e+ZtFzbZCGWT2giXMfV3t /8Buuh9wwtMoaMT0LeifTZ3dj05+WdjXxRyNcO7gWUBmiyO8QSb8QpLEM83a19TON1b5K ik8qh9g4YhnSREylBbYbMD66i8feBDyblIuFgw1jlgzezBCkkSvCTVTUM7/srDyHG484u WnSj41BMvrwLaHaoJ7gvCV/S5ybr2TsWtSCxE9Tir8HFWig9GGFCmBWprYqwO5N2Ftg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=N0Te2cxf; arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2A4F606A681; Sat,  5 Dec 2026 04:36:44 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26C3C1F00A11; Sat,  5 Dec 2026 04:36:43 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796445404; bh=GtWUNkFCbfWv2PvHL/M1EcDldQFdCRKWNuPyQaHkCDQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=N0Te2cxfWd6MFaeBo3nVPHRjz5hAWBuMRXGoy3MPdfFuocJER88NAevhotyMPJqYK EtSlmVIB+V/+iM1uFzXMwJdNgSplb6Yk1QFMbrsLDJ2YaJqaM6B72zgjYVgz3a6HVN tKcBJpI/rSAT9hmzKoCGaBsR5HMckKfRBcI3M8K58dUqnDjN87j45D95XrKPxLDu9D FWIX4xbx/+ynbnaP+G60f9zVA9MPIyu5R4FUIvTJ98qH8q8s+C+sd9LmPzt+dN5QTE wCvLW3eCIs/U7gyEjWyPuvnZ+XKxPeQc9Skk5wWcuCNVXmHADsk5Zf6vuG7eMmyqCa gvirGmmRUTOfQ==
X-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
X-In-Reply-To: <hwc-v13.ab4ca86c3bf24a51ad8a84cc8a0220d1.4@linux.microsoft.com>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-Received-Bytes: 15717