Skip to contentSkip to conversation

net: phy: dp83867: perform soft reset and retain established link

PATCH Superseded [email protected] 5 participants 15 messages Mar 24, 2021 – Jun 14, 2021 3 messages not in the archive

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

PATCH 1/1 net: phy: dp83867: perform soft reset and retain established link

From: Praneeth Bajjuri <[email protected]>

Current logic is performing hard reset and causing the programmed registers to be wiped out.

as per datasheet: https://www.ti.com/lit/ds/symlink/dp83867cr.pdf
8.6.26 Control Register (CTRL)
do SW_RESTART to perform a reset not including the registers and is acceptable to do this if a link is already present.

---
 drivers/net/phy/dp83867.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/dp83867.c +1 -1
index 9bd9a5c0b1db..29ab49e894db 100644
@@ -826,7 +826,7 @@ static int dp83867_phy_reset(struct phy_device *phydev)
 {
 	int err;
 
-	err = phy_write(phydev, DP83867_CTRL, DP83867_SW_RESET);
+	err = phy_write(phydev, DP83867_CTRL, DP83867_SW_RESTART);
 	if (err < 0)
 		return err;
 
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 9 lines · On Tue, Mar 23, 2021 at 08:00:06PM -0500, [email protected] wrote:

From: Praneeth Bajjuri <[email protected]>

Current logic is performing hard reset and causing the programmed registers to be wiped out.

as per datasheet: https://www.ti.com/lit/ds/symlink/dp83867cr.pdf
8.6.26 Control Register (CTRL)
do SW_RESTART to perform a reset not including the registers and is acceptable to do this if a link is already present.

I don't see any code here to determine if the like is present. What if the cable is not plugged in?

drivers/net/phy/dp83867.c static int dp83867_phy_reset(struct phy_device *phydev) · line 831

Quoted 8 lines
drivers/net/phy/dp83867.c +1 -1
@@ -826,7 +826,7 @@ static int dp83867_phy_reset(struct phy_device *phydev)
 {
 	int err;
 
-	err = phy_write(phydev, DP83867_CTRL, DP83867_SW_RESET);
+	err = phy_write(phydev, DP83867_CTRL, DP83867_SW_RESTART);
 	if (err < 0)
 		return err;

The code continues

       usleep_range(10, 20);

        /* After reset FORCE_LINK_GOOD bit is set. Although the
         * default value should be unset. Disable FORCE_LINK_GOOD
         * for the phy to work properly.
         */
        return phy_modify(phydev, MII_DP83867_PHYCTRL,
                         DP83867_PHYCR_FORCE_LINK_GOOD, 0);
}

Do you still need to clear the FORCE_LINK_GOOD bit after a restart?

Andrew

A message that is not in the archive (sent off-list or not yet received): [email protected]

maintainer
#3 lore raw
Quoted 8 lines
Quoted 5 lines

as per datasheet: https://www.ti.com/lit/ds/symlink/dp83867cr.pdf

8.6.26 Control Register (CTRL)
do SW_RESTART to perform a reset not including the registers and is acceptable to do this if a link is already present.

Quoted 6 lines

I don't see any code here to determine if the like is present. What if the cable is not plugged in?

This API is primarily used for reset. Link Status is checked thru different
register. This shall not impact the cable plug in/out. With this change, it will align with DP83822 driver API.

So why is there the comment:

Quoted 2 lines
Quoted 2 lines

and is
acceptable to do this if a link is already present.

That kind of says, it is not acceptable to do this if the link is not present. Which is why i'm asking.

Andrew

#4 lore raw

Hi Andrew,

If Link is present, the current reset will reset the registers including the link and Host will need to re-program all the registers. With the change proposed, it will reset the state machine while keeping the register content.

My understanding is that below API is called to perform the soft reset and not complete wipe of PHY. Do you agree ?

.soft_reset = dp83867_phy_reset,

Regards,
Geet

See below difference between the two reset from DP83867 datasheet.

8.5.5.3 Global Software Reset
A global software reset is accomplished by setting bit 15 of register CTRL (address 0x001F) to 1. This bit resets all the internal circuits in the PHY including IEEE-defined registers and all the extended registers. The global software reset resets the device such that all registers are reset to default values and the hardware configuration values are maintained.
8.5.5.4 Global Software Restart
A global software restart is accomplished by setting bit 14 of register CTRL (0x001F) to 1. This action resets all the PHY circuits except the registers in the Register File.

In DP83822 linux, the API is calling the software reset and we are aligning DP83867 implementaiton with DP83822.

Regards,
Geet

Quoted 8 lines · Andrew Lunn
Quoted 5 lines

as per datasheet: https://www.ti.com/lit/ds/symlink/dp83867cr.pdf

8.6.26 Control Register (CTRL)
do SW_RESTART to perform a reset not including the registers and is acceptable to do this if a link is already present.

Quoted 6 lines

I don't see any code here to determine if the like is present. What if the cable is not plugged in?

This API is primarily used for reset. Link Status is checked thru different
register. This shall not impact the cable plug in/out. With this change, it will align with DP83822 driver API.

So why is there the comment:

> > and is
> > acceptable to do this if a link is already present.

That kind of says, it is not acceptable to do this if the link is not present. Which is why i'm asking.

Andrew

#5 lore raw
In reply to Andrew Lunn

Hi Andrew,

Quoted 15 lines · Andrew Lunn
Quoted 8 lines

> as per datasheet: https://www.ti.com/lit/ds/symlink/dp83867cr.pdf

> 8.6.26 Control Register (CTRL)
> do SW_RESTART to perform a reset not including the registers and is > acceptable to do this if a link is already present.

Quoted 6 lines

I don't see any code here to determine if the like is present. What if the cable is not plugged in?

This API is primarily used for reset. Link Status is checked thru different
register. This shall not impact the cable plug in/out. With this change, it will align with DP83822 driver API.

Quoted 7 lines

So why is there the comment:

Quoted 2 lines

> and is
> acceptable to do this if a link is already present.

That kind of says, it is not acceptable to do this if the link is not present. Which is why i'm asking.

Does the feedback from Geet help in clarity you requested. Ref:
https://lore.kernel.org/netdev/[email protected]/

Quoted 3 lines

Andrew

maintainer
#6 lore raw
Quoted 22 lines · Praneeth

Hi Andrew,

Quoted 19 lines · Andrew Lunn
Quoted 7 lines

> as per datasheet: https://www.ti.com/lit/ds/symlink/dp83867cr.pdf

> 8.6.26 Control Register (CTRL)
> do SW_RESTART to perform a reset not including the registers and is > acceptable to do this if a link is already present.

Quoted 6 lines

I don't see any code here to determine if the like is present. What if the cable is not plugged in?

This API is primarily used for reset. Link Status is checked thru different
register. This shall not impact the cable plug in/out. With this change, it will align with DP83822 driver API.

So why is there the comment:

Quoted 2 lines

> and is
> acceptable to do this if a link is already present.

Quoted 6 lines
Quoted 2 lines

That kind of says, it is not acceptable to do this if the link is not present. Which is why i'm asking.

Does the feedback from Geet help in clarity you requested. Ref:
https://lore.kernel.org/netdev/[email protected]/

Not really.

Quoted 2 lines

and is

Quoted 1 line
Quoted 1 line

> acceptable to do this if a link is already present.

There needs to be something to either:

1) Ensure there is link, so we known we are within acceptable behaviour.

