netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: sfp: fix PHY discovery for FS SFP-10G-T module
@ 2023-12-19 16:24 Marek Behún
  2023-12-20  8:30 ` Lei Wei
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Marek Behún @ 2023-12-19 16:24 UTC (permalink / raw)
  To: netdev, Russell King
  Cc: Jakub Kicinski, Andrew Lunn, Marek Behún, Wei Lei

Commit 2f3ce7a56c6e ("net: sfp: rework the RollBall PHY waiting code")
changed the long wait before accessing RollBall / FS modules into
probing for PHY every 1 second, and trying 25 times.

Wei Lei reports that this does not work correctly on FS modules: when
initializing, they may report values different from 0xffff in PHY ID
registers for some MMDs, causing get_phy_c45_ids() to find some bogus
MMD.

Fix this by adding the module_t_wait member back, and setting it to 4
seconds for FS modules.

Fixes: 2f3ce7a56c6e ("net: sfp: rework the RollBall PHY waiting code")
Reported-by: Wei Lei <quic_leiwei@quicinc.com>
Signed-off-by: Marek Behún <kabel@kernel.org>
---
Lei, could you please test this and send a Tested-by tag?
---
 drivers/net/phy/sfp.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index 3780a96d2caa..f75c9eb3958e 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -274,6 +274,7 @@ struct sfp {
 	struct sfp_eeprom_id id;
 	unsigned int module_power_mW;
 	unsigned int module_t_start_up;
+	unsigned int module_t_wait;
 	unsigned int phy_t_retry;
 
 	unsigned int rate_kbd;
@@ -388,6 +389,12 @@ static void sfp_fixup_fs_10gt(struct sfp *sfp)
 {
 	sfp_fixup_10gbaset_30m(sfp);
 	sfp_fixup_rollball(sfp);
+
+	/* The RollBall fixup is not enough for FS modules, the AQR chip inside
+	 * them does not return 0xffff for PHY ID registers in all MMDs for the
+	 * while initializing. They need a 4 second wait before accessing PHY.
+	 */
+	sfp->module_t_wait = msecs_to_jiffies(4000);
 }
 
 static void sfp_fixup_halny_gsfp(struct sfp *sfp)
@@ -2329,6 +2336,7 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report)
 		mask |= SFP_F_RS1;
 
 	sfp->module_t_start_up = T_START_UP;
+	sfp->module_t_wait = T_WAIT;
 	sfp->phy_t_retry = T_PHY_RETRY;
 
 	sfp->state_ignore_mask = 0;
@@ -2566,9 +2574,10 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
 
 		/* We need to check the TX_FAULT state, which is not defined
 		 * while TX_DISABLE is asserted. The earliest we want to do
-		 * anything (such as probe for a PHY) is 50ms.
+		 * anything (such as probe for a PHY) is 50ms (or more on
+		 * specific modules).
 		 */
-		sfp_sm_next(sfp, SFP_S_WAIT, T_WAIT);
+		sfp_sm_next(sfp, SFP_S_WAIT, sfp->module_t_wait);
 		break;
 
 	case SFP_S_WAIT:
@@ -2582,8 +2591,8 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
 			 * deasserting.
 			 */
 			timeout = sfp->module_t_start_up;
-			if (timeout > T_WAIT)
-				timeout -= T_WAIT;
+			if (timeout > sfp->module_t_wait)
+				timeout -= sfp->module_t_wait;
 			else
 				timeout = 1;
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: sfp: fix PHY discovery for FS SFP-10G-T module
  2023-12-19 16:24 [PATCH net-next] net: sfp: fix PHY discovery for FS SFP-10G-T module Marek Behún
@ 2023-12-20  8:30 ` Lei Wei
  2023-12-21 10:03 ` Andrew Lunn
  2023-12-25  6:32 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Lei Wei @ 2023-12-20  8:30 UTC (permalink / raw)
  To: Marek Behún, netdev, Russell King; +Cc: Jakub Kicinski, Andrew Lunn



On 12/20/2023 12:24 AM, Marek Behún wrote:
> Commit 2f3ce7a56c6e ("net: sfp: rework the RollBall PHY waiting code")
> changed the long wait before accessing RollBall / FS modules into
> probing for PHY every 1 second, and trying 25 times.
> 
> Wei Lei reports that this does not work correctly on FS modules: when
> initializing, they may report values different from 0xffff in PHY ID
> registers for some MMDs, causing get_phy_c45_ids() to find some bogus
> MMD.
> 
> Fix this by adding the module_t_wait member back, and setting it to 4
> seconds for FS modules.
> 
> Fixes: 2f3ce7a56c6e ("net: sfp: rework the RollBall PHY waiting code")
> Reported-by: Wei Lei <quic_leiwei@quicinc.com>
> Signed-off-by: Marek Behún <kabel@kernel.org>
Tested-by: Lei Wei <quic_leiwei@quicinc.com>

Regards,
Lei Wei
> ---
> Lei, could you please test this and send a Tested-by tag?
Marek, verified it is working, thank you for the fix.
> ---
>   drivers/net/phy/sfp.c | 17 +++++++++++++----
>   1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> index 3780a96d2caa..f75c9eb3958e 100644
> --- a/drivers/net/phy/sfp.c
> +++ b/drivers/net/phy/sfp.c
> @@ -274,6 +274,7 @@ struct sfp {
>   	struct sfp_eeprom_id id;
>   	unsigned int module_power_mW;
>   	unsigned int module_t_start_up;
> +	unsigned int module_t_wait;
>   	unsigned int phy_t_retry;
>   
>   	unsigned int rate_kbd;
> @@ -388,6 +389,12 @@ static void sfp_fixup_fs_10gt(struct sfp *sfp)
>   {
>   	sfp_fixup_10gbaset_30m(sfp);
>   	sfp_fixup_rollball(sfp);
> +
> +	/* The RollBall fixup is not enough for FS modules, the AQR chip inside
> +	 * them does not return 0xffff for PHY ID registers in all MMDs for the
> +	 * while initializing. They need a 4 second wait before accessing PHY.
> +	 */
> +	sfp->module_t_wait = msecs_to_jiffies(4000);
>   }
>   
>   static void sfp_fixup_halny_gsfp(struct sfp *sfp)
> @@ -2329,6 +2336,7 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report)
>   		mask |= SFP_F_RS1;
>   
>   	sfp->module_t_start_up = T_START_UP;
> +	sfp->module_t_wait = T_WAIT;
>   	sfp->phy_t_retry = T_PHY_RETRY;
>   
>   	sfp->state_ignore_mask = 0;
> @@ -2566,9 +2574,10 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
>   
>   		/* We need to check the TX_FAULT state, which is not defined
>   		 * while TX_DISABLE is asserted. The earliest we want to do
> -		 * anything (such as probe for a PHY) is 50ms.
> +		 * anything (such as probe for a PHY) is 50ms (or more on
> +		 * specific modules).
>   		 */
> -		sfp_sm_next(sfp, SFP_S_WAIT, T_WAIT);
> +		sfp_sm_next(sfp, SFP_S_WAIT, sfp->module_t_wait);
>   		break;
>   
>   	case SFP_S_WAIT:
> @@ -2582,8 +2591,8 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
>   			 * deasserting.
>   			 */
>   			timeout = sfp->module_t_start_up;
> -			if (timeout > T_WAIT)
> -				timeout -= T_WAIT;
> +			if (timeout > sfp->module_t_wait)
> +				timeout -= sfp->module_t_wait;
>   			else
>   				timeout = 1;
>   

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: sfp: fix PHY discovery for FS SFP-10G-T module
  2023-12-19 16:24 [PATCH net-next] net: sfp: fix PHY discovery for FS SFP-10G-T module Marek Behún
  2023-12-20  8:30 ` Lei Wei
