From patchwork Fri Oct 22 14:16:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12577927 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C439CC4332F for ; Fri, 22 Oct 2021 14:17:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B02436101C for ; Fri, 22 Oct 2021 14:17:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233006AbhJVOUK (ORCPT ); Fri, 22 Oct 2021 10:20:10 -0400 Received: from mail-eopbgr60040.outbound.protection.outlook.com ([40.107.6.40]:37344 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232974AbhJVOUI (ORCPT ); Fri, 22 Oct 2021 10:20:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jWyfdRfiIbGW5/a0+HfHfagdTnZ31nOsuItMOmkh6zJzq+gKMVQm3AWx+TS7smWgvXCJYY9viNLWe9GoStgXgDqWJiuJY2YhAz/NdtldLGJY4TZqcpfgp3mXmvtqkXJOaaXhz91r0nCAKRVQ/aBx7JeauzJFZKj+0KxBXbq5jLpARMiC1faLxVCH1KOJP4fkpEI5DHqkX9e1rh6ouheGzhS5YHbbLI46wrNhjDInO9xm1OxzfBOVivTiJWjen8Yz2xDZ8G3AJPsFbekpdf97T3O+gYW2IcwYQIMb6Gslp3TQw7HMn7PuortbWN7wJrOw6V9S/aP62bspf3U+EY9K2A== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uXPQ1kGmLDc4MxjhE3mZ9yd1U45r/8dJzMYU0u1a4cU=; b=SfKYXi3W8Bog0Tr2EU9wf6sX+OhGoie6CXT+VOeD8U7Z43wqII5Xeg8Pg6X6/2ZOZp9+sYR6JMJlwW+VB1O3jxK1sYjaorjAxG4mGNzBC6Vc2liUbMUeIX0lnkR8lpnAzyBmoRSAjQb7ansgS3mcsne4ZM490TfNNEY0l1VNwLzFhYW+DzO5cwR1mQR02vrINiQzZ0uKoYtKv7CotrPOED2GJxCaeixw4mnqDuQG31pcXhoS0N3ptJVPusRvg5ZXBMDLPBsC/9inJeY6ZXEk0rHprHjMpwEWtgcFgdkyQYFlmlmKoSJrj+SHFPEp1j20fnCoJNcJ3qxm0tWWHW29ug== 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=uXPQ1kGmLDc4MxjhE3mZ9yd1U45r/8dJzMYU0u1a4cU=; b=pIrq/cA4O7cuejio4ZXBhyKdA9E0hruCL3nWSDOIEn6LQiAmBZJpGlL/5vJur2q+SDQzT1EqRywh3gRqGbT5IqpYve06ixOZVOiGXYpDrQ5NTHNU8sZCw9pP1N+KbjIZhPFzOKxezxKoySvIcXtJ4rSLeMRmtXC977RWexZz0s4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3406.eurprd04.prod.outlook.com (2603:10a6:803:c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Fri, 22 Oct 2021 14:17:49 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4%5]) with mapi id 15.20.4608.018; Fri, 22 Oct 2021 14:17:49 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean , UNGLinuxDriver@microchip.com, DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Alexandre Belloni , George McCollister , John Crispin , Aleksander Jan Bajkowski , Egil Hjelmeland , Oleksij Rempel , Prasanna Vengateshan , Ansuel Smith , =?utf-8?q?Alvin_=C5=A0ipraga?= Subject: [PATCH v2 net-next 1/9] net: dsa: sja1105: wait for dynamic config command completion on writes too Date: Fri, 22 Oct 2021 17:16:08 +0300 Message-Id: <20211022141616.2088304-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022141616.2088304-1-vladimir.oltean@nxp.com> References: <20211022141616.2088304-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0159.eurprd02.prod.outlook.com (2603:10a6:20b:28d::26) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 Received: from localhost.localdomain (188.25.174.251) by AM0PR02CA0159.eurprd02.prod.outlook.com (2603:10a6:20b:28d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 14:17:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7449d8bd-16e6-4735-88e6-08d99566b9e0 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3406: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QIY8hlXDmfaEtbTn1IJKNQSipxZDy84xh9ynhrpYDuHBytQDE0zP5Ay7nZmkN9pALcHGOj2axYAdgCUtaxetu75hGaL8wKQzS0Wu+EG3Jof+JKROUYXO7rKkvFN5rApKZ9aRKRtKbUIFNeLUnSQhETA9jcIfh5TLzX597NSOuTzhU+ZxrqY1HY5wYTqBxvOpF87qHxBPleYisHqdW3a2PzORIAXEUqXKKTqsTM5tcr68rK+4wriXW0jCBw0JJXczgXHhPLzXteLpOeF0eXv/mdFL0/FHnVu4NfFM9fuXqDEto4S4VGyUlSHc75ASdv3Uvq0g+wm6boRWYjq70dWEJi3B0YqHpjdQjQIWF9p6oRb3ZG8h4irGYx0h4r5tWQAQFBoa4tMCY0o3L92W3RAYO13ND8jfIfyE11mugSGwuuHq545a6l1kvcJYmvh4P1W11Fzlss7phCqnDyB2MtNf1eFxi4nnaPa1IgW/6DAJ1L8OE2J0ziDcRbf/kQtkbfqw6eiwucOUZ9ChsgmGPXlXEcZrkVeVhy7qLYl4ytKy+O/UxRdigQSI1Gf3y5xmtii8youH8TjCzQOUEEbXtCraGa6kLfXTyyz1KxjJCFR1g9VuzeH0LT/3ULaGWcf85nrEwnfw8cHoPnLyTQb4e49qFYMX0Dt/WMOafXB40WHv3GYBJgKdr/+1BX7bixJ+o3edXa8jl62IDD1mJmUVATNxng== 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)(366004)(7416002)(8936002)(44832011)(38350700002)(6916009)(956004)(83380400001)(54906003)(66556008)(508600001)(66476007)(66946007)(6512007)(86362001)(4326008)(6486002)(52116002)(5660300002)(2616005)(316002)(6506007)(1076003)(8676002)(36756003)(2906002)(186003)(38100700002)(26005)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 36E+/rtCU7WvFpS8wMOD/yMkgaDvNVH7qIMA4Y9U+7JQ4KZD4bxMzS4zz6gBUyVGStB5jkFjqyuxrYI+Y+P83vTM0TOHt18oL6VjxGvXrhx422P4o7RGQpKT6E749i9lPIBKxae08O7IpP8WQZJwSMOcyGfCgXQJkpoVqxZiJINRFuylEqvswSV9fIXiU4Obj2U4GEVArg35ITCZhuW4jZhNuNhrthL+Z2Iqx9Hh2lxAwzXhrDTU8Tzf7W3l+O8RZXEK51Uhbsugk0Z5X43yB6rP1Y5n88yLdRjLcdozN4ddAUHKqonO4sihUKcpHZ9qP709CIncDOeT/v2LLyffmtctZVUzvIhKLsp712LMYBpGPGTRUTZPRYpc6jitdAjgW7h+Lv1PLVRtT39YxNgPJ49kQpix3hMFNRxQMcHKryeSUnqTDWfGgwQG/Z1gKYgTrI1oyooBXI1vn20W9lPnCRlWGjCQLoLt2G/sJgQbWp6WBL8Tcm9ZEk6SiyAhD05GFJmHm95wdfmxG9h9r8DRnFjeh9cw1e33oLFsdJEZysWglQ8qrOcyOI6m/k0GUGj3XB7jfk57+c2E7p7w2Dgz+s8QNJeBnqwHfU44SUtqBCDLF6hRv4ebOfMtKzix3QCdiwC442V2eD0h1Hz7ksaGYcOdsk/zQOdxjdyq6qRBef1GyJMENLMz8uNUFkkSXRbLau9RP3ReOnnN2Dp1KCah+ygT6DoR98rnUpPLZ2sNyzRxu9kxBMAGzXcS2Tjglgp2l/JJAw1BawOvnufhH1MtM3pVk6U02y5Zjb/zopmEGHiemLu3GY2Y2ThLZg2dSBTQvPpP68Vc2QxO8KZb8sF7zIegYZHhzjKRL3LYm6yt4QYqsDsBhwHdAVydX6v28y0qc0J2L+pfHgouPOeGEduv8JOHalQjOChX3q9yHoOv6sU/IZzyBqGs2jb2wXam78VNl5LUK839t4nvJ17qNHacT3HsTkPa3OTj5UsDjj55AMSK/6vk3cAq1fJN6mQkY/Tk81pdx/SUdbRzi4RyUTOkTCXNKE0zuYmieUm3ZZ/k4b4gYGAg7fzziISUevOqpD+XXaxfdFfMaHrYefvVZvjAdrIkgfncgi+QUPmXycqbJG1ORxjeIt+0gQWLUeg89YSs7UhNErTY5g1nxxLz/ocgs/Ro6fqTH7Fd02nyI1kchohizRhnuZytFjq95OzcrSoRaoPsFfR1Pm9NUZHHnYV4dEBBUFGVsUHdn7aLGg+cg67axabuardtmVNIGeJFmsW3a0+tGeNTuEf2TOoxRqCW8ib5CpgaopwzFJA0f3zXfOgtlT7js84Ztsz8E8je3b6Sq/mXNHN4PfNpzDrj9UZa4+6/i5euOjGnW3c0W0BdBxUKPCg/blFhLWTgue9/z9FfmbRcorqKvA+lXiEtRkQOpCsmY1e4bGy4rjUY3nNXzUmXt3HaTDQfP8GTLUqYVyII X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7449d8bd-16e6-4735-88e6-08d99566b9e0 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 14:17:48.8707 (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: vladimir.oltean@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3406 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The hardware manual says that software should attempt a new dynamic config access (be it a a write or a read-back) only while the VALID bit is cleared. The VALID bit is set by software to 1, and it remains set as long as the hardware is still processing the request. Currently the driver only polls for the command completion only for reads, because that's when we need the actual data read back. Writes have been more or less "asynchronous", although this has never been an observable issue. This change makes sja1105_dynamic_config_write poll the VALID bit as well, to absolutely ensure that a follow-up access to the static config finds the VALID bit cleared. So VALID means "work in progress", while VALIDENT means "entry being read is valid". On reads we check the VALIDENT bit too, while on writes that bit is not always defined. So we need to factor it out of the loop, and make the loop provide back the unpacked command structure, so that sja1105_dynamic_config_read can check the VALIDENT bit. The change also attempts to convert the open-coded loop to use the read_poll_timeout macro, since I know this will come up during review. It's more code, but hey, it uses read_poll_timeout! Tested on SJA1105T, SJA1105S, SJA1110A. Signed-off-by: Vladimir Oltean --- .../net/dsa/sja1105/sja1105_dynamic_config.c | 81 ++++++++++++++----- 1 file changed, 59 insertions(+), 22 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_dynamic_config.c b/drivers/net/dsa/sja1105/sja1105_dynamic_config.c index f2049f52833c..32ec34f181de 100644 --- a/drivers/net/dsa/sja1105/sja1105_dynamic_config.c +++ b/drivers/net/dsa/sja1105/sja1105_dynamic_config.c @@ -1170,6 +1170,56 @@ const struct sja1105_dynamic_table_ops sja1110_dyn_ops[BLK_IDX_MAX_DYN] = { }, }; +#define SJA1105_DYNAMIC_CONFIG_SLEEP_US 10 +#define SJA1105_DYNAMIC_CONFIG_TIMEOUT_US 100000 + +static int +sja1105_dynamic_config_poll_valid(struct sja1105_private *priv, + struct sja1105_dyn_cmd *cmd, + const struct sja1105_dynamic_table_ops *ops) +{ + u8 packed_buf[SJA1105_MAX_DYN_CMD_SIZE] = {}; + int rc; + + /* We don't _need_ to read the full entry, just the command area which + * is a fixed SJA1105_SIZE_DYN_CMD. But our cmd_packing() API expects a + * buffer that contains the full entry too. Additionally, our API + * doesn't really know how many bytes into the buffer does the command + * area really begin. So just read back the whole entry. + */ + rc = sja1105_xfer_buf(priv, SPI_READ, ops->addr, packed_buf, + ops->packed_size); + if (rc) + return rc; + + /* Unpack the command structure, and return it to the caller in case it + * needs to perform further checks on it (VALIDENT). + */ + memset(cmd, 0, sizeof(*cmd)); + ops->cmd_packing(packed_buf, cmd, UNPACK); + + /* Hardware hasn't cleared VALID => still working on it */ + return cmd->valid ? -EAGAIN : 0; +} + +/* Poll the dynamic config entry's control area until the hardware has + * cleared the VALID bit, which means we have confirmation that it has + * finished processing the command. + */ +static int +sja1105_dynamic_config_wait_complete(struct sja1105_private *priv, + struct sja1105_dyn_cmd *cmd, + const struct sja1105_dynamic_table_ops *ops) +{ + int rc; + + return read_poll_timeout(sja1105_dynamic_config_poll_valid, + rc, rc != -EAGAIN, + SJA1105_DYNAMIC_CONFIG_SLEEP_US, + SJA1105_DYNAMIC_CONFIG_TIMEOUT_US, + false, priv, cmd, ops); +} + /* Provides read access to the settings through the dynamic interface * of the switch. * @blk_idx is used as key to select from the sja1105_dynamic_table_ops. @@ -1196,7 +1246,6 @@ int sja1105_dynamic_config_read(struct sja1105_private *priv, struct sja1105_dyn_cmd cmd = {0}; /* SPI payload buffer */ u8 packed_buf[SJA1105_MAX_DYN_CMD_SIZE] = {0}; - int retries = 3; int rc; if (blk_idx >= BLK_IDX_MAX_DYN) @@ -1239,28 +1288,12 @@ int sja1105_dynamic_config_read(struct sja1105_private *priv, if (rc < 0) return rc; - /* Loop until we have confirmation that hardware has finished - * processing the command and has cleared the VALID field - */ - do { - memset(packed_buf, 0, ops->packed_size); - - /* Retrieve the read operation's result */ - rc = sja1105_xfer_buf(priv, SPI_READ, ops->addr, packed_buf, - ops->packed_size); - if (rc < 0) - return rc; - - cmd = (struct sja1105_dyn_cmd) {0}; - ops->cmd_packing(packed_buf, &cmd, UNPACK); - - if (!cmd.valident && !(ops->access & OP_VALID_ANYWAY)) - return -ENOENT; - cpu_relax(); - } while (cmd.valid && --retries); + rc = sja1105_dynamic_config_wait_complete(priv, &cmd, ops); + if (rc < 0) + return rc; - if (cmd.valid) - return -ETIMEDOUT; + if (!cmd.valident && !(ops->access & OP_VALID_ANYWAY)) + return -ENOENT; /* Don't dereference possibly NULL pointer - maybe caller * only wanted to see whether the entry existed or not. @@ -1321,6 +1354,10 @@ int sja1105_dynamic_config_write(struct sja1105_private *priv, if (rc < 0) return rc; + rc = sja1105_dynamic_config_wait_complete(priv, &cmd, ops); + if (rc < 0) + return rc; + cmd = (struct sja1105_dyn_cmd) {0}; ops->cmd_packing(packed_buf, &cmd, UNPACK); if (cmd.errors) From patchwork Fri Oct 22 14:16:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12577929 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F367CC433EF for ; Fri, 22 Oct 2021 14:17:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D86D16101C for ; Fri, 22 Oct 2021 14:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233054AbhJVOUM (ORCPT ); Fri, 22 Oct 2021 10:20:12 -0400 Received: from mail-eopbgr60040.outbound.protection.outlook.com ([40.107.6.40]:37344 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232825AbhJVOUK (ORCPT ); Fri, 22 Oct 2021 10:20:10 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aZCIAi7RqK2InI0RUuadxWfpkPAyTJO5odE5vUCZndPg9cDoLQOuJhIYgQnrj+eGCiNi/RM+/c6LaIhThxeP277eT26+mAwN38QNQ2rVlI0Ud3ikUFTvCgL/pc9pIddUDNFaYoPnJDJm+SYiyHB6e3QPGf9klIxvmdCTXC1ExfPHPyZua2VDv1I1guEIfBK7eh4B7hEH7vegG9G5Lsba3usMePhtgi2949Fug946Sgf2f2e79sqmLzqSGLriK9dhAKrE+K7SZ/x1Vp1PE22cdr7S3A54BBoXfS0bcvUVIXFK7zDXT8npEubAKnRUlE9QBbM39sMBDJYp+94X0hlthw== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=O+b+nnj4MngZr97T0VE4bizcVWlZgndCASvnj52NTuU=; b=k48gV3y2Bb8mB+dKB7uXc7VNuhU3dJwVaZbQjJ/NkwXMkqNNdeJ20ByW6C98PBiS6cWr/wMnuFJu03qEpqy9TDf66WEiZQj/Aqqtpem24/FY1MZ0zrZDhlh3nOnZoBhVTj1H2v5n0N9pVNG54TRnbnpG97F2ynhgDTLVcGmek3HIYT5EUrwKhtFJnJGEXntIV6pEIy8kQMXFO0CYPVbC/la5B1yi8xKRG2BiCpL40+/VR6SH5sZjn3Io3w9cjZX8SYt9IvCNt9Xj8DDmnnrET/VueY1awlYwXtZshVL66YpiGgNSzo1p4dlv0cF8CXzw+qqLa8m9I55YbMVREtiwrw== 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=O+b+nnj4MngZr97T0VE4bizcVWlZgndCASvnj52NTuU=; b=p1sJQDrJsTuyQEw+FfzS1NFEiaRz2UE7yW+98aaAvuUGxKr6rFjs8uSZYouPaHgVZK1euHo4+H856Rnm5jh4TQ0gaaCGdGID0Vb6vw3kMvsysYIV6pTaJlwuwEXLYlQwwgWQThCh0B23ZE1eq1A7T1Z4ekZRudqAzFhIqU9aggM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3406.eurprd04.prod.outlook.com (2603:10a6:803:c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Fri, 22 Oct 2021 14:17:50 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4%5]) with mapi id 15.20.4608.018; Fri, 22 Oct 2021 14:17:50 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean , UNGLinuxDriver@microchip.com, DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Alexandre Belloni , George McCollister , John Crispin , Aleksander Jan Bajkowski , Egil Hjelmeland , Oleksij Rempel , Prasanna Vengateshan , Ansuel Smith , =?utf-8?q?Alvin_=C5=A0ipraga?= Subject: [PATCH v2 net-next 2/9] net: dsa: sja1105: serialize access to the dynamic config interface Date: Fri, 22 Oct 2021 17:16:09 +0300 Message-Id: <20211022141616.2088304-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022141616.2088304-1-vladimir.oltean@nxp.com> References: <20211022141616.2088304-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0159.eurprd02.prod.outlook.com (2603:10a6:20b:28d::26) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 Received: from localhost.localdomain (188.25.174.251) by AM0PR02CA0159.eurprd02.prod.outlook.com (2603:10a6:20b:28d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 14:17:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 422da8bf-a9e2-4e9d-d0b6-08d99566baf1 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3406: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ijgKs3Q6K5ZKLRwHbZYvrUwgzCt0jw0E3Np8VJvR+KjwAJk1d7tyAl+CbHn74qMj6hr4eKIFalr5kbHt/enTUxikpJtaXIknWKH55EykM6nqSsUA4TIRq41vP49EfFkgFFejY7s38UCXcKwzCQmERBifmf1phxQXiASCoz5WRi1ZbERg/poThQopH45dGXi6fijjdcWkYty1Mt/vMCOJeE/6n+xwSItboT64tZV8tHQQaQ/wykkWeCHb00kIqOeJLD6lek1vGFaJzNE7lFhongcgW5L8Jis4N0CRZbRKb+2sj/FreYuDP231aVw9YFb9bodLRC5EiGpfR8FlcneCuCm+siYKN15cUPSuN20cERicFGirawZ1ismh184atx72kA6zKywqu7Kv74wiP5CHsEQerBBiBwPtNsrvxGgV5rpL9rXhXARCITgMb8xSp/GJ8nmgWPl8OXdlHpdzhAn6t9la40mpB4EG7oYx0VsL/RvsyOFnL0KUT1+4WTQuiFmjkLjJiqUGdiUqyoY7L0Km2YI3KYRi8/K1Y7r+k3RxwVdw0PvDsdoVdzUQekmqhJMCnvx39qwu0Nsn3l386gzq9QTJr93Cn1sx0U0VcWPXT4QeQn70lsN5VWWnRHzfuaw5lBQhQwhNHEMhZ8SQDQ1rzZsBWSJjZfKbF3Vq8tXo8tJMpZqSJ5kFDmcoqU6Z6HomUdcRF04YNG2NhhuILUMjgvKgRs6H8/crkM9pbO10Wpg= 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)(366004)(7416002)(8936002)(44832011)(38350700002)(6916009)(956004)(83380400001)(54906003)(66556008)(508600001)(66476007)(66946007)(6512007)(86362001)(4326008)(6486002)(52116002)(5660300002)(2616005)(316002)(6506007)(1076003)(8676002)(36756003)(2906002)(186003)(38100700002)(26005)(6666004)(290074003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tzWYtNXYiZXtEA2DwMAxU2p8ZJ2WoWrNPk7H1bbik+oPVejg0b1W2AHedowH+P2hR4HCk6Fz7psdKoFtapfH5WkEn+9LfYrf4BnGLVeMPnAk8GSQAiIqus92ta48e7YQViyyt1srOxAFIRLuoUV4oZanJmVH7AEpcZHsnv41a1LtZdaOwzh7/v+gilIuW3ymr7pt4F6WMZuM3wmnh8FmiEuvJuvc9w1vlxJZBLZb4ZnT/LVBcc9jk29ymNIKqkJQRe0MaZNc+kVELeOOFz5GzxzuwgaLBS4Xs4a+dAeFarkdTSiT/AtxynIo89xicdc7a7KPKEui/NHaIIN3x3SbQzrUAk4qqQl52B9A4QJ3XkCJhg3+o39EAtasUoB4dmG8VkxgrpOjcRJmy457l03m1mtT0lG+uJWds33auShdGXu8OC1gKxZIcxdY2NqyxDg19nHM724OPkw/DxpVAOcEcpqEQQUa6dy2Xpig1FoQNtKCXFr/9r9kl0Pp4AJK3OqCnEe2Amprfdn1o6af8tqdKCWsvG4Vcx1HyR0+Y7QA0z8RUotxpeq/cfsLe1flVh6mqzLL13d4HvYjtbXBM9zJG3JvwjgJvpSBsfkg+Meg5CbxuGNG7gjxzYjtbQu5GWYUDzlzwOQbhkvURKrquOtnlNkbsDs4pl/vE3k3pO/SWlXdvsFzJM5imJUHZb4A8PY9mgntGadvP1ZMx1szknOHF0QS1n+LXXF5G15T37lltYtnURFQZiPJfxJjbn0Nrqy6ZN3MPqFM4g9ZUJCA7A0boYvdYtnN5vc6ebNdRIu94GBCjHEQWCSMVbl/+APh+zDTMysSVVu8kZU2KOWwit55QLZmWPOT2N5lAY+qlb5cmtYC+l9GMJOznDRmGhrNPchcYyYcKYH6Sw4i0ak7LP4NEoKqn9UQb4iGLPgswQCokYmx07lL/8mnHL32T84W5tQAmhTFM+DYWR5IS7xFQBEcAxp5COvqfUYaEEvwZxmSn7hM1WTyniQiEgFFw+NZMHfscGAgiDKawJ6r7rgNsgYCDCGlWTS/vByA6DjUqU/6oiW0Mna6rKxb1Z33ALBFraLoB+TnaOoKLcvbAqhlKCEp4LIQB6U37BkU/dZhBL0tjFlGxuj7iHO0zhdvBXuoBVLgHoDQUliCsLP95AMHDUG9biHQSfR+anSdzz+32rVGKOr/28Xui8U7gRioAK4fRojZ0s8SZV7ZT1s128yoL1Kv8KWUSwAkqesCd/cl+6rYUXVRWyiHVxf1mDiy2Una43LfqYE2zdx7pUfOV9eCy+7VmezgDYXIZJIvYCdWnZr3biYqMw7872JEL5S+trsuCKROT0ygVyPZVREKj6TYu6MK8zRiDAmp03gfqL2uEyf0YhZdoraVkr/Ka4rbX7rjEsp6Pf/rbsSrisIi0T0jb6ztRgA9Y2/Qo00dbwB/2uGbTbYkzHTDCBc7Gh7djr5mzboy X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 422da8bf-a9e2-4e9d-d0b6-08d99566baf1 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 14:17:50.6527 (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: vladimir.oltean@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3406 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The sja1105 hardware seems as concurrent as can be, but when we create a background script that adds/removes a rain of FDB entries without the rtnl_mutex taken, then in parallel we do another operation like run 'bridge fdb show', we can notice these errors popping up: sja1105 spi2.0: port 2 failed to read back entry for 00:01:02:03:00:40 vid 0: -ENOENT sja1105 spi2.0: port 2 failed to add 00:01:02:03:00:40 vid 0 to fdb: -2 sja1105 spi2.0: port 2 failed to read back entry for 00:01:02:03:00:46 vid 0: -ENOENT sja1105 spi2.0: port 2 failed to add 00:01:02:03:00:46 vid 0 to fdb: -2 Luckily what is going on does not require a major rework in the driver. The sja1105_dynamic_config_read() function sends multiple SPI buffers to the peripheral until the operation completes. We should not do anything until the hardware clears the VALID bit. But since there is no locking (i.e. right now we are implicitly serialized by the rtnl_mutex, but if we remove that), it might be possible that the process which performs the dynamic config read is preempted and another one performs a dynamic config write. What will happen in that case is that sja1105_dynamic_config_read(), when it resumes, expects to see VALIDENT set for the entry it reads back. But it won't. This can be corrected by introducing a mutex for serializing SPI accesses to the dynamic config interface which should be atomic with respect to each other. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105.h | 2 ++ drivers/net/dsa/sja1105/sja1105_dynamic_config.c | 12 ++++++++++-- drivers/net/dsa/sja1105/sja1105_main.c | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105.h b/drivers/net/dsa/sja1105/sja1105.h index 808419f3b808..21dba16af097 100644 --- a/drivers/net/dsa/sja1105/sja1105.h +++ b/drivers/net/dsa/sja1105/sja1105.h @@ -261,6 +261,8 @@ struct sja1105_private { * the switch doesn't confuse them with one another. */ struct mutex mgmt_lock; + /* Serializes access to the dynamic config interface */ + struct mutex dynamic_config_lock; struct devlink_region **regions; struct sja1105_cbs_entry *cbs; struct mii_bus *mdio_base_t1; diff --git a/drivers/net/dsa/sja1105/sja1105_dynamic_config.c b/drivers/net/dsa/sja1105/sja1105_dynamic_config.c index 32ec34f181de..7729d3f8b7f5 100644 --- a/drivers/net/dsa/sja1105/sja1105_dynamic_config.c +++ b/drivers/net/dsa/sja1105/sja1105_dynamic_config.c @@ -1283,12 +1283,16 @@ int sja1105_dynamic_config_read(struct sja1105_private *priv, ops->entry_packing(packed_buf, entry, PACK); /* Send SPI write operation: read config table entry */ + mutex_lock(&priv->dynamic_config_lock); rc = sja1105_xfer_buf(priv, SPI_WRITE, ops->addr, packed_buf, ops->packed_size); - if (rc < 0) + if (rc < 0) { + mutex_unlock(&priv->dynamic_config_lock); return rc; + } rc = sja1105_dynamic_config_wait_complete(priv, &cmd, ops); + mutex_unlock(&priv->dynamic_config_lock); if (rc < 0) return rc; @@ -1349,12 +1353,16 @@ int sja1105_dynamic_config_write(struct sja1105_private *priv, ops->entry_packing(packed_buf, entry, PACK); /* Send SPI write operation: read config table entry */ + mutex_lock(&priv->dynamic_config_lock); rc = sja1105_xfer_buf(priv, SPI_WRITE, ops->addr, packed_buf, ops->packed_size); - if (rc < 0) + if (rc < 0) { + mutex_unlock(&priv->dynamic_config_lock); return rc; + } rc = sja1105_dynamic_config_wait_complete(priv, &cmd, ops); + mutex_unlock(&priv->dynamic_config_lock); if (rc < 0) return rc; diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 1832d4bd3440..6b4a76bbe548 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -3364,6 +3364,7 @@ static int sja1105_probe(struct spi_device *spi) priv->ds = ds; mutex_init(&priv->ptp_data.lock); + mutex_init(&priv->dynamic_config_lock); mutex_init(&priv->mgmt_lock); rc = sja1105_parse_dt(priv); From patchwork Fri Oct 22 14:16:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12577931 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61039C433F5 for ; Fri, 22 Oct 2021 14:17:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4A0396023D for ; Fri, 22 Oct 2021 14:17:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233069AbhJVOUO (ORCPT ); Fri, 22 Oct 2021 10:20:14 -0400 Received: from mail-eopbgr60040.outbound.protection.outlook.com ([40.107.6.40]:37344 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232974AbhJVOUM (ORCPT ); Fri, 22 Oct 2021 10:20:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kJZQVa3tAYrgw1PA9ZiUz6dbg8dirIZf1p1J7tq8f/w63GLhN65jIIgCFrmiK9cVCfPiHjUZkY/QquxAOLZBx7NMMf2NCjIKEuO0qeUMD/x2ROQCRQjhA2NGs2/AGgyQN7E0QhQLfoHX4zMZGEZnfDz04goa1v1PD+SDxjDEIpNSqxhrscnxtfWVcgvsCUlQukCaEI2ozrS+WmJ7VcZJ8rFekgTkZw6q8vfJFeSV7ICiN4Ix7f7rEOjT9JKra8xfOLYIkiW5UnABMvBkCv35vktcsK8wakqEmCw3w/ri6ntLpW27M+4xt/A8YsxHYfYVXdhSKL5ehNagK8qvP2hvTw== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ITOiY2f0G4/Q5EwGadBA2Pphs/9an4p9N8Qvna5SQdM=; b=THTDJK5zDz/u5WYHd/lUfQGxIcnQjKEHRWpRFEFxgP42XyzLuMpvR+kSMy7cyc0p7EgTe+EOB5NZkUgnqOuNnAk6wKGPzUU/OvZLxo7voJcIughgsSexmwIuxLFK6OIGo9BsAE5GsN+OW1955qPa4w0Wk4uTO6KlIZl9Yfl5HeauNs6+hqL4SpjQG3+Kj/Q/uibCG7SvJcSSPlmKiX5i1xUEIe7+i3QbDMDrd7+ufpcaklUYhliSJ2EQzDVmgefGJuQn59hwuX/FceF2N60331zO9NFLf9V7TS64U0T4zc7e8izgwBlIa+MKVDqs9kAQf+tXcJHlhqew4H0Jwt9RmQ== 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=ITOiY2f0G4/Q5EwGadBA2Pphs/9an4p9N8Qvna5SQdM=; b=eucEwo6xdXOduHjBXfSHXgBL3h8X1eGNvtFRObVeTJ3FiXirHdns+uHMxvsfDuRqGMuqvxSBG3D9bvmm9DiMfFM6tzoJXUDS2GeoBxi9e1+0QGd5v68Hr0Uz+MZRf5a1hmknHFYj/s1MEoCSjXxAxRQudOKiTdFf7X/C9v4LrM8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3406.eurprd04.prod.outlook.com (2603:10a6:803:c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Fri, 22 Oct 2021 14:17:52 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4%5]) with mapi id 15.20.4608.018; Fri, 22 Oct 2021 14:17:52 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean , UNGLinuxDriver@microchip.com, DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Alexandre Belloni , George McCollister , John Crispin , Aleksander Jan Bajkowski , Egil Hjelmeland , Oleksij Rempel , Prasanna Vengateshan , Ansuel Smith , =?utf-8?q?Alvin_=C5=A0ipraga?= Subject: [PATCH v2 net-next 3/9] net: mscc: ocelot: serialize access to the MAC table Date: Fri, 22 Oct 2021 17:16:10 +0300 Message-Id: <20211022141616.2088304-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022141616.2088304-1-vladimir.oltean@nxp.com> References: <20211022141616.2088304-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0159.eurprd02.prod.outlook.com (2603:10a6:20b:28d::26) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 Received: from localhost.localdomain (188.25.174.251) by AM0PR02CA0159.eurprd02.prod.outlook.com (2603:10a6:20b:28d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 14:17:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2546f02e-1e2f-4545-1883-08d99566bc03 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3406: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qi4QRouiIO73a2fTmjh1zUbNt6cdoVRnt04bhZoy0pe4TQqZChsOmxA0/kgTrddRWs6F8t73wvgPs2Q+5xqKBAuGoj69tGAaTzaZmiIgfAQI1GufDj3Tg+WaqpFzxwHKl/5PI8Xs9st/BMGZ3ch8D5EDrupDzNLjUOaWhmfIldDQMVztA0v5fn5Cs5YUKyKQK8+OF/hGU+nTJFu7R3VJYEmqusz6g/XZIPFjxSJrzxEDpWOekV/813ilCHYTJYT1JiatakqgoCdXLgj9lhlvddsL5szxm804erdRDnHq8R4Ycbhsd6FpxteNZ0A9wXqRRFopmiKl7t2jDOhjC53xhNQRM5kfCYvleL/zaEXefJfMOrl87MVXL27KAjSxQ250D219UYFSwE1D1bPXI2zPyNvhDPpdkdttNOpu+MGbeyB+cOS9fjjtZpL5BsSl9enl9LzC6fmFTYoXxBQx2AdaXrrApT+yqQDIZEk3+DJKTCyCnmvG26lqdIMtHKl6P5BGBCCQpy9gCkZJCAPuzTTUHV8E4DaNpByipPmwcZyT5cKjqBuzqrFqt3vuoWe3leIyKrBkjNu2CDIPCXP0TvG/ZqKskbDF5Bm7SNGizQnwJTy7qrbxASdq8S3HKaV/ixyk4UmTFs0+bQsRPXi/nbZxE0RfB8aJvvnwC2lqXvkV2qnDX4JLPVLvdYtm2Ebqo7kmDmGcS5eTqp593dJO8zBdeg== 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)(366004)(7416002)(8936002)(44832011)(38350700002)(6916009)(956004)(83380400001)(54906003)(66556008)(508600001)(66476007)(66946007)(6512007)(86362001)(4326008)(6486002)(52116002)(5660300002)(2616005)(316002)(6506007)(1076003)(8676002)(36756003)(2906002)(186003)(38100700002)(26005)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Y+1a1pOvKyBzeorXgehK+jvOtZq9OomwzUGG+fyo504BhFk7jy0f7yZUZ8S6mNOJhKnNJ4j450V2zf5U+y2OcPb1mVTjb87zemUuu2XPEzmOEs+0q3SbRL4a1nRhsnGcC7V8Li9UV8kEy8X+kbu1SW5hyK460629SW4MA7k4qHirc/y5/2K3iYXxKtC9Px/bmI2ZGll4/didwi7ujo0oqQs2I3H8WC7WR/kFmVf2acJRmVDZnPc2oZAkfMEO/hMnPFxp5le2DYtZCxV3dP539uzYugliE5GEL3M2BMITTD3xA3i+aM0Gq91txawlIF6cN6jtQZIvFQKqdGSheG48TsvmeKF93tN/XXnHTzbbW6g6wWH6kjcGmJ0n49drKufJx4uItJu+vcFBTRqe9uArgJJS5TMkLS3OMZzFoRBvjqah7D9ojo25XCgDHUuTZIhgk02hha2cZ2f9hvfFHf/QyfheInmb5PHr+Hw7oN8DyRLchD5ECV87McWRY/pAA2y1R3X/v+N3alN9vXBg6xIqrKlKjD9A/YuktJnM3CIXMsf18WAfo8stuON3kgbsrOJYwrSyd4xGmgXbID23Qaa27+Zjtdh6EKPQHUIow653agei1FV3ve1D7OeROfomGYy5kEf5oVffLAeNPOGhO5OEHO9peh73rw8hBxUw5WlDvLsinzZf9/o37fQ1oomISvyoxL9xkqmhbQJdOqXas1CvEXJT9LLRqzOevjvK8w0RZYNZ1FiB15CDMoHl/XRf5y2LDjT4KrWzmG2VGHFaUPaKmc8ZbjRTzGLld9kC5oDW/ajkOW/8J0e9coTApITDATzboVpreVCJUanhq9VQXEcBAKrksT/ncpdgsgdKzuVfmZ1z6sFXuv+mAwffmeH+ejbiGcs776VrxuloZ+A97gDD7IU6hEiC+4aj9yRcSotBXg8KWU5S95iepF/CQpv1qYdyNO2bqPIFsUpiuHdebNGvsBqVlPOF966XplLbX0finQQ9rJd4C9xocOEQbUs9zicFTYpB4MRjdojBW1c+2LMaEZ2aB1iidJpLZmxFcljfnXi1QJvgjG4DlaVxsHmdfAQIHOc6F8vEOIgLlcPAvtRa0a6Jo9Z4SVKpOP8cNlUGk7rwWg2/ve96r2HSnzED5Dx6Wi9gepjHgEdC171BwClojGVm6v30tMF8GCulBN7UXJh2MX/tO8eJT/L5unHVqfFzbRq3qSpOl9MvRLFuQYLOXikv508GUYchw/oCN63Iqa/68k9rZGr1dlNbgAxNIKxKr/BDDl9bGJ7oEe6RsrkKpwghpUHpXxFg5k6hSwjuI2cLAzy134K+z8kWQMlO7PHgMOOcyFr3NrUGTtAlKJYVpwsYXsvwVlYrm2nDey22Gp5idPbkPamMFih814GdZxTgOywkGIagcbsMcO9cFgakaazQ0MJp4wTwdPQFuVm2BDRd3xqkNWh9mzw4U4MilwXn X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2546f02e-1e2f-4545-1883-08d99566bc03 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 14:17:52.4587 (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: vladimir.oltean@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3406 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org DSA would like to remove the rtnl_lock from its SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE handlers, and the felix driver uses the same MAC table functions as ocelot. This means that the MAC table functions will no longer be implicitly serialized with respect to each other by the rtnl_mutex, we need to add a dedicated lock in ocelot for the non-atomic operations of selecting a MAC table row, reading/writing what we want and polling for completion. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot.c | 53 +++++++++++++++++++++++------- include/soc/mscc/ocelot.h | 3 ++ 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 4e5ae687d2e2..72925529b27c 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -20,11 +20,13 @@ struct ocelot_mact_entry { enum macaccess_entry_type type; }; +/* Must be called with &ocelot->mact_lock held */ static inline u32 ocelot_mact_read_macaccess(struct ocelot *ocelot) { return ocelot_read(ocelot, ANA_TABLES_MACACCESS); } +/* Must be called with &ocelot->mact_lock held */ static inline int ocelot_mact_wait_for_completion(struct ocelot *ocelot) { u32 val; @@ -36,6 +38,7 @@ static inline int ocelot_mact_wait_for_completion(struct ocelot *ocelot) TABLE_UPDATE_SLEEP_US, TABLE_UPDATE_TIMEOUT_US); } +/* Must be called with &ocelot->mact_lock held */ static void ocelot_mact_select(struct ocelot *ocelot, const unsigned char mac[ETH_ALEN], unsigned int vid) @@ -67,6 +70,7 @@ int ocelot_mact_learn(struct ocelot *ocelot, int port, ANA_TABLES_MACACCESS_ENTRYTYPE(type) | ANA_TABLES_MACACCESS_MAC_TABLE_CMD(MACACCESS_CMD_LEARN); unsigned int mc_ports; + int err; /* Set MAC_CPU_COPY if the CPU port is used by a multicast entry */ if (type == ENTRYTYPE_MACv4) @@ -79,18 +83,28 @@ int ocelot_mact_learn(struct ocelot *ocelot, int port, if (mc_ports & BIT(ocelot->num_phys_ports)) cmd |= ANA_TABLES_MACACCESS_MAC_CPU_COPY; + mutex_lock(&ocelot->mact_lock); + ocelot_mact_select(ocelot, mac, vid); /* Issue a write command */ ocelot_write(ocelot, cmd, ANA_TABLES_MACACCESS); - return ocelot_mact_wait_for_completion(ocelot); + err = ocelot_mact_wait_for_completion(ocelot); + + mutex_unlock(&ocelot->mact_lock); + + return err; } EXPORT_SYMBOL(ocelot_mact_learn); int ocelot_mact_forget(struct ocelot *ocelot, const unsigned char mac[ETH_ALEN], unsigned int vid) { + int err; + + mutex_lock(&ocelot->mact_lock); + ocelot_mact_select(ocelot, mac, vid); /* Issue a forget command */ @@ -98,7 +112,11 @@ int ocelot_mact_forget(struct ocelot *ocelot, ANA_TABLES_MACACCESS_MAC_TABLE_CMD(MACACCESS_CMD_FORGET), ANA_TABLES_MACACCESS); - return ocelot_mact_wait_for_completion(ocelot); + err = ocelot_mact_wait_for_completion(ocelot); + + mutex_unlock(&ocelot->mact_lock); + + return err; } EXPORT_SYMBOL(ocelot_mact_forget); @@ -114,7 +132,9 @@ static void ocelot_mact_init(struct ocelot *ocelot) | ANA_AGENCTRL_LEARN_IGNORE_VLAN, ANA_AGENCTRL); - /* Clear the MAC table */ + /* Clear the MAC table. We are not concurrent with anyone, so + * holding &ocelot->mact_lock is pointless. + */ ocelot_write(ocelot, MACACCESS_CMD_INIT, ANA_TABLES_MACACCESS); } @@ -1170,6 +1190,7 @@ int ocelot_port_fdb_do_dump(const unsigned char *addr, u16 vid, } EXPORT_SYMBOL(ocelot_port_fdb_do_dump); +/* Must be called with &ocelot->mact_lock held */ static int ocelot_mact_read(struct ocelot *ocelot, int port, int row, int col, struct ocelot_mact_entry *entry) { @@ -1220,33 +1241,40 @@ static int ocelot_mact_read(struct ocelot *ocelot, int port, int row, int col, int ocelot_fdb_dump(struct ocelot *ocelot, int port, dsa_fdb_dump_cb_t *cb, void *data) { + int err = 0; int i, j; + /* We could take the lock just around ocelot_mact_read, but doing so + * thousands of times in a row seems rather pointless and inefficient. + */ + mutex_lock(&ocelot->mact_lock); + /* Loop through all the mac tables entries. */ for (i = 0; i < ocelot->num_mact_rows; i++) { for (j = 0; j < 4; j++) { struct ocelot_mact_entry entry; bool is_static; - int ret; - ret = ocelot_mact_read(ocelot, port, i, j, &entry); + err = ocelot_mact_read(ocelot, port, i, j, &entry); /* If the entry is invalid (wrong port, invalid...), * skip it. */ - if (ret == -EINVAL) + if (err == -EINVAL) continue; - else if (ret) - return ret; + else if (err) + break; is_static = (entry.type == ENTRYTYPE_LOCKED); - ret = cb(entry.mac, entry.vid, is_static, data); - if (ret) - return ret; + err = cb(entry.mac, entry.vid, is_static, data); + if (err) + break; } } - return 0; + mutex_unlock(&ocelot->mact_lock); + + return err; } EXPORT_SYMBOL(ocelot_fdb_dump); @@ -2231,6 +2259,7 @@ int ocelot_init(struct ocelot *ocelot) mutex_init(&ocelot->stats_lock); mutex_init(&ocelot->ptp_lock); + mutex_init(&ocelot->mact_lock); spin_lock_init(&ocelot->ptp_clock_lock); spin_lock_init(&ocelot->ts_id_lock); snprintf(queue_name, sizeof(queue_name), "%s-stats", diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 9b872da0c246..fef3a36b0210 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -675,6 +675,9 @@ struct ocelot { struct delayed_work stats_work; struct workqueue_struct *stats_queue; + /* Lock for serializing access to the MAC table */ + struct mutex mact_lock; + struct workqueue_struct *owq; u8 ptp:1; From patchwork Fri Oct 22 14:16:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12577933 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7FE4C433EF for ; Fri, 22 Oct 2021 14:18:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DDD26101C for ; Fri, 22 Oct 2021 14:18:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233071AbhJVOUP (ORCPT ); Fri, 22 Oct 2021 10:20:15 -0400 Received: from mail-eopbgr60040.outbound.protection.outlook.com ([40.107.6.40]:37344 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232825AbhJVOUN (ORCPT ); Fri, 22 Oct 2021 10:20:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mOCWKtxuF9Vn7HkJ7ePO4SvnnzusI8T1ZiBYiQvNk/lpenUKCheZPUygAIF7k9sNMRf+EXH4wsU07skdKX3y87V5ezTOmt0DXFw54DrMkE3Ewu5q6lnLryWUMFhLZpYS0Nlnm/Yea8h6WMu+Bye+vg5DnYClOmA3IHThYu3Du2wSvNaiyb2mnckWR94VnDhK2u0rrOGRXYzEfuF6zsTCMUFovb/GWPNYN9JpzmXFHvJzxLtf1C8CyTgQFDSifntuAHQDKKuDWpn9dWtf6zYuWV3HGgu8b5kuak8+BSR7Bk8CHIv1prYEo0q8FqV4lqHfAVxpfAPt5n2872ZKKlco1g== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=G8tuqUgp79V7Am++ArotmvPBOiP/B4srEdjqcUJtZYk=; b=W+7jzfv5USMt7ATJMFRANbhcZWj404vutj4QYFbFNs8DlwbdDBR+3cZ5Usj1bW4w34n9muXwNAiXtOytyj6mShHSTtZPJMM0hgGUdu8DgaV6WNadyaWfLtrnjA2zmlbsj3U8zQrHZ19XpkVrr5OFGGy5vrl083LGB9yCx86IVdvhFf4eMvzBw5ObiE+7i/ErUt26mfHfbDRlZaiGcTw4qkdo3D2eE+jrcIJsoPmMBnkVTw+W132SLfzy4jbKGKkUNWnNpOaSYCg6BdlYd8JMTgcFS6rr2dyEvvRYdMNTc0vQPcI0/BiicDzoqjygJpauDNpK5TCxytidvG/R3K2mfQ== 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=G8tuqUgp79V7Am++ArotmvPBOiP/B4srEdjqcUJtZYk=; b=QcWgQd5rTSY0WrIwmrytna2kdpEjmzi1WQG6xPPLpQr2y9Eq4OmO/mucQr1zZayrnKqhBmXm+if+iOqnTrEcz1pedLRhkHTIWf4E33IyeMhieUhmgFjKocrUpa3DUkosI92OK8hep4xdU06mp1RUl4BymvsjnotKNkTTvKo4v5w= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3406.eurprd04.prod.outlook.com (2603:10a6:803:c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Fri, 22 Oct 2021 14:17:54 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4%5]) with mapi id 15.20.4608.018; Fri, 22 Oct 2021 14:17:54 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean , UNGLinuxDriver@microchip.com, DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Alexandre Belloni , George McCollister , John Crispin , Aleksander Jan Bajkowski , Egil Hjelmeland , Oleksij Rempel , Prasanna Vengateshan , Ansuel Smith , =?utf-8?q?Alvin_=C5=A0ipraga?= Subject: [PATCH v2 net-next 4/9] net: dsa: b53: serialize access to the ARL table Date: Fri, 22 Oct 2021 17:16:11 +0300 Message-Id: <20211022141616.2088304-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022141616.2088304-1-vladimir.oltean@nxp.com> References: <20211022141616.2088304-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0159.eurprd02.prod.outlook.com (2603:10a6:20b:28d::26) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 Received: from localhost.localdomain (188.25.174.251) by AM0PR02CA0159.eurprd02.prod.outlook.com (2603:10a6:20b:28d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 14:17:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 856e81ee-d414-4207-82e2-08d99566bd16 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3406: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a7OF++HiZJ91IIofPCfn7/r3/pIHVUY8Rl68+gcj/vrezxo8ZhWNoNebC2BlZUmCc99s6JqHOVkjQL2P2/1R0eqTHbd/zDjFTCClvEk9fY0cbSsWaSTEwn99kN9DxA72fxHQ48WDcMLp5e5ME+mSPLDRN8ctH1VeicYUJvLAgJ24dokOBszIllTWJGudjce1Q4t4Oiq7I7VK69POTML0UzsMjcAmKInPhvcTk/KtBd4gosmjVALWvzFJxKdAUeCMJD7UdSVunDWPR+mCoknHdJMRTi2sWF1iq1XtsBgbh0akQSON38D2JrRgVE39c5VhnOOGNOaMdhBkC4UfxCLZjwRWzuoTW3koLCaSS8EmdFkzb+eIcQgEI//1PtJs20WWR9N3mLvFxd1D9MpgrpPyWJ1/eg1xVAyhPLP3ElrgIgdnYLFWFOdVslMLQ7Yqq6hfZRA37SXOhmYNJSJFv/sp0vmB1C7tncMtbIXVqRXNCgar1Il/MJCOyXVpVMc3d/IoLA2zIqVF/rizB7kALnW6oIey6f0NVEpUqWbRR/k5De0+4KdKyx+PugOIvBrxnWKGciKmZHw6BR9NDFGEOcxgWnYRHlo3KWXMjwhQ+4mXaAHIOL4EaI91wHbR+wkeZGc0tE0oFlYg8qmgKy1Jt4yPw68ATioVzDbbDg75w5xVhre6IzOun0yRNuVKgKKevG5ZIrptqIsN6nbeouhV0NrIcQ== 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)(366004)(7416002)(8936002)(44832011)(38350700002)(6916009)(956004)(83380400001)(54906003)(66556008)(508600001)(66476007)(66946007)(6512007)(86362001)(4326008)(6486002)(52116002)(5660300002)(2616005)(316002)(6506007)(1076003)(8676002)(36756003)(2906002)(186003)(38100700002)(26005)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PtEFbFmjsGX9f4HgE5/+7bfA8aRr0Mdi543N2K8Z7ppvp1Xz5Idy10do92Jgny6dCTuPQAZxZxaB+6pKBl3i20KU55hVEJXFb8GbKxvEPFKy2UO0YFjQFfhAxwAH9mw34xmSSbjfjofo5iCFWZnbPdVYIqU2tspJ7W3Jk+lwOMl9iaGei+KNzYjFFtlN4dW9TBnwhkdr+iH7NLd3Cs+Hku+SJV5DGVqi/uWmiwjlIJj3dkoxGptn0VChE7zv+EJAUXPP+S/rRzbSBGJS6D3gcZmUpR527OXxkpics3l+11uZsJuEOe9EAOaGFErBHyJlu8EnmJklrw4wd28GLGEBqRl+LooCLU5QswqpEwHNQQQFInjiXODDYzpZJs+ZA89rWSc0THmfMAAVpnN/NjicRInIChtr1F2ciE72Hng2oxP7nqMgLN0Zu+SSTlqFOnU83p7bmMJ5KS8C9bbMtW44pBUzVC3mC73uAECdkIcDXDAIk2U4D0DlcW+XnxcjGstNbrFddy57gl2aOXZoeW9I/+GMOONTZYazvI9K6dQPYmmDGhCgwXbWZpwt70GvtZHH+ToiJsDS8kNDdAeqg4K+5BpD+eMD5OoeKM/VHRAPPTuuRQCc5+ZRFl9Gzsac4OGeO3hcSh8wWvpfy3DUk7i8V3m2uzo1xDYEDj5fa6g3jB4aX3Yi2oj36Z2zuBw+cSB+EClzxP9jRhHAPNuVFQtJxoqemVzdVFxzUAWE0gYCupzuF/2oy07fCRgZGcsFVK7qsE37ZFQ3P67eHrz+UdKY9WCvDAJS1H9quLKeRJC8X8qqLAzgluXexfxaeGmDjziefTVXtexzybvUPeM7exeirQKtvWO5BdHuZNyv6y8TxYk+CHxplnIwQO2ll8IILQc43vn6H0sUP1SNrQwwgLHE4ZWHArrsdJ8njFy/2mewsCBfojO/FV/xw/MbY4mtD8e2zgx8LN5WHiBtNyMkhLnDhdRZNQJcyptwGDxO4cGHVGpHSfFOE43wXlkjsrgs64GRfSAlLDE6CLki2YHgPIhEs+GLK7AEkgibSo4ybUQPLTxA1VD1Ii7CfmKRkVF0aFa4d1gwaUpwpV0L4o/VLF4XgTXY/TyUtoWMwHFXELNzjS1eV9mBLR1Z4F3u9qIlx9ydGHed6r4DTglpD8vHYlLORyYH1mpzS95Q9UV+VUi3XokFHA6joX15GkTDtuGu3ftA7qPd1IbFMYbS3ihqTIsW6vx/5hv9fpqg5JV3JAQ6Fu1Df4aqCHlmMBuEw7KtHBeN2tmNfRomhkx0G/UFAO7APQEoV7yHI2R4uj2xWw98qbq092xgrdc7011ZshZDL7lUY4CXK2RXL3B89rAinDXVFKHSnvfevnZeWdcinIKoc4viHJ68P4NsYcteAD9sn3eAoRdm+uYsux9PoCI4esnnQbcOKuKPP+2A0V/d8IjVf9JVbzIzinZ/ne0sCeSCh5jn X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 856e81ee-d414-4207-82e2-08d99566bd16 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 14:17:54.2437 (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: vladimir.oltean@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3406 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The b53 driver performs non-atomic transactions to the ARL table when adding, deleting and reading FDB and MDB entries. Traditionally these were all serialized by the rtnl_lock(), but now it is possible that DSA calls ->port_fdb_add and ->port_fdb_del without holding that lock. So the driver must have its own serialization logic. Add a mutex and hold it from all entry points (->port_fdb_{add,del,dump}, ->port_mdb_{add,del}). Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- drivers/net/dsa/b53/b53_common.c | 41 +++++++++++++++++++++++++++----- drivers/net/dsa/b53/b53_priv.h | 1 + 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index 06279ba64cc8..22a6e3934a6f 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -1630,6 +1630,7 @@ static int b53_arl_read(struct b53_device *dev, u64 mac, return -ENOENT; } +/* Caller must hold &dev->arl_mutex */ static int b53_arl_op(struct b53_device *dev, int op, int port, const unsigned char *addr, u16 vid, bool is_valid) { @@ -1709,6 +1710,7 @@ int b53_fdb_add(struct dsa_switch *ds, int port, const unsigned char *addr, u16 vid) { struct b53_device *priv = ds->priv; + int ret; /* 5325 and 5365 require some more massaging, but could * be supported eventually @@ -1716,7 +1718,11 @@ int b53_fdb_add(struct dsa_switch *ds, int port, if (is5325(priv) || is5365(priv)) return -EOPNOTSUPP; - return b53_arl_op(priv, 0, port, addr, vid, true); + mutex_lock(&priv->arl_mutex); + ret = b53_arl_op(priv, 0, port, addr, vid, true); + mutex_unlock(&priv->arl_mutex); + + return ret; } EXPORT_SYMBOL(b53_fdb_add); @@ -1724,8 +1730,13 @@ int b53_fdb_del(struct dsa_switch *ds, int port, const unsigned char *addr, u16 vid) { struct b53_device *priv = ds->priv; + int ret; - return b53_arl_op(priv, 0, port, addr, vid, false); + mutex_lock(&priv->arl_mutex); + ret = b53_arl_op(priv, 0, port, addr, vid, false); + mutex_unlock(&priv->arl_mutex); + + return ret; } EXPORT_SYMBOL(b53_fdb_del); @@ -1782,25 +1793,33 @@ int b53_fdb_dump(struct dsa_switch *ds, int port, int ret; u8 reg; + mutex_lock(&priv->arl_mutex); + /* Start search operation */ reg = ARL_SRCH_STDN; b53_write8(priv, B53_ARLIO_PAGE, B53_ARL_SRCH_CTL, reg); do { ret = b53_arl_search_wait(priv); - if (ret) + if (ret) { + mutex_unlock(&priv->arl_mutex); return ret; + } b53_arl_search_rd(priv, 0, &results[0]); ret = b53_fdb_copy(port, &results[0], cb, data); - if (ret) + if (ret) { + mutex_unlock(&priv->arl_mutex); return ret; + } if (priv->num_arl_bins > 2) { b53_arl_search_rd(priv, 1, &results[1]); ret = b53_fdb_copy(port, &results[1], cb, data); - if (ret) + if (ret) { + mutex_unlock(&priv->arl_mutex); return ret; + } if (!results[0].is_valid && !results[1].is_valid) break; @@ -1808,6 +1827,8 @@ int b53_fdb_dump(struct dsa_switch *ds, int port, } while (count++ < b53_max_arl_entries(priv) / 2); + mutex_unlock(&priv->arl_mutex); + return 0; } EXPORT_SYMBOL(b53_fdb_dump); @@ -1816,6 +1837,7 @@ int b53_mdb_add(struct dsa_switch *ds, int port, const struct switchdev_obj_port_mdb *mdb) { struct b53_device *priv = ds->priv; + int ret; /* 5325 and 5365 require some more massaging, but could * be supported eventually @@ -1823,7 +1845,11 @@ int b53_mdb_add(struct dsa_switch *ds, int port, if (is5325(priv) || is5365(priv)) return -EOPNOTSUPP; - return b53_arl_op(priv, 0, port, mdb->addr, mdb->vid, true); + mutex_lock(&priv->arl_mutex); + ret = b53_arl_op(priv, 0, port, mdb->addr, mdb->vid, true); + mutex_unlock(&priv->arl_mutex); + + return ret; } EXPORT_SYMBOL(b53_mdb_add); @@ -1833,7 +1859,9 @@ int b53_mdb_del(struct dsa_switch *ds, int port, struct b53_device *priv = ds->priv; int ret; + mutex_lock(&priv->arl_mutex); ret = b53_arl_op(priv, 0, port, mdb->addr, mdb->vid, false); + mutex_unlock(&priv->arl_mutex); if (ret) dev_err(ds->dev, "failed to delete MDB entry\n"); @@ -2670,6 +2698,7 @@ struct b53_device *b53_switch_alloc(struct device *base, mutex_init(&dev->reg_mutex); mutex_init(&dev->stats_mutex); + mutex_init(&dev->arl_mutex); return dev; } diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h index 544101e74bca..579da74ada64 100644 --- a/drivers/net/dsa/b53/b53_priv.h +++ b/drivers/net/dsa/b53/b53_priv.h @@ -107,6 +107,7 @@ struct b53_device { struct mutex reg_mutex; struct mutex stats_mutex; + struct mutex arl_mutex; const struct b53_io_ops *ops; /* chip specific data */ From patchwork Fri Oct 22 14:16:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12577935 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1AB0C433EF for ; Fri, 22 Oct 2021 14:18:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C8E586101C for ; Fri, 22 Oct 2021 14:18:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233089AbhJVOUT (ORCPT ); Fri, 22 Oct 2021 10:20:19 -0400 Received: from mail-eopbgr60040.outbound.protection.outlook.com ([40.107.6.40]:37344 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233067AbhJVOUP (ORCPT ); Fri, 22 Oct 2021 10:20:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DJUn2+IlM5xMKoYbWrb6PLbEfWWtG6KGS+SDnnPfiOgbUzc7ocwIrOOAoPUJFnr6x6gAaf+nm6Zu7EMKCXk6+yBOyYiQaODSfKzFY6o67/qkTP8dGC0MNYvphDhuFjfjy04xAXegXxClvjmoSLUwHpcw674UmsSrhLifLOSGiietsiIYlK1QZ8QD1r2mNx2NWGAKTVStuso8dSB0Erh/PwTxrIaFUOWR2Qn2jnNKGxc73Hv4rnUJuQWDbzQDhNqVP80CubzczCFTfcuKsIQ8Fulf9GnPt6hAM/NK9T38rA4JC+xJlg+iahpXTIp03WJMBk9pzEi39zShimnkUpkX/w== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=U1r/hWaELiKMk4wJCp+yQTDgHdoJ9nno2Eq/ONGDI0k=; b=T/L90C+DnSK2l+7I3OKtA4+L2LO7HzMuDdPaP7G7WKoZkaDtB8RmPvjGsdTa/B+kP1RHxcoTHWfSFaVWFh2+GEKGqwu67wxlW4UZCvoM6pQmHDzRVmFzeBOqKcpsUXIr+4N+Qju0uymxKroV9kjYtRB+XSwncsvyJLUbsH2TmL29byyVpgwt1efl4GTFSn6Ur9PA2oTNn/DKjNkhe+oJo1ljkBQZQubDCdQsAjsJ/8jjLUeK8NMTEfvepTDVw0Ig5XVe9V/qgYWSYy9A9tWV4aMEj9kXgCxSFzGLgCult4zxrujW2yEfX4UnHaQKOTcvGaWGiyg/623sZ+kvUN2g1Q== 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=U1r/hWaELiKMk4wJCp+yQTDgHdoJ9nno2Eq/ONGDI0k=; b=YbNBSb1B3Qbec1Hn6AdT20i0vEInjALKq2LaWeqQA2jC4lM8T6NY0KZVU0rVfdwIx2RcS55QwW5QB9geHIcALuczD+MoYM4Tm7hk/NQ/d9nmItv3tDgOgDPFbqBqGLS/5PiAmqI5CICfATw9WPs83EG0Q5350Z7pUeOUPSTTdic= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3406.eurprd04.prod.outlook.com (2603:10a6:803:c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Fri, 22 Oct 2021 14:17:56 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4%5]) with mapi id 15.20.4608.018; Fri, 22 Oct 2021 14:17:56 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean , UNGLinuxDriver@microchip.com, DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Alexandre Belloni , George McCollister , John Crispin , Aleksander Jan Bajkowski , Egil Hjelmeland , Oleksij Rempel , Prasanna Vengateshan , Ansuel Smith , =?utf-8?q?Alvin_=C5=A0ipraga?= Subject: [PATCH v2 net-next 5/9] net: dsa: lantiq_gswip: serialize access to the PCE table Date: Fri, 22 Oct 2021 17:16:12 +0300 Message-Id: <20211022141616.2088304-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022141616.2088304-1-vladimir.oltean@nxp.com> References: <20211022141616.2088304-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0159.eurprd02.prod.outlook.com (2603:10a6:20b:28d::26) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 Received: from localhost.localdomain (188.25.174.251) by AM0PR02CA0159.eurprd02.prod.outlook.com (2603:10a6:20b:28d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 14:17:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6e2017c8-d83f-42b4-cf2e-08d99566be25 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3406: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MyWEN+hdpj0XIgi4fQKN1AnX+aepTXLVwqu+etXVTJeDqUjxrxZL5IlfhLCfttGoTBijdoIkF7Mkqp8akcULKw2Z3oL0U0Ur8Gw6oRDcyqmEIm7QUY6snZNBFZ1EeHdgB7+ftIGRGTmIoF/QZFBwnp8UMiZIxL1jXmjqOllkqev9nk1WBkYar/6JdEnzO5jH0ueq9YEn7frOTXclXyolXUm90PlN4FSTMn8gcw/8PuKFK/2DwpGrHpEweMu3XAXvB68uriNISsAdjELLG6N5fDR5PUz+NZc6hoeyNguCkO+jwYa84nmLZ3gOBSKZPOq3eyH+oBNO3bHvKKstxq59WqI8nik8fFBENws82O6lRV/c58c4Eq53GbFpgA3dhmXz+ubSCJ+3hCNOLDLmxQasmyCeXviw/TwnxJAaaZdbNBu5g9G59QRD1Cl2HTyzQF3R/Swv1QaowhC2goLJKPSdud1piS6hCTALwvr7lOoHL4zQEAFebZvZ0sULAcPMmWqCq6BNY6fX8/xwtjN6UCPrBUf8pqb20Oad2e5xig1NQ1TCK+pTYuC3ksnuMQlkflrfCycPJJqChd2pacMQe0z7oPN+fBNOY0YvWedDFOpqONZ+mdSaqkMQwyiCP2h2zeuOvFMpOhxtlhtqM7YomXsgbrYK5ZqfCIvTlGfxKw+O9n9vaU7JfgxG+6ZTZ2jONtsltiL1gaIkl6OzsCzLjtMPhw== 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)(366004)(7416002)(8936002)(44832011)(38350700002)(6916009)(956004)(83380400001)(54906003)(66556008)(508600001)(66476007)(66946007)(6512007)(86362001)(4326008)(6486002)(52116002)(5660300002)(2616005)(316002)(6506007)(1076003)(8676002)(36756003)(2906002)(186003)(38100700002)(26005)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GyFopCwJ2N5fg7NtFeZoBCjF3q3ME6+KQBPRVJv+OyNTBIrZh3+8am0OmEXRLbqKwSF4NxAz68accppFML8ESkloZaV8euuxjGE/LCpjnDhSIAHiElqgo1pJ7UNGgWAvYEcthBsGLL6PTN6zEWy64PpnPylJiDu3pCou/QUhXcOg4Wfz1T+q71VUmdcJwFwMjV7TXDAbbDvEg3x0KxN9L3+PCaiSnzPE1bU/2NvAM7IUDmSxi74NiLsezJEL7YbHBxD+s/LGfXtZXa0ixOpM4SX4RWlAiYriTsp56IcFp1z+JeHt47bMu9hRy3vaAL5G7m8Ug397P0DEMLUzekSZK1S/Lilvx5ZnXqrSkLjmb82JWasX7N3vR+oGZg9ftoSUSHW1+mtHSzYbwH3eSeJCplRJXezi7V0NgC+ad2rr6L8dft1fJmtS42MyNpO+0bMRyu7uxeZdFnu9fgyfRuUJsfDf0ZmsxQb7UAYYOHfnbmFHQYE/3DDeza59WWGibfPVWhZlYyS7lDSvNcsOgvtLue8mgVh7A7CVBWE31uyuEM22JrMfW0xJxNu2vyCB2JBzwPUlWmO6+ZqTlzcVckCDssmYmNUQjp4/gYdvg+GqOpR5buukRoihaefEeiM/dt31kArxzidk/fFodDYHQHKxc5rHM1Behqn6AoAYedhMu2taPgaDxHVe3bNqU6gl2bHTcbP4rS4Q8b4z3r+mqPZXUfzFI92R9dp0MCnJzYaiqD09Z5lxgltC6MfxkujrQ5+LiS0bObrLS00jVhB/uTLhx9PJncKwrMUfsqllT296TSBcVhxkoLwAalJq9g+d/B/FVEvvu6jmtAHD9g4zkokMrqqHXKXJSmvxYLcUUvb9s3+ccsx4R7ozKeeOHIkjvKJ81ndpcfpWbsJ9Dk0jNDFur9f044Q0pT3B2K7U7DbH+5T2yKECR0iztRdzQ+WN+NiP2A0fxzOgiTncM48ay/sk7BzWU4CqUlnY9S9NG+U4rRqsv7fHjNWHzyXzk9nijLGDNaXIDARjQD7kYN3ncDdhXpNHut7i+o4ABSrp0Wzy1da57PQFvwmvVJQJUSKNXzqwB3AvlFM1yo+6drMiPpnj0lndaiprJbbz2x+V/+u4u19jGlw312Ta4nwPo4jciansVE2yi8fFYo349nPnPzufIREU3uuYuE9cWxMGpXId9gFzzLc4AFYpCjDj1N4E0a4ZkeqFwgH32eF6aNVGxkDHHcQ5sCSJS+KyZtE80LHKSwWDkhU+GY4OIk6Pzd2oMoSpqfdhsVs/pMASCgstyeS9/fKUtLoq6E85xT5tkHwz/nV4yntmHBaIiHk9lwmH2Snr0vaLXi5Fp1BbQ6/wl2ZxkbG2i6PSIXr0Yw7yvwlryjPI9YKUVLw8WerTgBYEiSDROrP2d7iejfUqRWMkngpt850dA6W5I6GiGSRb9CBzN5m/y6WTXHiUGdCuQIGZ3BGX X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e2017c8-d83f-42b4-cf2e-08d99566be25 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 14:17:56.0276 (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: vladimir.oltean@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3406 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Looking at the code, the GSWIP switch appears to hold bridging service structures (VLANs, FDBs, forwarding rules) in PCE table entries. Hardware access to the PCE table is non-atomic, and is comprised of several register reads and writes. These accesses are currently serialized by the rtnl_lock, but DSA is changing its driver API and that lock will no longer be held when calling ->port_fdb_add() and ->port_fdb_del(). So this driver needs to serialize the access to the PCE table using its own locking scheme. This patch adds that. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/lantiq_gswip.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c index 3ff4b7e177f3..d0900abc10d1 100644 --- a/drivers/net/dsa/lantiq_gswip.c +++ b/drivers/net/dsa/lantiq_gswip.c @@ -276,6 +276,7 @@ struct gswip_priv { int num_gphy_fw; struct gswip_gphy_fw *gphy_fw; u32 port_vlan_filter; + struct mutex pce_table_lock; }; struct gswip_pce_table_entry { @@ -523,10 +524,14 @@ static int gswip_pce_table_entry_read(struct gswip_priv *priv, u16 addr_mode = tbl->key_mode ? GSWIP_PCE_TBL_CTRL_OPMOD_KSRD : GSWIP_PCE_TBL_CTRL_OPMOD_ADRD; + mutex_lock(&priv->pce_table_lock); + err = gswip_switch_r_timeout(priv, GSWIP_PCE_TBL_CTRL, GSWIP_PCE_TBL_CTRL_BAS); - if (err) + if (err) { + mutex_unlock(&priv->pce_table_lock); return err; + } gswip_switch_w(priv, tbl->index, GSWIP_PCE_TBL_ADDR); gswip_switch_mask(priv, GSWIP_PCE_TBL_CTRL_ADDR_MASK | @@ -536,8 +541,10 @@ static int gswip_pce_table_entry_read(struct gswip_priv *priv, err = gswip_switch_r_timeout(priv, GSWIP_PCE_TBL_CTRL, GSWIP_PCE_TBL_CTRL_BAS); - if (err) + if (err) { + mutex_unlock(&priv->pce_table_lock); return err; + } for (i = 0; i < ARRAY_SIZE(tbl->key); i++) tbl->key[i] = gswip_switch_r(priv, GSWIP_PCE_TBL_KEY(i)); @@ -553,6 +560,8 @@ static int gswip_pce_table_entry_read(struct gswip_priv *priv, tbl->valid = !!(crtl & GSWIP_PCE_TBL_CTRL_VLD); tbl->gmap = (crtl & GSWIP_PCE_TBL_CTRL_GMAP_MASK) >> 7; + mutex_unlock(&priv->pce_table_lock); + return 0; } @@ -565,10 +574,14 @@ static int gswip_pce_table_entry_write(struct gswip_priv *priv, u16 addr_mode = tbl->key_mode ? GSWIP_PCE_TBL_CTRL_OPMOD_KSWR : GSWIP_PCE_TBL_CTRL_OPMOD_ADWR; + mutex_lock(&priv->pce_table_lock); + err = gswip_switch_r_timeout(priv, GSWIP_PCE_TBL_CTRL, GSWIP_PCE_TBL_CTRL_BAS); - if (err) + if (err) { + mutex_unlock(&priv->pce_table_lock); return err; + } gswip_switch_w(priv, tbl->index, GSWIP_PCE_TBL_ADDR); gswip_switch_mask(priv, GSWIP_PCE_TBL_CTRL_ADDR_MASK | @@ -600,8 +613,12 @@ static int gswip_pce_table_entry_write(struct gswip_priv *priv, crtl |= GSWIP_PCE_TBL_CTRL_BAS; gswip_switch_w(priv, crtl, GSWIP_PCE_TBL_CTRL); - return gswip_switch_r_timeout(priv, GSWIP_PCE_TBL_CTRL, - GSWIP_PCE_TBL_CTRL_BAS); + err = gswip_switch_r_timeout(priv, GSWIP_PCE_TBL_CTRL, + GSWIP_PCE_TBL_CTRL_BAS); + + mutex_unlock(&priv->pce_table_lock); + + return err; } /* Add the LAN port into a bridge with the CPU port by From patchwork Fri Oct 22 14:16:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12577937 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A0F0C433F5 for ; Fri, 22 Oct 2021 14:18:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0253160FBF for ; Fri, 22 Oct 2021 14:18:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232891AbhJVOU0 (ORCPT ); Fri, 22 Oct 2021 10:20:26 -0400 Received: from mail-eopbgr60040.outbound.protection.outlook.com ([40.107.6.40]:37344 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233073AbhJVOUT (ORCPT ); Fri, 22 Oct 2021 10:20:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hTo3iPtpYjJr212k2f+RDno2XflqrNLUJMjUT9LHdBT1/HEp/ks4tJKLTqlSOPES5Tr7CPacoegOTnibPWJMfZ16lRlWh/cVYqAjSPsy3/yxR6v+NcxKhAH035mACGjBntDY0CiAaj6kagtcLEi0JPCchtkxW1c008wZGuR1e3FBvSun1AreX4DgXwEgsJ7equ8zLyLcsP8+Zv88AZkdXjI5xTLSi7ZvXddEIrvCyyDY47i5rdR1Bp0hEl1lrkBvfqHrZvIGUdtKtmoEYgjIMgRyLh2KanA7a2smO4X8wfmGCFAUH6rpzYuXPbe5DMXIvjvyQqZ9zh5BA6ZbkQIldw== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vFX1e49Woske/T2LLLmiux09MkF08b4pSiRYnyL86ic=; b=iHMtEG9XqXyJeVG/8SUG31GFmzufhg/1dbMYXzr6yKy3GuU6v9StPsDoZyRNA33uVLYsHszMsZ26ceFFR9qmI0yjjlDZvWr7f7XBWJtg6wv+hZwPTf/Gl0ECblcdnwj91YWg23oP5EPax6C/fMJpKQq7Uj0wCEHI8fRmMQgL4kRPstqfTGSWVbw3WQZu/cmfeU+QVndDB8n13HMg1DIz58Fs6Hle0A/AZswgtj3if6ur+r5Ci6A7hoBPhooOQx9GYOef4cz4RTiUTilIes/wRdsDCqAjtRqy/HbVUgTffA5p+V5Ml+QHuQrNuGOqe0rvSUxTMIfcG5N+LV1A/Ua6uw== 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=vFX1e49Woske/T2LLLmiux09MkF08b4pSiRYnyL86ic=; b=Jig1yUFwp2ApaHksy2HoihxKgpjhOFs9q7lwz6V70/reCxFLGlz5+oEMd5EYtHaMhbzVBZ/xEFc0XkA33diF7tIkdtRNwxxiB91WoMnKmnUc/b76nftHi2ZHAb2OixjIVmrzNL331cMXqETIKG4tcxPDp0mVrhJrUTAXpm1qchg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3406.eurprd04.prod.outlook.com (2603:10a6:803:c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Fri, 22 Oct 2021 14:17:58 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4%5]) with mapi id 15.20.4608.018; Fri, 22 Oct 2021 14:17:57 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean , UNGLinuxDriver@microchip.com, DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Alexandre Belloni , George McCollister , John Crispin , Aleksander Jan Bajkowski , Egil Hjelmeland , Oleksij Rempel , Prasanna Vengateshan , Ansuel Smith , =?utf-8?q?Alvin_=C5=A0ipraga?= Subject: [PATCH v2 net-next 6/9] net: dsa: introduce locking for the address lists on CPU and DSA ports Date: Fri, 22 Oct 2021 17:16:13 +0300 Message-Id: <20211022141616.2088304-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022141616.2088304-1-vladimir.oltean@nxp.com> References: <20211022141616.2088304-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0159.eurprd02.prod.outlook.com (2603:10a6:20b:28d::26) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 Received: from localhost.localdomain (188.25.174.251) by AM0PR02CA0159.eurprd02.prod.outlook.com (2603:10a6:20b:28d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 14:17:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 50aafaaa-7bec-45f6-3512-08d99566bf3b X-MS-TrafficTypeDiagnostic: VI1PR0402MB3406: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: izXZ1nzlIFxMAessCwRDbIJaQkhYYQfzQyyPHEVUT+xCWo8fYx3astnIoLRmOYyXw4KRU2UvPv2UE3b6+9sjCA1f+qgMkvOsGasNXad1pzfadDJTSeguD3ZeHwwpjjolIV2DjyyxCIImZhGBVfrzMBgM3Mf9Pvaw0pSHztWyqb2QoXnP7C04LF/QqeLwslsEfXgmCLa2eBD0v/Cdu5LJUZxNLqX42TplIen4udJQDJe733wuYp9zFj3YuMFRAnD6MBfYwTbAUaekPcpLlS9oiDUqqnmSFJ/8UwoOxXZz9AMfGgXSykD7A6IPSHFpJ3LgS1rMlGPnKjbZu+7nlZ7w6Q7FMf3W1kWrHBHaYrc75LK8SCXhl3sXMwDpKACfOvsEGyS4Xbu0dGEjkMmfJV076DFmWpjlMIDyMO3ThbcRicZAwmBpWEMVpk6q8mDfrPdoEcwbuWJB9ljCYqhTPAO8Mj13GilGMlLUi6Lx+TgZ7Ijk7ondhvLnE5XS49t0/txzx3iEDP91lMEWwgJtWN69MFnVwvfBcWf1QPS4gHKcoq+M4bu5TJtaEscl1oOdNzrruPqJtqfumUlZpFpY3n7YLo8Xj92JDxnO03XTSGhBHojRorhUiBk9vMjUU/ndpq5q/5iYnRSZOROdx+39YwH1pnHkPST5nAPBJ11CYORZ/0KRH38zgKst0wR9jyP4RvrwhK2aidpuWZDYUAquZnjWXg== 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)(366004)(7416002)(8936002)(44832011)(38350700002)(6916009)(956004)(83380400001)(54906003)(66556008)(508600001)(66476007)(66946007)(6512007)(86362001)(4326008)(6486002)(52116002)(5660300002)(2616005)(316002)(6506007)(1076003)(8676002)(36756003)(2906002)(186003)(38100700002)(26005)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tKC/SJt/zDSg3F1g/hKSczbtSnCWBs+LlqwGb792MzOGesEIQr3WPxqDAjAAx3tEuhiYA92Br6/hvXYFANsFbIK7M2xdlVlY7ECqH43OwzLiqEyEsmBDpOgo5jIfpi4KwIQUIx0qqdS1qVz9kObMipCcjZe8QALrqzoiRHSgKww2gP8VqQgDZbRN8chxXppUfH9ke46K2louVPvX4AJ1DpDbvZAswZu2DHITmYJJoIvV46DRFE7zOBtqcVhzPHyn2y3v41V7aSH3T/FtgrPEAiEc+VDK8YJvvlXjlG01UPbx4dZ4t5JRbefb6JlDRGo3C8IHMQj+X++jgSpPb2LInH1RUFJ1Ndhj3Ep6UvrrJzfJxyMprPi9c34ZbNIDX2wS/UwO5YJQlCHrGrCQkXOhQIFCJ7Z7QxJtyoynmIursCnMPkevhyrLUVOuxUiDCn4QdDaBwid1+8Wokf+TpLmkdYQxnuFYQ28uy2+9sOY9P0dH+b8XbxffVGv5BPL1ghu9cxTtw4Hi9fMlpwVxIscJvbCSVhgOldqPRxT+eG1bYcUmzAWhcHg6sXrEKzfWaKiCMFkCYhE6ehqRfuUvbHOL16WgMrE66Pt57acwvMf/Mllbw5GKe3ZcUkEMvoHbz/RBGZWbzk8UANDll38tDPALTltDSDEfcnD5T0QvK4AmZSxisqGgzWH+KbqNk1dlBNnAnfpHQFZ6Qe3pnPbHNW4zMpx96MqT9cKtUy+LFF/m0LqiJtYu5DNcFU4EOgw5j0F9DI2SN+9DCBzSCBZj7YePtJZ9L0M11yM5dPdBFwe3LuAOzJGwxeejmFwOvft0vYeIVRZu0z9gZxllqAkvvrSD+PlkY5grh03IcsjIUDoykpLrED4H82w+esBKkjcbrX8rxAIx1DABnK0oks8iYIr1xiSBINEGAwBzS4pAGEiYIni2O+7fDUQBYSvoFK3tKOsfTtDdDSOeUgIpkNJs6MzKAXCUioYkDkiKjjmfxOdngY6bkruVdwneCAHWoLviGb30g8Kr0kLjiPkNKk6kKpQiAmuAkYl8bWUuD7QoJEoBhDgixPXauFjDS4rkxiqcvDbZ9smCvdgll0nJTcr1mh4BvhcmYub9twwwLSg9Z9ivj9+w8CNscHP/FtpHs2g9/k0X89m/XpxBQb3Z1qYMKOZ6d3jxCvWe0TRWVeN7bOO7f3/lwlFJ0WxwIt/ysWx2yS/tNUzoJqQDndRD0OF7/cy74aBnYTYIMhQBLCBMaYaXJ5mFBcNLMnMITxQabUiyw9ULQq+nIZBxTL+CfQsrp1/DlJYShWugRFCRSgGYFxUPQRx9SxpYcqM4hYJvEZD12djTd2EKzgFUpJwTQB0bP/xKYXlExWQ0VBBvqEvXJIxTV7rxi6GVJnjADpwHubHSrX8BNJqDZVRsPC5OnJaySgZ3zrvRljb8kHiNPcMy36JXoio7DexD7dLzGSarpcpgzOsE X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50aafaaa-7bec-45f6-3512-08d99566bf3b X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 14:17:57.8506 (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: vladimir.oltean@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3406 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Now that the rtnl_mutex is going away for dsa_port_{host_,}fdb_{add,del}, no one is serializing access to the address lists that DSA keeps for the purpose of reference counting on shared ports (CPU and cascade ports). It can happen for one dsa_switch_do_fdb_del to do list_del on a dp->fdbs element while another dsa_switch_do_fdb_{add,del} is traversing dp->fdbs. We need to avoid that. Currently dp->mdbs is not at risk, because dsa_switch_do_mdb_{add,del} still runs under the rtnl_mutex. But it would be nice if it would not depend on that being the case. So let's introduce a mutex per port (the address lists are per port too) and share it between dp->mdbs and dp->fdbs. The place where we put the locking is interesting. It could be tempting to put a DSA-level lock which still serializes calls to .port_fdb_{add,del}, but it would still not avoid concurrency with other driver code paths that are currently under rtnl_mutex (.port_fdb_dump, .port_fast_age). So it would add a very false sense of security (and adding a global switch-wide lock in DSA to resynchronize with the rtnl_lock is also counterproductive and hard). So the locking is intentionally done only where the dp->fdbs and dp->mdbs lists are traversed. That means, from a driver perspective, that .port_fdb_add will be called with the dp->addr_lists_lock mutex held on the CPU port, but not held on user ports. This is done so that driver writers are not encouraged to rely on any guarantee offered by dp->addr_lists_lock. Signed-off-by: Vladimir Oltean --- include/net/dsa.h | 1 + net/dsa/dsa2.c | 1 + net/dsa/switch.c | 76 ++++++++++++++++++++++++++++++++--------------- 3 files changed, 54 insertions(+), 24 deletions(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index 1cd9c2461f0d..badd214f7470 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -287,6 +287,7 @@ struct dsa_port { /* List of MAC addresses that must be forwarded on this port. * These are only valid on CPU ports and DSA links. */ + struct mutex addr_lists_lock; struct list_head fdbs; struct list_head mdbs; diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 2a339fb09f4e..04cc2aa3186d 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -433,6 +433,7 @@ static int dsa_port_setup(struct dsa_port *dp) if (dp->setup) return 0; + mutex_init(&dp->addr_lists_lock); INIT_LIST_HEAD(&dp->fdbs); INIT_LIST_HEAD(&dp->mdbs); diff --git a/net/dsa/switch.c b/net/dsa/switch.c index 2b1b21bde830..6871e5f9b597 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -215,26 +215,30 @@ static int dsa_port_do_mdb_add(struct dsa_port *dp, struct dsa_switch *ds = dp->ds; struct dsa_mac_addr *a; int port = dp->index; - int err; + int err = 0; /* No need to bother with refcounting for user ports */ if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) return ds->ops->port_mdb_add(ds, port, mdb); + mutex_lock(&dp->addr_lists_lock); + a = dsa_mac_addr_find(&dp->mdbs, mdb->addr, mdb->vid); if (a) { refcount_inc(&a->refcount); - return 0; + goto out; } a = kzalloc(sizeof(*a), GFP_KERNEL); - if (!a) - return -ENOMEM; + if (!a) { + err = -ENOMEM; + goto out; + } err = ds->ops->port_mdb_add(ds, port, mdb); if (err) { kfree(a); - return err; + goto out; } ether_addr_copy(a->addr, mdb->addr); @@ -242,7 +246,10 @@ static int dsa_port_do_mdb_add(struct dsa_port *dp, refcount_set(&a->refcount, 1); list_add_tail(&a->list, &dp->mdbs); - return 0; +out: + mutex_unlock(&dp->addr_lists_lock); + + return err; } static int dsa_port_do_mdb_del(struct dsa_port *dp, @@ -251,29 +258,36 @@ static int dsa_port_do_mdb_del(struct dsa_port *dp, struct dsa_switch *ds = dp->ds; struct dsa_mac_addr *a; int port = dp->index; - int err; + int err = 0; /* No need to bother with refcounting for user ports */ if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) return ds->ops->port_mdb_del(ds, port, mdb); + mutex_lock(&dp->addr_lists_lock); + a = dsa_mac_addr_find(&dp->mdbs, mdb->addr, mdb->vid); - if (!a) - return -ENOENT; + if (!a) { + err = -ENOENT; + goto out; + } if (!refcount_dec_and_test(&a->refcount)) - return 0; + goto out; err = ds->ops->port_mdb_del(ds, port, mdb); if (err) { refcount_inc(&a->refcount); - return err; + goto out; } list_del(&a->list); kfree(a); - return 0; +out: + mutex_unlock(&dp->addr_lists_lock); + + return err; } static int dsa_port_do_fdb_add(struct dsa_port *dp, const unsigned char *addr, @@ -282,26 +296,30 @@ static int dsa_port_do_fdb_add(struct dsa_port *dp, const unsigned char *addr, struct dsa_switch *ds = dp->ds; struct dsa_mac_addr *a; int port = dp->index; - int err; + int err = 0; /* No need to bother with refcounting for user ports */ if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) return ds->ops->port_fdb_add(ds, port, addr, vid); + mutex_lock(&dp->addr_lists_lock); + a = dsa_mac_addr_find(&dp->fdbs, addr, vid); if (a) { refcount_inc(&a->refcount); - return 0; + goto out; } a = kzalloc(sizeof(*a), GFP_KERNEL); - if (!a) - return -ENOMEM; + if (!a) { + err = -ENOMEM; + goto out; + } err = ds->ops->port_fdb_add(ds, port, addr, vid); if (err) { kfree(a); - return err; + goto out; } ether_addr_copy(a->addr, addr); @@ -309,7 +327,10 @@ static int dsa_port_do_fdb_add(struct dsa_port *dp, const unsigned char *addr, refcount_set(&a->refcount, 1); list_add_tail(&a->list, &dp->fdbs); - return 0; +out: + mutex_unlock(&dp->addr_lists_lock); + + return err; } static int dsa_port_do_fdb_del(struct dsa_port *dp, const unsigned char *addr, @@ -318,29 +339,36 @@ static int dsa_port_do_fdb_del(struct dsa_port *dp, const unsigned char *addr, struct dsa_switch *ds = dp->ds; struct dsa_mac_addr *a; int port = dp->index; - int err; + int err = 0; /* No need to bother with refcounting for user ports */ if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) return ds->ops->port_fdb_del(ds, port, addr, vid); + mutex_lock(&dp->addr_lists_lock); + a = dsa_mac_addr_find(&dp->fdbs, addr, vid); - if (!a) - return -ENOENT; + if (!a) { + err = -ENOENT; + goto out; + } if (!refcount_dec_and_test(&a->refcount)) - return 0; + goto out; err = ds->ops->port_fdb_del(ds, port, addr, vid); if (err) { refcount_inc(&a->refcount); - return err; + goto out; } list_del(&a->list); kfree(a); - return 0; +out: + mutex_unlock(&dp->addr_lists_lock); + + return err; } static int dsa_switch_host_fdb_add(struct dsa_switch *ds, From patchwork Fri Oct 22 14:16:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12577939 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C90EFC433EF for ; Fri, 22 Oct 2021 14:18:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A74B160FBF for ; Fri, 22 Oct 2021 14:18:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232994AbhJVOU2 (ORCPT ); Fri, 22 Oct 2021 10:20:28 -0400 Received: from mail-eopbgr60040.outbound.protection.outlook.com ([40.107.6.40]:37344 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233026AbhJVOU0 (ORCPT ); Fri, 22 Oct 2021 10:20:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PYiiUaXp/ilxIiUXTflAEYxNQaHcvU9ZXUVTB4/XusKCiN7ZJHtjbBErwxrVYb0AaibN0kCyLPsSV5oGbfWj9NSccZi+1h7NblxjMCaGMnROtCeyM8WGei84sug/rJ3xxreCOXz36I98rfjPzaDvlxeRLlwnMusIRg7SFAj7f4w2G0XiIB3pU6srvAzEFDfTSI1F0p5P6vXiRdLeM9mHVw5/i+6cJEzLFgAlPcYcVkNshASlhiE4mZjnK0Ts/pt5XFaSRlvBw0/qldV6EtgaFI19/dpwWKAoqXxMbHYfE2r1lJ8IghTsCgmt2uea8jf9mkmDRXsw/eYTSzy1hDeQZA== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=moRF2dH6E8ZFK1D4xqVmioIbskX61Dz3VexgeVOa1AA=; b=eStCequRCGSYyspiCUlOvpZQoizeojlcIo6Kta2XBmjGJ6qulOO2g5jw+mdZU1WwgJ8PRCdDUEaiwYopY2QgwUHX/tgiaHyNqwJ7SGOZR3YwPtqz/n5hWIUPEpDOj03KEQssvNt51uF1vwiOwYI4xh2qxli4WOlAc4RQapHOTOyWvzvLrjKePG7jiARdezO6DQ2YALnVCM0nZAIUDVea/0Wpls5L1R0vXrF9iq01fQwTdNxe3zfQkCvXm93qY0PqEr2xLbXVBin8GPFKKvfYg5GOUHKt4K1Xg3lsKWZ6vsDq3aqbxv68YMABCGqBxqNvFgcICUhVUs9mEtA+6atnwg== 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=moRF2dH6E8ZFK1D4xqVmioIbskX61Dz3VexgeVOa1AA=; b=GExCbfYePMz0UkJLQ9ajJfMonJNR1DZbh55CjF5j1n0xbsKQl52AxYBe7IJD8J+pWZa+kjaK8hQXjMbqfyLeMgRk2bEyXH4IKQLPXwWxKWF2IZ/9YyGBItgXz9SeeiNSU8jydJOKYndKU/244ul0IWrt5Ywi//Z/UTszZOX1kic= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3406.eurprd04.prod.outlook.com (2603:10a6:803:c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Fri, 22 Oct 2021 14:17:59 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4%5]) with mapi id 15.20.4608.018; Fri, 22 Oct 2021 14:17:59 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean , UNGLinuxDriver@microchip.com, DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Alexandre Belloni , George McCollister , John Crispin , Aleksander Jan Bajkowski , Egil Hjelmeland , Oleksij Rempel , Prasanna Vengateshan , Ansuel Smith , =?utf-8?q?Alvin_=C5=A0ipraga?= Subject: [PATCH v2 net-next 7/9] net: dsa: drop rtnl_lock from dsa_slave_switchdev_event_work Date: Fri, 22 Oct 2021 17:16:14 +0300 Message-Id: <20211022141616.2088304-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022141616.2088304-1-vladimir.oltean@nxp.com> References: <20211022141616.2088304-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0159.eurprd02.prod.outlook.com (2603:10a6:20b:28d::26) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 Received: from localhost.localdomain (188.25.174.251) by AM0PR02CA0159.eurprd02.prod.outlook.com (2603:10a6:20b:28d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 14:17:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3c0a561a-fb52-4211-d7c5-08d99566c04f X-MS-TrafficTypeDiagnostic: VI1PR0402MB3406: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C/HhIRSRDgvBVDw7WGmx3lnMOkB+GsBJslrwcjTkneiRY8Al6CZT0al7uV5kIiBaDgf9xGNuEsd1xY40eYpKDp1DaOmbJ0Aoy2BJhltFh7haVrBYALh+SNFOGb/V+lOs4izPrzqqxNpv1qLneyT2z1amNKyEXhCdR/45XEBVivfZIRQfqNh89npLwvbylMEGJmRDtTYeIFjZNZ/lL1GDAjwvPe2QJUDoZNeb+xrfIFnVEMtroWG/TiDos9VyfT/gu4dVh8KFKPOWvJviOhBObrMFNY5c7p1qJ4Ap2xz89oW8USkHIBnK0nAVSrb7R4n4QP8ekQ0tq+YwJGavzFS6xVfZsm9YFLEnOOps8ZWHUwuqEZJpsGYdNTUSO13M3VmAeurp57M1eilFVBJ8E5EWxWZI5q4ICgNHb6nRAGAGRGXYT49lPq9qYBsYUY9m4HYGyKEB88oge6uYbM7RHY+Wd9s3Tt60D9N11tpY/8KAI97kTfECLpTVhtXnns77860yeDmeb0xXH+t1VHqlq0/1KygulFJEum6R2909iNkSs9vDPbFy8CznhbjMQl6PrY19DvJXHf/bnkXfkW4/9x9fqLlXv19eQsiIPDGw4McSP8/+LWHpMeh3c71q8d5tJeIHwSBetyNliRXf20IFfmPquj6Q/n9UdfUh6f2bO+r0YO8cD4RC6UGeP0kfyM2DhDqAuTjoni+VyE/7BS/K9g5b8Q== 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)(366004)(7416002)(8936002)(44832011)(38350700002)(6916009)(956004)(83380400001)(54906003)(66556008)(508600001)(66476007)(66946007)(6512007)(86362001)(4326008)(6486002)(52116002)(5660300002)(2616005)(316002)(6506007)(1076003)(8676002)(36756003)(2906002)(186003)(38100700002)(26005)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dSKK33hRG5z2otykLSEfkpor0CYHDem2IO+jePEZiaqCohl5qmzi+HqVa+iw7DM9QyjEJRTIxVLuiaw9RoO+SyWpbi7PntMwnH1JmB/lBjaRIxKaiVwx/UqO3cE2xjMziXILnRNwuVWdHibEvU9/E3sDoWLO6rvoRQNJ9y7QBnr8cFo8SzGe3DO2pLW3nIdwj3r+6XcFjhK+pEBH6KmDPPSs8OWm9n4s1z//lEk7zqBVM0EPi0+wCgcorn/1gh0tgQUUXEnjliLuWvasyvNbyh/fpVnSsWjZiRM5R7xZw5/ejj9ulpTroBSEN8DJCrxLsKyGQ64wHbDS+KP8EK7m12bmL+qyOvK1XC0MvWACcFWsJNcXRxTxrOGoE/N9MoYkWJ9Fa/rvb/6CK4L7Fqz9BCG02y1kjgsrWlp+12VB9zQAifbcSBokauPyfyKsUuSATrU7agIgPAAZnbuYHIQdvz98PttVZHR6K8mzYgA6evW25JbH23kA1rU396nQQe39c+pqKJU+Lb1BJEVNC3ITWbl8esHDMLTXqkSu1Ph8PgZhs7ipHQhc3Z8+ZKVQL3kRn4J5D+Aq+wWmmk0f3hTK5YYI/0xD9ikbClWysISC9Ajrl0EKvgRyc7TPULOsnLDRmV6Vjzf+wCRvnQsrTpo3OoxLUXgppP2mnyPxlRBsyPLCQNY7dXsHFN41R6oJJq069HK+e8/f1RKA0m3n04UPXZy5FpJycf9BcokEIPYMs020+nTyHSBeks5mjGDCOERoYmN+Qm+/lHdF2IesXEow8SScb1HHKoJ5pPsmX9oay+dIjscpXY0N9JFAtrsBiiOzo+AscC664aYjILdnN87RMpo1PBEyCDHdTOLDvpOiPs5n5cfmwdl9WQipr5iPQR0cktj3KlDJ0oU6qNk0v02bOkmg4BMBTEm5oiJL1J5I05S4A6hI0mn+T23zjjY3HbcX+moCMaJG3PCHt6CEnI+TMcxYEqURqBUv+DE23ugXb3CnIPSQJeJ/+gaH7xfjI8gzumAJRS1XKVysf5gGaFW9i2saKAuBh3ulk/K6EvWToGUgffZX2f0HupSRBZ89620NhsJ2FkIAgWHd06jxTZ9FkzKM3VwBfgaWZLMvtFNm8qtySzr1gmgfVUEIYVHXQVnh8Mrva75aYgW47bObZkPIYxZWnW1syfurYvZC5h3fLsiaiORiZVws18A3LI8r/UurAfRY23hJA7RCPkihRcwC8InUjlPgztMDRPWT2V5oI5wXldRyM7AO38JKLdlHi7/jQ3DJEY9YIXQszygIduRb463SfovqnHSyp0RIqdfVQfw/zoqXHgq1otYXGGfZ8Dijh7JtXBuk+DwImFvCtt/qjslxkdCjBqytXBaKUVxtCK3/1IpI01Vh81i2+5Sk/0LXR3kUHVSFF2hPOmQmW03zm3LqEu6JNvJwTwM0tTAUNAgN3H1XFUGfllKNIaSu8XQW X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c0a561a-fb52-4211-d7c5-08d99566c04f X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 14:17:59.6635 (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: vladimir.oltean@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3406 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org After talking with Ido Schimmel, it became clear that rtnl_lock is not actually required for anything that is done inside the SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE deferred work handlers. The reason why it was probably added by Arkadi Sharshevsky in commit c9eb3e0f8701 ("net: dsa: Add support for learning FDB through notification") was to offer the same locking/serialization guarantees as .ndo_fdb_{add,del} and avoid reworking any drivers. DSA has implemented .ndo_fdb_add and .ndo_fdb_del until commit b117e1e8a86d ("net: dsa: delete dsa_legacy_fdb_add and dsa_legacy_fdb_del") - that is to say, until fairly recently. But those methods have been deleted, so now we are free to drop the rtnl_lock as well. Note that exposing DSA switch drivers to an unlocked method which was previously serialized by the rtnl_mutex is a potentially dangerous affair. Driver writers couldn't ensure that their internal locking scheme does the right thing even if they wanted. We could err on the side of paranoia and introduce a switch-wide lock inside the DSA framework, but that seems way overreaching. Instead, we could check as many drivers for regressions as we can, fix those first, then let this change go in once it is assumed to be fairly safe. Signed-off-by: Vladimir Oltean --- net/dsa/slave.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 9d9fef668eba..adcfb2cb4e61 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -2413,7 +2413,6 @@ static void dsa_slave_switchdev_event_work(struct work_struct *work) dp = dsa_to_port(ds, switchdev_work->port); - rtnl_lock(); switch (switchdev_work->event) { case SWITCHDEV_FDB_ADD_TO_DEVICE: if (switchdev_work->host_addr) @@ -2448,7 +2447,6 @@ static void dsa_slave_switchdev_event_work(struct work_struct *work) break; } - rtnl_unlock(); dev_put(switchdev_work->dev); kfree(switchdev_work); From patchwork Fri Oct 22 14:16:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12577941 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B32E8C433F5 for ; Fri, 22 Oct 2021 14:18:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DDC860FBF for ; Fri, 22 Oct 2021 14:18:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233113AbhJVOU3 (ORCPT ); Fri, 22 Oct 2021 10:20:29 -0400 Received: from mail-eopbgr60040.outbound.protection.outlook.com ([40.107.6.40]:37344 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233059AbhJVOU1 (ORCPT ); Fri, 22 Oct 2021 10:20:27 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S08G8mr9kTVhKY4+JXekZYJ7XYcibfrr+A9fC5M3vxLWPVOlpCEDH48nuVUdtAgPR8rQS/9n0ImtB7lqj5LanwsxcmimlYBX/WwSm+rPyzOAnaHOd4SryDiGUl/cy0DsajVQvsD8En+kpDAI4l339JtI9UU9/2jpL/wttFNX96h6IWcdodJ6ISvQzFfay6X+b+1/diqAFeD2IFGXIHnxpJjchDadqhcKwFM6YEoIdq2FAubkSn0nPEhzrZU2e+kA3v7+UqXxOGAgQQWz3htnzSSFlNCGc8HyMxJdaDllyeSA2qF5RE/0Bvfgig2xYRopWRiwuAPLFu0a7pCnG+mbUA== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Wp6y/wQG3E6+O1ToLzm5Cn0t+pqax6RObs/OjdtECwY=; b=DsvaSeXXXrtMyc+ySa1dVZdVC8e7o/IHVWPoAOeGkqj0NpVFO7eGmTMNRBWwQgofYTKu2DSb29tRl7ZV17FJuDFzIWEeOt5ewKSrTtRYD+zCNWEx97LXA/cpgq2jEnoYa2mmcPJ3dwFUf5r/f/JfzRTnFzt0FBTTUJy1qEuAPboWypgC7UEdmQr4syvmFWBRvE165N8KjEtG6UIfGphVrGsmS9nAyjqHxVqf+opmYWOUbUIQ8X38Sht4/iuykOpjuO+E4BH+KW20XAhYQiwTSmQEJdPvKhbzlEmfXkQvZ+VCDEY2YV0sLcNlwE6BLgOKhSFZ12LjHHyivo89gYfyoQ== 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=Wp6y/wQG3E6+O1ToLzm5Cn0t+pqax6RObs/OjdtECwY=; b=Xt/TH7ISPxAiQLl7yt3onJen8Txl5IDYjvZF+c/Xh4lpUNBYfadLPbAefhvYIhOwU0D78Lhb7/P7Pnn9UNpSY2aaU3daZ8iiAVD8E5yR/GHg3+kQOfrs2EE3x0hKYhgQk26AG53iV6BynDyPK5qMSG3NsnjHla6ZQPCLP8XFmQE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3406.eurprd04.prod.outlook.com (2603:10a6:803:c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Fri, 22 Oct 2021 14:18:01 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4%5]) with mapi id 15.20.4608.018; Fri, 22 Oct 2021 14:18:01 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean , UNGLinuxDriver@microchip.com, DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Alexandre Belloni , George McCollister , John Crispin , Aleksander Jan Bajkowski , Egil Hjelmeland , Oleksij Rempel , Prasanna Vengateshan , Ansuel Smith , =?utf-8?q?Alvin_=C5=A0ipraga?= , Nikolay Aleksandrov , Ido Schimmel , Guillaume Nault , Po-Hsu Lin Subject: [PATCH v2 net-next 8/9] selftests: lib: forwarding: allow tests to not require mz and jq Date: Fri, 22 Oct 2021 17:16:15 +0300 Message-Id: <20211022141616.2088304-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022141616.2088304-1-vladimir.oltean@nxp.com> References: <20211022141616.2088304-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0159.eurprd02.prod.outlook.com (2603:10a6:20b:28d::26) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 Received: from localhost.localdomain (188.25.174.251) by AM0PR02CA0159.eurprd02.prod.outlook.com (2603:10a6:20b:28d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 14:17:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f839f287-7571-46a5-7c62-08d99566c186 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3406: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1079; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0WTiZ9gfGA9VsnX+mb8OByr2R9MahiGRH3UF5nY67K8AmMMdsBq5hSayAzXwuoIfZo1uukJzm/DAYihYkJQzAjRaiXzo3Ggc7zoHJOQ+Zr0hnKONMn0VPSgkCutqeKEAtona6QkwZzC9E2agmF00YgiDjgQnwrI0PotRqOS7bHucSHYuoPsVMyGGWiARYZeXs04Eiz4osjEwHvReq/smBJdAK80cNm/SjCOVUtqz4SFFhFVQLuMg6Jj+O3BodZ5ZhFakmr7a0HuNOZNG47eas52Pzr66jyfljCAHccQ4kTCiKJJ1oB2UJFISIeKhjRpCpOaTsFOvDKbCNO2F/TGpk4m9Qbsirpqp8Lr3kextipPq2KJPscQ44vTenFkkAQ9fbj9kHMBRIJyBKjJpDuxsUqi1xRcv7XsZwGZBmukqS+b2u/NSOBYKpB88VUX5JmhyzguMdGx1P9qpEvCYMG+p5rVzRXIhw6he9VUsNg2Conr1Jqi3MUUlW659X3UYfCMHXQIOe9J1ov/Cd/PfUgr0ucabcHWbr6GF9Othea2coH4z7ZKzdbz7xadkBMd9Voee1Ot3fp+35+ccMxdjnP8QQA9H0yGNKi0FUhVCziVEgOL/x0TSzTrmQVBGOMHlCMJQXGPhfHp5lgmg7YbZYLA53b3tTqK5fzFhogS8UjurSKcG5Ms7VGqcBP/IeveszGcW+zXWMuDxKNPQevMkrbKAAA== 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)(366004)(7416002)(8936002)(44832011)(38350700002)(6916009)(956004)(83380400001)(54906003)(66556008)(508600001)(66476007)(66946007)(6512007)(86362001)(4326008)(6486002)(52116002)(5660300002)(2616005)(316002)(6506007)(1076003)(8676002)(36756003)(2906002)(186003)(38100700002)(26005)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YjeetYWFZ+zTNIBPHTUyXCTtj836OPOWOpbNt4gmNN0T1+y4QnhsoR+Bzuc9ZXrksghRf33osK7S6/nvZ2KDdLWTA+VFEdDkPIlflZhRyeVYso9c6ihnwy+re3HYJLBCFoXQrqk6Uk1BxOD7NN8QeSTlUIDzekQgCwXr2AS1J6toZr0rshzsF3AyMif4rd+HceSHqMb3x+LX4hEBjfYOF+D847kh3U5rqEa6ED5wp58cURYQPn+/wlX3StzMRCZ2O1aC9X6Egt9Rsbz+fE71Fp5CjCMMTq6lVYNzUvG/SHqv1jvomEsH6rW4iGE3linj7/ntrDhEJwtFlJMsozVxGJ56qghZBXkVaTBr/GnBls1yNEe4l7p4wAOdqfTWeSz1gasx2e4Jbg44v4ma9yiR40AYO1Sxws02NeeeEBxWdCcdu0u/4HvlH+M3QHrDTp5F9aYDhEPjMSfl48P+rHXUhJA0RDB21GvA+GhQcUUcNIPIquS+7ypQLV6eZWeuMRC4KEKE7vDckql72qI/ofAmwKS+zQ5Dp7vnmp/7sCOSUgyozpefNuE5hgiU0kpxIC5C6Qa32GzomVC9+0E7cAgZ8iMJUmhmY++rKUuatUhMSP8ON3z55tet/PNeabhWiLGPdtJUu5edd33Jb5bN7d1FfM+m1Wvw4O6wgneKJNuiNvksUrkOfSbrG1EUw+6MsiBWPwaEekP/2/4MKQpEjUW5XxIh5j1e6T670lHKRZRHgMV+JRexa5ihQFLnl436+yntH6jFtGfJnmIXIfmETyfuCtMb5rB8naeN1ddp+h00lx76mYm+buD/yu/muvp3oGJ7jsmv2/guvcFb5YlX47NnrV211AZ4BSNSPTv5GYrthm2xqvDAJ7MFgM+0II/bEKrWowpjbWHfpCyvim1aDliVO/LCi9XNN5LVxI1ZSG6TiizILlDIvGC2WHiV3MYSHaVs13GhTVtvW/RV4GstV1zVVKMmYEkdFG0UwDKeFw2wUAMTAUp5qT5/lYDK5ceY/BVQ6RqfyumwLhuyRAz//POkniaWZNf1RRcOztGe1zI6Thn6Ytu5J9VKRbajS+E5DJgIGLKrMUAvXcVsafpZvWB8DpcfmlQcbXy2qV2xJ+LbIXyLqGmQsBF1EJqPU4u6rUXuI3As+j9NMqF+wYc/sPXzozb5obB89ZysNyPG3DC+cQb7ABVqIgshYAuo90nvTpR4Cuk0MrJmgxaWbgqhxJirEBHm20zUm0UDpkG7pHVVzYBYkmchL+Ymfk30CneB3lDqGLLcs5Kror5aCrwlQWxITBkDrrsC4CA8TsgkwTUtTEhHLrkmDLb88P1GT3bbvOEQy7R2CSgpDbtnYkFx7mo5XL7bBuZQuMxdsk1u6epfehTX5KVniXpBONX1alC8XrQWdsANVStwJQS0ySOiU5217cfS4Om4m6FaPEMJCA/Bt9AFsUojOGGKWChsLvmmTDcR X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f839f287-7571-46a5-7c62-08d99566c186 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 14:18:01.7004 (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: vladimir.oltean@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3406 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org These programs are useful, but not all selftests require them. Additionally, on embedded boards without package management (things like buildroot), installing mausezahn or jq is not always as trivial as downloading a package from the web. So it is actually a bit annoying to require programs that are not used. Introduce options that can be set by scripts to not enforce these dependencies. For compatibility, default to "yes". Cc: Nikolay Aleksandrov Cc: Ido Schimmel Cc: Guillaume Nault Cc: Po-Hsu Lin Signed-off-by: Vladimir Oltean --- tools/testing/selftests/net/forwarding/lib.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index e7fc5c35b569..eb8c783f35b0 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -23,6 +23,8 @@ MC_CLI=${MC_CLI:=smcroutectl} PING_TIMEOUT=${PING_TIMEOUT:=5} WAIT_TIMEOUT=${WAIT_TIMEOUT:=20} INTERFACE_TIMEOUT=${INTERFACE_TIMEOUT:=600} +REQUIRE_JQ=${REQUIRE_JQ:=yes} +REQUIRE_MZ=${REQUIRE_MZ:=yes} relative_path="${BASH_SOURCE%/*}" if [[ "$relative_path" == "${BASH_SOURCE}" ]]; then @@ -141,8 +143,12 @@ require_command() fi } -require_command jq -require_command $MZ +if [[ "$REQUIRE_JQ" = "yes" ]]; then + require_command jq +fi +if [[ "$REQUIRE_MZ" = "yes" ]]; then + require_command $MZ +fi if [[ ! -v NUM_NETIFS ]]; then echo "SKIP: importer does not define \"NUM_NETIFS\"" From patchwork Fri Oct 22 14:16:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12577943 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75848C433EF for ; Fri, 22 Oct 2021 14:18:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5788A60FBF for ; Fri, 22 Oct 2021 14:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233059AbhJVOUm (ORCPT ); Fri, 22 Oct 2021 10:20:42 -0400 Received: from mail-eopbgr60040.outbound.protection.outlook.com ([40.107.6.40]:37344 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233026AbhJVOU3 (ORCPT ); Fri, 22 Oct 2021 10:20:29 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T4ezYwm6l96L1FJYKaWnAhOiH/YbXxW7knVqHF/+xhx/RkYzoV72KV0ckZWXj/NvXZQkUitBrhsognc8SwtsUzu5R+Emncex6LuawS55DTFcN7F2mu7VL/kbRuR+xghONKs9xNPYeIk33WsNpH3+BRdNXKd8RJehjnXFrBOoOmGNtkGuk+QQQS1XhK0oGSORO5A2rK6RAEkwWeGv09ub5QpWGm9Y3ApYTQXqjRQVd25JsMWM/O84n6m0nytosQiRJsa1dRPsvqrmkCi3AAnoBPMf7HoVNG1sGFMEz4jx/6NVDkY2fptaRaF0WuIuKiM3IgX3mlS0AidL68akLHmAVg== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3PWTbqITJPkSQdgm2xTfieSUveBWc5U1KkmzMOQDlEA=; b=jshhYtUhRDbtyNKSuZOCpjmSGi4SweZ7tXFfxEHmjQIFs3qT0nXELxs3rNlYeKY5Io9vGHez05Iraw9xhVyEXfBOOHgJupn+il/yMGLFnGewpivpylBumgYILOU1mMO4wW3gNipxjZZYqNMLgyMKuHkt/dlrZ4D39GHod7Tk36ZkY3c/H1+5o2Zoii9ctdg1xJBPVguYgMsQglpGuKFZcUsCTuORPeW3gV9yWiryOQEDM/aJwOCkf/9dq9SYMdIRgW/nbUnB/vCh9tiCootccZefDRi7k/68iyhncHAP/jxUJbrAIm0mqsrkrwbO81oCh+3RuoMDMAHKHNYmE7xJng== 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=3PWTbqITJPkSQdgm2xTfieSUveBWc5U1KkmzMOQDlEA=; b=dzyD/84aVM5uOtzAV0mcpcq7gEQS/o484FyU8hJKPr/SGSe1uIBk3RtHmamHAAunGwjNue2hl0rDSmdQYawnPYlDMQywl8heaYxcP2VIY+YIkwEGK9AAVjbwD44NudhCiLVHb3Z0knmyPmgbO2RIpkddhk6fmTF/retuwSiRRCY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3406.eurprd04.prod.outlook.com (2603:10a6:803:c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Fri, 22 Oct 2021 14:18:03 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4%5]) with mapi id 15.20.4608.018; Fri, 22 Oct 2021 14:18:03 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean , UNGLinuxDriver@microchip.com, DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Alexandre Belloni , George McCollister , John Crispin , Aleksander Jan Bajkowski , Egil Hjelmeland , Oleksij Rempel , Prasanna Vengateshan , Ansuel Smith , =?utf-8?q?Alvin_=C5=A0ipraga?= Subject: [PATCH v2 net-next 9/9] selftests: net: dsa: add a stress test for unlocked FDB operations Date: Fri, 22 Oct 2021 17:16:16 +0300 Message-Id: <20211022141616.2088304-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022141616.2088304-1-vladimir.oltean@nxp.com> References: <20211022141616.2088304-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0159.eurprd02.prod.outlook.com (2603:10a6:20b:28d::26) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 Received: from localhost.localdomain (188.25.174.251) by AM0PR02CA0159.eurprd02.prod.outlook.com (2603:10a6:20b:28d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 14:18:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e36b1317-00c8-4e21-0955-08d99566c29c X-MS-TrafficTypeDiagnostic: VI1PR0402MB3406: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UU7ZLxPfMKYn/Gecv+XMzTN0XBW2p1wLm3e0VmvfjK8lA/8UKAQ8hKsQv6V/zgmbuJjnr2U0kx24SiW6bMVVHFRp8pVFxzdaEogRdWufWeiW7BTgRzwxYrSvplzM3o0swRafbGsTDPhs6AWBRWvwDpXjsFe8Z1hFRvh/GB6p7Bl8TrnDlNUXXb0C66AEnTbxpagweuyh8UoPCgUszAhpSyMsUHdNumihlWKQE98EK11SF44s8d7b388uC+nMoHHsfOWX3RZVMOOCN9Qq+YIS7XqfouWl1P+PhVV/zpCVPWKY+kk28sY1bEghglLMx/9tXmaSjU9veXN9itHHzM83QqmoACw1icD4LK9Nj8v9CPV1AJahHixnZyb1WublIoUL731W2PROgyJXyYWIhocPlWeD+IZH0Q67+EvSUBcR8TIdLhLYnVn3xGYSXXCBoQxm5iN1c/GRTSHWzkcGFW6UAgyuN4Rv9Jcns/36fogwgOquiA+Na2/Fr1RErNBkpd9MQBxUHiffJiJQk7KZf/N1+RMlrquVnKmW0ZKQ36lvz+OlVMye93fpa9OXuLE9JWPzDIMEowx/6p3lgidT/zXGJKJFhwHxWPHxabnn37npaYAnOXMxFgUGkPhkTLy6g4sS//mRG4fNWYbd5Bg+zwFrQ1qQVI2fpN+x14tXQn3v8Dt86Z4zGxjpW5rZubQZnuHxUbLoLJG/ZUty/LcQUxkzkw== 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)(366004)(7416002)(8936002)(44832011)(38350700002)(6916009)(956004)(83380400001)(54906003)(66556008)(508600001)(66476007)(66946007)(6512007)(86362001)(4326008)(6486002)(52116002)(5660300002)(2616005)(316002)(6506007)(1076003)(8676002)(36756003)(2906002)(186003)(38100700002)(26005)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bajAzMrbAlE7ykddJc80HlaFzHAOf3c8gk//sxc/+JlnZ9Jgj1N9NIZydidUv2lVOJhGf+U480gttZGqofGMAmv0BEdCYtx/SXDoNMxiI/DxWcx0VW/0r5HlB+kWK5Z4WC2EbX65yu8PIiJ9bfZLlRjWqPtcu/X9fmhK3ZLpZEACNNt0HAmczfsB9wZY1VZTRRoixJWnJUl8G5pi2yraolrnYY6+9tbLwZnf4NZEq1NuxDJ3LG7bBWnQ0y7u24yhXJMBk/ZPn7H8ixMTp0uMnh6ogq/fjKdP/YwJP/Y/KWixgqS/DdsHykT0i/j7AXndr819eC06iuJKelbU+QiD4HmWnfRLSQC+9xuie2YIJ0F/pTV1bg1AUD6tQ+nWd+Q0q6nYuvM9LPu85LeBqEGYxXcZpONwMtebnnpVh3Wz87VPm6SC5nYRC4wAKhJ2Wlh7JwMFK+5pDoCU110W6U/n83yqEYckWHaxunC+OK7P1Tb2DL1iDQoDylRiMTzvElt/15T0iamRRRz9PszhAGls9teTPMgczqXM50URdKoUXkmhRcJAXR48jih3nXabj4K+x+rGcdBkpZB35laEhT1JAh7+sgCINPxCtmkpKyZ0g2HuZUR4ydgD1qQMk0X9UmPF+Ayn+S238jOQbEJ/gtxiR3ncxWetKBsSdDdrmx5Vc427Q6gsrTAKIAWL+IF0brI/AeEXrZmo6A6qfulZdcr6MkGznmlmHq9R8Zg0fq826Csf2a1TGOmCq6XIGR8S9REQxgkd7K1Vb5GgnMBaLaEMbj2SqyBFIOAz90Ez4ebdiRvJUCBUSy9e/D8Ic6q1vUApvezcNBkCVEcOmCNMa98y2O+/kjHXTE63nUvy0q5CXJfz2p4bR9ty0EOtCYw+2L5LE/RJFtU1tFD3rgqqeE6tMoPHMEk9+pRyzpZ3bX/90sc5Entmh+wZP1oiXi3gXWxEJhzriPb5lxxI8g+NjvyTRr1x/5k4wqk/YpiNdIa06/nzSJ97iZvqO079ReGyweeWBxWlRKUhHdYWyZA8yQmAWvyCX2cgC0fvNZRW5pj+84P8oxDyZvxHgkITQKwEYKMVBsoGfAT9f7kj581HGCOQRUziLAHXOqRWimtfc0T/hwklJCehoWd13cxxuP46o6K4ahBNQ/QHnM1E5t4ACSHQO8aCuy/ljlxv4En0/dm68vpuOBqk6xA+pJWEDjLUB+5jmRX3nDuA9PZK9Wyv4NVWZbT6MAt43P96H7Xnaacc8E8SS89mtKRjoFNT/OWzX+x9EBi91VY1LTssaNi0Cx2uo7TcZtO6R+nXalE7fjKHWQTn13cuBO3sK5Ygqrarsn0tLBviGvUMfDD4SEEDB4AfFirDs+0Vx7+HUnhLfIAj6R/knSDd0lngjIV/utpnqPC8pzmb2/dOO2DGpgC/Iu/TMNcrOJgs+MnT0NAX19Eu/XAwgAxag70YWbmQ29GurJn0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e36b1317-00c8-4e21-0955-08d99566c29c X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 14:18:03.5193 (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: vladimir.oltean@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3406 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This test is a bit strange in that it is perhaps more manual than others: it does not transmit a clear OK/FAIL verdict, because user space does not have synchronous feedback from the kernel. If a hardware access fails, it is in deferred context. Nonetheless, on sja1105 I have used it successfully to find and solve a concurrency issue, so it can be used as a starting point for other driver maintainers too. Signed-off-by: Vladimir Oltean --- MAINTAINERS | 1 + .../drivers/net/dsa/test_bridge_fdb_stress.sh | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100755 tools/testing/selftests/drivers/net/dsa/test_bridge_fdb_stress.sh diff --git a/MAINTAINERS b/MAINTAINERS index 20ea3338404f..997bdbf615f4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13054,6 +13054,7 @@ F: include/linux/dsa/ F: include/linux/platform_data/dsa.h F: include/net/dsa.h F: net/dsa/ +F: tools/testing/selftests/drivers/net/dsa/ NETWORKING [GENERAL] M: "David S. Miller" diff --git a/tools/testing/selftests/drivers/net/dsa/test_bridge_fdb_stress.sh b/tools/testing/selftests/drivers/net/dsa/test_bridge_fdb_stress.sh new file mode 100755 index 000000000000..cdb7f9ca2251 --- /dev/null +++ b/tools/testing/selftests/drivers/net/dsa/test_bridge_fdb_stress.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# Bridge FDB entries can be offloaded to DSA switches without holding the +# rtnl_mutex. Traditionally this mutex has conferred drivers implicit +# serialization, which means their code paths are not well tested in the +# presence of concurrency. +# This test creates a background task that stresses the FDB by adding and +# deleting an entry many times in a row without the rtnl_mutex held. +# It then tests the driver resistance to concurrency by calling .ndo_fdb_dump +# (with rtnl_mutex held) from a foreground task. +# Since either the FDB dump or the additions/removals can fail, but the +# additions and removals are performed in deferred as opposed to process +# context, we cannot simply check for user space error codes. + +WAIT_TIME=1 +NUM_NETIFS=1 +REQUIRE_JQ="no" +REQUIRE_MZ="no" +NETIF_CREATE="no" +lib_dir=$(dirname $0)/../../../net/forwarding +source $lib_dir/lib.sh + +cleanup() { + echo "Cleaning up" + ip link del br0 + kill $pid + killall bash + echo "Please check kernel log for errors" +} +trap 'cleanup' EXIT + +eth=${NETIFS[p1]} + +ip link del br0 2&>1 >/dev/null || : +ip link add br0 type bridge && ip link set $eth master br0 + +(while :; do + bridge fdb add 00:01:02:03:04:05 dev $eth master static + bridge fdb del 00:01:02:03:04:05 dev $eth master static +done) & +pid=$! + +for i in $(seq 1 50); do + bridge fdb show > /dev/null + sleep 3 + echo "$((${i} * 2))% complete..." +done