[PATCH net-next v04 1/4] hinic3: Fix the RX stalls in hinic3_rx_poll()

From: Fan Gong

Date: Tue Nov 17 2026 - 07:09:24 EST


hinic3_rx_poll() can leave the loop with a completed CQE still sitting at
the head of the ring, or with no WQE left to receive into, and still
return nr_pkts, which is below budget. hinic3_poll() then calls
napi_complete_done() and re-enables the MSI-X interrupt, which is edge
triggered, so nothing re-arms the queue if no further packet arrives.

Three exits behave this way:

- a large LRO packet consumed enough WQEs to cross lro_replenish_thld;
- napi_alloc_skb() failed in recv_one_pkt();
- hinic3_rx_fill_buffers() posted fewer WQEs than rxq->delta - 1 because
page_pool_dev_alloc_frag() failed.

The first two leave a completed CQE unprocessed. The third leaves the
device without a WQE to receive into: it then drops every packet and,
because no CQE is written, raises no interrupt either, so the queue stays
dead until the interface is reset.

Return budget from all three paths so that hinic3_poll() skips
napi_complete_done() and NAPI runs again immediately.

When recv_one_pkt() fails no CQE is consumed and no state is advanced, so
the same CQE is simply retried on the next poll; this is the only way to
make progress, as the completed CQE cannot be dropped. Likewise
hinic3_rx_fill_buffers() keeps the WQEs it could not post accounted for in
rxq->delta, so the next poll retries the refill and the ring is complete
again as soon as a full refill succeeds. All three failures are transient
(memory pressure), which bounds the immediate repoll, and i40e, ice and
iavf return budget on a ring refill failure in the same way. A deferred
refill would need to be serialized against hinic3_rx_poll(), which
retries the same WQEs from rxq->delta, so the poll based retry is used
instead.

Fixes: 17fcb3dc12bb ("hinic3: module initialization and tx/rx logic")
Co-developed-by: Wu Di <wudi234@xxxxxxxxxx>
Signed-off-by: Wu Di <wudi234@xxxxxxxxxx>
Co-developed-by: Teng Peisen <tengpeisen@xxxxxxxxxx>
Signed-off-by: Teng Peisen <tengpeisen@xxxxxxxxxx>
Signed-off-by: Fan Gong <gongfan1@xxxxxxxxxx>
---
.../net/ethernet/huawei/hinic3/hinic3_rx.c | 22 ++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c b/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c
index 309ab5901379..9a02a7bf6c50 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c
@@ -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,21 @@ 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);
+ if (rxq->delta >= HINIC3_RX_BUFFER_WRITE) {
+ u32 free_wqebbs = rxq->delta - 1;
+
+ /* Refill stops at the first failed allocation, so a short
+ * refill may leave the ring without any WQE posted.
+ */
+ if (hinic3_rx_fill_buffers(rxq) != free_wqebbs)
+ poll_again = true;
+ }

- return nr_pkts;
+ return poll_again ? budget : nr_pkts;
}
--
2.43.0