Skip to contentSkip to conversation

bug fixes for the hibmcge ethernet driver

PATCH Applied Jijie Shao 2 participants 5 messages Oct 25, 2025 – Oct 29, 2025

Subsystems (4)
lore
Share & tools
lore

Jijie Shao

author maintainer
#0 lore raw

v2 cover bug fixes for the hibmcge ethernet driver

This patch set is intended to fix several issues for hibmcge driver:
1. Patch1 fixes the issue where buf avl irq is disabled after irq_handle.
2. Patch2 eliminates the error logs in scenarios without phy.
3. Patch3 fixes the issue where the network port becomes unusable after a PCIe RAS event.

---
v1 -> v2:
- add more details in commit log for patch1 and patch3.
v1: https://lore.kernel.org/all/[email protected]/
---

Jijie Shao (3):
net: hibmcge: fix rx buf avl irq is not re-enabled in irq_handle issue
net: hibmcge: remove unnecessary check for np_link_fail in scenarios
without phy.
net: hibmcge: fix the inappropriate netif_device_detach()

 drivers/net/ethernet/hisilicon/hibmcge/hbg_common.h |  1 +
 drivers/net/ethernet/hisilicon/hibmcge/hbg_err.c    | 10 ++++++----
 drivers/net/ethernet/hisilicon/hibmcge/hbg_hw.c     |  3 +++
 drivers/net/ethernet/hisilicon/hibmcge/hbg_irq.c    |  1 +
 drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.c   |  1 -
 5 files changed, 11 insertions(+), 5 deletions(-)
Signature · 1 line
2.33.0
author maintainer
#1 lore raw

PATCH v2 1/3 net: hibmcge: fix rx buf avl irq is not re-enabled in irq_handle issue

irq initialized with the macro HBG_ERR_IRQ_I will automatically be re-enabled, whereas those initialized with the macro HBG_IRQ_I will not be re-enabled.

Since the rx buf avl irq is initialized using the macro HBG_IRQ_I, it needs to be actively re-enabled;
otherwise priv->stats.rx_fifo_less_empty_thrsld_cnt cannot be correctly incremented.

Fixes fd394a334b1c ("net: hibmcge: Add support for abnormal irq handling feature")
---
 drivers/net/ethernet/hisilicon/hibmcge/hbg_irq.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/hisilicon/hibmcge/hbg_irq.c +1 -0
index 8af0bc4cca21..ae4cb35186d8 100644
@@ -32,6 +32,7 @@ static void hbg_irq_handle_rx_buf_val(struct hbg_priv *priv,
 				      const struct hbg_irq_info *irq_info)
 {
 	priv->stats.rx_fifo_less_empty_thrsld_cnt++;
+	hbg_hw_irq_enable(priv, irq_info->mask, true);
 }
 
 #define HBG_IRQ_I(name, handle) \
Signature · 1 line
2.33.0
author maintainer
#2 lore raw

PATCH v2 2/3 net: hibmcge: remove unnecessary check for np_link_fail in scenarios without phy.

In reply to Jijie Shao

hibmcge driver uses fixed_phy to configure scenarios without PHY, where the driver is always in a linked state. However, there might be no link in hardware, so the np_link error is detected in hbg_hw_adjust_link(), which can cause abnormal logs.

Therefore, in scenarios without a PHY, the driver no longer checks the np_link status.

Fixes 1d7cd7a9c69c ("net: hibmcge: support scenario without PHY")
---
 drivers/net/ethernet/hisilicon/hibmcge/hbg_common.h | 1 +
 drivers/net/ethernet/hisilicon/hibmcge/hbg_hw.c     | 3 +++
 drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.c   | 1 -
 3 files changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hibmcge/hbg_common.h +1 -0
index ea09a09c451b..2097e4c2b3d7 100644
@@ -17,6 +17,7 @@
 #define HBG_PCU_CACHE_LINE_SIZE		32
 #define HBG_TX_TIMEOUT_BUF_LEN		1024
 #define HBG_RX_DESCR			0x01
+#define HBG_NO_PHY			0xFF
 
 #define HBG_PACKET_HEAD_SIZE	((HBG_RX_SKIP1 + HBG_RX_SKIP2 + \
 				  HBG_RX_DESCR) * HBG_PCU_CACHE_LINE_SIZE)