2) Document what happens when there is no link, meaning we do something which is not acceptable. Is the magic smoke going to be released? Does the link die until the next reboot? Or despite it being unacceptable, nothing really happens, and it is not a problem?

Andrew

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

maintainer
#9 lore raw
Quoted 16 lines · Geet

Hello Andrew,

Please let me know if you have additional questions/clarifications to approve below change request.

Regards,
Geet

Quoted 8 lines

From: Geet Modi <[email protected]>
Date: Friday, May 28, 2021 at 10:10 AM
To: Andrew Lunn <[email protected]>, "Bajjuri, Praneeth" <[email protected]>
Cc: "David S . Miller" <[email protected]>, Jakub Kicinski <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>
Subject: Re: [EXTERNAL] Re: [EXTERNAL] Re: [PATCH] net: phy: dp83867: perform soft reset and retain established link

So this all seems to boil down to, it does not matter if it is acceptable or not, you are going to do it. So please just remove that part of the comment. It has no value.

Andrew

#10 lore raw

Praneeth,

Can you please help edit the comment and resubmit for approval ?

Regards,
Geet

On 6/1/21, 12:18 PM, "Andrew Lunn" <[email protected]> wrote:

On Tue, Jun 01, 2021 at 07:01:04PM +0000, Modi, Geet wrote:
> Hello Andrew,
>
>
>
> Please let me know if you have additional questions/clarifications to approve > below change request.
>
>
>
> Regards,
> Geet
>
>
>
>
>
> From: Geet Modi <[email protected]>
> Date: Friday, May 28, 2021 at 10:10 AM
> To: Andrew Lunn <[email protected]>, "Bajjuri, Praneeth" <[email protected]> > Cc: "David S . Miller" <[email protected]>, Jakub Kicinski <[email protected]>, > "[email protected]" <[email protected]>,
> "[email protected]" <[email protected]>
> Subject: Re: [EXTERNAL] Re: [EXTERNAL] Re: [PATCH] net: phy: dp83867: perform > soft reset and retain established link

