* [PATCH net-next] net: sfp: rework the RollBall PHY waiting code
@ 2023-11-21 17:20 Marek Behún
2023-11-25 17:21 ` Andrew Lunn
2023-11-25 19:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Marek Behún @ 2023-11-21 17:20 UTC (permalink / raw)
To: netdev, Russell King; +Cc: Jakub Kicinski, Andrew Lunn, Marek Behún
RollBall SFP modules allow the access to PHY registers only after a
certain time has passed. Until then, the registers read 0xffff.
Currently we have quirks for modules where we need to wait either 25
seconds or 4 seconds, but recently I got hands on another module where
the wait is even shorter.
Instead of hardcoding different wait times, lets rework the code:
- increase the PHY retry count to 25
- when RollBall module is detected, increase the PHY retry time from
50ms to 1s
Signed-off-by: Marek Behún <kabel@kernel.org>
---
drivers/net/phy/sfp.c | 41 +++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index 5468bd209fab..5eb00295b8bf 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -191,7 +191,7 @@ static const enum gpiod_flags gpio_flags[] = {
* R_PHY_RETRY is the number of attempts.
*/
#define T_PHY_RETRY msecs_to_jiffies(50)
-#define R_PHY_RETRY 12
+#define R_PHY_RETRY 25
/* SFP module presence detection is poor: the three MOD DEF signals are
* the same length on the PCB, which means it's possible for MOD DEF 0 to
@@ -274,7 +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;
unsigned int rs_threshold_kbd;
@@ -372,18 +372,22 @@ static void sfp_fixup_10gbaset_30m(struct sfp *sfp)
sfp->id.base.extended_cc = SFF8024_ECC_10GBASE_T_SR;
}
-static void sfp_fixup_rollball_proto(struct sfp *sfp, unsigned int secs)
+static void sfp_fixup_rollball(struct sfp *sfp)
{
sfp->mdio_protocol = MDIO_I2C_ROLLBALL;
- sfp->module_t_wait = msecs_to_jiffies(secs * 1000);
+
+ /* RollBall modules may disallow access to PHY registers for up to 25
+ * seconds, and the reads return 0xffff before that. Increase the time
+ * between PHY probe retries from 50ms to 1s so that we will wait for
+ * the PHY for a sufficient amount of time.
+ */
+ sfp->phy_t_retry = msecs_to_jiffies(1000);
}
static void sfp_fixup_fs_10gt(struct sfp *sfp)
{
sfp_fixup_10gbaset_30m(sfp);
-
- // These SFPs need 4 seconds before the PHY can be accessed
- sfp_fixup_rollball_proto(sfp, 4);
+ sfp_fixup_rollball(sfp);
}
static void sfp_fixup_halny_gsfp(struct sfp *sfp)
@@ -395,12 +399,6 @@ static void sfp_fixup_halny_gsfp(struct sfp *sfp)
sfp->state_hw_mask &= ~(SFP_F_TX_FAULT | SFP_F_LOS);
}
-static void sfp_fixup_rollball(struct sfp *sfp)
-{
- // Rollball SFPs need 25 seconds before the PHY can be accessed
- sfp_fixup_rollball_proto(sfp, 25);
-}
-
static void sfp_fixup_rollball_cc(struct sfp *sfp)
{
sfp_fixup_rollball(sfp);
@@ -2331,7 +2329,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;
@@ -2568,10 +2566,9 @@ 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 (or more on
- * specific modules).
+ * anything (such as probe for a PHY) is 50ms.
*/
- sfp_sm_next(sfp, SFP_S_WAIT, sfp->module_t_wait);
+ sfp_sm_next(sfp, SFP_S_WAIT, T_WAIT);
break;
case SFP_S_WAIT:
@@ -2585,8 +2582,8 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
* deasserting.
*/
timeout = sfp->module_t_start_up;
- if (timeout > sfp->module_t_wait)
- timeout -= sfp->module_t_wait;
+ if (timeout > T_WAIT)
+ timeout -= T_WAIT;
else
timeout = 1;
@@ -2629,7 +2626,11 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
ret = sfp_sm_probe_for_phy(sfp);
if (ret == -ENODEV) {
if (--sfp->sm_phy_retries) {
- sfp_sm_next(sfp, SFP_S_INIT_PHY, T_PHY_RETRY);
+ sfp_sm_next(sfp, SFP_S_INIT_PHY,
+ sfp->phy_t_retry);
+ dev_dbg(sfp->dev,
+ "no PHY detected, %u tries left\n",
+ sfp->sm_phy_retries);
break;
} else {
dev_info(sfp->dev, "no PHY detected\n");
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: sfp: rework the RollBall PHY waiting code
2023-11-21 17:20 [PATCH net-next] net: sfp: rework the RollBall PHY waiting code Marek Behún
@ 2023-11-25 17:21 ` Andrew Lunn
2023-11-25 19:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2023-11-25 17:21 UTC (permalink / raw)
To: Marek Behún; +Cc: netdev, Russell King, Jakub Kicinski
On Tue, Nov 21, 2023 at 06:20:24PM +0100, Marek Behún wrote:
> RollBall SFP modules allow the access to PHY registers only after a
> certain time has passed. Until then, the registers read 0xffff.
>
> Currently we have quirks for modules where we need to wait either 25
> seconds or 4 seconds, but recently I got hands on another module where
> the wait is even shorter.
>
> Instead of hardcoding different wait times, lets rework the code:
> - increase the PHY retry count to 25
> - when RollBall module is detected, increase the PHY retry time from
> 50ms to 1s
>
> Signed-off-by: Marek Behún <kabel@kernel.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: sfp: rework the RollBall PHY waiting code
2023-11-21 17:20 [PATCH net-next] net: sfp: rework the RollBall PHY waiting code Marek Behún
2023-11-25 17:21 ` Andrew Lunn
@ 2023-11-25 19:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-11-25 19:20 UTC (permalink / raw)
To: =?utf-8?q?Marek_Beh=C3=BAn_=3Ckabel=40kernel=2Eorg=3E?=
Cc: netdev, rmk+kernel, kuba, andrew
Hello:
This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:
On Tue, 21 Nov 2023 18:20:24 +0100 you wrote:
> RollBall SFP modules allow the access to PHY registers only after a
> certain time has passed. Until then, the registers read 0xffff.
>
> Currently we have quirks for modules where we need to wait either 25
> seconds or 4 seconds, but recently I got hands on another module where
> the wait is even shorter.
>
> [...]
Here is the summary with links:
- [net-next] net: sfp: rework the RollBall PHY waiting code
https://git.kernel.org/netdev/net-next/c/2f3ce7a56c6e
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] 3+ messages in thread
end of thread, other threads:[~2023-11-25 19:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-21 17:20 [PATCH net-next] net: sfp: rework the RollBall PHY waiting code Marek Behún
2023-11-25 17:21 ` Andrew Lunn
2023-11-25 19:20 ` 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).