[PATCH 0/3] Fix for KSZ DSA switch shutdown

Lino Sanfilippo
2021-09-09T09:54:03Z

This patch series fixes a system hang I got each time i tried to shutdown
or reboot a system that uses a KSZ9897 as a DSA switch with a broadcom
GENET network device as the DSA master device. At the time the system hangs
the message "unregister_netdevice: waiting for eth0 to become free. Usage
count = 2." is dumped periodically to the console.

After some investigation I found the reason to be unreleased references to
the master device which are still held by the slave devices at the time the
system is shut down (I have two slave devices in use).

While these references are supposed to be released in ksz_switch_remove()
this function never gets the chance to be called due to the system hang at
the master device deregistration which happens before ksz_switch_remove()
is called.

The fix is to make sure that the master device references are already
released when the device is unregistered. For this reason PATCH1 provides
a new function dsa_tree_shutdown() that can be called by DSA drivers to
untear the DSA switch at shutdown. PATCH2 uses this function in a new
helper function for KSZ switches to properly shutdown the KSZ switch.
PATCH 3 uses the new helper function in the KSZ9477 shutdown handler.

Theses patches have been tested on a Raspberry PI 5.10 kernel with a
KSZ9897. The patches have been adjusted to apply against net-next and are
compile tested with next-next.

Lino Sanfilippo (3):
net: dsa: introduce function dsa_tree_shutdown()
net: dsa: microchip: provide the function ksz_switch_shutdown()
net: dsa: microchip: tear down DSA tree at system shutdown

drivers/net/dsa/microchip/ksz9477.c | 12 +++++++++++-
drivers/net/dsa/microchip/ksz_common.c | 13 +++++++++++++
drivers/net/dsa/microchip/ksz_common.h | 1 +
include/net/dsa.h | 1 +
net/dsa/dsa2.c | 8 ++++++++
5 files changed, 34 insertions(+), 1 deletion(-)

base-commit: 626bf91a292e2035af5b9d9cce35c5c138dfe06d
--
2.33.0