Skip to contentSkip to conversation

net: hinic3: Bugfix for later patch-set.

PATCH Superseded Fan Gong 2 participants 8 messages Nov 12 – Nov 16

Subsystems (4)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Fan Gong

author maintainer
#0 lore raw

v3 cover net: hinic3: Bugfix for later patch-set.

These issues were discovered by LLM Gemini-4-Argon and Claude-Opus-5-5. At the same time, LLM recommended submitting an independent patch. These issues were not actually triggered. Based on theoretical analysis and consideration of actual risks, this patch is used to fix the issues.

Testing:
These patch-set have been tested on hinic3 hardware.

V03:
* Clenaup checkpatchs in file hinic3_netdev_ops.c.(AI Review)
* nic_svc_cap->max_sqs is already in the range [1, 256].(AI Review)

V02: https://lore.kernel.org/all/[email protected]/
* Rewrite the commit message and provide an explanation for each patch.(AI Review)
* Split checkpatchs in to a separate patch.(AI Review)
* Fix the failure of napi_alloc_skb() in recv_one_pkt().(AI Review)
* READ_ONCE()/WRITE_ONCE() only stop the compiler from tearing or caching the access. They don't order anything against the work item, and they can't stop it from running. So, remove READ_ONCE() and WRITE_ONCE() on nic_dev->adaptive_rx_coal.(AI Review)

V01: https://lore.kernel.org/netdev/[email protected]/

Fan Gong (4):
hinic3: Solve an stall issue in hinic3_rx_poll()
hinic3: Avoid concurrent updates on 32-bit systems.
hinic3: fix some checkpatchs.
hinic3: Ensure that the value of max_qps is not changed

 .../huawei/hinic3/hinic3_netdev_ops.c         | 76 ++++++++-----------
 .../net/ethernet/huawei/hinic3/hinic3_rss.c   |  9 +--
 .../net/ethernet/huawei/hinic3/hinic3_rx.c    | 11 ++-
 3 files changed, 44 insertions(+), 52 deletions(-)

base-commit: 73022f605c447f31610b94ed4a983d2b4bf2c721

Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH v3 1/4 hinic3: Solve an stall issue in hinic3_rx_poll()

When Large Receive Offload (LRO) packets are large, such as 32KB, each packet consumes 16 Work Queue Elements (WQEs). If multiple large LRO packets occur at this time, it will cause rapid consumption of WQEs in the RQ and WQEs cannot be replenished in time. The chip will drop packets due to lack of WQEs, causing the RQ to be unable to receive packets. Furthermore, the NAPI instance will not be polled again, resulting in residual packets in the RQ.

When napi_alloc_skb() fails inside recv_one_pkt(), hinic3_rx_poll() breaks out of the loop without advancing rxq->cons_idx or clearing rx_cqe->status, and returns nr_pkts (< budget). hinic3_poll() then calls napi_complete_done() and re-enables the edge-triggered MSI-X interrupt while the unprocessed CQE remains at the head of the ring, stalling the receive queue until a new packet arrives to trigger another interrupt.

Fixes 17fcb3dc12bb ("hinic3: module initialization and tx/rx logic")
---
 drivers/net/ethernet/huawei/hinic3/hinic3_rx.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/ethernet/huawei/hinic3/hinic3_rx.c +8 -3
index 309ab5901379..f2262cdd6628 100644
@@ -555,6 +555,7 @@ int hinic3_rx_poll(struct hinic3_rxq *rxq, int budget)
 	struct hinic3_nic_dev *nic_dev = netdev_priv(rxq->netdev);
 	u32 sw_ci, status, pkt_len, vlan_len;
 	struct hinic3_rq_cqe *rx_cqe;
+	bool poll_again = false;
 	u32 num_wqe = 0;
 	int nr_pkts = 0;
 	u16 num_lro;
