From patchwork Thu Sep 9 09:53:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 509116 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB9A8C433FE for ; Thu, 9 Sep 2021 09:54:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8883611AF for ; Thu, 9 Sep 2021 09:54:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233440AbhIIJzI (ORCPT ); Thu, 9 Sep 2021 05:55:08 -0400 Received: from mout.gmx.net ([212.227.17.20]:55077 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230145AbhIIJzH (ORCPT ); Thu, 9 Sep 2021 05:55:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1631181225; bh=lOMq6mIVSm791q9k547I0Pwd+JX/iGxJ0ezFxEmjQMU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=X7WMtApsAwTudpzbERjcgss498fi+47/LqseH1v7tp6wB3+K135WpMJ3JXlq9KZXF bg2PFt72n9RbuGWhr73Sw5rYSsXSJBq8C0X/O4AMz+EK5I7+/hqFMHeHhhiE+HhlVf pLYWSB5j53ujoEJS/LOAJ79Wtgm8pkDd8s+kBvks= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([46.223.119.124]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M89L1-1mK81S2AOh-005JPk; Thu, 09 Sep 2021 11:53:45 +0200 From: Lino Sanfilippo To: olteanv@gmail.com Cc: p.rosenberger@kunbus.com, woojung.huh@microchip.com, UNGLinuxDriver@microchip.com, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Lino Sanfilippo Subject: [PATCH 1/3] net: dsa: introduce function dsa_tree_shutdown() Date: Thu, 9 Sep 2021 11:53:22 +0200 Message-Id: <20210909095324.12978-2-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210909095324.12978-1-LinoSanfilippo@gmx.de> References: <20210909095324.12978-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:zY7aPPcJ0rmWg4P/dSuY7pJFB0odksbjtzKJhmdm/EzodkWhJ3T uzskNG0ufBfkEC+ciIyvyc2Xxv96ezfWkTR0ZPZbS0U2EfNNQUk8OB9vAWgPUPM7LJUULTR IdsDIWeknCES1pVfsZhZknxCYroHwG31KNoty/F/P2QKLhOLBj3Nf4tX3z4zn2vTKARbrsJ IgQW4hVV0QFN7W78HVj2w== X-UI-Out-Filterresults: notjunk:1; V03:K0:tliuW64YXfo=:2lwrRn40DgF3MBgCVKhleE HxENN0vqsKNMtOzaBwm+9C2w13Xxi+21OJ8Y0CgRJ6KNFQT83zKIeO9KUZCiXy/r7zLondTNG ndMcaMSccKi1cNA6TyI6Il1tigoRRYqlniXPkz/AhfFYvZZAHWgEWJZ0pgWdhTVB80URlofTT 1CBDrRbQ5kPJPpIi50Wr8J17IK42Jy4xJfQvXxXGUKWULCoSRPsu1arsJAJDXQfgMqVWLFlwh XUt4m40QLdPRJWbihch0HqXEK0BQb4CkB+uXBuHg0bCj6GVFo7Mh2ndl5enaPFbr82vahRqFl nGsR+jnNH1Ap++vdhHzPN9ZKetojvY8Jsnlx3W20bSXBSBfJbR8ITCjSVaDeVmbhMCUcZ7rpH +M9NqvmXXs4AO6JjlbRbdOfT3pUJHW36g5xJMukKqwA7pkYRpKgkeBclUdWz+uio07nRnglcm AKkWMfMIBtb35efrNhsG9iLhWJRLTRWxj3a6cXNmuEfc1SwDk8928q3sHMDqOYj+ciUM7Ms7X MBeDP5o2hKSIhoWg044XFxgXoTdVUK0GGnfyhVLc6eP1IJhG1VPeWK9I/JBmmfGH+k0/cJYdM I4D2t3FhXG1YXnNNmUQ+1rfFWPlfW/Pr7DHhXle7wuo/47knD3iP00vVNXC+bFJ4zsQF4oKak Bx+PGV1S3ndlPkjIdipHw3Wg88oFmEv/+a3Sp6/TuhQV1fDXrwsGjNf2BpbQw/wijkXtKCVcS 1eT31IBWH2bYKIV3hDmUgwjtx5xhdLYEq6tDlpFwGUCQJfRYpJctXaZh7wI2yiRB5nHogWOnU JjKrFw6IqNqTw9MxTUw27i83zsKiXxr0IE2qmzrbzI/9Rt5U8uXLVm0qimqXfMDgD2BmXd7bM Ccok5xnvFeKDwgnYpBqpkIi9f4T9bxwLBG8WmqTheJSTNP34rR2j8oPWbnooPUXX+XTlnuVxK 7M7eB/b/q87RxyqWJaZA/Vb5XWCWdvmOrVtg+5zT7PBXDKxyAA9nwLZUZS0EW/xLrWaEXiEV9 b38eLQLg2BVcRkCIc97OxKKfaYeyEbzpFVAv6Ajvbun5zY+WLU/v/F1rxv8rRrRILND4Yfa7P W+bmeggn3mZYIQ= Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Provide the function dsa_tree_shutdown() that can be called by DSA drivers to tear down the DSA tree. This is particularly useful for shutdown handlers to make sure that the DSA tree is torn down (and thus all references to the master device are released) before the master device is deregistered. Signed-off-by: Lino Sanfilippo --- include/net/dsa.h | 1 + net/dsa/dsa2.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index f9a17145255a..7d4094faaa3a 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -1039,6 +1039,7 @@ static inline int dsa_ndo_eth_ioctl(struct net_device *dev, struct ifreq *ifr, } #endif +void dsa_tree_shutdown(struct dsa_switch_tree *dst); void dsa_unregister_switch(struct dsa_switch *ds); int dsa_register_switch(struct dsa_switch *ds); struct dsa_switch *dsa_switch_find(int tree_index, int sw_index); diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 1b2b25d7bd02..0588581f6531 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -1066,6 +1066,14 @@ static void dsa_tree_teardown(struct dsa_switch_tree *dst) dst->setup = false; } +void dsa_tree_shutdown(struct dsa_switch_tree *dst) +{ + mutex_lock(&dsa2_mutex); + dsa_tree_teardown(dst); + mutex_unlock(&dsa2_mutex); +} +EXPORT_SYMBOL_GPL(dsa_tree_shutdown); + /* Since the dsa/tagging sysfs device attribute is per master, the assumption * is that all DSA switches within a tree share the same tagger, otherwise * they would have formed disjoint trees (different "dsa,member" values). From patchwork Thu Sep 9 09:53:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 508712 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CADCCC4332F for ; Thu, 9 Sep 2021 09:54:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AFDEF61209 for ; Thu, 9 Sep 2021 09:54:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233617AbhIIJzL (ORCPT ); Thu, 9 Sep 2021 05:55:11 -0400 Received: from mout.gmx.net ([212.227.17.22]:34135 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233298AbhIIJzI (ORCPT ); Thu, 9 Sep 2021 05:55:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1631181226; bh=s/Hv4I9PogZdkQVbwtwCM/QWYxj2wQTqldNgJavrJoI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=cEIMG72gAiMlxkREfNv0y8646lXORwA0hM4IPDxwf2IziBNYRSoxnEj1uorcgwdj9 EdYXf/vtlovblfDKYsTE211e8xbdMQF53oqwwYc5BL3lj+IK70oYC+Fh8jmWQuqox3 wEKzcFaBzFns+cHFD0pwgsXTMrmtnSBMlOz7aVAw= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([46.223.119.124]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M72sJ-1mJ1Yk3tHz-008cns; Thu, 09 Sep 2021 11:53:46 +0200 From: Lino Sanfilippo To: olteanv@gmail.com Cc: p.rosenberger@kunbus.com, woojung.huh@microchip.com, UNGLinuxDriver@microchip.com, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Lino Sanfilippo Subject: [PATCH 2/3] net: dsa: microchip: provide the function ksz_switch_shutdown() Date: Thu, 9 Sep 2021 11:53:23 +0200 Message-Id: <20210909095324.12978-3-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210909095324.12978-1-LinoSanfilippo@gmx.de> References: <20210909095324.12978-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:VscG5hDGP1HJbbSfBbJ2MFcsUsJYwimuUKYpw5D0TDrP6oMrB/E zn2IGBdFjpgnmXaw5zzuvCsRYjR51zZdTf0ONqBUed8m2TcK8yXWwyXyZ9OJKWPR+aM37m+ KtEfHPFa0UL4KBM5y0MoIMXwUhYZIwbb060HTH/76DjOyU7NeMbRGdQgU1b60x3jBLD18Ue w9vxNXbgK46GkmPJRkUyw== X-UI-Out-Filterresults: notjunk:1; V03:K0:9tf3mufsHwg=:3HVGNeYjp6DvIBt2TUvV5+ U65PEKjBzSqCgy7psLlqiY7/MP1UQDaVyNXy5wsSWWruK7chENeqY5kzrlLGDma41ESvD0vRm e9WgMvWXC+py49gkuL71T8/AjhPfgth0XqYhx2hRJ2fRx/ocZpfs8BuCPINp9LHMgt5IOkulI /dL7y6ywNjqB/sR+Qvrskh1j0KSPqhefhZyOrZr5RBuYigT1lY5YyNBu/Z5FArPBYIpZVmbmk RelCUyy7K0AwJQ3C3X7MhLTilIc5J0U44l/Rb86pHZaxDokeBxvN7QTOYib7NugGf9ppcI1CN GXnyGjKVkS+VuQ4nJFurh2zRJg59oNzqo8y/aJrrxB+4uoAU+ngJmAD6HhvE4maacKq3djYBh SF6YCN/0CJP6V+UbN0ROPRW1EqXazBasWcKOVM73hybJ855ufPU6ytJBJj5VXsrbQzm8o6SZn a5g2rO9/R2aZxZ1m93NJKVS8kriMUGu/zYrIXw2uEjwoaMvJmaiMGTRqB297WxBjET8nbVhyG Nz1M3NC2VE22kg7F9I053ZuALNhx7ZFtoEswcOvhDWwb6g4RyW/W8/MolDrZCcGfoWdAmhvGU jwl8mVYDDkC61BKR5Ub+TL9wnb0o/2CeyNuIvM67kOTs0sWq3z+K33YM8iirFXOZeAXZ6eiFb sG262GtfGljpMyi7SMKm3Lnw2+/9QqCCmZKnSjMICLM6pvsuLffQRNmQTRdLAUO/ABXyC4cYD /wXbsKsWuB01qc6l8Nvlohm/5k9coFccHZ9qU3/Nyk233VAmBeAkrd5L3bJERQ+3yQLeIsR6j XOd/c/fqOjL6Ik/DB8Msq/QvkLogO3Oif3IcnvM+UftZfuIBdjjqpt2WSC1pQ1xE0aufxQYOE NrF0XMJbaKdFDDc6Atul0yRY0n8L/rP4ogUSTe887eUdOHtPRJ4lRbf4KUyGHOqCPLMb9u/5t QP1X5cpx2WwnnEjWMY4tJ+FpefZhJ6XdoWkhcVKKPWC8hKoF0nN64yUC9RXQ0vDkeqcEkyet3 NaIE1cCWmXC0I3Qa/8Ug/pa4fCMtatln8T9vXIhBk5ZeSCwFsNe6wJsaCs0FCZ5glC1XxRBQu FpQiT6H6AUvOvg= Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Provide a function ksz_switch_shutdown() which properly shuts down the KSZ switch by stopping the mib_read worker thread and then tearing down the DSA tree. Signed-off-by: Lino Sanfilippo --- drivers/net/dsa/microchip/ksz_common.c | 13 +++++++++++++ drivers/net/dsa/microchip/ksz_common.h | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 1542bfb8b5e5..aaa5c45f4823 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -446,6 +446,19 @@ int ksz_switch_register(struct ksz_device *dev, } EXPORT_SYMBOL(ksz_switch_register); +void ksz_switch_shutdown(struct ksz_device *dev) +{ + struct dsa_switch *ds = dev->ds; + + /* timer started */ + if (dev->mib_read_interval) { + cancel_delayed_work_sync(&dev->mib_read); + dev->mib_read_interval = 0; + } + dsa_tree_shutdown(ds->dst); +} +EXPORT_SYMBOL(ksz_switch_shutdown); + void ksz_switch_remove(struct ksz_device *dev) { /* timer started */ diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 1597c63988b4..9986f6c4c1e7 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -143,6 +143,7 @@ struct ksz_device *ksz_switch_alloc(struct device *base, void *priv); int ksz_switch_register(struct ksz_device *dev, const struct ksz_dev_ops *ops); void ksz_switch_remove(struct ksz_device *dev); +void ksz_switch_shutdown(struct ksz_device *dev); int ksz8_switch_register(struct ksz_device *dev); int ksz9477_switch_register(struct ksz_device *dev); From patchwork Thu Sep 9 09:53:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 509115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D9F0C433FE for ; Thu, 9 Sep 2021 09:54:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 64815611C2 for ; Thu, 9 Sep 2021 09:54:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233720AbhIIJzM (ORCPT ); Thu, 9 Sep 2021 05:55:12 -0400 Received: from mout.gmx.net ([212.227.17.22]:53389 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233436AbhIIJzI (ORCPT ); Thu, 9 Sep 2021 05:55:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1631181226; bh=iAMRA7J7B75qAx18nV5A5l4I0o/uKALUFm0ZoKS/HHg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=cXAyqhcJyiqOIZsACbKqoinbmnr/7VmWILgGOkAg/JcAMRhT9LrLWIxdVzEDbBi6U pAt/tTzHtbO1tzX/Erk71p15XOaia5BG/eRmhPBvIH/yL+2oicH+d66eHZv1HeBWhW K5+8GlQ+N0af7tVTbrE4A9+rMfx9QOPutBVcIWiU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([46.223.119.124]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MVvPJ-1mXrXb1RCP-00RoLG; Thu, 09 Sep 2021 11:53:46 +0200 From: Lino Sanfilippo To: olteanv@gmail.com Cc: p.rosenberger@kunbus.com, woojung.huh@microchip.com, UNGLinuxDriver@microchip.com, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Lino Sanfilippo Subject: [PATCH 3/3] net: dsa: microchip: tear down DSA tree at system shutdown Date: Thu, 9 Sep 2021 11:53:24 +0200 Message-Id: <20210909095324.12978-4-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210909095324.12978-1-LinoSanfilippo@gmx.de> References: <20210909095324.12978-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:UbZPGZWtRgdxY+0Xbb+EY2aJRkm0/k/LthL4CtHbi2KZq/rfe0g Fw6SC7V+pEtF72erFJ9lBzjd4I4d6qlrM6r5T7OozRS0MmwIxLBXKd6hLP2ybcG8l/hghZk 9X0KZrHSOTQENyoXrNKalfn10SG+IfAb5tANNhuU/WhkuvZWbtAgwQNFwCZ1Inkx20NmKee ai9frIHEigrqU+9cb3l1w== X-UI-Out-Filterresults: notjunk:1; V03:K0:2B41uqs+kGA=:axrewgqKY8dNNzqw4KXZrU TOfdgrq5sJ5MmsARhKW7OYPoVrF/zBrdqQx3bPrI9/mpr/+uWMxU4Bh151t2Jb+TmkOJd62lu uo3hWF+mhABAVcRhwPtdt1Q/OZ5MgTB3WfcZYtKMxv1rWnpVemVtWREyf7hrjUq9+FRJTkoII Yj8YkRTTGd2NKICe6hBHfhihRB4WES9M01oCHG7UMKhQ0K1XmtLAz8Pmw0fWj3uqXjomVvx11 rtNCQb8AgJ0OtuapliDJh1K8qKTyprQxlZcY94ZLpQUE85gduwZaLmqVOh5Uy7Z/RdSvZ/fbe Vvkf+3MQeYuBpdlqpULtxGuzjKS8UPDHoKMHOciDhyleKur5z+m6ufsMkeQbVg1UV86/nzBbd MeW6PvrM5zlDT/loPyiGSfj2zdDI/zMMHcOCmXOtnooi8saoSQKV9fm9dF+qi6B6tTTuFTmG/ EDUSBfg8Go05YqDh/mJrHSH0LG3s2D7N13cpRZGFxvMp0IqppQiE6VTPGgi431bmeHHmV0DUg K7G5jp/J1Op6Si+c0vpAWzrXZmtadF6pLCu1t2Vdw6y++eDzsj64EaFvW54H4NTg1tmWaB7n9 +J0SRD0l56M0Bhf2t25z6wT2937lB7SVueH2ilQ3j5xMNC41/aWk/2DJFxcNP2Io5CbWkheVe lj2fbwyagb6H5wqRJaiqXT0Ft+6U32aR60+h/A+wYHCsKlJR5LurVzB2+41PaZahaRsfv4BTF w6h7QRv2PJIhEWTtGZt7TRJPGGxYrSki9N7gC6TLKvyat1od24Lj+kkxDhtshGYCGLlDyGG73 p0no8uI5erZk2hRPg6Dxd4fnCKXu5yyd2LqdsTQftr6pZgfo3sYYg8DZxEGlepcu5Fs0EdMvt 6Tu3yGvQkPTOkMJv54EPO2eOkA1K2h7UyFpn7MzrM5vNfz4n3/5qjsHhLh/UdW6r73oxsuKvE bTYTFw+jpAJZinIZ51MyUKHoR9fMDKUy7KyobsAwFD2qNJJVE6NPACk9CeV4s8qoTmv1e1qy8 FRjJtRkMS4pkltM7bzEa+5Wll1MjUx/VgLoeWpMlykxEUqBK1erZXR9dN4mAuAvC6+SpMIDua vE/Vy92+x9fzIY= Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- drivers/net/dsa/microchip/ksz9477.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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,