* [PATCH] net: phy: marvell: Fix bits clear bug
@ 2019-11-02 14:15 Hansen Yang
2019-11-02 17:00 ` Heiner Kallweit
0 siblings, 1 reply; 2+ messages in thread
From: Hansen Yang @ 2019-11-02 14:15 UTC (permalink / raw)
To: andrew
Cc: f.fainelli, hkallweit1, davem, netdev, linux-kernel, 496645649,
Hansen Yang
The correct way to clear bits before setting some of them is using
"& = ~BIT_MASK".
The wrong operation "& = BIT_MASK" will clear other bits.
m88e1116r_config_init() calls marvell_set_polarity() to config
MDI crossover mode by modifying reg MII_M1011_PHY_SCR, then it
calls marvell_set_downshift() to config downshift by modifying
the same reg. According to the bug, marvell_set_downshift()
clears other bits and set MDI Crossover Mode to Manual MDI
configuration. If we connect two devices both using this driver
with a wrong Ethernet cable, they can't automatically adjust
their crossover mode. Finally they fail to link.
Signed-off-by: Hansen Yang <yanghansen1@163.com>
---
drivers/net/phy/marvell.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index a7796134e3be..6ab8fe339043 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -282,7 +282,7 @@ static int marvell_set_downshift(struct phy_device *phydev, bool enable,
if (reg < 0)
return reg;
- reg &= MII_M1011_PHY_SRC_DOWNSHIFT_MASK;
+ reg &= ~MII_M1011_PHY_SRC_DOWNSHIFT_MASK;
reg |= ((retries - 1) << MII_M1011_PHY_SCR_DOWNSHIFT_SHIFT);
if (enable)
reg |= MII_M1011_PHY_SCR_DOWNSHIFT_EN;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: phy: marvell: Fix bits clear bug
2019-11-02 14:15 [PATCH] net: phy: marvell: Fix bits clear bug Hansen Yang
@ 2019-11-02 17:00 ` Heiner Kallweit
0 siblings, 0 replies; 2+ messages in thread
From: Heiner Kallweit @ 2019-11-02 17:00 UTC (permalink / raw)
To: Hansen Yang, andrew; +Cc: f.fainelli, davem, netdev, linux-kernel, 496645649
On 02.11.2019 15:15, Hansen Yang wrote:
> The correct way to clear bits before setting some of them is using
> "& = ~BIT_MASK".
> The wrong operation "& = BIT_MASK" will clear other bits.
>
> m88e1116r_config_init() calls marvell_set_polarity() to config
> MDI crossover mode by modifying reg MII_M1011_PHY_SCR, then it
> calls marvell_set_downshift() to config downshift by modifying
> the same reg. According to the bug, marvell_set_downshift()
> clears other bits and set MDI Crossover Mode to Manual MDI
> configuration. If we connect two devices both using this driver
> with a wrong Ethernet cable, they can't automatically adjust
> their crossover mode. Finally they fail to link.
>
Function marvell_set_downshift() doesn't exist any longer.
Note that all new developments should be against net-next.
If you want to submit this as a fix for stable:
- annotate patch as [PATCH net]
- add Fixes tag
- mention that fix applies up to 5.4 only
> Signed-off-by: Hansen Yang <yanghansen1@163.com>
> ---
> drivers/net/phy/marvell.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
> index a7796134e3be..6ab8fe339043 100644
> --- a/drivers/net/phy/marvell.c
> +++ b/drivers/net/phy/marvell.c
> @@ -282,7 +282,7 @@ static int marvell_set_downshift(struct phy_device *phydev, bool enable,
> if (reg < 0)
> return reg;
>
> - reg &= MII_M1011_PHY_SRC_DOWNSHIFT_MASK;
> + reg &= ~MII_M1011_PHY_SRC_DOWNSHIFT_MASK;
> reg |= ((retries - 1) << MII_M1011_PHY_SCR_DOWNSHIFT_SHIFT);
> if (enable)
> reg |= MII_M1011_PHY_SCR_DOWNSHIFT_EN;
>
Heiner
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-11-02 17:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-02 14:15 [PATCH] net: phy: marvell: Fix bits clear bug Hansen Yang
2019-11-02 17:00 ` Heiner Kallweit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).