@ 2023-12-21 10:03 ` Andrew Lunn
  2023-12-25  6:32 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2023-12-21 10:03 UTC (permalink / raw)
  To: Marek Behún; +Cc: netdev, Russell King, Jakub Kicinski, Wei Lei

On Tue, Dec 19, 2023 at 05:24:15PM +0100, Marek Behún wrote:
> Commit 2f3ce7a56c6e ("net: sfp: rework the RollBall PHY waiting code")
> changed the long wait before accessing RollBall / FS modules into
> probing for PHY every 1 second, and trying 25 times.
> 
> Wei Lei reports that this does not work correctly on FS modules: when
> initializing, they may report values different from 0xffff in PHY ID
> registers for some MMDs, causing get_phy_c45_ids() to find some bogus
> MMD.
> 
> Fix this by adding the module_t_wait member back, and setting it to 4
> seconds for FS modules.
> 
> Fixes: 2f3ce7a56c6e ("net: sfp: rework the RollBall PHY waiting code")
> Reported-by: Wei Lei <quic_leiwei@quicinc.com>
> Signed-off-by: Marek Behún <kabel@kernel.org>

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

    Andrew

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: sfp: fix PHY discovery for FS SFP-10G-T module
  2023-12-19 16:24 [PATCH net-next] net: sfp: fix PHY discovery for FS SFP-10G-T module Marek Behún
  2023-12-20  8:30 ` Lei Wei
  2023-12-21 10:03 ` Andrew Lunn
@ 2023-12-25  6:32 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-12-25  6:32 UTC (permalink / raw)
  To: =?utf-8?q?Marek_Beh=C3=BAn_=3Ckabel=40kernel=2Eorg=3E?=
  Cc: netdev, rmk+kernel, kuba, andrew, quic_leiwei

Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Tue, 19 Dec 2023 17:24:15 +0100 you wrote:
> Commit 2f3ce7a56c6e ("net: sfp: rework the RollBall PHY waiting code")
> changed the long wait before accessing RollBall / FS modules into
> probing for PHY every 1 second, and trying 25 times.
> 
> Wei Lei reports that this does not work correctly on FS modules: when
> initializing, they may report values different from 0xffff in PHY ID
> registers for some MMDs, causing get_phy_c45_ids() to find some bogus
> MMD.
> 
> [...]

Here is the summary with links:
  - [net-next] net: sfp: fix PHY discovery for FS SFP-10G-T module
    https://git.kernel.org/netdev/net-next/c/e9301af385e7

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-25  6:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-19 16:24 [PATCH net-next] net: sfp: fix PHY discovery for FS SFP-10G-T module Marek Behún
2023-12-20  8:30 ` Lei Wei
2023-12-21 10:03 ` Andrew Lunn
2023-12-25  6:32 ` patchwork-bot+netdevbpf

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).