sst-linux/drivers/net
David Oberhollenzer 5eaa143ba3 net: dsa: mv88e6xxx: propperly shutdown PPU re-enable timer on destroy
[ Upstream commit a58d882841a0750da3c482cd3d82432b1c7edb77 ]

The mv88e6xxx has an internal PPU that polls PHY state. If we want to
access the internal PHYs, we need to disable the PPU first. Because
that is a slow operation, a 10ms timer is used to re-enable it,
canceled with every access, so bulk operations effectively only
disable it once and re-enable it some 10ms after the last access.

If a PHY is accessed and then the mv88e6xxx module is removed before
the 10ms are up, the PPU re-enable ends up accessing a dangling pointer.

This especially affects probing during bootup. The MDIO bus and PHY
registration may succeed, but registration with the DSA framework
may fail later on (e.g. because the CPU port depends on another,
very slow device that isn't done probing yet, returning -EPROBE_DEFER).
In this case, probe() fails, but the MDIO subsystem may already have
accessed the MIDO bus or PHYs, arming the timer.

This is fixed as follows:
 - If probe fails after mv88e6xxx_phy_init(), make sure we also call
   mv88e6xxx_phy_destroy() before returning
 - In mv88e6xxx_remove(), make sure we do the teardown in the correct
   order, calling mv88e6xxx_phy_destroy() after unregistering the
   switch device.
 - In mv88e6xxx_phy_destroy(), destroy both the timer and the work item
   that the timer might schedule, synchronously waiting in case one of
   the callbacks already fired and destroying the timer first, before
   waiting for the work item.
 - Access to the PPU is guarded by a mutex, the worker acquires it
   with a mutex_trylock(), not proceeding with the expensive shutdown
   if that fails. We grab the mutex in mv88e6xxx_phy_destroy() to make
   sure the slow PPU shutdown is already done or won't even enter, when
   we wait for the work item.

Fixes: 2e5f032095 ("dsa: add support for the Marvell 88E6131 switch chip")
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Link: https://patch.msgid.link/20250401135705.92760-1-david.oberhollenzer@sigma-star.at
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-04-10 14:33:41 +02:00
..
appletalk
arcnet
bonding bonding: fix incorrect MAC address setting to receive NS messages 2025-03-28 21:58:49 +01:00
caif caif_virtio: fix wrong pointer check in cfv_probe() 2025-03-13 12:53:16 +01:00
can can: flexcan: disable transceiver during system PM 2025-03-28 21:59:00 +01:00
dsa net: dsa: mv88e6xxx: propperly shutdown PPU re-enable timer on destroy 2025-04-10 14:33:41 +02:00
ethernet net: mvpp2: Prevent parser TCAM memory corruption 2025-04-10 14:33:40 +02:00
fddi
fjes
hamradio
hippi
hyperv
ieee802154
ipa
ipvlan ipvlan: ensure network headers are in skb linear part 2025-03-07 16:56:45 +01:00
mctp net: mctp i2c: Copy headers if cloned 2025-03-28 21:58:49 +01:00
mdio
netdevsim
pcs
phy
plip
ppp ppp: Fix KMSAN uninit-value warning with bpf 2025-03-13 12:53:18 +01:00
pse-pd
slip
team
usb rndis_host: Flag RNDIS modems as WWAN devices 2025-04-10 14:33:37 +02:00
vmxnet3
vxlan
wan
wireguard
wireless wifi: brcmfmac: keep power during suspend if board requires it 2025-04-10 14:33:38 +02:00
wwan net: wwan: mhi_wwan_mbim: Silence sequence number glitch errors 2025-03-28 21:58:52 +01:00
xen-netback
amt.c
bareudp.c
dummy.c
eql.c
geneve.c geneve: Suppress list corruption splat in geneve_destroy_tunnels(). 2025-03-07 16:56:35 +01:00
gtp.c gtp: Suppress list corruption splat in gtp_net_exit_batch_rtnl(). 2025-03-07 16:56:35 +01:00
ifb.c
Kconfig
LICENSE.SRC
loopback.c net: loopback: Avoid sending IP packets without an Ethernet header 2025-03-07 16:56:43 +01:00
macsec.c
macvlan.c
macvtap.c
Makefile
mdio.c
mhi_net.c
mii.c
net_failover.c
netconsole.c
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c
Space.c
sungem_phy.c
tap.c
thunderbolt.c
tun.c
veth.c
virtio_net.c
vrf.c
vsockmon.c
xen-netfront.c