diff mbox series

enetc: fix bitfields, we are clearing wrong bits

Message ID 20210321162500.GA26497@amd (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series enetc: fix bitfields, we are clearing wrong bits | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch warning CHECK: From:/Signed-off-by: email comments mismatch: 'From: Pavel Machek <pavel@denx.de>' != 'Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>'
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Pavel Machek March 21, 2021, 4:25 p.m. UTC
Bitfield manipulation in enetc_mac_config() looks wrong. Fix
it. Untested.

Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>

Comments

Vladimir Oltean March 21, 2021, 5:44 p.m. UTC | #1
On Sun, Mar 21, 2021 at 05:25:00PM +0100, Pavel Machek wrote:
> Bitfield manipulation in enetc_mac_config() looks wrong. Fix
> it. Untested.
> 
> Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
> 
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
> index 224fc37a6757..b85079493933 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
> @@ -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);
>  	}
> 
> -- 
> 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")
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>

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!
Vladimir Oltean March 21, 2021, 5:49 p.m. UTC | #2
On Sun, Mar 21, 2021 at 07:44:19PM +0200, Vladimir Oltean wrote:
> On Sun, Mar 21, 2021 at 05:25:00PM +0100, Pavel Machek wrote:
> > Bitfield manipulation in enetc_mac_config() looks wrong. Fix
> > it. Untested.
> > 
> > Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
> > 
> > diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
> > index 224fc37a6757..b85079493933 100644
> > --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
> > +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
> > @@ -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);
> >  	}
> > 
> > -- 
> > 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")
> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> 
> 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.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
index 224fc37a6757..b85079493933 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
@@ -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);
 	}