So this all seems to boil down to, it does not matter if it is acceptable or not, you are going to do it. So please just remove that part of the comment. It has no value.

Andrew

#11 lore raw
In reply to Andrew Lunn

Andrew,

Quoted 26 lines · Andrew Lunn
Quoted 16 lines · Geet

Hello Andrew,

Please let me know if you have additional questions/clarifications to approve below change request.

Regards,
Geet

Quoted 8 lines

From: Geet Modi <[email protected]>
Date: Friday, May 28, 2021 at 10:10 AM
To: Andrew Lunn <[email protected]>, "Bajjuri, Praneeth" <[email protected]>
Cc: "David S . Miller" <[email protected]>, Jakub Kicinski <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>
Subject: Re: [EXTERNAL] Re: [EXTERNAL] Re: [PATCH] net: phy: dp83867: perform soft reset and retain established link

Quoted 3 lines

So this all seems to boil down to, it does not matter if it is acceptable or not, you are going to do it. So please just remove that part of the comment. It has no value.

Sent v2 addressing comment as per your suggestion.
Ref: https://lore.kernel.org/patchwork/patch/1444281/

Thanks
Praneeth

Quoted 3 lines

Andrew

#12 lore raw

PATCH v2 1/1 net: phy: dp83867: perform soft reset and retain established link

In reply to Bajjuri, Praneeth

From: Praneeth Bajjuri <[email protected]>

Current logic is performing hard reset and causing the programmed registers to be wiped out.

as per datasheet: https://www.ti.com/lit/ds/symlink/dp83867cr.pdf
8.6.26 Control Register (CTRL)

do SW_RESTART to perform a reset not including the registers, If performed when link is already present,
it will drop the link and trigger re-auto negotiation.

---
 drivers/net/phy/dp83867.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/phy/dp83867.c +1 -5
index 9bd9a5c0b1db..6bbc81ad295f 100644
@@ -826,16 +826,12 @@ static int dp83867_phy_reset(struct phy_device *phydev)
 {
 	int err;
 
-	err = phy_write(phydev, DP83867_CTRL, DP83867_SW_RESET);
+	err = phy_write(phydev, DP83867_CTRL, DP83867_SW_RESTART);
 	if (err < 0)
 		return err;
 
 	usleep_range(10, 20);
 
-	/* After reset FORCE_LINK_GOOD bit is set. Although the
-	 * default value should be unset. Disable FORCE_LINK_GOOD
-	 * for the phy to work properly.
-	 */
 	return phy_modify(phydev, MII_DP83867_PHYCTRL,
 			 DP83867_PHYCR_FORCE_LINK_GOOD, 0);
 }
Signature · 1 line
2.17.1
maintainer Reviewed-by on v2 1/1
#13 lore raw
Quoted 8 lines · On Wed, Jun 09, 2021 at 07:43:42PM -0500, [email protected] wrote:

From: Praneeth Bajjuri <[email protected]>

Current logic is performing hard reset and causing the programmed registers to be wiped out.

as per datasheet: https://www.ti.com/lit/ds/symlink/dp83867cr.pdf
8.6.26 Control Register (CTRL)

Quoted 6 lines

do SW_RESTART to perform a reset not including the registers, If performed when link is already present,
it will drop the link and trigger re-auto negotiation.

Andrew

#14 lore raw

Hello,

Quoted 14 lines · Andrew Lunn
Quoted 12 lines · On Wed, Jun 09, 2021 at 07:43:42PM -0500, [email protected] wrote:

