b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From 4d6bfb6fbb00af38402db4d1ce464e22def9fd9e Mon Sep 17 00:00:00 2001 |
| 2 | From: Russell King <rmk+kernel@armlinux.org.uk> |
| 3 | Date: Thu, 28 Nov 2019 14:24:40 +0000 |
| 4 | Subject: [PATCH 1/4] net: sfp: use a definition for the fault recovery |
| 5 | attempts |
| 6 | |
| 7 | Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> |
| 8 | --- |
| 9 | drivers/net/phy/sfp.c | 14 +++++++++++--- |
| 10 | 1 file changed, 11 insertions(+), 3 deletions(-) |
| 11 | |
| 12 | --- a/drivers/net/phy/sfp.c |
| 13 | +++ b/drivers/net/phy/sfp.c |
| 14 | @@ -172,6 +172,14 @@ static const enum gpiod_flags gpio_flags |
| 15 | #define T_RESET_US 10 |
| 16 | #define T_FAULT_RECOVER msecs_to_jiffies(1000) |
| 17 | |
| 18 | +/* N_FAULT_INIT is the number of recovery attempts at module initialisation |
| 19 | + * time. If the TX_FAULT signal is not deasserted after this number of |
| 20 | + * attempts at clearing it, we decide that the module is faulty. |
| 21 | + * N_FAULT is the same but after the module has initialised. |
| 22 | + */ |
| 23 | +#define N_FAULT_INIT 5 |
| 24 | +#define N_FAULT 5 |
| 25 | + |
| 26 | /* SFP module presence detection is poor: the three MOD DEF signals are |
| 27 | * the same length on the PCB, which means it's possible for MOD DEF 0 to |
| 28 | * connect before the I2C bus on MOD DEF 1/2. |
| 29 | @@ -1980,7 +1988,7 @@ static void sfp_sm_main(struct sfp *sfp, |
| 30 | sfp_module_tx_enable(sfp); |
| 31 | |
| 32 | /* Initialise the fault clearance retries */ |
| 33 | - sfp->sm_retries = 5; |
| 34 | + sfp->sm_retries = N_FAULT_INIT; |
| 35 | |
| 36 | /* We need to check the TX_FAULT state, which is not defined |
| 37 | * while TX_DISABLE is asserted. The earliest we want to do |
| 38 | @@ -2020,7 +2028,7 @@ static void sfp_sm_main(struct sfp *sfp, |
| 39 | * or t_start_up, so assume there is a fault. |
| 40 | */ |
| 41 | sfp_sm_fault(sfp, SFP_S_INIT_TX_FAULT, |
| 42 | - sfp->sm_retries == 5); |
| 43 | + sfp->sm_retries == N_FAULT_INIT); |
| 44 | } else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) { |
| 45 | init_done: /* TX_FAULT deasserted or we timed out with TX_FAULT |
| 46 | * clear. Probe for the PHY and check the LOS state. |
| 47 | @@ -2033,7 +2041,7 @@ static void sfp_sm_main(struct sfp *sfp, |
| 48 | sfp_sm_link_check_los(sfp); |
| 49 | |
| 50 | /* Reset the fault retry count */ |
| 51 | - sfp->sm_retries = 5; |
| 52 | + sfp->sm_retries = N_FAULT; |
| 53 | } |
| 54 | break; |
| 55 | |