7830b9268f9d2f3c18b050b440427a81011e606f
[openwrt/staging/rmilecki.git] / target / linux / generic / backport-5.4 / 728-v5.5-net-sfp-split-the-PHY-probe-from-sfp_sm_mod_init.patch
1 From 5ed0bd49b2d3ac4439c2d7f44e5a82b7cf6f409a Mon Sep 17 00:00:00 2001
2 From: Russell King <rmk+kernel@armlinux.org.uk>
3 Date: Fri, 18 Oct 2019 10:09:02 +0100
4 Subject: [PATCH 626/660] net: sfp: split the PHY probe from sfp_sm_mod_init()
5
6 Move the PHY probe into a separate function, splitting it from
7 sfp_sm_mod_init(). This will allow us to eliminate the 50ms mdelay()
8 inside the state machine.
9
10 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
11 ---
12 drivers/net/phy/sfp.c | 21 +++++++++++++--------
13 1 file changed, 13 insertions(+), 8 deletions(-)
14
15 --- a/drivers/net/phy/sfp.c
16 +++ b/drivers/net/phy/sfp.c
17 @@ -1288,14 +1288,10 @@ static void sfp_sm_fault(struct sfp *sfp
18 static void sfp_sm_mod_init(struct sfp *sfp)
19 {
20 sfp_module_tx_enable(sfp);
21 +}
22
23 - /* Wait t_init before indicating that the link is up, provided the
24 - * current state indicates no TX_FAULT. If TX_FAULT clears before
25 - * this time, that's fine too.
26 - */
27 - sfp_sm_next(sfp, SFP_S_INIT, T_INIT_JIFFIES);
28 - sfp->sm_retries = 5;
29 -
30 +static void sfp_sm_probe_for_phy(struct sfp *sfp)
31 +{
32 /* Setting the serdes link mode is guesswork: there's no
33 * field in the EEPROM which indicates what mode should
34 * be used.
35 @@ -1580,8 +1576,17 @@ static void sfp_sm_main(struct sfp *sfp,
36 switch (sfp->sm_state) {
37 case SFP_S_DOWN:
38 if (sfp->sm_mod_state == SFP_MOD_PRESENT &&
39 - sfp->sm_dev_state == SFP_DEV_UP)
40 + sfp->sm_dev_state == SFP_DEV_UP) {
41 sfp_sm_mod_init(sfp);
42 + sfp_sm_probe_for_phy(sfp);
43 +
44 + /* Wait t_init before indicating that the link is up,
45 + * provided the current state indicates no TX_FAULT. If
46 + * TX_FAULT clears before this time, that's fine too.
47 + */
48 + sfp_sm_next(sfp, SFP_S_INIT, T_INIT_JIFFIES);
49 + sfp->sm_retries = 5;
50 + }
51 break;
52
53 case SFP_S_INIT: