1 From 38b62a12231be4b86fc5ca5477579d29831c02a5 Mon Sep 17 00:00:00 2001
2 From: Russell King <rmk+kernel@armlinux.org.uk>
3 Date: Fri, 18 Oct 2019 10:31:07 +0100
4 Subject: [PATCH 629/660] net: sfp: ensure TX_FAULT has deasserted before
7 TX_FAULT should be deasserted to indicate that the module has completed
8 its initialisation. This may include the on-board PHY, so wait until
9 the module has deasserted TX_FAULT before probing the PHY.
11 This means that we need an extra state to handle a TX_FAULT that
12 remains set for longer than t_init, since using the existing handling
13 state would bypass the PHY probe.
15 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
17 drivers/net/phy/sfp.c | 31 +++++++++++++++++++++++++------
18 1 file changed, 25 insertions(+), 6 deletions(-)
20 --- a/drivers/net/phy/sfp.c
21 +++ b/drivers/net/phy/sfp.c
22 @@ -54,6 +54,7 @@ enum {
26 + SFP_S_INIT_TX_FAULT,
30 @@ -111,6 +112,7 @@ static const char * const sm_state_strin
31 [SFP_S_DOWN] = "down",
32 [SFP_S_WAIT] = "wait",
33 [SFP_S_INIT] = "init",
34 + [SFP_S_INIT_TX_FAULT] = "init_tx_fault",
35 [SFP_S_WAIT_LOS] = "wait_los",
36 [SFP_S_LINK_UP] = "link_up",
37 [SFP_S_TX_FAULT] = "tx_fault",
38 @@ -1595,8 +1597,6 @@ static void sfp_sm_main(struct sfp *sfp,
39 if (event != SFP_E_TIMEOUT)
42 - sfp_sm_probe_for_phy(sfp);
44 if (sfp->state & SFP_F_TX_FAULT) {
45 /* Wait t_init before indicating that the link is up,
46 * provided the current state indicates no TX_FAULT. If
47 @@ -1618,10 +1618,29 @@ static void sfp_sm_main(struct sfp *sfp,
51 - if (event == SFP_E_TIMEOUT && sfp->state & SFP_F_TX_FAULT)
52 - sfp_sm_fault(sfp, SFP_S_TX_FAULT, true);
53 - else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR)
54 - init_done: sfp_sm_link_check_los(sfp);
55 + if (event == SFP_E_TIMEOUT && sfp->state & SFP_F_TX_FAULT) {
56 + /* TX_FAULT is still asserted after t_init, so assume
59 + sfp_sm_fault(sfp, SFP_S_INIT_TX_FAULT,
60 + sfp->sm_retries == 5);
61 + } else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) {
62 + init_done: /* TX_FAULT deasserted or we timed out with TX_FAULT
63 + * clear. Probe for the PHY and check the LOS state.
65 + sfp_sm_probe_for_phy(sfp);
66 + sfp_sm_link_check_los(sfp);
68 + /* Reset the fault retry count */
69 + sfp->sm_retries = 5;
73 + case SFP_S_INIT_TX_FAULT:
74 + if (event == SFP_E_TIMEOUT) {
75 + sfp_module_tx_fault_reset(sfp);
76 + sfp_sm_next(sfp, SFP_S_INIT, T_INIT_JIFFIES);