linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Arseny Solokha <asolokha@kb.kras.ru>,
	Russell King <rmk+kernel@armlinux.org.uk>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 5.2 25/56] net: phylink: dont start and stop SGMII PHYs in SFP modules twice
Date: Thu,  8 Aug 2019 21:04:51 +0200	[thread overview]
Message-ID: <20190808190453.926761189@linuxfoundation.org> (raw)
In-Reply-To: <20190808190452.867062037@linuxfoundation.org>

From: Arseny Solokha <asolokha@kb.kras.ru>

[ Upstream commit c7fa7f567cab6532be285a5df104617d80bce245 ]

SFP modules connected using the SGMII interface have their own PHYs which
are handled by the struct phylink's phydev field. On the other hand, for
the modules connected using 1000Base-X interface that field is not set.

Since commit ce0aa27ff3f6 ("sfp: add sfp-bus to bridge between network
devices and sfp cages") phylink_start() ends up setting the phydev field
using the sfp-bus infrastructure, which eventually calls phy_start() on it,
and then calling phy_start() again on the same phydev from phylink_start()
itself. Similar call sequence holds for phylink_stop(), only in the reverse
order. This results in WARNs during network interface bringup and shutdown
when a copper SFP module is connected, as phy_start() and phy_stop() are
called twice in a row for the same phy_device:

  % ip link set up dev eth0
  ------------[ cut here ]------------
  called from state UP
  WARNING: CPU: 1 PID: 155 at drivers/net/phy/phy.c:895 phy_start+0x74/0xc0
  Modules linked in:
  CPU: 1 PID: 155 Comm: backend Not tainted 5.2.0+ #1
  NIP:  c0227bf0 LR: c0227bf0 CTR: c004d224
  REGS: df547720 TRAP: 0700   Not tainted  (5.2.0+)
  MSR:  00029000 <CE,EE,ME>  CR: 24002822  XER: 00000000

  GPR00: c0227bf0 df5477d8 df5d7080 00000014 df9d2370 df9d5ac4 1f4eb000 00000001
  GPR08: c061fe58 00000000 00000000 df5477d8 0000003c 100c8768 00000000 00000000
  GPR16: df486a00 c046f1c8 c046eea0 00000000 c046e904 c0239604 db68449c 00000000
  GPR24: e9083204 00000000 00000001 db684460 e9083404 00000000 db6dce00 db6dcc00
  NIP [c0227bf0] phy_start+0x74/0xc0
  LR [c0227bf0] phy_start+0x74/0xc0
  Call Trace:
  [df5477d8] [c0227bf0] phy_start+0x74/0xc0 (unreliable)
  [df5477e8] [c023cad0] startup_gfar+0x398/0x3f4
  [df547828] [c023cf08] gfar_enet_open+0x364/0x374
  [df547898] [c029d870] __dev_open+0xe4/0x140
  [df5478c8] [c029db70] __dev_change_flags+0xf0/0x188
  [df5478f8] [c029dc28] dev_change_flags+0x20/0x54
  [df547918] [c02ae304] do_setlink+0x310/0x818
  [df547a08] [c02b1eb8] __rtnl_newlink+0x384/0x6b0
  [df547c28] [c02b222c] rtnl_newlink+0x48/0x68
  [df547c48] [c02ad7c8] rtnetlink_rcv_msg+0x240/0x27c
  [df547c98] [c02cc068] netlink_rcv_skb+0x8c/0xf0
  [df547cd8] [c02cba3c] netlink_unicast+0x114/0x19c
  [df547d08] [c02cbd74] netlink_sendmsg+0x2b0/0x2c0
  [df547d58] [c027b668] sock_sendmsg_nosec+0x20/0x40
  [df547d68] [c027d080] ___sys_sendmsg+0x17c/0x1dc
  [df547e98] [c027df7c] __sys_sendmsg+0x68/0x84
  [df547ef8] [c027e430] sys_socketcall+0x1a0/0x204
  [df547f38] [c000d1d8] ret_from_syscall+0x0/0x38
  --- interrupt: c01 at 0xfd4e030
      LR = 0xfd4e010
  Instruction dump:
  813f0188 38800000 2b890005 419d0014 3d40c046 5529103a 394aa208 7c8a482e
  3c60c046 3863a1b8 4cc63182 4be009a1 <0fe00000> 48000030 3c60c046 3863a1d0
  ---[ end trace d4c095aeaf6ea998 ]---

and

  % ip link set down dev eth0
  ------------[ cut here ]------------
  called from state HALTED
  WARNING: CPU: 1 PID: 184 at drivers/net/phy/phy.c:858 phy_stop+0x3c/0x88

  <...>

  Call Trace:
  [df581788] [c0228450] phy_stop+0x3c/0x88 (unreliable)
  [df581798] [c022d548] sfp_sm_phy_detach+0x1c/0x44
  [df5817a8] [c022e8cc] sfp_sm_event+0x4b0/0x87c
  [df581848] [c022f04c] sfp_upstream_stop+0x34/0x44
  [df581858] [c0225608] phylink_stop+0x7c/0xe4
  [df581868] [c023c57c] stop_gfar+0x7c/0x94
  [df581888] [c023c5b8] gfar_close+0x24/0x94
  [df5818a8] [c0298688] __dev_close_many+0xdc/0xf8
  [df5818c8] [c029db58] __dev_change_flags+0xd8/0x188
  [df5818f8] [c029dc28] dev_change_flags+0x20/0x54
  [df581918] [c02ae304] do_setlink+0x310/0x818
  [df581a08] [c02b1eb8] __rtnl_newlink+0x384/0x6b0
  [df581c28] [c02b222c] rtnl_newlink+0x48/0x68
  [df581c48] [c02ad7c8] rtnetlink_rcv_msg+0x240/0x27c
  [df581c98] [c02cc068] netlink_rcv_skb+0x8c/0xf0
  [df581cd8] [c02cba3c] netlink_unicast+0x114/0x19c
  [df581d08] [c02cbd74] netlink_sendmsg+0x2b0/0x2c0
  [df581d58] [c027b668] sock_sendmsg_nosec+0x20/0x40
  [df581d68] [c027d080] ___sys_sendmsg+0x17c/0x1dc
  [df581e98] [c027df7c] __sys_sendmsg+0x68/0x84
  [df581ef8] [c027e430] sys_socketcall+0x1a0/0x204
  [df581f38] [c000d1d8] ret_from_syscall+0x0/0x38

  <...>

  ---[ end trace d4c095aeaf6ea999 ]---

SFP modules with the 1000Base-X interface are not affected.

Place explicit calls to phy_start() and phy_stop() before enabling or after
disabling an attached SFP module, where phydev is not yet set (or is
already unset), so they will be made only from the inside of sfp-bus, if
needed.

Fixes: 217962615662 ("net: phy: warn if phy_start is called from invalid state")
Signed-off-by: Arseny Solokha <asolokha@kb.kras.ru>
Acked-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/phy/phylink.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -912,10 +912,10 @@ void phylink_start(struct phylink *pl)
 
 	if (pl->link_an_mode == MLO_AN_FIXED && !IS_ERR(pl->link_gpio))
 		mod_timer(&pl->link_poll, jiffies + HZ);
-	if (pl->sfp_bus)
-		sfp_upstream_start(pl->sfp_bus);
 	if (pl->phydev)
 		phy_start(pl->phydev);
+	if (pl->sfp_bus)
+		sfp_upstream_start(pl->sfp_bus);
 }
 EXPORT_SYMBOL_GPL(phylink_start);
 
