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 v8 4/4] net: mana: add dynamic HWC queue depth with reinit path
Date: Tue, 20 Oct 2026 13:36:34 +0000 [thread overview]
Message-ID: <179250339474.3135.8335532818248262678@kernel.org> (raw)
In-Reply-To: <877e674c0255820b0517f863e535615b4028a48a.1791998462.git.weh@linux.microsoft.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · 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).
- [Medium] Rebuilt HWC rings change size with depth, but the PF is never
told the new size.
- [Low] The fix for the unchecked HWC init doorbell index ships inside a
large feature patch, and the patch has no Fixes: tag.
- [Low] mana_hwc_rebuild_channel() saves hwc_timeout into timeout_ms on
entry.
--
net: mana: add dynamic HWC queue depth with reinit path
The HWC now starts with depth-one bootstrap queues. When the PF reports a
depth from 2 to 128 with 4096-byte maxima, the channel is torn down and
rebuilt at that depth. If the rebuild fails, the driver falls back to
fresh bootstrap queues. Request sizes are bounded by the negotiated limits
in the GDMA and RDMA builders, and the HWC init doorbell index is now
validated against BAR0 before use.
Link: https://lore.kernel.org/r/20260908035201.402424-5-longli@microsoft.com
Link: https://lore.kernel.org/r/179196575846.434549.7933818740976196422@kernel.org
> diff --git a/drivers/net/ethernet/microsoft/mana/hw_channel.c b/drivers/net/ethernet/microsoft/mana/hw_channel.c
> index 9ea67c076ebda..c4cae1baaef4d 100644
> --- a/drivers/net/ethernet/microsoft/mana/hw_channel.c
> +++ b/drivers/net/ethernet/microsoft/mana/hw_channel.c
[ ... ]
> @@ -247,8 +263,18 @@ static void mana_hwc_init_event_handler(void *ctx, struct gdma_queue *q_self,
> switch (event->type) {
> case GDMA_EQE_HWC_INIT_EQ_ID_DB:
> eq_db.as_uint32 = event->details[0];
> + if (!mana_gd_is_valid_doorbell(gd->gdma_context,
> + eq_db.doorbell)) {
> + dev_err(hwc->dev, "HWC: invalid doorbell %u\n",
> + eq_db.doorbell);
> + WRITE_ONCE(hwc->hwc_init_error, -EPROTO);
> + complete(&hwc->hwc_init_eqe_comp);
> + break;
> + }
> +
> hwc->cq->gdma_eq->id = eq_db.eq_id;
> gd->doorbell = eq_db.doorbell;
> + hwc->hwc_init_doorbell = true;
> break;
[Severity: Low]
This isn't a bug, but the unchecked HWC init doorbell index fixed here
dates back to ca9c54d2d6a5 ("net: mana: Add a driver for Microsoft Azure
Network Adapter (MANA)").
Before this patch, mana_hwc_init_event_handler() did:
gd->doorbell = eq_db.doorbell;
with no bounds check. mana_gd_ring_doorbell() then used that index to
compute the MMIO address.
The fix looks self-contained: mana_gd_is_valid_doorbell(), the
INVALID_DOORBELL check in mana_gd_ring_doorbell() and the hwc_init_error
completion. Would it be easier to review and backport as a separate patch
ahead of the dynamic depth rebuild?
The similar hardening commit 89fe91c65992 ("net: mana: hardening: Validate
doorbell ID from GDMA_REGISTER_DEVICE response") was merged without a
Fixes: tag, so leaving the tag off here may be intentional.
[ ... ]
> @@ -1179,32 +1258,168 @@ void mana_hwc_free_retained_channel(struct gdma_context *gc)
[ ... ]
> +static int mana_hwc_rebuild_channel(struct hw_channel_context *hwc,
> + u16 q_depth,
> + struct mana_hwc_init_report *report)
> +{
> + u32 timeout_ms = mana_hwc_timeout_read(hwc);
> + int cleanup_err;
> + int err;
> +
> + err = mana_hwc_teardown_queues(hwc);
> + if (err)
> + return err;
> +
> + err = mana_hwc_build_channel(hwc, q_depth, report);
[Severity: Medium]
How does the PF learn the size of the rebuilt rings?
mana_hwc_create_cq() and mana_hwc_create_wq() size the rings from the
depth:
eq_size = roundup_pow_of_two(GDMA_EQE_SIZE * q_depth);
cq_size = roundup_pow_of_two(GDMA_CQE_SIZE * q_depth);
queue_size = roundup_pow_of_two(GDMA_MAX_RQE_SIZE * q_depth);
queue_size = roundup_pow_of_two(GDMA_MAX_SQE_SIZE * q_depth);
At depth 128 the CQ is 16 KiB, the RQ 32 KiB and the SQ 64 KiB. At depth
1 every ring is 4 KiB.
The ESTABLISH_HWC message built by mana_smc_setup_hwc_locked() carries
only the four frame addresses, their high 4 bits and the EQ MSI-X index:
hdr->msg_type = SMC_MSG_TYPE_ESTABLISH_HWC;
hdr->msg_version = SMC_MSG_TYPE_ESTABLISH_HWC_VERSION;
It has no size or depth field, and the message version is unchanged.
mana_hwc_rebuild_channel() sends this message for the depth-N rings. If
that fails, mana_hwc_restore_bootstrap() sends the same message for 4 KiB
rings, after the PF has already accepted a depth-N establish. A later
driver reload does the same, because mana_hwc_create_channel() always
starts with a bootstrap establish.
If the PF sizes the rings from the depth it advertised, could it write
EQEs or CQEs past the end of the 4 KiB bootstrap rings? If it assumes
4 KiB instead, would the owner-bit phase diverge after the first wrap of
a rebuilt ring and stall the HWC?
The check_depth test in mana_hwc_validate_report() confirms the depth the
PF reports, not the ring size it actually uses. Is there a firmware
contract that covers this? If so, could it be documented here?
> + if (!err)
> + err = mana_hwc_validate_report(hwc, report, q_depth, true, true);
> + if (!err)
> + err = mana_hwc_finish_channel(hwc, report);
> + if (!err)
> + return 0;
> +
> + dev_warn(hwc->dev,
> + "HWC depth %u rebuild failed, restoring bootstrap: %d\n",
> + q_depth, err);
> +
> + cleanup_err = mana_hwc_teardown_queues(hwc);
> + if (cleanup_err)
> + return cleanup_err;
> +
> + /* Do not carry the failed test's reduced wait into the retry. */
> + mana_hwc_timeout_update(hwc, timeout_ms);
[Severity: Low]
Can this restore overwrite a timeout that firmware set during the
rebuild?
timeout_ms is read once at the top of mana_hwc_rebuild_channel(). While
the depth-N channel is being built, its EQ is live with
mana_hwc_init_event_handler(), which can run this from IRQ context:
case HWC_DATA_CFG_HWC_TIMEOUT:
mana_hwc_timeout_update(hwc, val);
mana_hwc_timeout_update() replaces any nonzero value. If the rebuild then
fails, this call writes the stale snapshot over the firmware-supplied
value, not just over the value of 1 left by mana_hwc_timeout_reduce().
The commit message says the restore is there so that "a failed test's
fail-fast reduction does not poison the retry". Would a cmpxchg from 1 to
timeout_ms match that intent and keep concurrent firmware updates?
The effect looks temporary. Once mana_hwc_create_channel() succeeds,
mana_gd_verify_vf_version() queries the PF timeout again through
mana_gd_query_hwc_timeout() when GDMA_DRV_CAP_FLAG_1_HWC_TIMEOUT_RECONFIG
is advertised.
> +
> + return mana_hwc_restore_bootstrap(hwc, report);
> +}
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1791998462.git.weh%40linux.microsoft.com
next reply other threads:[~2026-10-20 13:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 13:36 netdev-bot+sashiko [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-10-16 12:06 [PATCH net-next v8 0/4] net: mana: concurrent HWC requests and dynamic queue depth Wei Hu
2026-10-16 12:06 ` [PATCH net-next v8 4/4] net: mana: add dynamic HWC queue depth with reinit path Wei Hu
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=179250339474.3135.8335532818248262678@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