All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wei Hu" <weh@linux.microsoft.com>
Cc: linux-rdma@vger.kernel.org, linux-hyperv@vger.kernel.org
Subject: Re: [PATCH net-next v11 4/4] net: mana: add dynamic HWC queue depth with reinit path
Date: Wed, 18 Nov 2026 16:01:28 +0000	[thread overview]
Message-ID: <sashiko-outbox-221403@kernel.org> (raw)
In-Reply-To: <100c6b7a71e86c8d7afd0c55f6b231f01db184d5.1794751992.git.weh@linux.microsoft.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] net: mana: swapped HWC request/response limits in
  mana_hwc_finish_channel()
- [Medium] net: mana: duplicate mana_hwc_teardown_queues() on HWC
  rebuild failure
--

commit 3fabf9cbfe8a174f5953b462e57e3b1f0fcf54f1
Author: Long Li <longli@microsoft.com>

net: mana: add dynamic HWC queue depth with reinit path

This commit adds support for dynamically rebuilding the MANA hardware
channel queues to the PF-reported queue depth (up to 128), validating
reported message size limits and doorbells, and falling back to bootstrap
queues if rebuilding fails.

Link: https://lore.kernel.org/r/20260908035201.402424-5-longli@microsoft.com
Link: https://lore.kernel.org/r/179196575846.434549.7933818740976196422@kernel.org
Link: https://lore.kernel.org/r/179455240227.2199510.2666165032389090040@kernel.org

> diff --git a/drivers/net/ethernet/microsoft/mana/hw_channel.c b/drivers/net/ethernet/microsoft/mana/hw_channel.c
> index 8c2495ce5f526..cb73d0725206e 100644
> --- a/drivers/net/ethernet/microsoft/mana/hw_channel.c
> +++ b/drivers/net/ethernet/microsoft/mana/hw_channel.c

[ ... ]

> @@ -1175,32 +1256,169 @@ void mana_hwc_free_retained_channel(struct gdma_context *gc)
>  	gc->hwc.gdma_context = NULL;
>  }
>  
> -static int mana_hwc_create_bootstrap_channel(struct hw_channel_context *hwc)
> +static int
> +mana_hwc_validate_report(struct hw_channel_context *hwc,
> +			 const struct mana_hwc_init_report *report,
> +			 u32 expected_depth, bool check_depth,
> +			 bool require_exact_msg_sizes)
> +{
> +	if (!report->queue_depth || !report->max_req_msg_size ||
> +	    !report->max_resp_msg_size) {
> +		dev_err(hwc->dev,
> +			"HWC: invalid maxima depth=%u req=%u resp=%u\n",
> +			report->queue_depth, report->max_req_msg_size,
> +			report->max_resp_msg_size);
> +		return -EPROTO;
> +	}
> +
> +	if (require_exact_msg_sizes &&
> +	    (report->max_req_msg_size != HW_CHANNEL_MAX_REQUEST_SIZE ||
> +	     report->max_resp_msg_size != HW_CHANNEL_MAX_RESPONSE_SIZE)) {
> +		dev_err(hwc->dev,
> +			"HWC: rebuilt message maxima req=%u resp=%u, expected %u/%u\n",
> +			report->max_req_msg_size, report->max_resp_msg_size,
> +			HW_CHANNEL_MAX_REQUEST_SIZE,
> +			HW_CHANNEL_MAX_RESPONSE_SIZE);
> +		return -EPROTO;
> +	}
> +
> +	if (check_depth && report->queue_depth != expected_depth) {
> +		dev_err(hwc->dev, "HWC: rebuilt depth %u, expected %u\n",
> +			report->queue_depth, expected_depth);
> +		return -EPROTO;
> +	}
> +
> +	return 0;
> +}
> +
> +static int mana_hwc_finish_channel(struct hw_channel_context *hwc,
> +				   const struct mana_hwc_init_report *report)
> +{
> +	int err;
> +
> +	/* MAX_REQUEST sizes the RQ; MAX_RESPONSE sizes the SQ. */
> +	hwc->rx_msg_size_limit = report->max_req_msg_size;
> +	hwc->tx_msg_size_limit = report->max_resp_msg_size;

[Severity: Medium]
Are rx_msg_size_limit and tx_msg_size_limit swapped here?

On the HWC, the host sends requests over hwc->txq (GDMA_SQ) in
mana_hwc_send_request() and receives responses over hwc->rxq (GDMA_RQ) in
mana_hwc_rx_event_handler().  Because tx_msg_size_limit is populated from
report->max_resp_msg_size and rx_msg_size_limit from
report->max_req_msg_size, mana_hwc_get_max_req_size() and
mana_hwc_get_msg_index() check outgoing req_len against the PF-reported
response limit and incoming resp_len against the request limit.

When the PF reports asymmetric HWC_INIT_DATA_MAX_REQUEST and
HWC_INIT_DATA_MAX_RESPONSE values (where mana_hwc_prepare_channel() keeps
the bootstrap queues), a smaller MAX_RESPONSE will cause outgoing requests
such as mana_gd_create_dma_region() and mana_ib_gd_create_dma_region() to be
capped or rejected with -EMSGSIZE or -EINVAL against the response limit.

> +
> +	err = mana_hwc_test_channel(hwc);
> +	if (err)
> +		dev_err(hwc->dev, "Failed to test HWC: %d\n", err);
> +
> +	return err;
> +}