drivers/net/ethernet/hisilicon/hibmcge/hbg_hw.c +3 -0
index d0aa0661ecd4..d6e8ce8e351a 100644
@@ -244,6 +244,9 @@ void hbg_hw_adjust_link(struct hbg_priv *priv, u32 speed, u32 duplex)
 
 	hbg_hw_mac_enable(priv, HBG_STATUS_ENABLE);
 
+	if (priv->mac.phy_addr == HBG_NO_PHY)
+		return;
+
 	/* wait MAC link up */
 	ret = readl_poll_timeout(priv->io_base + HBG_REG_AN_NEG_STATE_ADDR,
 				 link_status,
drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.c +0 -1
index 37791de47f6f..b6f0a2780ea8 100644
@@ -20,7 +20,6 @@
 #define HBG_MDIO_OP_INTERVAL_US		(5 * 1000)
 
 #define HBG_NP_LINK_FAIL_RETRY_TIMES	5
-#define HBG_NO_PHY			0xFF
 
 static void hbg_mdio_set_command(struct hbg_mac *mac, u32 cmd)
 {
Signature · 1 line
2.33.0
author maintainer
#3 lore raw

PATCH v2 3/3 net: hibmcge: fix the inappropriate netif_device_detach()

In reply to Jijie Shao

current, driver will call netif_device_detach() in pci_error_handlers.error_detected() and do reset in pci_error_handlers.slot_reset().
However, if pci_error_handlers.slot_reset() is not called after pci_error_handlers.error_detected(), driver will be detached and unable to recover.

drivers/pci/pcie/err.c/report_error_detected() says:
If any device in the subtree does not have an error_detected callback, PCI_ERS_RESULT_NO_AER_DRIVER prevents subsequent error callbacks of any device in the subtree, and will exit in the disconnected error state.

Therefore, when the hibmcge device and other devices that do not support the error_detected callback are under the same subtree, hibmcge will be unable to do slot_reset even for non-fatal errors.

This path move netif_device_detach() from error_detected() to slot_reset(), ensuring that detach and reset are always executed together.

Fixes fd394a334b1c ("net: hibmcge: Add support for abnormal irq handling feature")
---
 drivers/net/ethernet/hisilicon/hibmcge/hbg_err.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/ethernet/hisilicon/hibmcge/hbg_err.c +6 -4
index 83cf75bf7a17..e11495b7ee98 100644
@@ -136,12 +136,11 @@ static pci_ers_result_t hbg_pci_err_detected(struct pci_dev *pdev,
 {
 	struct net_device *netdev = pci_get_drvdata(pdev);
 
-	netif_device_detach(netdev);
-
-	if (state == pci_channel_io_perm_failure)
+	if (state == pci_channel_io_perm_failure) {
+		netif_device_detach(netdev);
 		return PCI_ERS_RESULT_DISCONNECT;
+	}
 
-	pci_disable_device(pdev);
 	return PCI_ERS_RESULT_NEED_RESET;
 }
 
@@ -150,6 +149,9 @@ static pci_ers_result_t hbg_pci_err_slot_reset(struct pci_dev *pdev)
 	struct net_device *netdev = pci_get_drvdata(pdev);
 	struct hbg_priv *priv = netdev_priv(netdev);
 
+	netif_device_detach(netdev);
+	pci_disable_device(pdev);
+
 	if (pci_enable_device(pdev)) {
 		dev_err(&pdev->dev,
 			"failed to re-enable PCI device after reset\n");
Signature · 1 line
2.33.0
#4 lore raw
In reply to Jijie Shao
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Sat, 25 Oct 2025 09:46:39 +0800 you wrote:

This patch set is intended to fix several issues for hibmcge driver:
1. Patch1 fixes the issue where buf avl irq is disabled after irq_handle.
2. Patch2 eliminates the error logs in scenarios without phy.
3. Patch3 fixes the issue where the network port becomes unusable after a PCIe RAS event.

[...]

Here is the summary with links:
- [V2,net,1/3] net: hibmcge: fix rx buf avl irq is not re-enabled in irq_handle issue

    https://git.kernel.org/netdev/net/c/12d2303db892
  - [V2,net,2/3] net: hibmcge: remove unnecessary check for np_link_fail in scenarios without phy.
    https://git.kernel.org/netdev/net/c/71eb8d1e0756
  - [V2,net,3/3] net: hibmcge: fix the inappropriate netif_device_detach()
    https://git.kernel.org/netdev/net/c/7e2958aee59c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html