@@ -229,6 +229,16 @@ static int ksz9477_reset_switch(struct ksz_device *dev)
return 0;
}
+static int ksz9477_shutdown(struct ksz_device *dev)
+{
+ int ret;
+
+ ret = ksz9477_reset_switch(dev);
+ ksz_switch_shutdown(dev);
+
+ return ret;
+}
+
static void ksz9477_r_mib_cnt(struct ksz_device *dev, int port, u16 addr,
u64 *cnt)
{
@@ -1601,7 +1611,7 @@ static const struct ksz_dev_ops ksz9477_dev_ops = {
.r_mib_pkt = ksz9477_r_mib_pkt,
.freeze_mib = ksz9477_freeze_mib,
.port_init_cnt = ksz9477_port_init_cnt,
- .shutdown = ksz9477_reset_switch,
+ .shutdown = ksz9477_shutdown,
.detect = ksz9477_switch_detect,
.init = ksz9477_switch_init,
.exit = ksz9477_switch_exit,
Shutting down the system with registered KSZ9477 slave devices results in a system hang. Additionally the message "unregister_netdevice: waiting for ETH to become free. Usage count = X" is dumped into the kernel log (with ETH being the DSA master device and X the number of registered slave devices). The reason for this issue are pending references to the DSA master device which are still held by the slave devices at the time master device is unregistered. While these references are supposed to be released in ksz_switch_remove() this function never gets the chance to be called due to the earlier system hang at the master device deregistration. Fix this deadlock situation by deregistering the switch (and thus releasing the master device references) in the KSZ9477 shutdown handler. Since this handler is called before the master device deregistration all references to the master device are released at the time of deregistration and thus the deadlock does not occur. Signed-off-by: Lino Sanfilippo <LinoSanfilippo@gmx.de> --- drivers/net/dsa/microchip/ksz9477.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)