diff mbox series

net: phy: Fix marvell_set_downshift() from clobbering MSCR register

Message ID 20200311224138.1b98ca46f948789a0eec7ecf@gmail.com
State Not Applicable
Delegated to: David Miller
Headers show
Series net: phy: Fix marvell_set_downshift() from clobbering MSCR register | expand

Commit Message

Darell Tan March 11, 2020, 2:41 p.m. UTC
Fix marvell_set_downshift() from clobbering MSCR register.

A typo in marvell_set_downshift() clobbers the MSCR register. This
register also shares settings with the auto MDI-X detection, set by
marvell_set_polarity(). In the 1116R init, downshift is set after
polarity, causing the polarity settings to be clobbered.

This bug is present on the 5.4 series and was introduced in commit
6ef05eb73c8f ("net: phy: marvell: Refactor setting downshift into a
helper"). This patch need not be forward-ported to 5.5 because the
functions were rewritten.

Signed-off-by: Darell Tan <darell.tan@gmail.com>
---
 drivers/net/phy/marvell.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Lunn March 11, 2020, 3:21 p.m. UTC | #1
On Wed, Mar 11, 2020 at 10:41:38PM +0800, Darell Tan wrote:
> Fix marvell_set_downshift() from clobbering MSCR register.
> 
> A typo in marvell_set_downshift() clobbers the MSCR register. This
> register also shares settings with the auto MDI-X detection, set by
> marvell_set_polarity(). In the 1116R init, downshift is set after
> polarity, causing the polarity settings to be clobbered.
> 
> This bug is present on the 5.4 series and was introduced in commit
> 6ef05eb73c8f ("net: phy: marvell: Refactor setting downshift into a
> helper"). This patch need not be forward-ported to 5.5 because the
> functions were rewritten.
> 
> Signed-off-by: Darell Tan <darell.tan@gmail.com>

Hi Darell

You should put net into the subject line: [patch net] ...  to indicate
this is a fix. But you have a bit of a special case here. Also, you
should indicate what it fixes:

Fixes: 6ef05eb73c8f ("net: phy: marvell: Refactor setting downshift into a helper")

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
David Miller March 12, 2020, 6:45 a.m. UTC | #2
From: Darell Tan <darell.tan@gmail.com>
Date: Wed, 11 Mar 2020 22:41:38 +0800

> Fix marvell_set_downshift() from clobbering MSCR register.
> 
> A typo in marvell_set_downshift() clobbers the MSCR register. This
> register also shares settings with the auto MDI-X detection, set by
> marvell_set_polarity(). In the 1116R init, downshift is set after
> polarity, causing the polarity settings to be clobbered.
> 
> This bug is present on the 5.4 series and was introduced in commit
> 6ef05eb73c8f ("net: phy: marvell: Refactor setting downshift into a
> helper"). This patch need not be forward-ported to 5.5 because the
> functions were rewritten.
> 
> Signed-off-by: Darell Tan <darell.tan@gmail.com>

I don't see marvell_set_downshift() in 'net' nor 'net-next'.
Darell Tan March 12, 2020, 2:14 p.m. UTC | #3
On Thu, Mar 12, 2020 at 2:45 PM David Miller <davem@davemloft.net> wrote:
>
> From: Darell Tan <darell.tan@gmail.com>
> Date: Wed, 11 Mar 2020 22:41:38 +0800
>
> > Fix marvell_set_downshift() from clobbering MSCR register.
> >
> > A typo in marvell_set_downshift() clobbers the MSCR register. This
> > register also shares settings with the auto MDI-X detection, set by
> > marvell_set_polarity(). In the 1116R init, downshift is set after
> > polarity, causing the polarity settings to be clobbered.
> >
> > This bug is present on the 5.4 series and was introduced in commit
> > 6ef05eb73c8f ("net: phy: marvell: Refactor setting downshift into a
> > helper"). This patch need not be forward-ported to 5.5 because the
> > functions were rewritten.
> >
> > Signed-off-by: Darell Tan <darell.tan@gmail.com>
>
> I don't see marvell_set_downshift() in 'net' nor 'net-next'.

This patch applies to the 5.4.x long term series and earlier, but not
to -stable or -next because the affected functions have already been
refactored.

Sorry I'm new to this. Should I be incorporating Andrew's comments and
sending a v2 to the linux-kernel list instead?

Thanks.
David Miller March 15, 2020, 3:51 a.m. UTC | #4
From: Darell Tan <darell.tan@gmail.com>
Date: Thu, 12 Mar 2020 22:14:08 +0800

> On Thu, Mar 12, 2020 at 2:45 PM David Miller <davem@davemloft.net> wrote:
>>
>> From: Darell Tan <darell.tan@gmail.com>
>> Date: Wed, 11 Mar 2020 22:41:38 +0800
>>
>> > Fix marvell_set_downshift() from clobbering MSCR register.
>> >
>> > A typo in marvell_set_downshift() clobbers the MSCR register. This
>> > register also shares settings with the auto MDI-X detection, set by
>> > marvell_set_polarity(). In the 1116R init, downshift is set after
>> > polarity, causing the polarity settings to be clobbered.
>> >
>> > This bug is present on the 5.4 series and was introduced in commit
>> > 6ef05eb73c8f ("net: phy: marvell: Refactor setting downshift into a
>> > helper"). This patch need not be forward-ported to 5.5 because the
>> > functions were rewritten.
>> >
>> > Signed-off-by: Darell Tan <darell.tan@gmail.com>
>>
>> I don't see marvell_set_downshift() in 'net' nor 'net-next'.
> 
> This patch applies to the 5.4.x long term series and earlier, but not
> to -stable or -next because the affected functions have already been
> refactored.
> 
> Sorry I'm new to this. Should I be incorporating Andrew's comments and
> sending a v2 to the linux-kernel list instead?

Submit it to stable@vger.kernel.org, include my:

Acked-by: David S. Miller <davem@davemloft.net>

And be sure to CC: me and make it clear that I directed you to do this.

Thank you.
diff mbox series

Patch

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index a7796134e..6ab8fe339 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;