From nobody Mon Nov 08 11:06:58 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 113C61845479; Mon, 8 Nov 2021 11:06:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HnpGV6j7hz4XQN; Mon, 8 Nov 2021 11:06:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C5ADF10AA3; Mon, 8 Nov 2021 11:06:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A8B6wpu020761; Mon, 8 Nov 2021 11:06:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A8B6wFb020760; Mon, 8 Nov 2021 11:06:58 GMT (envelope-from git) Date: Mon, 8 Nov 2021 11:06:58 GMT Message-Id: <202111081106.1A8B6wFb020760@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Peter Grehan Subject: git: 561cd74b1704 - main - igc: Use hardware routine for PHY reset List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: grehan X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 561cd74b1704ab76a3286733fb43da53b6892ea4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by grehan: URL: https://cgit.FreeBSD.org/src/commit/?id=561cd74b1704ab76a3286733fb43da53b6892ea4 commit 561cd74b1704ab76a3286733fb43da53b6892ea4 Author: Peter Grehan AuthorDate: 2021-11-01 13:35:43 +0000 Commit: Peter Grehan CommitDate: 2021-11-08 13:33:10 +0000 igc: Use hardware routine for PHY reset Summary: The previously used software reset routine wasn't sufficient to reset the PHY if the bootloader hadn't left the device in an initialized state. This was seen with the onboard igc port on an 11th-gen Intel NUC. The software reset isn't used in the Linux driver so all related code has been removed. Tested on: Netgate 6100 onboard ports, a discrete PCIe I225-LM card, and an 11th-gen Intel NUC. Reported by: woodsb02 Tested by: woodsb02 (NUC) MFC after: 3 days Sponsored by: Rubicon Communications, LLC ("Netgate") Reviewed by: kbowling Differential Revision: https://reviews.freebsd.org/D32772 --- sys/dev/igc/igc_api.c | 15 --------------- sys/dev/igc/igc_api.h | 1 - sys/dev/igc/igc_hw.h | 1 - sys/dev/igc/igc_i225.c | 11 +++-------- sys/dev/igc/igc_phy.c | 37 ++----------------------------------- sys/dev/igc/igc_phy.h | 1 - 6 files changed, 5 insertions(+), 61 deletions(-) diff --git a/sys/dev/igc/igc_api.c b/sys/dev/igc/igc_api.c index cad116c2395d..6aafc9898df8 100644 --- a/sys/dev/igc/igc_api.c +++ b/sys/dev/igc/igc_api.c @@ -535,21 +535,6 @@ s32 igc_phy_hw_reset(struct igc_hw *hw) return IGC_SUCCESS; } -/** - * igc_phy_commit - Soft PHY reset - * @hw: pointer to the HW structure - * - * Performs a soft PHY reset on those that apply. This is a function pointer - * entry point called by drivers. - **/ -s32 igc_phy_commit(struct igc_hw *hw) -{ - if (hw->phy.ops.commit) - return hw->phy.ops.commit(hw); - - return IGC_SUCCESS; -} - /** * igc_set_d0_lplu_state - Sets low power link up state for D0 * @hw: pointer to the HW structure diff --git a/sys/dev/igc/igc_api.h b/sys/dev/igc/igc_api.h index a0fc9ff21166..f9064b540c7c 100644 --- a/sys/dev/igc/igc_api.h +++ b/sys/dev/igc/igc_api.h @@ -42,7 +42,6 @@ s32 igc_get_phy_info(struct igc_hw *hw); void igc_release_phy(struct igc_hw *hw); s32 igc_acquire_phy(struct igc_hw *hw); s32 igc_phy_hw_reset(struct igc_hw *hw); -s32 igc_phy_commit(struct igc_hw *hw); void igc_power_up_phy(struct igc_hw *hw); void igc_power_down_phy(struct igc_hw *hw); s32 igc_read_mac_addr(struct igc_hw *hw); diff --git a/sys/dev/igc/igc_hw.h b/sys/dev/igc/igc_hw.h index a07d2894f97a..a8323a8578a9 100644 --- a/sys/dev/igc/igc_hw.h +++ b/sys/dev/igc/igc_hw.h @@ -382,7 +382,6 @@ struct igc_phy_operations { s32 (*init_params)(struct igc_hw *); s32 (*acquire)(struct igc_hw *); s32 (*check_reset_block)(struct igc_hw *); - s32 (*commit)(struct igc_hw *); s32 (*force_speed_duplex)(struct igc_hw *); s32 (*get_info)(struct igc_hw *); s32 (*set_page)(struct igc_hw *, u16); diff --git a/sys/dev/igc/igc_i225.c b/sys/dev/igc/igc_i225.c index 75c4b5125a97..4c50daa16b79 100644 --- a/sys/dev/igc/igc_i225.c +++ b/sys/dev/igc/igc_i225.c @@ -136,7 +136,6 @@ static s32 igc_init_phy_params_i225(struct igc_hw *hw) { struct igc_phy_info *phy = &hw->phy; s32 ret_val = IGC_SUCCESS; - u32 ctrl_ext; DEBUGFUNC("igc_init_phy_params_i225"); @@ -155,10 +154,10 @@ static s32 igc_init_phy_params_i225(struct igc_hw *hw) phy->ops.acquire = igc_acquire_phy_base; phy->ops.check_reset_block = igc_check_reset_block_generic; - phy->ops.commit = igc_phy_sw_reset_generic; phy->ops.release = igc_release_phy_base; - - ctrl_ext = IGC_READ_REG(hw, IGC_CTRL_EXT); + phy->ops.reset = igc_phy_hw_reset_generic; + phy->ops.read_reg = igc_read_phy_reg_gpy; + phy->ops.write_reg = igc_write_phy_reg_gpy; /* Make sure the PHY is in a good state. Several people have reported * firmware leaving the PHY's page select register set to something @@ -169,10 +168,6 @@ static s32 igc_init_phy_params_i225(struct igc_hw *hw) if (ret_val) goto out; - IGC_WRITE_REG(hw, IGC_CTRL_EXT, ctrl_ext); - phy->ops.read_reg = igc_read_phy_reg_gpy; - phy->ops.write_reg = igc_write_phy_reg_gpy; - ret_val = igc_get_phy_id(hw); /* Verify phy id and set remaining function pointers */ switch (phy->id) { diff --git a/sys/dev/igc/igc_phy.c b/sys/dev/igc/igc_phy.c index a1d71ab15829..a6823ddf7bac 100644 --- a/sys/dev/igc/igc_phy.c +++ b/sys/dev/igc/igc_phy.c @@ -26,7 +26,6 @@ void igc_init_phy_ops_generic(struct igc_hw *hw) phy->ops.init_params = igc_null_ops_generic; phy->ops.acquire = igc_null_ops_generic; phy->ops.check_reset_block = igc_null_ops_generic; - phy->ops.commit = igc_null_ops_generic; phy->ops.force_speed_duplex = igc_null_ops_generic; phy->ops.get_info = igc_null_ops_generic; phy->ops.set_page = igc_null_set_page; @@ -147,7 +146,7 @@ s32 igc_get_phy_id(struct igc_hw *hw) return ret_val; phy->id = (u32)(phy_id << 16); - usec_delay(20); + usec_delay(200); ret_val = phy->ops.read_reg(hw, PHY_ID2, &phy_id); if (ret_val) return ret_val; @@ -155,7 +154,6 @@ s32 igc_get_phy_id(struct igc_hw *hw) phy->id |= (u32)(phy_id & PHY_REVISION_MASK); phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK); - return IGC_SUCCESS; } @@ -314,7 +312,7 @@ static s32 igc_phy_setup_autoneg(struct igc_hw *hw) if ((phy->autoneg_mask & ADVERTISE_2500_FULL) && hw->phy.id == I225_I_PHY_ID) { - /* Read the MULTI GBT AN Control Register - reg 7.32 */ + /* Read the MULTI GBT AN Control Register - reg 7.32 */ ret_val = phy->ops.read_reg(hw, (STANDARD_AN_REG_MASK << MMD_DEVADDR_SHIFT) | ANEG_MULTIGBT_AN_CTRL, @@ -847,37 +845,6 @@ s32 igc_phy_has_link_generic(struct igc_hw *hw, u32 iterations, return ret_val; } -/** - * igc_phy_sw_reset_generic - PHY software reset - * @hw: pointer to the HW structure - * - * Does a software reset of the PHY by reading the PHY control register and - * setting/write the control register reset bit to the PHY. - **/ -s32 igc_phy_sw_reset_generic(struct igc_hw *hw) -{ - s32 ret_val; - u16 phy_ctrl; - - DEBUGFUNC("igc_phy_sw_reset_generic"); - - if (!hw->phy.ops.read_reg) - return IGC_SUCCESS; - - ret_val = hw->phy.ops.read_reg(hw, PHY_CONTROL, &phy_ctrl); - if (ret_val) - return ret_val; - - phy_ctrl |= MII_CR_RESET; - ret_val = hw->phy.ops.write_reg(hw, PHY_CONTROL, phy_ctrl); - if (ret_val) - return ret_val; - - usec_delay(1); - - return ret_val; -} - /** * igc_phy_hw_reset_generic - PHY hardware reset * @hw: pointer to the HW structure diff --git a/sys/dev/igc/igc_phy.h b/sys/dev/igc/igc_phy.h index 61cc46cdc583..36fa0677c3e6 100644 --- a/sys/dev/igc/igc_phy.h +++ b/sys/dev/igc/igc_phy.h @@ -18,7 +18,6 @@ s32 igc_null_set_page(struct igc_hw *hw, u16 data); s32 igc_check_downshift_generic(struct igc_hw *hw); s32 igc_check_reset_block_generic(struct igc_hw *hw); s32 igc_get_phy_id(struct igc_hw *hw); -s32 igc_phy_sw_reset_generic(struct igc_hw *hw); void igc_phy_force_speed_duplex_setup(struct igc_hw *hw, u16 *phy_ctrl); s32 igc_phy_hw_reset_generic(struct igc_hw *hw); s32 igc_phy_reset_dsp_generic(struct igc_hw *hw);