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: 12482843 X-Patchwork-Delegate: kuba@kernel.org 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).