@@ -571,8 +572,10 @@ int hinic3_rx_poll(struct hinic3_rxq *rxq, int budget)
 
 		vlan_len = le32_to_cpu(rx_cqe->vlan_len);
 		pkt_len = RQ_CQE_SGE_GET(vlan_len, LEN);
-		if (recv_one_pkt(rxq, rx_cqe, pkt_len, vlan_len, status))
+		if (recv_one_pkt(rxq, rx_cqe, pkt_len, vlan_len, status)) {
+			poll_again = true;
 			break;
+		}
 
 		nr_pkts++;
 		num_lro = RQ_CQE_STATUS_GET(status, NUM_LRO);
@@ -581,12 +584,14 @@ int hinic3_rx_poll(struct hinic3_rxq *rxq, int budget)
 
 		rx_cqe->status = 0;
 
-		if (num_wqe >= nic_dev->lro_replenish_thld)
+		if (num_wqe >= nic_dev->lro_replenish_thld) {
+			poll_again = true;
 			break;
+		}
 	}
 
 	if (rxq->delta >= HINIC3_RX_BUFFER_WRITE)
 		hinic3_rx_fill_buffers(rxq);
 
-	return nr_pkts;
+	return poll_again ? budget : nr_pkts;
 }
Signature · 1 line
2.43.0
author maintainer
#3 lore raw

PATCH v3 2/4 hinic3: Avoid concurrent updates on 32-bit systems.

In reply to Fan Gong

Within the while loop of hinic3_get_stats64(), the counters between u64_stats_fetch_retry and u64_stats_fetch_begin are incremented by +=. This operation will cause repeated counting of the counters on a 32-bit system. Therefore, change += to + and the counters are incremented out side the wile loop.

csum_errors and other_errors are not the same things. csum_errors will go to csum_bad in netdev netlink qstats.

Remove unnecessary checks for the nic_dev->txqs and nic_dev->rxqs.

Remove dead stores before the loop.

Fixes f47872bed40f ("hinic3: Add .ndo_tx_timeout and .ndo_get_stats64")
---
 .../huawei/hinic3/hinic3_netdev_ops.c         | 42 +++++++------------
 1 file changed, 14 insertions(+), 28 deletions(-)
drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c +14 -28
index da73811641a9..d1fd91d97ccf 100644
@@ -791,49 +791,35 @@ static void hinic3_get_stats64(struct net_device *netdev,
 	unsigned int start;
 	int i;
 
-	bytes = 0;
-	packets = 0;
-	dropped = 0;
 	for (i = 0; i < nic_dev->max_qps; i++) {
-		if (!nic_dev->txqs)
-			break;
-
 		txq = &nic_dev->txqs[i];
 		txq_stats = &txq->txq_stats;
 		do {
 			start = u64_stats_fetch_begin(&txq_stats->syncp);
-			bytes += txq_stats->bytes;
-			packets += txq_stats->packets;
-			dropped += txq_stats->dropped;
+			bytes = txq_stats->bytes;
+			packets = txq_stats->packets;
+			dropped = txq_stats->dropped;
 		} while (u64_stats_fetch_retry(&txq_stats->syncp, start));
+		stats->tx_packets += packets;
+		stats->tx_bytes   += bytes;
+		stats->tx_dropped += dropped;
 	}
-	stats->tx_packets = packets;
-	stats->tx_bytes   = bytes;
-	stats->tx_dropped = dropped;
 
-	bytes = 0;
-	packets = 0;
-	errors = 0;
-	dropped = 0;
 	for (i = 0; i < nic_dev->max_qps; i++) {
-		if (!nic_dev->rxqs)
-			break;
-
 		rxq = &nic_dev->rxqs[i];
 		rxq_stats = &rxq->rxq_stats;
 		do {
 			start = u64_stats_fetch_begin(&rxq_stats->syncp);
-			bytes += rxq_stats->bytes;
-			packets += rxq_stats->packets;
-			errors += rxq_stats->csum_errors +
-				rxq_stats->other_errors;
-			dropped += rxq_stats->dropped;
+			bytes = rxq_stats->bytes;
+			packets = rxq_stats->packets;
+			errors = rxq_stats->other_errors;
+			dropped = rxq_stats->dropped;
 		} while (u64_stats_fetch_retry(&rxq_stats->syncp, start));
+		stats->rx_packets += packets;
+		stats->rx_bytes   += bytes;
+		stats->rx_errors  += errors;
+		stats->rx_dropped += dropped;
 	}
-	stats->rx_packets = packets;
-	stats->rx_bytes   = bytes;
-	stats->rx_errors  = errors;
-	stats->rx_dropped = dropped;
 }
 
 static void hinic3_nic_set_rx_mode(struct net_device *netdev)
