@@ -191,7 +191,7 @@ static const enum gpiod_flags gpio_flags[] = {
191191 * R_PHY_RETRY is the number of attempts.
192192 */
193193#define T_PHY_RETRY msecs_to_jiffies(50)
194- #define R_PHY_RETRY 12
194+ #define R_PHY_RETRY 25
195195
196196/* SFP module presence detection is poor: the three MOD DEF signals are
197197 * the same length on the PCB, which means it's possible for MOD DEF 0 to
@@ -274,7 +274,7 @@ struct sfp {
274274 struct sfp_eeprom_id id ;
275275 unsigned int module_power_mW ;
276276 unsigned int module_t_start_up ;
277- unsigned int module_t_wait ;
277+ unsigned int phy_t_retry ;
278278
279279 unsigned int rate_kbd ;
280280 unsigned int rs_threshold_kbd ;
@@ -372,18 +372,22 @@ static void sfp_fixup_10gbaset_30m(struct sfp *sfp)
372372 sfp -> id .base .extended_cc = SFF8024_ECC_10GBASE_T_SR ;
373373}
374374
375- static void sfp_fixup_rollball_proto (struct sfp * sfp , unsigned int secs )
375+ static void sfp_fixup_rollball (struct sfp * sfp )
376376{
377377 sfp -> mdio_protocol = MDIO_I2C_ROLLBALL ;
378- sfp -> module_t_wait = msecs_to_jiffies (secs * 1000 );
378+
379+ /* RollBall modules may disallow access to PHY registers for up to 25
380+ * seconds, and the reads return 0xffff before that. Increase the time
381+ * between PHY probe retries from 50ms to 1s so that we will wait for
382+ * the PHY for a sufficient amount of time.
383+ */
384+ sfp -> phy_t_retry = msecs_to_jiffies (1000 );
379385}
380386
381387static void sfp_fixup_fs_10gt (struct sfp * sfp )
382388{
383389 sfp_fixup_10gbaset_30m (sfp );
384-
385- // These SFPs need 4 seconds before the PHY can be accessed
386- sfp_fixup_rollball_proto (sfp , 4 );
390+ sfp_fixup_rollball (sfp );
387391}
388392
389393static void sfp_fixup_halny_gsfp (struct sfp * sfp )
@@ -395,12 +399,6 @@ static void sfp_fixup_halny_gsfp(struct sfp *sfp)
395399 sfp -> state_hw_mask &= ~(SFP_F_TX_FAULT | SFP_F_LOS );
396400}
397401
398- static void sfp_fixup_rollball (struct sfp * sfp )
399- {
400- // Rollball SFPs need 25 seconds before the PHY can be accessed
401- sfp_fixup_rollball_proto (sfp , 25 );
402- }
403-
404402static void sfp_fixup_rollball_cc (struct sfp * sfp )
405403{
406404 sfp_fixup_rollball (sfp );
@@ -2331,7 +2329,7 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report)
23312329 mask |= SFP_F_RS1 ;
23322330
23332331 sfp -> module_t_start_up = T_START_UP ;
2334- sfp -> module_t_wait = T_WAIT ;
2332+ sfp -> phy_t_retry = T_PHY_RETRY ;
23352333
23362334 sfp -> state_ignore_mask = 0 ;
23372335
@@ -2568,10 +2566,9 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
25682566
25692567 /* We need to check the TX_FAULT state, which is not defined
25702568 * while TX_DISABLE is asserted. The earliest we want to do
2571- * anything (such as probe for a PHY) is 50ms (or more on
2572- * specific modules).
2569+ * anything (such as probe for a PHY) is 50ms.
25732570 */
2574- sfp_sm_next (sfp , SFP_S_WAIT , sfp -> module_t_wait );
2571+ sfp_sm_next (sfp , SFP_S_WAIT , T_WAIT );
25752572 break ;
25762573
25772574 case SFP_S_WAIT :
@@ -2585,8 +2582,8 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
25852582 * deasserting.
25862583 */
25872584 timeout = sfp -> module_t_start_up ;
2588- if (timeout > sfp -> module_t_wait )
2589- timeout -= sfp -> module_t_wait ;
2585+ if (timeout > T_WAIT )
2586+ timeout -= T_WAIT ;
25902587 else
25912588 timeout = 1 ;
25922589
@@ -2629,7 +2626,11 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
26292626 ret = sfp_sm_probe_for_phy (sfp );
26302627 if (ret == - ENODEV ) {
26312628 if (-- sfp -> sm_phy_retries ) {
2632- sfp_sm_next (sfp , SFP_S_INIT_PHY , T_PHY_RETRY );
2629+ sfp_sm_next (sfp , SFP_S_INIT_PHY ,
2630+ sfp -> phy_t_retry );
2631+ dev_dbg (sfp -> dev ,
2632+ "no PHY detected, %u tries left\n" ,
2633+ sfp -> sm_phy_retries );
26332634 break ;
26342635 } else {
26352636 dev_info (sfp -> dev , "no PHY detected\n" );
0 commit comments