[PATCH V2 net 0/4] net: hns3: fix configuration deadlocks and refactor link setup

From: Jijie Shao

Date: Wed Jun 24 2026 - 10:14:18 EST


This patch series addresses a sequence of link configuration deadlocks
and parameter contamination issues in the hns3 network driver, which
typically occur during hardware resets or driver initialization under
specific user-configured scenarios.

The bugs root from asynchronous discrepancies between the MAC state
machine and cached user requests during sudden hardware resets, leading
to invalid parameter combos or frozen registers.

Changes in V2:
- Squashed the former patch 5 ("fix init failure caused by lane_num
contamination") into patch 2, introducing the req_lane_num separation
directly where the helper is created. This avoids a bisect-time
regression where an intermediate commit could fail probe with an
inconsistent (speed, lane_num) pair.
- Added a NULL phydev guard in patch 1 (hclge_set_phy_link_ksettings)
to prevent a kernel panic when firmware reports PHY_INEXISTENT on a
copper port. The previous netdev->phydev check was lost during the
ethtool refactor.
- In patch 1, for copper ports where neither IMP firmware nor a kernel
PHY is available (e.g. PHY_INEXISTENT), hclge_set_phy_link_ksettings()
now returns -ENODEV, and hns3_set_link_ksettings() catches this error
to proceed to the existing MAC-level path (check_ksettings_param
-> cfg_mac_speed_dup_h), preserving compatibility with PHY-less copper
deployments.
- Preserved the 1000BASE-T forced-mode rejection in the kernel PHY
path inside the new hclge_set_phy_link_ksettings() wrapper, closing
a gap identified in community review.
- Fixed a link-loss regression in patch 4 where fiber ports in forced
mode would be configured with the static default_speed instead of the
firmware-probed SFP speed, by synchronizing req_speed from mac.speed
when req_autoneg is overridden to AUTONEG_DISABLE.
- Rewrote the commit message of patch 2 to accurately describe the
init/reset path asymmetry and the req_lane_num rationale.

The series is organized as follows:
- Patch 1 refactors the ethtool link settings entry path to unify copper
port handling (both native kernel PHY_LIB and firmware-controlled PHY)
and ensures req_xxx configurations are uniformly saved across all modes.
For PHY_INEXISTENT copper ports, -ENODEV is returned to allow fallthrough
to MAC-level configuration.
- Patch 2 refactors the MAC initialization by extracting the autoneg and
speed configuration logic out of hclge_mac_init() into a dedicated
helper function, and introduces req_lane_num to isolate the user-
requested lane count from firmware-overwritten mac.lane_num.
- Patch 3 fixes a permanent link-down deadlock after a reset by ensuring
that the driver caches and uses the user's intended autoneg/speed
settings (req_***) rather than unsynchronized runtime states or
SPEED_UNKNOWN tokens.
- Patch 4 fixes a link loss issue on optical ports during initialization
by differentiating autoneg default values between copper and fiber
media types, and synchronizing req_speed with the firmware-probed
SFP speed when forced mode is detected.

Shuaisong Yang (4):
net: hns3: unify copper port ksettings configuration path
net: hns3: refactor MAC autoneg and speed configuration
net: hns3: fix permanent link down deadlock after reset
net: hns3: differentiate autoneg default values between copper and
fiber

.../ethernet/hisilicon/hns3/hns3_ethtool.c | 31 +++--
.../hisilicon/hns3/hns3pf/hclge_main.c | 108 ++++++++++++++----
.../hisilicon/hns3/hns3pf/hclge_main.h | 1 +
3 files changed, 102 insertions(+), 38 deletions(-)


base-commit: d87363b0edfc7504ff2b144fe4cdd8154f90f42e
--
2.33.0