From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 931ED3002C8; Tue, 11 Aug 2026 02:38:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786415932; cv=none; b=TFTuIvvGRPghFICZ36ZGpGkYQ5ZAiImrs0sLsi5k7u1DrS0LQ5fy98KjH0Y97a6JBbKAOBxkcU6pvsNnJ0BCndWETjVepGUUi5NtPJHspNAQOIty0JHmfipowTtZobatO3LjIyCIztFFjFOPM3klH7Hm6NnPwC5/f3IC0Ugqnxk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786415932; c=relaxed/simple; bh=i7J7zOiG/NdtzRshbQmSHrjnHXBXzN2crUS3sptkw0E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B8oUZIlxFmrVibwexE58zGnavj1ykmVwvqDQZV/wEMaDfBp5iPTLZPRerRBH8E07/KfmEbvN0wN/dmFAKI8g7LtmHkZ3+uKXyapz7Vg8eNitaSxH/xrewE/SD6dA3dP0e1/p+XLy493g2TwSwhR4K4TgQ/2aXA9GFjojOQZBTfY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: by linux.microsoft.com (Postfix, from userid 1202) id DE61E20B710C; Mon, 10 Aug 2026 19:38:27 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com DE61E20B710C From: Long Li To: Long Li , Konstantin Taranov , Jakub Kicinski , "David S . Miller" , Paolo Abeni , Eric Dumazet , Andrew Lunn , Jason Gunthorpe , Leon Romanovsky , Haiyang Zhang , "K . Y . Srinivasan" , Wei Liu , Dexuan Cui , shradhagupta@linux.microsoft.com, Simon Horman , ernis@linux.microsoft.com, stephen@networkplumber.org Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v6 2/7] net: mana: fix HWC RQ/SQ buffer size swap Date: Mon, 10 Aug 2026 19:38:16 -0700 Message-ID: <20260811023823.2391255-3-longli@microsoft.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: <20260811023823.2391255-1-longli@microsoft.com> References: <20260811023823.2391255-1-longli@microsoft.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The HWC RQ receives responses and the SQ sends requests, but mana_hwc_init_queues() sized the RQ with max_req_msg_size and the SQ with max_resp_msg_size -- backwards. mana_hwc_rx_event_handler() also recovered the RX slot index by dividing by max_req_msg_size instead of the response size that strides the RQ buffer. Both mistakes are latent today: the only caller passes HW_CHANNEL_MAX_REQUEST_SIZE and HW_CHANNEL_MAX_RESPONSE_SIZE, which are both 0x1000, and the queues are never re-created with the hardware-reported sizes (those are only used by mana_hwc_test_channel()), so max_req_msg_size == max_resp_msg_size on every path and there is no observable overflow or mis-indexing. The bug would only surface if the two sizes ever diverged. Size the RQ by max_resp_msg_size and the SQ by max_req_msg_size, store max_resp_msg_size in hw_channel_context, and use it as the RX slot stride so the code is correct regardless of the two sizes. Fixes: ca9c54d2d6a5 ("net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)") Signed-off-by: Long Li --- Changes in v6: - None. Changes in v5: - No code changes since v4 (resend as a standalone thread). Changes in v4: - Reworded the changelog as a latent-correctness fix (both message sizes are 0x1000, so the swap has no observable overflow) and dropped the note about hoisting the queue dimensions above mana_hwc_create_cq(). drivers/net/ethernet/microsoft/mana/hw_channel.c | 7 ++++--- include/net/mana/hw_channel.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/hw_channel.c b/drivers/net/ethernet/microsoft/mana/hw_channel.c index 409e20caeccdcccec0f8972c95db69ebff7ce30c..3f011ebbe7b3e3de2665bfa164c678c89b9b3005 100644 --- a/drivers/net/ethernet/microsoft/mana/hw_channel.c +++ b/drivers/net/ethernet/microsoft/mana/hw_channel.c @@ -263,7 +263,7 @@ static void mana_hwc_rx_event_handler(void *ctx, u32 gdma_rxq_id, /* Select the RX work request for virtual address and for reposting. */ rq_base_addr = hwc_rxq->msg_buf->mem_info.dma_handle; - rx_req_idx = (sge->address - rq_base_addr) / hwc->max_req_msg_size; + rx_req_idx = (sge->address - rq_base_addr) / hwc->max_resp_msg_size; if (rx_req_idx >= hwc_rxq->msg_buf->num_reqs) { dev_err(hwc->dev, "HWC RX: wrong rx_req_idx=%llu, num_reqs=%u\n", @@ -733,14 +733,14 @@ static int mana_hwc_init_queues(struct hw_channel_context *hwc, u16 q_depth, goto out; } - err = mana_hwc_create_wq(hwc, GDMA_RQ, q_depth, max_req_msg_size, + err = mana_hwc_create_wq(hwc, GDMA_RQ, q_depth, max_resp_msg_size, hwc->cq, &hwc->rxq); if (err) { dev_err(hwc->dev, "Failed to create HWC RQ: %d\n", err); goto out; } - err = mana_hwc_create_wq(hwc, GDMA_SQ, q_depth, max_resp_msg_size, + err = mana_hwc_create_wq(hwc, GDMA_SQ, q_depth, max_req_msg_size, hwc->cq, &hwc->txq); if (err) { dev_err(hwc->dev, "Failed to create HWC SQ: %d\n", err); @@ -749,6 +749,7 @@ static int mana_hwc_init_queues(struct hw_channel_context *hwc, u16 q_depth, hwc->num_inflight_msg = q_depth; hwc->max_req_msg_size = max_req_msg_size; + hwc->max_resp_msg_size = max_resp_msg_size; return 0; out: diff --git a/include/net/mana/hw_channel.h b/include/net/mana/hw_channel.h index 16feb39616c1bead1a043b3fadc2e18a90651516..73671f479399ac296cf472ec6449e5e6b00a8515 100644 --- a/include/net/mana/hw_channel.h +++ b/include/net/mana/hw_channel.h @@ -181,6 +181,7 @@ struct hw_channel_context { u16 num_inflight_msg; u32 max_req_msg_size; + u32 max_resp_msg_size; u16 hwc_init_q_depth_max; u32 hwc_init_max_req_msg_size; -- 2.43.0