[ ... ]

> +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);
> +	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;

[ ... ]

> @@ -1233,7 +1451,7 @@ int mana_hwc_create_channel(struct gdma_context *gc)
>  	gd->pdid = INVALID_PDID;
>  	gd->doorbell = INVALID_DOORBELL;
>  
> -	err = mana_hwc_create_bootstrap_channel(hwc);
> +	err = mana_hwc_prepare_channel(hwc);
>  	if (err) {
>  		mana_hwc_release_channel(hwc);
>  		return err;

[Severity: Medium]
Does failing inside mana_hwc_teardown_queues() during
mana_hwc_rebuild_channel() cause mana_hwc_release_channel() to run
mana_hwc_teardown_queues() a second time on the same active channel?

When mana_smc_teardown_hwc() fails in mana_hwc_teardown_queues(),
hwc->setup_active remains true and the channel is fenced, and that error is
returned through mana_hwc_prepare_channel() to mana_hwc_create_channel().
mana_hwc_release_channel() then calls mana_hwc_teardown_queues() again while
hwc->setup_active is still true, issuing a second SMC teardown transaction
that can stall in mana_smc_poll_register() for another 20 to 40 seconds or
send a duplicate SMC_MSG_TYPE_DESTROY_HWC if the PF completed the first
teardown right after it timed out.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1794751992.git.weh@linux.microsoft.com?part=4

  parent reply	other threads:[~2026-11-18 16:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 16:00 [PATCH net-next v11 0/4] net: mana: concurrent HWC requests and dynamic queue depth Wei Hu
2026-11-17 16:00 ` [PATCH net-next v11 1/4] net: mana: prepare HWC ownership for safe reinitialization Wei Hu
2026-11-18 16:01   ` sashiko-bot
2026-11-17 16:00 ` [PATCH net-next v11 2/4] net: mana: give each HWC message slot its own completion state Wei Hu
2026-11-18 16:01   ` sashiko-bot
2026-11-17 16:01 ` [PATCH net-next v11 3/4] net: mana: support concurrent HWC requests Wei Hu
2026-11-17 18:07   ` Leon Romanovsky
2026-11-18 16:01   ` sashiko-bot
2026-11-17 16:01 ` [PATCH net-next v11 4/4] net: mana: add dynamic HWC queue depth with reinit path Wei Hu
2026-11-17 18:09   ` Leon Romanovsky
2026-11-18 16:01   ` sashiko-bot [this message]
2026-11-17 16:03 ` [PATCH net-next v11 0/4] net: mana: concurrent HWC requests and dynamic queue depth netdev-bot+sinfo

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=sashiko-outbox-221403@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=weh@linux.microsoft.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.