diff options
| author | Paolo Abeni <pabeni@redhat.com> | 2026-08-11 16:02:04 +0200 |
|---|---|---|
| committer | Paolo Abeni <pabeni@redhat.com> | 2026-08-11 16:02:04 +0200 |
| commit | 31397cf1819210bd63fa3d2c7d8c24f7c8667d99 (patch) | |
| tree | cf9d69329f7f09767ad9e849010b08d3ed1fcc15 | |
| parent | b54074ffb813aa4b97585d97ae1ead69d96432b5 (diff) | |
| parent | f57b277e8b6f6e6d3bc082be6b67c6bec02d5cbd (diff) | |
| download | linux-31397cf1819210bd63fa3d2c7d8c24f7c8667d99.tar.gz linux-31397cf1819210bd63fa3d2c7d8c24f7c8667d99.zip | |
Merge branch 'net-hns3-some-cleanups-for-hns3-driver'
Jijie Shao says:
====================
net: hns3: some cleanups for hns3 driver
Patch 1 sets msg->desc to NULL after kfree to avoid leaving a
dangling pointer in a struct that is reused across loop iterations.
Patch 2 adds the missing const qualifier to the reg parameter of
hclge_log_error(), which is never modified within the function.
Patch 3 uses the txqueue parameter passed by the ndo_tx_timeout
callback directly, instead of iterating all tx queues to find the
timed out one.
====================
Link: https://patch.msgid.link/20260807095435.2959246-1-shaojijie@huawei.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
| -rw-r--r-- | drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 48 | ||||
| -rw-r--r-- | drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c | 3 |
2 files changed, 24 insertions, 27 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 6ecb32e28e79..47788be64be6 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2825,32 +2825,28 @@ static int hns3_nic_change_mtu(struct net_device *netdev, int new_mtu) return ret; } -static int hns3_get_timeout_queue(struct net_device *ndev) +static bool hns3_dump_timeout_queue(struct net_device *ndev, + unsigned int txqueue) { - unsigned int i; - - /* Find the stopped queue the same way the stack does */ - for (i = 0; i < ndev->num_tx_queues; i++) { - unsigned int timedout_ms; - struct netdev_queue *q; + unsigned int timedout_ms; + struct netdev_queue *q; - q = netdev_get_tx_queue(ndev, i); - timedout_ms = netif_xmit_timeout_ms(q); - if (timedout_ms) { + q = netdev_get_tx_queue(ndev, txqueue); + timedout_ms = netif_xmit_timeout_ms(q); + if (timedout_ms) { #ifdef CONFIG_BQL - struct dql *dql = &q->dql; + struct dql *dql = &q->dql; - netdev_info(ndev, "DQL info last_cnt: %u, queued: %u, adj_limit: %u, completed: %u\n", - dql->last_obj_cnt, dql->num_queued, - dql->adj_limit, dql->num_completed); + netdev_info(ndev, "DQL info last_cnt: %u, queued: %u, adj_limit: %u, completed: %u\n", + dql->last_obj_cnt, dql->num_queued, + dql->adj_limit, dql->num_completed); #endif - netdev_info(ndev, "queue state: 0x%lx, delta msecs: %u\n", - q->state, timedout_ms); - break; - } + netdev_info(ndev, "queue state: 0x%lx, delta msecs: %u\n", + q->state, timedout_ms); + return true; } - return i; + return false; } static void hns3_dump_queue_stats(struct net_device *ndev, @@ -2900,15 +2896,15 @@ static void hns3_dump_queue_reg(struct net_device *ndev, HNS3_RING_TX_RING_EBD_OFFSET_REG)); } -static bool hns3_get_tx_timeo_queue_info(struct net_device *ndev) +static bool hns3_get_tx_timeo_queue_info(struct net_device *ndev, + unsigned int txqueue) { struct hns3_nic_priv *priv = netdev_priv(ndev); struct hnae3_handle *h = hns3_get_handle(ndev); struct hns3_enet_ring *tx_ring; - u32 timeout_queue; - timeout_queue = hns3_get_timeout_queue(ndev); - if (timeout_queue >= ndev->num_tx_queues) { + if (txqueue >= h->kinfo.num_tqps || + !hns3_dump_timeout_queue(ndev, txqueue)) { netdev_info(ndev, "no netdev TX timeout queue found, timeout count: %llu\n", priv->tx_timeout_count); @@ -2917,8 +2913,8 @@ static bool hns3_get_tx_timeo_queue_info(struct net_device *ndev) priv->tx_timeout_count++; - tx_ring = &priv->ring[timeout_queue]; - hns3_dump_queue_stats(ndev, tx_ring, timeout_queue); + tx_ring = &priv->ring[txqueue]; + hns3_dump_queue_stats(ndev, tx_ring, txqueue); /* When mac received many pause frames continuous, it's unable to send * packets, which may cause tx timeout @@ -2941,7 +2937,7 @@ static void hns3_nic_net_timeout(struct net_device *ndev, unsigned int txqueue) struct hns3_nic_priv *priv = netdev_priv(ndev); struct hnae3_handle *h = priv->ae_handle; - if (!hns3_get_tx_timeo_queue_info(ndev)) + if (!hns3_get_tx_timeo_queue_info(ndev, txqueue)) return; /* request the reset, and let the hclge to determine diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c index dac051e798da..6093a60d257b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c @@ -1592,6 +1592,7 @@ hclge_query_reg_info(struct hclge_dev *hdev, } kfree(msg->desc); + msg->desc = NULL; } static void hclge_query_reg_info_of_ssu(struct hclge_dev *hdev) @@ -1761,7 +1762,7 @@ static const struct hclge_hw_type_id hclge_hw_type_id_st[] = { }, }; -static void hclge_log_error(struct device *dev, char *reg, +static void hclge_log_error(struct device *dev, const char *reg, const struct hclge_hw_error *err, u32 err_sts, unsigned long *reset_requests) { |
