* [PATCH net-next 1/1] net: phy: dp83867: retrigger SGMII AN when link change
@ 2022-05-26 1:37 Tan Tee Min
2022-05-26 4:56 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: Tan Tee Min @ 2022-05-26 1:37 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: netdev, linux-kernel, Voon Wei Feng, Sit Michael Wei Hong,
Ling Pei Lee, Looi Hong Aun, Tan Tee Min
There is a limitation in TI DP83867 PHY device where SGMII AN is only
triggered once after the device is booted up. Even after the PHY TPI is
down and up again, SGMII AN is not triggered and hence no new in-band
message from PHY to MAC side SGMII.
This could cause an issue during power up, when PHY is up prior to MAC.
At this condition, once MAC side SGMII is up, MAC side SGMII wouldn`t
receive new in-band message from TI PHY with correct link status, speed
and duplex info.
As suggested by TI, implemented a SW solution here to retrigger SGMII
Auto-Neg whenever there is a link change.
Signed-off-by: Sit, Michael Wei Hong <michael.wei.hong.sit@intel.com>
Reviewed-by: Voon Weifeng <weifeng.voon@intel.com>
Signed-off-by: Tan Tee Min <tee.min.tan@linux.intel.com>
---
drivers/net/phy/dp83867.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 8561f2d4443b..13dafe7a29bd 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -137,6 +137,7 @@
#define DP83867_DOWNSHIFT_2_COUNT 2
#define DP83867_DOWNSHIFT_4_COUNT 4
#define DP83867_DOWNSHIFT_8_COUNT 8
+#define DP83867_SGMII_AUTONEG_EN BIT(7)
/* CFG3 bits */
#define DP83867_CFG3_INT_OE BIT(7)
@@ -855,6 +856,32 @@ static int dp83867_phy_reset(struct phy_device *phydev)
DP83867_PHYCR_FORCE_LINK_GOOD, 0);
}
+static void dp83867_link_change_notify(struct phy_device *phydev)
+{
+ /* There is a limitation in DP83867 PHY device where SGMII AN is
+ * only triggered once after the device is booted up. Even after the
+ * PHY TPI is down and up again, SGMII AN is not triggered and
+ * hence no new in-band message from PHY to MAC side SGMII.
+ * This could cause an issue during power up, when PHY is up prior
+ * to MAC. At this condition, once MAC side SGMII is up, MAC side
+ * SGMII wouldn`t receive new in-band message from TI PHY with
+ * correct link status, speed and duplex info.
+ * Thus, implemented a SW solution here to retrigger SGMII Auto-Neg
+ * whenever there is a link change.
+ */
+ if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
+ int val = 0;
+
+ val = phy_clear_bits(phydev, DP83867_CFG2,
+ DP83867_SGMII_AUTONEG_EN);
+ if (val < 0)
+ return;
+
+ phy_set_bits(phydev, DP83867_CFG2,
+ DP83867_SGMII_AUTONEG_EN);
+ }
+}
+
static struct phy_driver dp83867_driver[] = {
{
.phy_id = DP83867_PHY_ID,
@@ -879,6 +906,8 @@ static struct phy_driver dp83867_driver[] = {
.suspend = genphy_suspend,
.resume = genphy_resume,
+
+ .link_change_notify = dp83867_link_change_notify,
},
};
module_phy_driver(dp83867_driver);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next 1/1] net: phy: dp83867: retrigger SGMII AN when link change
2022-05-26 1:37 [PATCH net-next 1/1] net: phy: dp83867: retrigger SGMII AN when link change Tan Tee Min
@ 2022-05-26 4:56 ` Jakub Kicinski
2022-05-26 8:18 ` Tan Tee Min
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2022-05-26 4:56 UTC (permalink / raw)
To: Tan Tee Min
Cc: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
Eric Dumazet, Paolo Abeni, netdev, linux-kernel, Voon Wei Feng,
Sit Michael Wei Hong, Ling Pei Lee, Looi Hong Aun, Tan Tee Min
On Thu, 26 May 2022 09:37:14 +0800 Tan Tee Min wrote:
> There is a limitation in TI DP83867 PHY device where SGMII AN is only
> triggered once after the device is booted up. Even after the PHY TPI is
> down and up again, SGMII AN is not triggered and hence no new in-band
> message from PHY to MAC side SGMII.
>
> This could cause an issue during power up, when PHY is up prior to MAC.
> At this condition, once MAC side SGMII is up, MAC side SGMII wouldn`t
> receive new in-band message from TI PHY with correct link status, speed
> and duplex info.
>
> As suggested by TI, implemented a SW solution here to retrigger SGMII
> Auto-Neg whenever there is a link change.
Thanks, sounds like this bug has always been in the driver so we should
add:
Fixes: 2a10154abcb7 ("net: phy: dp83867: Add TI dp83867 phy")
Is that right? Getting a workaround like this into stable eventually
seems like a good idea so Fixes tag will help.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next 1/1] net: phy: dp83867: retrigger SGMII AN when link change
2022-05-26 4:56 ` Jakub Kicinski
@ 2022-05-26 8:18 ` Tan Tee Min
0 siblings, 0 replies; 3+ messages in thread
From: Tan Tee Min @ 2022-05-26 8:18 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
Eric Dumazet, Paolo Abeni, netdev, linux-kernel, Voon Wei Feng,
Sit Michael Wei Hong, Ling Pei Lee, Looi Hong Aun, Tan Tee Min
On Wed, May 25, 2022 at 09:56:29PM -0700, Jakub Kicinski wrote:
> On Thu, 26 May 2022 09:37:14 +0800 Tan Tee Min wrote:
> > As suggested by TI, implemented a SW solution here to retrigger SGMII
> > Auto-Neg whenever there is a link change.
>
> Thanks, sounds like this bug has always been in the driver so we should
> add:
>
> Fixes: 2a10154abcb7 ("net: phy: dp83867: Add TI dp83867 phy")
>
> Is that right? Getting a workaround like this into stable eventually
> seems like a good idea so Fixes tag will help.
Thanks for the quick response.
Yes, you are right.
Let me add the Fixes tag and Cc <stable@vger.kernel.org> in v2 patch.
Thanks,
Tee Min
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-05-26 8:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-26 1:37 [PATCH net-next 1/1] net: phy: dp83867: retrigger SGMII AN when link change Tan Tee Min
2022-05-26 4:56 ` Jakub Kicinski
2022-05-26 8:18 ` Tan Tee Min
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).