From: Praneeth Bajjuri <[email protected]>

Current logic is performing hard reset and causing the programmed registers to be wiped out.

as per datasheet: https://www.ti.com/lit/ds/symlink/dp83867cr.pdf
8.6.26 Control Register (CTRL)

do SW_RESTART to perform a reset not including the registers, If performed when link is already present,
it will drop the link and trigger re-auto negotiation.

Quoted 6 lines
Quoted 2 lines

Andrew

I reported a few days ago an issue with the DP83822 which I think is caused by a similar change.
https://lore.kernel.org/netdev/CAHvQdo2yzJC89K74c_CZFjPydDQ5i22w36XPR5tKVv_W8a2vcg@mail.gmail.com/
In my case I can't get an link after this change, reverting it fixes the problem for me.

Hannes

#15 lore raw

Hannes,

Quoted 22 lines · Johannes Pointner

Hello,

Quoted 19 lines · Andrew Lunn
Quoted 8 lines · On Wed, Jun 09, 2021 at 07:43:42PM -0500, [email protected] wrote:

From: Praneeth Bajjuri <[email protected]>

Current logic is performing hard reset and causing the programmed registers to be wiped out.

as per datasheet: https://www.ti.com/lit/ds/symlink/dp83867cr.pdf
8.6.26 Control Register (CTRL)

Quoted 6 lines

do SW_RESTART to perform a reset not including the registers, If performed when link is already present,
it will drop the link and trigger re-auto negotiation.

Quoted 7 lines
Quoted 1 line

Andrew

I reported a few days ago an issue with the DP83822 which I think is caused by a similar change.
https://lore.kernel.org/netdev/CAHvQdo2yzJC89K74c_CZFjPydDQ5i22w36XPR5tKVv_W8a2vcg@mail.gmail.com/
In my case I can't get an link after this change, reverting it fixes the problem for me.

Are you saying that instead of reset if sw_restart is done as per this patch, there is no issue?

Quoted 3 lines

Hannes

#16 lore raw

Hello Praneeth,

Quoted 28 lines · Praneeth

Hannes,

Quoted 24 lines · Johannes Pointner

Hello,

Quoted 20 lines · Andrew Lunn
Quoted 8 lines · On Wed, Jun 09, 2021 at 07:43:42PM -0500, [email protected] wrote:

From: Praneeth Bajjuri <[email protected]>

Current logic is performing hard reset and causing the programmed registers to be wiped out.

as per datasheet: https://www.ti.com/lit/ds/symlink/dp83867cr.pdf
8.6.26 Control Register (CTRL)

Quoted 6 lines

do SW_RESTART to perform a reset not including the registers, If performed when link is already present,
it will drop the link and trigger re-auto negotiation.

Andrew

Quoted 8 lines
Quoted 5 lines

I reported a few days ago an issue with the DP83822 which I think is caused by a similar change.
https://lore.kernel.org/netdev/CAHvQdo2yzJC89K74c_CZFjPydDQ5i22w36XPR5tKVv_W8a2vcg@mail.gmail.com/
In my case I can't get an link after this change, reverting it fixes the problem for me.

Are you saying that instead of reset if sw_restart is done as per this patch, there is no issue?

In my case(DP83822 connected to an i.MX6) if the digital(SW) restart is used (Bit 14) I have the issue that I can' get a link.
ip addr shows:
1: lo: <LOOPBACK> mtu 65536 qdisc noop qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:60:65:54:32:10 brd ff:ff:ff:ff:ff:ff

If I revert this back to using the SW reset (Bit 15) it works again.

Regards,
Hannes

#17 lore raw
In reply to [email protected]
This patch was applied to netdev/net.git (refs/heads/master):

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

Quoted 9 lines · On Wed, 9 Jun 2021 19:43:42 -0500 you wrote:

From: Praneeth Bajjuri <[email protected]>

Current logic is performing hard reset and causing the programmed registers to be wiped out.

as per datasheet: https://www.ti.com/lit/ds/symlink/dp83867cr.pdf
8.6.26 Control Register (CTRL)

[...]

Here is the summary with links:
- [v2] net: phy: dp83867: perform soft reset and retain established link

    https://git.kernel.org/netdev/net/c/da9ef50f545f

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html