Skip to contentSkip to conversation

enetc: fix bitfields, we are clearing wrong bits

PATCH Pavel Machek 2 participants 3 messages Mar 21, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Bitfield manipulation in enetc_mac_config() looks wrong. Fix it. Untested.

drivers/net/ethernet/freescale/enetc/enetc_pf.c +1 -1
index 224fc37a6757..b85079493933 100644
@@ -505,7 +505,7 @@ static void enetc_mac_config(struct enetc_hw *hw, phy_interface_t phy_mode)
 	if (phy_interface_mode_is_rgmii(phy_mode)) {
 		val = enetc_port_rd(hw, ENETC_PM0_IF_MODE);
 		val &= ~ENETC_PM0_IFM_EN_AUTO;
-		val &= ENETC_PM0_IFM_IFMODE_MASK;
+		val &= ~ENETC_PM0_IFM_IFMODE_MASK;
 		val |= ENETC_PM0_IFM_IFMODE_GMII | ENETC_PM0_IFM_RG;
 		enetc_port_wr(hw, ENETC_PM0_IF_MODE, val);
 	}
Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Reviewed-by
#1 lore raw
Quoted 22 lines · Pavel Machek

Bitfield manipulation in enetc_mac_config() looks wrong. Fix it. Untested.

drivers/net/ethernet/freescale/enetc/enetc_pf.c +1 -1
index 224fc37a6757..b85079493933 100644
@@ -505,7 +505,7 @@ static void enetc_mac_config(struct enetc_hw *hw, phy_interface_t phy_mode)
 	if (phy_interface_mode_is_rgmii(phy_mode)) {
 		val = enetc_port_rd(hw, ENETC_PM0_IF_MODE);
 		val &= ~ENETC_PM0_IFM_EN_AUTO;
-		val &= ENETC_PM0_IFM_IFMODE_MASK;
+		val &= ~ENETC_PM0_IFM_IFMODE_MASK;
 		val |= ENETC_PM0_IFM_IFMODE_GMII | ENETC_PM0_IFM_RG;
 		enetc_port_wr(hw, ENETC_PM0_IF_MODE, val);
 	}
Signature · 3 lines
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Fixes c76a97218dcb ("net: enetc: force the RGMII speed and duplex instead of operating in inband mode")

Note that for normal operation, the bug was inconsequential, due to the fact that we write the IF_MODE register in two stages, first in .phylink_mac_config (which incorrectly cleared out a bunch of stuff), then we update the speed and duplex to the correct values in .phylink_mac_link_up. Maybe loopback mode was broken.

Thanks!

#2 lore raw
Quoted 27 lines · Vladimir Oltean
Quoted 22 lines · Pavel Machek

Bitfield manipulation in enetc_mac_config() looks wrong. Fix it. Untested.

drivers/net/ethernet/freescale/enetc/enetc_pf.c +1 -1
index 224fc37a6757..b85079493933 100644
@@ -505,7 +505,7 @@ static void enetc_mac_config(struct enetc_hw *hw, phy_interface_t phy_mode)
 	if (phy_interface_mode_is_rgmii(phy_mode)) {
 		val = enetc_port_rd(hw, ENETC_PM0_IF_MODE);
 		val &= ~ENETC_PM0_IFM_EN_AUTO;
-		val &= ENETC_PM0_IFM_IFMODE_MASK;
+		val &= ~ENETC_PM0_IFM_IFMODE_MASK;
 		val |= ENETC_PM0_IFM_IFMODE_GMII | ENETC_PM0_IFM_RG;
 		enetc_port_wr(hw, ENETC_PM0_IF_MODE, val);
 	}
Signature · 3 lines
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Fixes c76a97218dcb ("net: enetc: force the RGMII speed and duplex instead of operating in inband mode")
Quoted 7 lines

Note that for normal operation, the bug was inconsequential, due to the fact that we write the IF_MODE register in two stages, first in .phylink_mac_config (which incorrectly cleared out a bunch of stuff), then we update the speed and duplex to the correct values in .phylink_mac_link_up. Maybe loopback mode was broken.

Thanks!

I forgot to mention, target tree should be "net" and patch should be queued up for stable.