@@ -932,10 +932,10 @@ void phylink_stop(struct phylink *pl)
 {
 	ASSERT_RTNL();
 
-	if (pl->phydev)
-		phy_stop(pl->phydev);
 	if (pl->sfp_bus)
 		sfp_upstream_stop(pl->sfp_bus);
+	if (pl->phydev)
+		phy_stop(pl->phydev);
 	if (pl->link_an_mode == MLO_AN_FIXED && !IS_ERR(pl->link_gpio))
 		del_timer_sync(&pl->link_poll);
 



  parent reply	other threads:[~2019-08-08 19:06 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-08 19:04 [PATCH 5.2 00/56] 5.2.8-stable review Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 01/56] scsi: fcoe: Embed fc_rport_priv in fcoe_rport structure Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 02/56] libnvdimm/bus: Prepare the nd_ioctl() path to be re-entrant Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 03/56] libnvdimm/bus: Fix wait_nvdimm_bus_probe_idle() ABBA deadlock Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 04/56] ALSA: usb-audio: Sanity checks for each pipe and EP types Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 05/56] ALSA: usb-audio: Fix gpf in snd_usb_pipe_sanity_check Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 06/56] HID: wacom: fix bit shift for Cintiq Companion 2 Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 07/56] HID: Add quirk for HP X1200 PIXART OEM mouse Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 08/56] atm: iphase: Fix Spectre v1 vulnerability Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 09/56] bnx2x: Disable multi-cos feature Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 10/56] drivers/net/ethernet/marvell/mvmdio.c: Fix non OF case Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 11/56] ife: error out when nla attributes are empty Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 12/56] ip6_gre: reload ipv6h in prepare_ip6gre_xmit_ipv6 Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 13/56] ip6_tunnel: fix possible use-after-free on xmit Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 14/56] ipip: validate header length in ipip_tunnel_xmit Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 15/56] mlxsw: spectrum: Fix error path in mlxsw_sp_module_init() Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 16/56] mvpp2: fix panic on module removal Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 17/56] mvpp2: refactor MTU change code Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 18/56] net: bridge: delete local fdb on device init failure Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 19/56] net: bridge: mcast: dont delete permanent entries when fast leave is enabled Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 20/56] net: bridge: move default pvid init/deinit to NETDEV_REGISTER/UNREGISTER Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 21/56] net: fix ifindex collision during namespace removal Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 22/56] net/mlx5e: always initialize frag->last_in_page Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 23/56] net/mlx5: Use reversed order when unregister devices Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 24/56] net: phy: fixed_phy: print gpio error only if gpio node is present Greg Kroah-Hartman
