Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2366203pxb; Fri, 17 Sep 2021 08:14:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwp2DE5Dpj6cgIfsxTs7cgB8Ge2rYIAqv91JWXA2EfZFthHRmlIBc0etKW0RcwGniYhj3Ge X-Received: by 2002:a92:90a:: with SMTP id y10mr8511706ilg.108.1631891654339; Fri, 17 Sep 2021 08:14:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1631891654; cv=pass; d=google.com; s=arc-20160816; b=pmR0b1855N91IiFqZ/KwcZhh487CEXv4tn9IBJUvKHAdPxGn75ExToZaMD06QX2aNI kFBbNnCFnO5E23nCl45iZCWyknItjEgKpfBq/FYo3Cea6tUfWVgtk0UpY4C5rR6eQkqr KkFTJ2CCZkimVwi7HilGgN03BBmCBfvbTOnVqyjQZHlCQsxAHFKccyEuv4M9okmesHGz rqGWADzGNWt0GT6WsmcFdouZh5TKuDsoAb4ms32NAXs5yQ4AVLi+n9D0TRdmMW61opjM Q40SLIx0sLTAG/tj6QXk8UAN1bKtpi+KSRYGMHFOQfbq9B4s3YSqPMrJxhaCKCQQbXqm iI5A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=LwJ59Yi5GcAxZQXwokAFNKOBXp7/+wq5dkINbobpu/0=; b=sgFBPsWIQWXlE0krJtd5AqelNSURromhl11vYeoqYaGnQTVCIgzwMrEPH9ZrfZgBw3 nkP4zhV9478RJso0E0trIovKgypLtrFs9LT0EA1X4yMLCbDMR+EoD0yzmL8cnL3fy4Z8 iuRYI8tz6aJPitcgDAgQUpSH1N+nay+4iKH+/RBEtnQ0rTNFzTevEjt9d0on/rjAUtQo zL+mRgjlcYX16IadS4TceQ4cx0yocgZz48EBmAd7BJ2bfW7QOFhvPvNpuNMpiw/ik9xb MAdYv9aITGQNohWfmVC/XvCnx1tbKds351eoxj3NRTa+y6NUBwqQF/34yDY5ERMZ+prS uxGA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=H6jI6dAH; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 10si6343900ilq.33.2021.09.17.08.14.00; Fri, 17 Sep 2021 08:14:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=H6jI6dAH; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344189AbhIQNge (ORCPT + 99 others); Fri, 17 Sep 2021 09:36:34 -0400 Received: from mail-eopbgr80082.outbound.protection.outlook.com ([40.107.8.82]:4832 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S244662AbhIQNgN (ORCPT ); Fri, 17 Sep 2021 09:36:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n+PlaIi9j8fWHPH3lEECH5H/AcUC35WfCZBeq8FrbHo3+Yr9w64jezNZfgrKLwPBWyyOtkw2EOwUOLU8wA/R2AUyJl1xFYfsTHRGQXrXH0vKCk1pVYBEuy35p0V2804bZlNqojvXLGGxPmUaMqj62chZWyXYZfZn5RS15EX8irw/uk9U1NPhm7pbTuU4fIUv4Vd3Z6hDUmfRXqiGIF8muvrF8mG7ZrQ51nqZ5TWKgeTYuW1Shqz0nn0r7AcpClDIG3vJoEXh6oH9lXrl+S1oaKjIoaGI9+5fILUgpJRvIJ2CrbmP4dD5s6IafqYlc2kmy4J0h503VT7axWvpIfDgEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=LwJ59Yi5GcAxZQXwokAFNKOBXp7/+wq5dkINbobpu/0=; b=k8CwbDBNpMcBdR4wwCXeF7JVfL+dvY0DsCxngiyO8hZpQMEb94AI62eEIeEesd9csdswGjS8YBRH5JKQaNRFGBAuAwpD9xLYOvpUtAv61t2guNCqIQ1pJOW2YsP0R64J3At/ezZJfmIUZO61ObFxIp5+pKhsSjiIm/HoVzUnEL4acppcCTKC3/yA0jurybOwIhdSbAp39faxfwZzNYwXnyUnqnKESJpJWGNvzgm5QVl9aZl0vb32aCPjSYk/NCGlNanIjmR65IxME0g3b10ZL1ceOMr29XrO4XHBWI/v38tzFKWenwqaVRMZa9b5c9QFjjUx62wDtmwYrjDfN4jlaQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LwJ59Yi5GcAxZQXwokAFNKOBXp7/+wq5dkINbobpu/0=; b=H6jI6dAH8UKFTvd246b2+o+TBnns/uIzpJKomuHQIEkrzzJNkak07A6SzdFUP5FcuX4L/cJIEeJGLCJjg6r+PzVf/ORI1J1uLTuroJe/1yLB46BtkfOht1Jws2XuwKv2mylJi7MS609o6fvulhK1AUBlbMuMkedjKbnLlbIEBgw= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VE1PR04MB7341.eurprd04.prod.outlook.com (2603:10a6:800:1a6::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16; Fri, 17 Sep 2021 13:34:50 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4500.019; Fri, 17 Sep 2021 13:34:49 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , UNGLinuxDriver@microchip.com, Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , Claudiu Manoil , Alexandre Belloni , Linus Walleij , George McCollister , Heiner Kallweit , Russell King , Oleksij Rempel , Michael Grzeschik , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Lino Sanfilippo Subject: [PATCH v2 net 0/5] Make DSA switch drivers compatible with masters which unregister on shutdown Date: Fri, 17 Sep 2021 16:34:31 +0300 Message-Id: <20210917133436.553995-1-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: AM0PR02CA0199.eurprd02.prod.outlook.com (2603:10a6:20b:28f::6) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (82.78.148.104) by AM0PR02CA0199.eurprd02.prod.outlook.com (2603:10a6:20b:28f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Fri, 17 Sep 2021 13:34:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f0877e87-c970-44a4-c9fa-08d979dfec33 X-MS-TrafficTypeDiagnostic: VE1PR04MB7341: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pA5rVuGRVWwTPFsCruyyEbMKABYdPTfH+tVSetcF+tKfBdeCKBF9hXbWEtDUp9iY8CXHC31CgFvN4zg8p19BMNBAW+t6uNZC+kHREhGR59GhvA5sc8/YSfPM6sQISKeKeTNy4KN6NzrOXMv0nBbibsejqr17Eq83orkANDH6itayQ0ACxIdhdYuPhm+Bn9vM7kD2MhFGyPRxa1ElOAFtVucfR4gGk1nqCYy2L/xofiZxZCu1gJD4JN5r4OZ5woKCsKKkSNKYHy8bBwctFI3Dmj1Z8EnouN3mEh7TwV+CFmMlLWfXV+HYjr8OjDGQGODlVUUrC5rqcUabGqe7gkwUMWf7wsLsrt8HHzfHSmiytdGvE0qmAUOtI32SyBswdcq0cUADZE3rK9y2lxoinTCsBX18shn0K1mwJALenP4bXjLFKE+6EviMdkHLDORIGwGLshrstkNK70BQSmn9cfE3VOmTuAQkjBmOiQG8pat/Gfjw/S60sIeRa0e0o5HAlxMlQ3KYmRbYU3b2wtawc+5Ajil8Dc/DLNrEyEm7MFr6Y9E+gF5hN7QuKI1a1na3znpVD/dkoLO4bqn0StZu/nhOkvH/oRywjpm905yeA3ax6fQZwkDMWu4BdIChTwXeoTyNldSSVsupLMRN1lRKobM0z9nnNz22agiih5dxfVbFBe9azgk5EY1t+piEQFa5/aHJLNCM372anugfR1p6oAJ9E6/q6ynOfsBdpO2Qa0k2T1qibCZENGNYIz/pd94Goa4o4W/Cc3Fs1nFs5VdgyLpJkn8eBIAV2A8QXnHfPp5yLtM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(366004)(376002)(136003)(39860400002)(346002)(54906003)(316002)(38100700002)(38350700002)(36756003)(44832011)(2616005)(86362001)(6916009)(66556008)(478600001)(6512007)(6666004)(966005)(6486002)(8936002)(8676002)(26005)(1076003)(5660300002)(6506007)(52116002)(186003)(83380400001)(2906002)(4326008)(7416002)(66946007)(66476007)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?XMMrQTp5K6ZGssd76fTOirnwT4YE75zHdQPyA562bCQikv2KIKRNtn5Lbp85?= =?us-ascii?Q?lQZ+Ra/JvznuqMi6gx1cd/so/rBdRL7zQ6UkiBeZvfnbNdiHNIS3ToerbFIu?= =?us-ascii?Q?d07ZQgdzcFoJXoJeXNhTEmczYO2HmMFZS6VOw7axjStRwLnxE8v4MxssvGvf?= =?us-ascii?Q?wA1/0/Tr/Dvw3iTwcLwWyNKQqe4pTWT2P+bVKncx09aiY4kSXcCElswSXhdX?= =?us-ascii?Q?SFAX/gldmeXCwVfZ56vgJShm/JioyHgsPlpuof88u0n604nlBsLrOT5aMly2?= =?us-ascii?Q?Pyesw97EQPY+RoPTeTPts3lbEckWI+lUzktg+PCNRRO+OfCIngX338aml75I?= =?us-ascii?Q?r1WWBt5dkEYnLMAtSgZewlJprefle09vETlltwpH9Lzk0z/dFy9wbcwllv+6?= =?us-ascii?Q?oVdE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NeFgH3QK8vu?= =?us-ascii?Q?qzW/QvAZkXly6BF8723Nn9Af?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f0877e87-c970-44a4-c9fa-08d979dfec33 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2021 13:34:49.9119 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: koGjziAXM2XA+C6m/NmJ5uFamo/WrHSw+cyIKDNp9nijr4Q6q7CdUOGcyeJUx0UwRWG8dbzZtviwcAkT90vb3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7341 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changes in v2: - fix build for b53_mmap - use unregister_netdevice_many It was reported by Lino here: https://lore.kernel.org/netdev/20210909095324.12978-1-LinoSanfilippo@gmx.de/ that when the DSA master attempts to unregister its net_device on shutdown, DSA should prevent that operation from succeeding because it holds a reference to it. This hangs the shutdown process. This issue was essentially introduced in commit 2f1e8ea726e9 ("net: dsa: link interfaces with the DSA master to get rid of lockdep warnings"). The present series patches all DSA drivers to handle that case, depending on whether those drivers were introduced before or after the offending commit, a different Fixes: tag is specified for them. The approach taken by this series solves the issue in essentially the same way as Lino's patches, except for three key differences: - this series takes a more minimal approach in what is done on shutdown, we do not attempt a full tree teardown as that is not strictly necessary. I might revisit this if there are compelling reasons to do otherwise - this series fixes the issues for all DSA drivers, not just KSZ9897 - this series works even if the ->remove driver method gets called for the same device too, not just ->shutdown. This is really possible to happen for SPI device drivers, and potentially possible for other bus device drivers too. Vladimir Oltean (5): net: mdio: introduce a shutdown method to mdio device drivers net: dsa: be compatible with masters which unregister on shutdown net: dsa: hellcreek: be compatible with masters which unregister on shutdown net: dsa: microchip: ksz8863: be compatible with masters which unregister on shutdown net: dsa: xrs700x: be compatible with masters which unregister on shutdown drivers/net/dsa/b53/b53_mdio.c | 21 ++++++++- drivers/net/dsa/b53/b53_mmap.c | 13 ++++++ drivers/net/dsa/b53/b53_priv.h | 5 +++ drivers/net/dsa/b53/b53_spi.c | 13 ++++++ drivers/net/dsa/b53/b53_srab.c | 21 ++++++++- drivers/net/dsa/bcm_sf2.c | 12 ++++++ drivers/net/dsa/dsa_loop.c | 22 +++++++++- drivers/net/dsa/hirschmann/hellcreek.c | 16 +++++++ drivers/net/dsa/lan9303-core.c | 6 +++ drivers/net/dsa/lan9303.h | 1 + drivers/net/dsa/lan9303_i2c.c | 24 +++++++++-- drivers/net/dsa/lan9303_mdio.c | 15 +++++++ drivers/net/dsa/lantiq_gswip.c | 18 ++++++++ drivers/net/dsa/microchip/ksz8795_spi.c | 11 ++++- drivers/net/dsa/microchip/ksz8863_smi.c | 13 ++++++ drivers/net/dsa/microchip/ksz9477_i2c.c | 14 +++++- drivers/net/dsa/microchip/ksz9477_spi.c | 8 +++- drivers/net/dsa/mt7530.c | 18 ++++++++ drivers/net/dsa/mv88e6060.c | 18 ++++++++ drivers/net/dsa/mv88e6xxx/chip.c | 22 +++++++++- drivers/net/dsa/ocelot/felix_vsc9959.c | 20 ++++++++- drivers/net/dsa/ocelot/seville_vsc9953.c | 20 ++++++++- drivers/net/dsa/qca/ar9331.c | 18 ++++++++ drivers/net/dsa/qca8k.c | 18 ++++++++ drivers/net/dsa/realtek-smi-core.c | 20 ++++++++- drivers/net/dsa/sja1105/sja1105_main.c | 21 ++++++++- drivers/net/dsa/vitesse-vsc73xx-core.c | 6 +++ drivers/net/dsa/vitesse-vsc73xx-platform.c | 22 +++++++++- drivers/net/dsa/vitesse-vsc73xx-spi.c | 22 +++++++++- drivers/net/dsa/vitesse-vsc73xx.h | 1 + drivers/net/dsa/xrs700x/xrs700x.c | 6 +++ drivers/net/dsa/xrs700x/xrs700x.h | 1 + drivers/net/dsa/xrs700x/xrs700x_i2c.c | 18 ++++++++ drivers/net/dsa/xrs700x/xrs700x_mdio.c | 18 ++++++++ drivers/net/phy/mdio_device.c | 11 +++++ include/linux/mdio.h | 3 ++ include/net/dsa.h | 1 + net/dsa/dsa2.c | 50 ++++++++++++++++++++++ 38 files changed, 543 insertions(+), 24 deletions(-) -- 2.25.1