Message ID | 20210909095324.12978-4-LinoSanfilippo@gmx.de (mailing list archive) |
---|---|
State | Not Applicable |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Fix for KSZ DSA switch shutdown | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Guessed tree name to be net-next |
netdev/subject_prefix | warning | Target tree name not specified in the subject |
netdev/cc_maintainers | success | CCed 9 of 9 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 24 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 854e25f43fa7..5db82898b737 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -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(-)