2019-08-08 19:04 ` Greg Kroah-Hartman [this message]
2019-08-08 19:04 ` [PATCH 5.2 26/56] net: phylink: Fix flow control for fixed-link Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 27/56] net: phy: mscc: initialize stats array Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 28/56] net: qualcomm: rmnet: Fix incorrect UL checksum offload logic Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 29/56] net: sched: Fix a possible null-pointer dereference in dequeue_func() Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 30/56] net sched: update vlan action for batched events operations Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 31/56] net: sched: use temporary variable for actions indexes Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 32/56] net/smc: do not schedule tx_work in SMC_CLOSED state Greg Kroah-Hartman
2019-08-08 19:04 ` [PATCH 5.2 33/56] net: stmmac: Use netif_tx_napi_add() for TX polling function Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 34/56] NFC: nfcmrvl: fix gpio-handling regression Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 35/56] ocelot: Cancel delayed work before wq destruction Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 36/56] tipc: compat: allow tipc commands without arguments Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 37/56] tipc: fix unitilized skb list crash Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 38/56] tun: mark small packets as owned by the tap sock Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 39/56] net/mlx5: Fix modify_cq_in alignment Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 40/56] net/mlx5e: Prevent encap flow counter update async to user query Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 41/56] r8169: dont use MSI before RTL8168d Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 42/56] bpf: fix XDP vlan selftests test_xdp_vlan.sh Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 43/56] selftests/bpf: add wrapper scripts for test_xdp_vlan.sh Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 44/56] selftests/bpf: reduce time to execute test_xdp_vlan.sh Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 45/56] net: fix bpf_xdp_adjust_head regression for generic-XDP Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 46/56] hv_sock: Fix hang when a connection is closed Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 47/56] net: phy: fix race in genphy_update_link Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 48/56] net/smc: avoid fallback in case of non-blocking connect Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 49/56] rocker: fix memory leaks of fib_work on two error return paths Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 50/56] mlxsw: spectrum_buffers: Further reduce pool size on Spectrum-2 Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 51/56] net/mlx5: Add missing RDMA_RX capabilities Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 52/56] net/mlx5e: Fix matching of speed to PRM link modes Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 53/56] compat_ioctl: pppoe: fix PPPOEIOCSFWD handling Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 54/56] drm/i915/vbt: Fix VBT parsing for the PSR section Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 55/56] Revert "mac80211: set NETIF_F_LLTX when using intermediate tx queues" Greg Kroah-Hartman
2019-08-08 19:05 ` [PATCH 5.2 56/56] spi: bcm2835: Fix 3-wire mode if DMA is enabled Greg Kroah-Hartman
2019-08-09  0:36 ` [PATCH 5.2 00/56] 5.2.8-stable review shuah
2019-08-09  6:30   ` Greg Kroah-Hartman
2019-08-09  7:45 ` Naresh Kamboju
2019-08-09  8:42   ` Greg Kroah-Hartman
2019-08-09 15:37 ` Guenter Roeck
2019-08-09 15:48   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190808190453.926761189@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=asolokha@kb.kras.ru \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).