Signature · 1 line
2.43.0
author maintainer
#5 lore raw

PATCH v3 3/4 hinic3: fix some checkpatchs.

In reply to Fan Gong

Cleanup checkpatchs of lines exceeding 80 columns.

---
 .../huawei/hinic3/hinic3_netdev_ops.c         | 34 +++++++++++--------
 1 file changed, 19 insertions(+), 15 deletions(-)
drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c +19 -15
index d1fd91d97ccf..621d8b12e247 100644
@@ -121,8 +121,9 @@ static void hinic3_destroy_num_qps(struct net_device *netdev)
 	kfree(nic_dev->qps_msix_entries);
 }
 
-static int hinic3_alloc_txrxq_resources(struct net_device *netdev,
-					struct hinic3_dyna_txrxq_params *q_params)
+static int
+hinic3_alloc_txrxq_resources(struct net_device *netdev,
+			     struct hinic3_dyna_txrxq_params *q_params)
 {
 	int err;
 
@@ -176,8 +177,9 @@ static int hinic3_alloc_txrxq_resources(struct net_device *netdev,
 	return err;
 }
 
-static void hinic3_free_txrxq_resources(struct net_device *netdev,
-					struct hinic3_dyna_txrxq_params *q_params)
+static void
+hinic3_free_txrxq_resources(struct net_device *netdev,
+			    struct hinic3_dyna_txrxq_params *q_params)
 {
 	hinic3_free_rxqs_res(netdev, q_params->num_qps, q_params->rq_depth,
 			     q_params->rxqs_res);
@@ -251,16 +253,17 @@ static void hinic3_remove_configure(struct net_device *netdev)
 		hinic3_rss_uninit(netdev);
 }
 
-static int hinic3_alloc_channel_resources(struct net_device *netdev,
-					  struct hinic3_dyna_qp_params *qp_params,
-					  struct hinic3_dyna_txrxq_params *trxq_params)
+static int
+hinic3_alloc_channel_resources(struct net_device *netdev,
+			       struct hinic3_dyna_qp_params *qp_params,
+			       struct hinic3_dyna_txrxq_params *q_params)
 {
 	struct hinic3_nic_dev *nic_dev = netdev_priv(netdev);
 	int err;
 
-	qp_params->num_qps = trxq_params->num_qps;
-	qp_params->sq_depth = trxq_params->sq_depth;
-	qp_params->rq_depth = trxq_params->rq_depth;
+	qp_params->num_qps = q_params->num_qps;
+	qp_params->sq_depth = q_params->sq_depth;
+	qp_params->rq_depth = q_params->rq_depth;
 
 	err = hinic3_alloc_qps(nic_dev, qp_params);
 	if (err) {
@@ -268,7 +271,7 @@ static int hinic3_alloc_channel_resources(struct net_device *netdev,
 		return err;
 	}
 
-	err = hinic3_alloc_txrxq_resources(netdev, trxq_params);
+	err = hinic3_alloc_txrxq_resources(netdev, q_params);
 	if (err) {
 		netdev_err(netdev, "Failed to alloc txrxq resources\n");
 		hinic3_free_qps(nic_dev, qp_params);
@@ -278,13 +281,14 @@ static int hinic3_alloc_channel_resources(struct net_device *netdev,
 	return 0;
 }
 
-static void hinic3_free_channel_resources(struct net_device *netdev,
-					  struct hinic3_dyna_qp_params *qp_params,
-					  struct hinic3_dyna_txrxq_params *trxq_params)
+static void
+hinic3_free_channel_resources(struct net_device *netdev,
+			      struct hinic3_dyna_qp_params *qp_params,
+			      struct hinic3_dyna_txrxq_params *q_params)
 {
 	struct hinic3_nic_dev *nic_dev = netdev_priv(netdev);
 
-	hinic3_free_txrxq_resources(netdev, trxq_params);
+	hinic3_free_txrxq_resources(netdev, q_params);
 	hinic3_free_qps(nic_dev, qp_params);
 }
 
Signature · 1 line
2.43.0
author maintainer
#6 lore raw

PATCH v3 4/4 hinic3: Ensure that the value of max_qps is not changed

In reply to Fan Gong

nic_dev->max_qps is used to allocate hardware resources. Therefore, it is assigned the value 1 only when its value is abnormal. In other scenarios, the value cannot be changed. However, the value of nic_dev->q_params.num_qps can be dynamically changed.

Fixes 1f3838b84a63 ("hinic3: Add Rss function")
---
 drivers/net/ethernet/huawei/hinic3/hinic3_rss.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/ethernet/huawei/hinic3/hinic3_rss.c +3 -6
index 25db74d8c7dd..75dc0c044071 100644
@@ -307,15 +307,13 @@ void hinic3_try_to_enable_rss(struct net_device *netdev)
 	int err;
 
 	nic_dev->max_qps = hinic3_func_max_qnum(hwdev);
-	if (nic_dev->max_qps <= 1 ||
+	if (nic_dev->max_qps == 1 ||
 	    !hinic3_test_support(nic_dev, HINIC3_NIC_F_RSS))
 		goto err_reset_q_params;
 
 	err = alloc_rss_resource(netdev);
-	if (err) {
-		nic_dev->max_qps = 1;
+	if (err)
 		goto err_reset_q_params;
-	}
 
 	set_bit(HINIC3_RSS_ENABLE, &nic_dev->flags);
 	decide_num_qps(netdev);
@@ -324,7 +322,6 @@ void hinic3_try_to_enable_rss(struct net_device *netdev)
 	if (err) {
 		dev_err(hwdev->dev, "Failed to set hardware rss parameters\n");
 		hinic3_clear_rss_config(netdev);
-		nic_dev->max_qps = 1;
 		goto err_reset_q_params;
 	}
 
@@ -332,5 +329,5 @@ void hinic3_try_to_enable_rss(struct net_device *netdev)
 
 err_reset_q_params:
 	clear_bit(HINIC3_RSS_ENABLE, &nic_dev->flags);
-	nic_dev->q_params.num_qps = nic_dev->max_qps;
+	nic_dev->q_params.num_qps = 1;
 }
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH net-next v03 1/4] hinic3: Solve an stall issue in hinic3_rx_poll()

In reply to Fan Gong
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.

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

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

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] The fix does not cover the case where the RX refill fails, so the RQ can still stall.

--

hinic3: Solve an stall issue in hinic3_rx_poll()

This patch makes hinic3_rx_poll() return the full budget in two cases:
recv_one_pkt() fails, or the LRO replenish threshold is reached. In both cases NAPI keeps polling instead of completing and re-enabling the interrupt while unprocessed CQEs or depleted WQEs remain.

Quoted 4 lines
drivers/net/ethernet/huawei/hinic3/hinic3_rx.c +0 -0
index 309ab59013797..f2262cdd66287 100644

[ ... ]

Quoted 6 lines
drivers/net/ethernet/huawei/hinic3/hinic3_rx.c +1 -1
@@ -581,12 +584,14 @@ int hinic3_rx_poll(struct hinic3_rxq *rxq, int budget)
 
 		rx_cqe->status = 0;
 
-		if (num_wqe >= nic_dev->lro_replenish_thld)
+		if (num_wqe >= nic_dev->lro_replenish_thld) {

drivers/net/ethernet/huawei/hinic3/hinic3_rx.c int hinic3_rx_poll(struct hinic3_rxq *rxq, int budget) · line 596

Quoted 10 lines
drivers/net/ethernet/huawei/hinic3/hinic3_rx.c +3 -1
+			poll_again = true;
 			break;
+		}
 	}
 
 	if (rxq->delta >= HINIC3_RX_BUFFER_WRITE)
 		hinic3_rx_fill_buffers(rxq);
 
-	return nr_pkts;
+	return poll_again ? budget : nr_pkts;

[Severity: High]
Can the RQ still stall when the refill itself fails? The return value of hinic3_rx_fill_buffers() is ignored here, and poll_again is not set when fewer WQEs than needed get posted.

hinic3_rx_fill_buffers() stops at the first page_pool allocation failure. If that happens on the very first WQE, it rings no doorbell at all:

drivers/net/ethernet/huawei/hinic3/hinic3_rx.c:hinic3_rx_fill_buffers() {
    ...
	for (i = 0; i < free_wqebbs; i++) {
		...
		err = rx_alloc_mapped_page(rxq->page_pool, rx_info,
					   rxq->buf_len);
		if (unlikely(err))
			break;
		...
	}

	if (likely(i)) {
		hinic3_write_db(rxq->rq, rxq->q_id & 3, DB_CFLAG_DP_RQ,
				rxq->next_to_update << HINIC3_NORMAL_RQ_WQE);
    ...
}

Under memory pressure, refills can fail across several polls while hinic3_fetch_rx_buffer() keeps adding sge_num to rxq->delta for each consumed packet. Large LRO frames, which use up to 16 WQEs each, drain the posted WQEs quickly.

On the last such poll the loop drains all CQEs and exits on !RXDONE. The refill fails again, and hinic3_rx_poll() returns nr_pkts < budget. Then hinic3_poll() does this:

drivers/net/ethernet/huawei/hinic3/hinic3_irq.c:hinic3_poll() {
    ...
	if (likely(napi_complete_done(napi, work_done))) {
		hinic3_net_dim(nic_dev, irq_cfg);
		hinic3_set_msix_state(nic_dev->hwdev, irq_cfg->msix_entry_idx,
				      HINIC3_MSIX_ENABLE);
    ...
}

As the commit message says, the chip drops packets when it has no WQEs, so no CQE is written and no RX interrupt is raised. qp_irq() is the only napi_schedule() caller in the driver. hinic3_rx_fill_buffers() is called only from hinic3_configure_rxqs() and hinic3_rx_poll(), and the periodic work does not refill RX buffers.

Wouldn't the queue then stay dead even after memory frees up, until the interface is reconfigured? That looks like the same "WQEs cannot be replenished in time ... the NAPI instance will not be polled again" failure, reached through the refill allocation failure path.

Would it make sense to also set poll_again when hinic3_rx_fill_buffers() posts fewer WQEs than requested? Several other drivers do this; i40e, for example, does "return failure ? budget : total_rx_packets". A deferred refill would be another option. The later patches in this series don't seem to touch hinic3_rx.c, so this case still looks open at the end of the series.

Quoted 1 line
drivers/net/ethernet/huawei/hinic3/hinic3_rx.c +0 -0
 }
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1794467919.git.gongfan1%40huawei.com
#4 lore raw

Re: [PATCH net-next v03 2/4] hinic3: Avoid concurrent updates on 32-bit systems.

In reply to Fan Gong
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…

Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message and Fixes: tag describe a bug this driver can never hit.
- [Low] The patch drops csum_errors from rx_errors in hinic3_get_stats64() (errors = rxq_stats->other_errors;).

--

hinic3: Avoid concurrent updates on 32-bit systems.

This commit reworks the u64_stats reader loops in hinic3_get_stats64(). Per-queue values are now assigned inside the fetch/retry loop and added into rtnl_link_stats64 outside it. The patch also drops csum_errors from rx_errors, removes the NULL checks on nic_dev->txqs and nic_dev->rxqs, and removes the zeroing of the local counters before each loop.

Quoted 7 lines

hinic3: Avoid concurrent updates on 32-bit systems.

Within the while loop of hinic3_get_stats64(), the counters between u64_stats_fetch_retry and u64_stats_fetch_begin are incremented by +=. This operation will cause repeated counting of the counters on a 32-bit system. Therefore, change += to + and the counters are incremented out side the wile loop.

[Severity: Low]
Can this driver be built on a 32-bit kernel? The Kconfig in drivers/net/ethernet/huawei/hinic3/ has:

	depends on PCI_MSI && 64BIT

When BITS_PER_LONG == 64, include/linux/u64_stats_sync.h defines:

static inline bool __u64_stats_fetch_retry(const struct u64_stats_sync *syncp,
unsigned int start)

{
	return false;
}

So the old loop body ran exactly once per queue. The += into locals that started at zero already gave correct totals in every configuration that can be built.

The subject says "Avoid concurrent updates". However, the patch only changes the reader side and does not change how updates are serialized.

This patch carries "Fixes: f47872bed40f" and will be picked up for stable. Would it be better described as a cleanup of the reader idiom, without the Fixes: tag?

Quoted 5 lines
drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c +0 -0
index da73811641a9d..d1fd91d97ccfc 100644
@@ -791,49 +791,35 @@ static void hinic3_get_stats64(struct net_device *netdev,

[ ... ]

drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c static void hinic3_get_stats64(struct net_device *netdev, · line 815

Quoted 12 lines
drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c +3 -5
 		rxq = &nic_dev->rxqs[i];
 		rxq_stats = &rxq->rxq_stats;
 		do {
 			start = u64_stats_fetch_begin(&rxq_stats->syncp);
-			bytes += rxq_stats->bytes;
-			packets += rxq_stats->packets;
-			errors += rxq_stats->csum_errors +
-				rxq_stats->other_errors;
-			dropped += rxq_stats->dropped;
+			bytes = rxq_stats->bytes;
+			packets = rxq_stats->packets;
+			errors = rxq_stats->other_errors;

[Severity: Low]
The commit message says:

csum_errors and other_errors are not the same things. csum_errors will go to csum_bad in netdev netlink qstats.

Where is csum_errors reported as csum_bad? I could not find a netdev queue stats implementation (stat_ops, get_queue_stats_rx or csum_bad) anywhere under drivers/net/ethernet/huawei/hinic3/. It is not in this patch, and it is not added later in the series.

After this change, the only remaining reference to csum_errors is the reset in hinic3_rxq_clean_stats():

	rxq_stats->csum_errors = 0;
	rxq_stats->other_errors = 0;

Neither counter is incremented anywhere today, so rx_errors does not change in practice. Once the datapath starts incrementing csum_errors, would those counts then be missing from every uAPI?

This rx_errors change is unrelated to the retry loop change. Could it be split into its own patch, or sent together with the qstats support it refers to?

[ ... ]

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1794467919.git.gongfan1%40huawei.com
#7 lore raw

Re: [PATCH net-next v03 4/4] hinic3: Ensure that the value of max_qps is not changed

In reply to Fan Gong
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.

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

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

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] The patch is presented as a bug fix (it carries `Fixes:
1f3838b84a63 ("hinic3: Add Rss function")`), but I could not find any…

--

hinic3: Ensure that the value of max_qps is not changed

This patch stops hinic3_try_to_enable_rss() from setting nic_dev->max_qps to 1 when RSS is unsupported or its setup fails. On those paths it now sets nic_dev->q_params.num_qps to 1 directly. It also changes the check on the function's queue count from "<= 1" to "== 1".

Quoted 19 lines
drivers/net/ethernet/huawei/hinic3/hinic3_rss.c +2 -4
index 25db74d8c7ddb..75dc0c044071c 100644
@@ -307,15 +307,13 @@ void hinic3_try_to_enable_rss(struct net_device *netdev)
 	int err;
 
 	nic_dev->max_qps = hinic3_func_max_qnum(hwdev);
-	if (nic_dev->max_qps <= 1 ||
+	if (nic_dev->max_qps == 1 ||
 	    !hinic3_test_support(nic_dev, HINIC3_NIC_F_RSS))
 		goto err_reset_q_params;
 
 	err = alloc_rss_resource(netdev);
-	if (err) {
-		nic_dev->max_qps = 1;
+	if (err)
 		goto err_reset_q_params;
-	}

[ ... ]

drivers/net/ethernet/huawei/hinic3/hinic3_rss.c void hinic3_try_to_enable_rss(struct net_device *netdev) · line 333

Quoted 7 lines
drivers/net/ethernet/huawei/hinic3/hinic3_rss.c +1 -1
@@ -332,5 +329,5 @@ void hinic3_try_to_enable_rss(struct net_device *netdev)
 
 err_reset_q_params:
 	clear_bit(HINIC3_RSS_ENABLE, &nic_dev->flags);
-	nic_dev->q_params.num_qps = nic_dev->max_qps;
+	nic_dev->q_params.num_qps = 1;
 }

[Severity: Medium]
Which bug does this fix? The patch has a Fixes: tag for 1f3838b84a63 ("hinic3: Add Rss function"), but I couldn't find a reachable problem in the old fallback.

The only caller of hinic3_try_to_enable_rss() is hinic3_sw_init(). Every allocation sized from nic_dev->max_qps happens after that call, so the value is already final when it is used:

hinic3_sw_init()
hinic3_try_to_enable_rss() <- max_qps settled here
hinic3_alloc_txrxqs()

    hinic3_alloc_txqs()               <- num_txqs = nic_dev->max_qps
    hinic3_alloc_rxqs()               <- num_rxqs = nic_dev->max_qps
    hinic3_init_intr_coalesce()

ndo_open
hinic3_setup_num_qps() <- qps_msix_entries sized by max_qps

With the old code, an RSS failure gave a consistent single-queue setup:
max_qps = 1, one txq and one rxq, one coalesce entry, one msix entry and num_qps = 1.

The commit message says:

"However, the value of nic_dev->q_params.num_qps can be dynamically changed."

Does that hold at this commit? hinic3_config_num_qps() already forces a single queue when RSS is off:

	if (!test_bit(HINIC3_RSS_ENABLE, &nic_dev->flags))
		q_params->num_qps = 1;

The driver also has no ethtool set_channels or set_rxfh callback, so nothing can turn RSS on or raise the queue count later.

The commit message also says:

"nic_dev->max_qps is used to allocate hardware resources. Therefore, it is assigned the value 1 only when its value is abnormal."

The diff removes both "nic_dev->max_qps = 1" assignments and adds none, so after this patch nothing ever sets max_qps to 1.

On the hardware side, the limit is nic_io->max_qps, which hinic3_init_nic_io() sets separately and this function never changed. nic_dev->max_qps only sizes software arrays. alloc_etherdev_mq() in hinic3_nic_probe() uses its own local max_qps.

The commit message also doesn't mention the "<= 1" to "== 1" change. It looks harmless, because max_sqs is computed as min(nic_max_sq_id + 1, HINIC3_CFG_MAX_QP) and is always at least 1.

As far as I can tell, the only change in behaviour is on the RSS failure path. There, txqs, rxqs, intr_coalesce and qps_msix_entries are now sized for the full hardware maximum while the device still runs on one queue.

Is this meant as a design change rather than a fix? If so, could the commit message say so, and could the Fixes: tag be dropped so this doesn't get backported to stable?

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1794467919.git.gongfan1%40huawei.com