From patchwork Mon Mar 25 21:49:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13603021 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2065.outbound.protection.outlook.com [40.107.102.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E1B26EB6A for ; Mon, 25 Mar 2024 21:49:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711403383; cv=fail; b=OxQfloqhIwT9UuIdxwfMB/Gfb6l4vjvjSruwv//BwMo/twyGD8DCK/8vIBDKUBGUHXv9c62TtaCk3AB86Q/XUJTuBxm/imzuwgiSJY99VuyK/l0It2ZlFQw07IkYWyENzFJQloc7cTZYzidn3RUG5wq5Tc+bTuxfydnjtqQcNLY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711403383; c=relaxed/simple; bh=kBnjuKwul0LnW5gd5ObXG/9SJgFq9BdFxQq/JbPr3v4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GrxtEzlz4Y0rMKpvJpFyF2CnFZV24roxyMkyky1/Dt99xMsDhJ0GJfQpIWOWmInVVLIGSYdLKO1chL/VXSzCKYbKiSHksHWQnISAQ0DF9aTVweuo2cxmfpH2yniKYh0pzkzt8hxWjfLc5ts7mvwOWF14tHQzNSkdDeMaNJ9BjXs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=QnGnTPAR; arc=fail smtp.client-ip=40.107.102.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="QnGnTPAR" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XiDjLEU6pPmyCTXd7wG56tVWmonr81lQQjQqgwjrva3oaauKY71FW+PbXqcKL90EYGMy0QRUNIVlxb2aDSyhgJLa7IYbBpIo4Y9L1hmHXGus2pNKqvdrLKOVVC6K0o5Wdelcr934vbSRFSWBXoGSpP8icZex0r9zIbEtHjfYQwMQb60hd7xbLBKKPMJlt4fkaUPidGeSVYQsq2RcDVD4voxjkMvRKt/3ViNPc140F8DPbY6o3PhB3BTL/HGXrd7/XVEf4XJx0WKXB2+20mDGsvAwylWxPKR2lks3h/rS0M/l281eYF4FQmQ7GYGACx2T1RJOo5dH1FPNEs4qd9JMxQ== 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=uYAQlY7FTodNSPI7QWCNrNQ5wehEHPQz1C9x0LNR0jA=; b=d2bq0qLgHGk/oCSMy2264ECK2EuYyVU7Hy3fZN1dM5wYWm2zvAccJOHLv4U6PyTVGlru7o3q4DI/IeKhyoHU22hNkGcpizBpaLOiX1CiaFmpGqGEUMGS3D0ytRcwhSN0FvUKsFfc0GS1MRi/JGgU5uHOXHd57LoSOzUL2mEd6AFoIv3JYTSpUB25vos4hDvzSKwfXgtV8kGr5fBUg3W7JsfmlmyOimzgi1O0uDhrCLjDxOxH5DICTun3i/W5XnjhDlGv/crQmwc219cFJSJkGGDWcNTsZJCt6EDTOtweYrYuwF79xPLnH0LpcSvnejLx6jEkoEoQX4Mfk3O0Af2ZNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uYAQlY7FTodNSPI7QWCNrNQ5wehEHPQz1C9x0LNR0jA=; b=QnGnTPARIbuUX6fSzkIXPaiZeI0QXvU4qRaSOkrdhuvOT/vGyzRbxGThRnn5edpFmdPw3nFxmGePDDgopzaZ++k0P60MkKGO2BoE8fbXuS0AMICwedKSJKEBz8msCGR5FrkFXc0Y89Ou2S00cew9748bmmuCyf0J7mNIP6opJi1fq/cDdrnETzviLig8gSSQAPLZSnzBvH0Y9oNTPy9TJixe/DdyrnW6PlFmoolNTzpvWsO1kFRS683L7vG35m3qvGyU0oxdWzzvi0n9Szb5rtjGcwUt+LPXY3FCvZlL4Ddg8ViIAaxlAmtbpaxM7xmap4cWHuZ8aDOTk3Rg11xsaw== Received: from BYAPR08CA0010.namprd08.prod.outlook.com (2603:10b6:a03:100::23) by SA1PR12MB5638.namprd12.prod.outlook.com (2603:10b6:806:229::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.28; Mon, 25 Mar 2024 21:49:36 +0000 Received: from SJ5PEPF000001D7.namprd05.prod.outlook.com (2603:10b6:a03:100:cafe::c4) by BYAPR08CA0010.outlook.office365.com (2603:10b6:a03:100::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Mon, 25 Mar 2024 21:49:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by SJ5PEPF000001D7.mail.protection.outlook.com (10.167.242.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.10 via Frontend Transport; Mon, 25 Mar 2024 21:49:36 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 25 Mar 2024 14:49:28 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Mon, 25 Mar 2024 14:49:28 -0700 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Mon, 25 Mar 2024 14:49:27 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next 1/4] virtio_net: Store RSS setting in virtnet_info Date: Mon, 25 Mar 2024 16:49:08 -0500 Message-ID: <20240325214912.323749-2-danielj@nvidia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240325214912.323749-1-danielj@nvidia.com> References: <20240325214912.323749-1-danielj@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001D7:EE_|SA1PR12MB5638:EE_ X-MS-Office365-Filtering-Correlation-Id: badd5146-dad7-4ccd-4ae3-08dc4d1576ba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A8NBz8EiA8YEQ9xw0pmkX9c80u9XAcyIK9GxghfuvtNxO/QtNBekIHKtvi6XQEiLRTJLY+0riXlhtBKedce6ZpdcvvzkZ9ZPh37EWxcS/RYkmszYSC1omsrxbbH1n8gr1ciFFnf5YKfBD+sjdq46sSLmOd0/g7nA5W6f8VG3uLjLQaKhDFB0QmIoT5snQLeWpRq5Dpxj5+C4nT4RXXI+OP9d1Gh69/4CNNBR2SJeHTPgaL6CstUgm2II/yG4n1GutSBOykXIQzRFazB0CgRB7kPPfOW0nRyLYLGPX2vekwTPBi26NZ+pUzUSENrRjsYqYSwpBfut5hZH95NUWzwEiGlLtuPtOuPZcNUInikZWU8mkz4NTzy1mnDGFMhennjkfJFWG3PkZZ/JAl3Thu0Avf4FuEdWqhjwkyNn1uuNMEhe2pmlyiDHV8WS1zezIJzAjU9P6PVpypf2T9MB5FTXGCNhtpoukSYB5puQ+azA5/r6VfOto2ECehV6QLmceC8YYQii976bnuPgg80NEExSWsgd+voklBjehUHevQ7uBUrHdIKKEZS9DDYSxkg5pPa+uaxovhEt3bNJiQGktw2EWOe3vldUe6L6HONhK5C2zdAYgHPytSQ2/Ul5Ewf6tJKpuAR16eHCqhdpkU2pqd2TManpHzeGGqxRwbKqr7NZ0yojm3kBYPb6eblZ8pgCPu3yW618KPCfd2duAIgIaQSDDGnEEYcrxRajUu0hNPdJS7QC5SztsLkY52cG1V5fcvIC X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230031)(1800799015)(376005)(36860700004)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 21:49:36.1183 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: badd5146-dad7-4ccd-4ae3-08dc4d1576ba X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001D7.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5638 X-Patchwork-Delegate: kuba@kernel.org Stop storing RSS setting in the control buffer. This is prep work for removing RTNL lock protection of the control buffer. Signed-off-by: Daniel Jurgens Reviewed-by: Jiri Pirko --- drivers/net/virtio_net.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index d7ce4a1011ea..7419a68cf6e2 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -240,7 +240,6 @@ struct control_buf { u8 allmulti; __virtio16 vid; __virtio64 offloads; - struct virtio_net_ctrl_rss rss; struct virtio_net_ctrl_coal_tx coal_tx; struct virtio_net_ctrl_coal_rx coal_rx; struct virtio_net_ctrl_coal_vq coal_vq; @@ -282,6 +281,7 @@ struct virtnet_info { u16 rss_indir_table_size; u32 rss_hash_types_supported; u32 rss_hash_types_saved; + struct virtio_net_ctrl_rss rss; /* Has control virtqueue */ bool has_cvq; @@ -3048,17 +3048,17 @@ static bool virtnet_commit_rss_command(struct virtnet_info *vi) sg_init_table(sgs, 4); sg_buf_size = offsetof(struct virtio_net_ctrl_rss, indirection_table); - sg_set_buf(&sgs[0], &vi->ctrl->rss, sg_buf_size); + sg_set_buf(&sgs[0], &vi->rss, sg_buf_size); - sg_buf_size = sizeof(uint16_t) * (vi->ctrl->rss.indirection_table_mask + 1); - sg_set_buf(&sgs[1], vi->ctrl->rss.indirection_table, sg_buf_size); + sg_buf_size = sizeof(uint16_t) * (vi->rss.indirection_table_mask + 1); + sg_set_buf(&sgs[1], vi->rss.indirection_table, sg_buf_size); sg_buf_size = offsetof(struct virtio_net_ctrl_rss, key) - offsetof(struct virtio_net_ctrl_rss, max_tx_vq); - sg_set_buf(&sgs[2], &vi->ctrl->rss.max_tx_vq, sg_buf_size); + sg_set_buf(&sgs[2], &vi->rss.max_tx_vq, sg_buf_size); sg_buf_size = vi->rss_key_size; - sg_set_buf(&sgs[3], vi->ctrl->rss.key, sg_buf_size); + sg_set_buf(&sgs[3], vi->rss.key, sg_buf_size); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_MQ, vi->has_rss ? VIRTIO_NET_CTRL_MQ_RSS_CONFIG @@ -3074,21 +3074,21 @@ static void virtnet_init_default_rss(struct virtnet_info *vi) u32 indir_val = 0; int i = 0; - vi->ctrl->rss.hash_types = vi->rss_hash_types_supported; + vi->rss.hash_types = vi->rss_hash_types_supported; vi->rss_hash_types_saved = vi->rss_hash_types_supported; - vi->ctrl->rss.indirection_table_mask = vi->rss_indir_table_size + vi->rss.indirection_table_mask = vi->rss_indir_table_size ? vi->rss_indir_table_size - 1 : 0; - vi->ctrl->rss.unclassified_queue = 0; + vi->rss.unclassified_queue = 0; for (; i < vi->rss_indir_table_size; ++i) { indir_val = ethtool_rxfh_indir_default(i, vi->curr_queue_pairs); - vi->ctrl->rss.indirection_table[i] = indir_val; + vi->rss.indirection_table[i] = indir_val; } - vi->ctrl->rss.max_tx_vq = vi->has_rss ? vi->curr_queue_pairs : 0; - vi->ctrl->rss.hash_key_length = vi->rss_key_size; + vi->rss.max_tx_vq = vi->has_rss ? vi->curr_queue_pairs : 0; + vi->rss.hash_key_length = vi->rss_key_size; - netdev_rss_key_fill(vi->ctrl->rss.key, vi->rss_key_size); + netdev_rss_key_fill(vi->rss.key, vi->rss_key_size); } static void virtnet_get_hashflow(const struct virtnet_info *vi, struct ethtool_rxnfc *info) @@ -3199,7 +3199,7 @@ static bool virtnet_set_hashflow(struct virtnet_info *vi, struct ethtool_rxnfc * if (new_hashtypes != vi->rss_hash_types_saved) { vi->rss_hash_types_saved = new_hashtypes; - vi->ctrl->rss.hash_types = vi->rss_hash_types_saved; + vi->rss.hash_types = vi->rss_hash_types_saved; if (vi->dev->features & NETIF_F_RXHASH) return virtnet_commit_rss_command(vi); } @@ -3752,11 +3752,11 @@ static int virtnet_get_rxfh(struct net_device *dev, if (rxfh->indir) { for (i = 0; i < vi->rss_indir_table_size; ++i) - rxfh->indir[i] = vi->ctrl->rss.indirection_table[i]; + rxfh->indir[i] = vi->rss.indirection_table[i]; } if (rxfh->key) - memcpy(rxfh->key, vi->ctrl->rss.key, vi->rss_key_size); + memcpy(rxfh->key, vi->rss.key, vi->rss_key_size); rxfh->hfunc = ETH_RSS_HASH_TOP; @@ -3776,10 +3776,10 @@ static int virtnet_set_rxfh(struct net_device *dev, if (rxfh->indir) { for (i = 0; i < vi->rss_indir_table_size; ++i) - vi->ctrl->rss.indirection_table[i] = rxfh->indir[i]; + vi->rss.indirection_table[i] = rxfh->indir[i]; } if (rxfh->key) - memcpy(vi->ctrl->rss.key, rxfh->key, vi->rss_key_size); + memcpy(vi->rss.key, rxfh->key, vi->rss_key_size); virtnet_commit_rss_command(vi); @@ -4098,9 +4098,9 @@ static int virtnet_set_features(struct net_device *dev, if ((dev->features ^ features) & NETIF_F_RXHASH) { if (features & NETIF_F_RXHASH) - vi->ctrl->rss.hash_types = vi->rss_hash_types_saved; + vi->rss.hash_types = vi->rss_hash_types_saved; else - vi->ctrl->rss.hash_types = VIRTIO_NET_HASH_REPORT_NONE; + vi->rss.hash_types = VIRTIO_NET_HASH_REPORT_NONE; if (!virtnet_commit_rss_command(vi)) return -EINVAL; From patchwork Mon Mar 25 21:49:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13603022 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2065.outbound.protection.outlook.com [40.107.101.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF72E6F533 for ; Mon, 25 Mar 2024 21:49:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711403385; cv=fail; b=Cqc20HeEz3ehuZY8hGk3WAVP5wnW+BeGOC15anXTYVoNeIZs9J69UnyinzRobCGXH26wBBGwKJg0YZGdO0DpIDyfRWSS6GnW5L7YHP9HZvaatvraEv9XZaAoMxutyepcYLus9O3Rtrg3nKI3p1wjQ416QbOR1rjCZ+qmtk5tcEw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711403385; c=relaxed/simple; bh=YyaZ+3iiLOs0EqGUSQkTIs3ccR+fggsONlEcMoERhkc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YTd3fOGfGN4RZ8GK31QY+Bb3JH5qDhmmyXtRKC9H5INBVertsDoYT2RTINmjxVyhB9FmYRyX7JEe6A2hGD0X4u0TyRG+yMM42f9N/W7t4/Bg8W6K4zSNYVPLFzZZdaHdM4f8dk5zX4vTQMb7ze9USWcbWZxWKiGMy0JdT4u05R0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=Gc1/aOuS; arc=fail smtp.client-ip=40.107.101.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="Gc1/aOuS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VLyFCupYPCc137Cd1S6cU/y+IL1JKtQ7kNve/J3NZs+POIQIM4P1ehhxolT3QM7KRjNTwD0i3Z6S9scdWUXIGTPHwUUpNiogNZpu325u7nanDOxhlBNqb3TM0lTE5TDJRI12BTVhiBNiGBm/6wQDGv6sX02ImTDqVUuRABl4gXAAKmWpsg1N7UNWJ/x9sWYiQNgVyqGyERdQaWHJR3PMSe3kUxlv6nhpezOIFd4lgZ6ejnrepASzuYtp8Ni6Rvmva8jQAVQfjDmObdrq/CQ6Zi76fnMqZZYImuPdP6wjR1n9WrGroYJXfAAoWo4DPhi90W+L1+kFB3+o3G9kpZUMWw== 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=FHn0IfNHVihzbal2FifemjkIRBX5bA9n9Am0qN773so=; b=Wrl2XT1gTY4v4CKK1XlnKNmwgk0CKzO4zQMEa7WmSWB6lAXOGidMCluGglAEk4fdeF8/Swy1yFm1Hfb8B5yGToLJ56JLH12qEkruKk2gIKzEjlANn96XlTCEbI4YNbd2x29d6GOVUz60NeBzp9gK8sGl7RyaAjyBMfYPyE0xy/mYSPCF/wC+8RMtukCFAyrwKdNVQUXhJ0zD6vLsabU40PBLJJs8lwlCIBlg0hyBPX+5cMn/bPRGXNPVQQr2iw2os1JOC3flFT4p4x4HSsbirneDecJ1HxdklDbTU2dUcyLO0V7Jwk40IgdZZR7EibgoUolPwwOlaop9Iu3DvcGuqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FHn0IfNHVihzbal2FifemjkIRBX5bA9n9Am0qN773so=; b=Gc1/aOuScS3eBVTmrAuAFKGdFd5BPY4YvTMmRYE6KDywMxQmo1Uql5LYv1TNugstacwlzgNmup1FJElBSEiyhs4m0g3cUhfu46xz8wIagiVKRT40yvmH30bDGBNcICcCcSqUb3AfxWRlJiaOzlYnbquJ8dLXS16CR2TbvpMazZe7QZBijtxNMDASpVp9Mn1EWUBRPCWuyKNoKTmbgou8u9XDQ5RZnlVC9/5Vdjfn/IHXpsB7QlAiseCMuZURbHr41qqrj6Z0uJgzbOxfCioRwTm9MPVqWcKISMmpu8AgFtV6FhE951QMFoWIWdKZb3cZLNzp6uYKu5DXecm+aSvOHA== Received: from CH0PR03CA0397.namprd03.prod.outlook.com (2603:10b6:610:11b::30) by DM6PR12MB4059.namprd12.prod.outlook.com (2603:10b6:5:215::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.32; Mon, 25 Mar 2024 21:49:41 +0000 Received: from CH1PEPF0000AD83.namprd04.prod.outlook.com (2603:10b6:610:11b:cafe::a4) by CH0PR03CA0397.outlook.office365.com (2603:10b6:610:11b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.18 via Frontend Transport; Mon, 25 Mar 2024 21:49:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by CH1PEPF0000AD83.mail.protection.outlook.com (10.167.244.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.10 via Frontend Transport; Mon, 25 Mar 2024 21:49:41 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 25 Mar 2024 14:49:32 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Mon, 25 Mar 2024 14:49:32 -0700 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Mon, 25 Mar 2024 14:49:31 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next 2/4] virtio_net: Remove command data from control_buf Date: Mon, 25 Mar 2024 16:49:09 -0500 Message-ID: <20240325214912.323749-3-danielj@nvidia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240325214912.323749-1-danielj@nvidia.com> References: <20240325214912.323749-1-danielj@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD83:EE_|DM6PR12MB4059:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c31c940-68f1-44c6-1c39-08dc4d1579b9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /CgP3n5usubz3BU5p2By+iiap6h4KrpZzuUcWSa6/rV0+A0C8lqJrSpoALYUcfQ6/at4EDMYeuWCqPzuCNgBtGoLkphs8/heJZbZq58akADPsBpP24jx/PBnKqo29/RjwBZxaZyEjExhyFdoQnqdgZEArOIhyJZACUy0gxCib8c3E0TG+1ZL3na7iXUX6ax32AJXVnFuFnPU79KTxBIobclU7CIseH73PitTQmhE0TvZ1WCh+248VjaOq5IqLL2YH9UUiFOdTZomZCK83DMMEpRaAEHhKfTtoElNPyuEzyMjSgXZtp9fFEVTIbyKx4iG0tOWQLysbOWHAKZgfcQsTfBMJHnlTe1ioz5XeOJy+0QBfV9gY3/1uMBeX5KOXSKaybkifqCuwz8fPzWfzV46HvVQtwqZ8+8+oviLT+yj1b/vZFtXJwzPImqi2loDezjWT2PYI4/iwsaWh8Bq7C40PDK8tOBFQAO2RrZVUrt1GPGyctPiCfHaYjyOABtieyYsFjc6p91jew9w4XnsAO8zZZouzouYGgiClCasuWHTYyfICdRlWHSyVGC2tW2GKEiEtG+RowtPADMUdp6ILkVoLZAUm3ITxUerIlVsVvQAXTEpaiyRUCLLvKd4E6sHxhLU04fUYMseKCfjOsB0irQRtCuSeE6wLJyvkaVMA7bpoo+GvNJxbXfRCmn9f61JtMtWwBM0vICrsqA3i8MrZlyEM6y0Kl5qwvbQCC/3QNljzYQ7muWHiIgPCQVnH0UDMj6Z X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230031)(1800799015)(36860700004)(82310400014)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 21:49:41.0031 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1c31c940-68f1-44c6-1c39-08dc4d1579b9 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD83.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4059 X-Patchwork-Delegate: kuba@kernel.org Allocate memory for the data when it's used. Ideally the could be on the stack, but we can't DMA stack memory. With this change only the header and status memory are shared between commands, which will allow using a tighter lock than RTNL. Signed-off-by: Daniel Jurgens Reviewed-by: Jiri Pirko --- drivers/net/virtio_net.c | 110 ++++++++++++++++++++++++++------------- 1 file changed, 74 insertions(+), 36 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 7419a68cf6e2..6780479a1e6c 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -235,14 +235,6 @@ struct virtio_net_ctrl_rss { struct control_buf { struct virtio_net_ctrl_hdr hdr; virtio_net_ctrl_ack status; - struct virtio_net_ctrl_mq mq; - u8 promisc; - u8 allmulti; - __virtio16 vid; - __virtio64 offloads; - struct virtio_net_ctrl_coal_tx coal_tx; - struct virtio_net_ctrl_coal_rx coal_rx; - struct virtio_net_ctrl_coal_vq coal_vq; }; struct virtnet_info { @@ -2654,14 +2646,19 @@ static void virtnet_ack_link_announce(struct virtnet_info *vi) static int _virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs) { + struct virtio_net_ctrl_mq *mq __free(kfree) = NULL; struct scatterlist sg; struct net_device *dev = vi->dev; if (!vi->has_cvq || !virtio_has_feature(vi->vdev, VIRTIO_NET_F_MQ)) return 0; - vi->ctrl->mq.virtqueue_pairs = cpu_to_virtio16(vi->vdev, queue_pairs); - sg_init_one(&sg, &vi->ctrl->mq, sizeof(vi->ctrl->mq)); + mq = kzalloc(sizeof(*mq), GFP_KERNEL); + if (!mq) + return -ENOMEM; + + mq->virtqueue_pairs = cpu_to_virtio16(vi->vdev, queue_pairs); + sg_init_one(&sg, mq, sizeof(*mq)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_MQ, VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET, &sg)) { @@ -2708,6 +2705,7 @@ static int virtnet_close(struct net_device *dev) static void virtnet_set_rx_mode(struct net_device *dev) { + u8 *promisc_allmulti __free(kfree) = NULL; struct virtnet_info *vi = netdev_priv(dev); struct scatterlist sg[2]; struct virtio_net_ctrl_mac *mac_data; @@ -2721,22 +2719,27 @@ static void virtnet_set_rx_mode(struct net_device *dev) if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_RX)) return; - vi->ctrl->promisc = ((dev->flags & IFF_PROMISC) != 0); - vi->ctrl->allmulti = ((dev->flags & IFF_ALLMULTI) != 0); + promisc_allmulti = kzalloc(sizeof(*promisc_allmulti), GFP_ATOMIC); + if (!promisc_allmulti) { + dev_warn(&dev->dev, "Failed to set RX mode, no memory.\n"); + return; + } - sg_init_one(sg, &vi->ctrl->promisc, sizeof(vi->ctrl->promisc)); + *promisc_allmulti = !!(dev->flags & IFF_PROMISC); + sg_init_one(sg, promisc_allmulti, sizeof(*promisc_allmulti)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_RX, VIRTIO_NET_CTRL_RX_PROMISC, sg)) dev_warn(&dev->dev, "Failed to %sable promisc mode.\n", - vi->ctrl->promisc ? "en" : "dis"); + *promisc_allmulti ? "en" : "dis"); - sg_init_one(sg, &vi->ctrl->allmulti, sizeof(vi->ctrl->allmulti)); + *promisc_allmulti = !!(dev->flags & IFF_ALLMULTI); + sg_init_one(sg, promisc_allmulti, sizeof(*promisc_allmulti)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_RX, VIRTIO_NET_CTRL_RX_ALLMULTI, sg)) dev_warn(&dev->dev, "Failed to %sable allmulti mode.\n", - vi->ctrl->allmulti ? "en" : "dis"); + *promisc_allmulti ? "en" : "dis"); uc_count = netdev_uc_count(dev); mc_count = netdev_mc_count(dev); @@ -2780,10 +2783,15 @@ static int virtnet_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) { struct virtnet_info *vi = netdev_priv(dev); + __virtio16 *_vid __free(kfree) = NULL; struct scatterlist sg; - vi->ctrl->vid = cpu_to_virtio16(vi->vdev, vid); - sg_init_one(&sg, &vi->ctrl->vid, sizeof(vi->ctrl->vid)); + _vid = kzalloc(sizeof(*_vid), GFP_KERNEL); + if (!_vid) + return -ENOMEM; + + *_vid = cpu_to_virtio16(vi->vdev, vid); + sg_init_one(&sg, _vid, sizeof(*_vid)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN, VIRTIO_NET_CTRL_VLAN_ADD, &sg)) @@ -2795,10 +2803,15 @@ static int virtnet_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid) { struct virtnet_info *vi = netdev_priv(dev); + __virtio16 *_vid __free(kfree) = NULL; struct scatterlist sg; - vi->ctrl->vid = cpu_to_virtio16(vi->vdev, vid); - sg_init_one(&sg, &vi->ctrl->vid, sizeof(vi->ctrl->vid)); + _vid = kzalloc(sizeof(*_vid), GFP_KERNEL); + if (!_vid) + return -ENOMEM; + + *_vid = cpu_to_virtio16(vi->vdev, vid); + sg_init_one(&sg, _vid, sizeof(*_vid)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN, VIRTIO_NET_CTRL_VLAN_DEL, &sg)) @@ -2911,12 +2924,17 @@ static void virtnet_cpu_notif_remove(struct virtnet_info *vi) static int virtnet_send_ctrl_coal_vq_cmd(struct virtnet_info *vi, u16 vqn, u32 max_usecs, u32 max_packets) { + struct virtio_net_ctrl_coal_vq *coal_vq __free(kfree) = NULL; struct scatterlist sgs; - vi->ctrl->coal_vq.vqn = cpu_to_le16(vqn); - vi->ctrl->coal_vq.coal.max_usecs = cpu_to_le32(max_usecs); - vi->ctrl->coal_vq.coal.max_packets = cpu_to_le32(max_packets); - sg_init_one(&sgs, &vi->ctrl->coal_vq, sizeof(vi->ctrl->coal_vq)); + coal_vq = kzalloc(sizeof(*coal_vq), GFP_KERNEL); + if (!coal_vq) + return -ENOMEM; + + coal_vq->vqn = cpu_to_le16(vqn); + coal_vq->coal.max_usecs = cpu_to_le32(max_usecs); + coal_vq->coal.max_packets = cpu_to_le32(max_packets); + sg_init_one(&sgs, coal_vq, sizeof(*coal_vq)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_NOTF_COAL, VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET, @@ -3062,11 +3080,15 @@ static bool virtnet_commit_rss_command(struct virtnet_info *vi) if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_MQ, vi->has_rss ? VIRTIO_NET_CTRL_MQ_RSS_CONFIG - : VIRTIO_NET_CTRL_MQ_HASH_CONFIG, sgs)) { - dev_warn(&dev->dev, "VIRTIONET issue with committing RSS sgs\n"); - return false; - } + : VIRTIO_NET_CTRL_MQ_HASH_CONFIG, sgs)) + goto err; + return true; + +err: + dev_warn(&dev->dev, "VIRTIONET issue with committing RSS sgs\n"); + return false; + } static void virtnet_init_default_rss(struct virtnet_info *vi) @@ -3371,12 +3393,17 @@ static int virtnet_get_link_ksettings(struct net_device *dev, static int virtnet_send_tx_notf_coal_cmds(struct virtnet_info *vi, struct ethtool_coalesce *ec) { + struct virtio_net_ctrl_coal_tx *coal_tx __free(kfree) = NULL; struct scatterlist sgs_tx; int i; - vi->ctrl->coal_tx.tx_usecs = cpu_to_le32(ec->tx_coalesce_usecs); - vi->ctrl->coal_tx.tx_max_packets = cpu_to_le32(ec->tx_max_coalesced_frames); - sg_init_one(&sgs_tx, &vi->ctrl->coal_tx, sizeof(vi->ctrl->coal_tx)); + coal_tx = kzalloc(sizeof(*coal_tx), GFP_KERNEL); + if (!coal_tx) + return -ENOMEM; + + coal_tx->tx_usecs = cpu_to_le32(ec->tx_coalesce_usecs); + coal_tx->tx_max_packets = cpu_to_le32(ec->tx_max_coalesced_frames); + sg_init_one(&sgs_tx, coal_tx, sizeof(*coal_tx)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_NOTF_COAL, VIRTIO_NET_CTRL_NOTF_COAL_TX_SET, @@ -3396,6 +3423,7 @@ static int virtnet_send_tx_notf_coal_cmds(struct virtnet_info *vi, static int virtnet_send_rx_notf_coal_cmds(struct virtnet_info *vi, struct ethtool_coalesce *ec) { + struct virtio_net_ctrl_coal_rx *coal_rx __free(kfree) = NULL; bool rx_ctrl_dim_on = !!ec->use_adaptive_rx_coalesce; struct scatterlist sgs_rx; int i; @@ -3414,6 +3442,10 @@ static int virtnet_send_rx_notf_coal_cmds(struct virtnet_info *vi, return 0; } + coal_rx = kzalloc(sizeof(*coal_rx), GFP_KERNEL); + if (!coal_rx) + return -ENOMEM; + if (!rx_ctrl_dim_on && vi->rx_dim_enabled) { vi->rx_dim_enabled = false; for (i = 0; i < vi->max_queue_pairs; i++) @@ -3424,9 +3456,9 @@ static int virtnet_send_rx_notf_coal_cmds(struct virtnet_info *vi, * we need apply the global new params even if they * are not updated. */ - vi->ctrl->coal_rx.rx_usecs = cpu_to_le32(ec->rx_coalesce_usecs); - vi->ctrl->coal_rx.rx_max_packets = cpu_to_le32(ec->rx_max_coalesced_frames); - sg_init_one(&sgs_rx, &vi->ctrl->coal_rx, sizeof(vi->ctrl->coal_rx)); + coal_rx->rx_usecs = cpu_to_le32(ec->rx_coalesce_usecs); + coal_rx->rx_max_packets = cpu_to_le32(ec->rx_max_coalesced_frames); + sg_init_one(&sgs_rx, coal_rx, sizeof(*coal_rx)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_NOTF_COAL, VIRTIO_NET_CTRL_NOTF_COAL_RX_SET, @@ -3893,10 +3925,16 @@ static int virtnet_restore_up(struct virtio_device *vdev) static int virtnet_set_guest_offloads(struct virtnet_info *vi, u64 offloads) { + u64 *_offloads __free(kfree) = NULL; struct scatterlist sg; - vi->ctrl->offloads = cpu_to_virtio64(vi->vdev, offloads); - sg_init_one(&sg, &vi->ctrl->offloads, sizeof(vi->ctrl->offloads)); + _offloads = kzalloc(sizeof(*_offloads), GFP_KERNEL); + if (!_offloads) + return -ENOMEM; + + *_offloads = cpu_to_virtio64(vi->vdev, offloads); + + sg_init_one(&sg, _offloads, sizeof(*_offloads)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_GUEST_OFFLOADS, VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET, &sg)) { From patchwork Mon Mar 25 21:49:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13603023 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2084.outbound.protection.outlook.com [40.107.93.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A217A6FE05 for ; Mon, 25 Mar 2024 21:49:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711403392; cv=fail; b=cm50ixSKmRdVecvn2++8nIVDSVJ5/XY93WPKR3ACkL6mixQIF8LruP3lmUMfJM4cT7Tao8hxeRxwqbMVQ+UAjJHYlOzFDUgOVDKVUt2prHWB+phOKngEQbxnPHTDxz1bV1yvpqIOJAMpuvqMGwAKNs73rLM6xLvgxolA7rgms38= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711403392; c=relaxed/simple; bh=fUrSzEmveQ/tacJU4e3V96M2ymMTxnbpApaYcYDbCgY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dbLID1GEzYGbUogQVirAnSMntNaLAKiQlbrjQGv2mrN5G33PAlIIUdoh57208Ltm0XNYuG3Jbj9S7FhUTATpbBCWa1nd1rKuDCNYtF/ZkwlJLvwymMz/YXWtIZAzFQfoBY/OVBWjsxjF6YZdgtOXGBA6qMZL7Bos8FWBFRCuTPs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=YMZS2SkC; arc=fail smtp.client-ip=40.107.93.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="YMZS2SkC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CsMKmvycWQE3mYAOwf72zk/khf/N2J4EzF6a8Z7ROnHi2eU7iP5xoJk+mdnQ2mZSJlA7c3JBiw+RL2GW/43qok6op6slYtzvb5K4ViiKiosrpgotsNt7ncovPO6dx0bM9WNLjTSCG+9YaFyWVbdp78ftvNz49r4ckCKgrp4HXRR7TpBaMD+y1nY9lSGYxLlysRh2zywuFhPurMjBpYUHbbaDjSCUlZFRDBpIJWOysrFWfum6xO4R5Pps3h4/dLjT/9xHRiilVkhSBLjgIT2dbVWyU8pNHfjTu5GQt2DY7Sla1rRRMwC6X1L876EQFmNeZQWL6z7mZtXficC7yKRdbQ== 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=1E3CfvFNUR8kZ50Cu+rMgjo9S0fkhN+zy7z3RkkTwEI=; b=RSkfM0KSjk++WmZ+RBCDi3nWwsyX49wsySw+87xTLBfUibUuNy9y0FEXU1aMHAwlrRNzI2makwlK2mBTHy0U68HGIvzA0CW7FkGdCcV/exrpCeD/IQWB2Ha6h8/SLMWlc6c9QTMPjj9DVVGjafaEKhveGrL09I1Q4Fkk8bof5hLviTvWiz/2z5me4kYKOHzsP9o7bz+Aq96au/+y9mliIOX8Rh+QTx6aMQqYGc35VFeOQOzFdyAXl9kyxIwj9Qdk9tHKDkxSW4vCbN0vOrzZmprf6DolXh/beHhHctMkfHYCMapHK4X9i12ndQ2LJY9p0DqoaOSHzeOWcQgOnwDz1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1E3CfvFNUR8kZ50Cu+rMgjo9S0fkhN+zy7z3RkkTwEI=; b=YMZS2SkCCmiWAxvhjXixzYKI1xeD0h2DBGGQMw+ahlQbUGJ6OgMbp3kHG6QlkaJvhGmfpUBgC5MgS6EaWZrht//xprFNOtsyZAw2KtBGgaccjNXwZi/SkIKwHMZIsmVbUnIxSQLRSIeII2NnnbnT3znmq8Lw2iwFo3cvBdW7RIIxe45qJTI628n+yW0FD/SJWSEqfLHi5fDtEPGc0kd2Lu+/v/K2yz7C80+CYYV62Mmq2t31xD9ltGC5anqe5d/OeaGSNAxmC/g4IeqYmTOIjorybpxVgKYpbx5OTPzcyBJz878vyO8a+o1s6GaH1ExYhMqtHirswGFQZPpeVfB4pg== Received: from SJ0P220CA0017.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::27) by BL3PR12MB9049.namprd12.prod.outlook.com (2603:10b6:208:3b8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Mon, 25 Mar 2024 21:49:47 +0000 Received: from SJ5PEPF000001D1.namprd05.prod.outlook.com (2603:10b6:a03:41b:cafe::12) by SJ0P220CA0017.outlook.office365.com (2603:10b6:a03:41b::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Mon, 25 Mar 2024 21:49:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by SJ5PEPF000001D1.mail.protection.outlook.com (10.167.242.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.10 via Frontend Transport; Mon, 25 Mar 2024 21:49:47 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 25 Mar 2024 14:49:36 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Mon, 25 Mar 2024 14:49:35 -0700 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Mon, 25 Mar 2024 14:49:35 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next 3/4] virtio_net: Add a lock for the command VQ. Date: Mon, 25 Mar 2024 16:49:10 -0500 Message-ID: <20240325214912.323749-4-danielj@nvidia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240325214912.323749-1-danielj@nvidia.com> References: <20240325214912.323749-1-danielj@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001D1:EE_|BL3PR12MB9049:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a2baeb8-7890-4789-8b46-08dc4d157d60 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0UpI8s0G5KWolWrX0aHR6TM4dCzR4tzWJHrVrjhOZgGlIfXvHyFFDu2PfZFojAoRJY+PDaPTkkJR8MO2HwNE6f2FBP8AkEygNUS9bsd/gO1mUqS3/6WfVwqNi8uK6fNiMu3mUGxyUiUkiYxmYrGuQK9FVB+wHth/AYRFxStf3zYR0nGyymnJB5PwtWk0rVwgLzcovdxSXN9IdU8bZcrFklLbsyy3c+2+l8WaJqzDjwjIFoZGa+vJEIrVOPd2JGSkBrWACPhrZ7RJ5MPYb7WXycCv0pnEXr1TanokWhDsyXCtfXCTqH56oBloeJPySwogm4zi+Kz7+cesP9HUNs6vUBf0sq60AEdr3SauJsC91Z29CDiiWpdh7EoyX3j+iUdvY9RF3Z87juXW9px+rPOctDndYZO86pMaeO5Pmme/np0OYDm4hqMZasaUQGdPIZo6Vtw8cYi+pt1rS3XFT79HmRSU33Jr0/Po+laercIXSPEj2bu1x8VI47+QhXdCObXmY3eOFS6kw+p5+xCNibaVmf/cEhAhlhx9YfOg2LEEDUjQmlHWdbbrjMrsXI72UemH+J8SU+jHxwWG27i2+xNcfoUtXd2uM8593p0tGgyU3zEWpFbK+TWReqF5iWPhuN6hhPfuW/J12+sFZINAPnPxSltrOOUlbMkfNaiTNRyCEaAttv40mTJ+l/Kw27c9UxcDIRs/3lEdO/vTEUtCwrcbfOBrcn9P/C4ZNpNNDCbjECBw9FNs2/icD7Deno7GRfj4 X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230031)(1800799015)(36860700004)(376005)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 21:49:47.2742 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7a2baeb8-7890-4789-8b46-08dc4d157d60 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001D1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB9049 X-Patchwork-Delegate: kuba@kernel.org The command VQ will no longer be protected by the RTNL lock. Use a spinlock to protect the control buffer header and the VQ. Signed-off-by: Daniel Jurgens Reviewed-by: Jiri Pirko --- drivers/net/virtio_net.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 6780479a1e6c..41f8dc16ff38 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -277,6 +277,7 @@ struct virtnet_info { /* Has control virtqueue */ bool has_cvq; + spinlock_t cvq_lock; /* Host can handle any s/g split between our header and packet data */ bool any_header_sg; @@ -2513,6 +2514,7 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, /* Caller should know better */ BUG_ON(!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ)); + guard(spinlock)(&vi->cvq_lock); vi->ctrl->status = ~0; vi->ctrl->hdr.class = class; vi->ctrl->hdr.cmd = cmd; @@ -4756,8 +4758,10 @@ static int virtnet_probe(struct virtio_device *vdev) virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) vi->any_header_sg = true; - if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) + if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) { vi->has_cvq = true; + spin_lock_init(&vi->cvq_lock); + } if (virtio_has_feature(vdev, VIRTIO_NET_F_MTU)) { mtu = virtio_cread16(vdev, From patchwork Mon Mar 25 21:49:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13603024 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2044.outbound.protection.outlook.com [40.107.223.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D3866FE1A for ; Mon, 25 Mar 2024 21:49:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711403393; cv=fail; b=rYlCJ2nWh9pcWuc921jlfSVzxfZ1nUaEgQuC/0S9xKuv/zHTa3Hqfo5/xP37amz2BvzCSW7ZxjDhjLapYH94/x/2S+PUwj27K/1hqHtLWPx5hvRJ2STVN1X17MHe86uDbJxEWh4V6EKAe1NMRSLlgPfNScP5sYLUzM4vyM/E0pY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711403393; c=relaxed/simple; bh=lv6lPrJt/U0U3xHcYjocm10dINiUjMK3xlv8n817bI4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=L3Qr6qRRLOW7pYHLaodSaAFDSVWzh2DA2oXW5oKxC0yI8fbvNQEDOyLpi0q/c7UkM7F5jIKeFDo9WYlV2z6EqU3ObibKYmQBsF3yorM11m2TtYyH8PN84CDfl1InE1f5r3zKrXId9M17Y2YQ8aTcl4C8NvO88VMayAgT/WI1Njw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=olahSlgB; arc=fail smtp.client-ip=40.107.223.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="olahSlgB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NSVwhAfbtOq6hHdydcke2p6n/14F8wjbSMm21FrLq4K0p4w7xkM68kcYY40N+dAt2JAevRFUeZcXuOnTl9vIcA04t/RpXoVAXVzvxkT67oGyBnzhDTJVLmOg2w8n7KSqKNdmWLxHnEWbH2sn6gLx+WjzsYpwCgRLDo6bjmb9kZxkfjkJL00BLgt7mGY/aT/KI8M3NJNbSpwA51GNLkZbCg2MuAWLdb3gEA8/emkJFli2jDRe0+t4i3ha5kgx9++OcnH0DteOUhD6uwQfZA1G5kLp9AK27nqmHICC4kHw5Mivd40un0N0GyVZlFXhijCToRVVaDkBvYIEbkRVfi1pMw== 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=WWhtsT8K9z8zGmNb8t/BUu3mY/6+GV/YCTTpk9JQh0A=; b=EMIWTfc8U+hHy92F0l/3xk3tEdyJkjiUPvfOMyzYMAsoicFxhjqtcgiHSs6/zyGnmLKl3J+5YaJ8BMYVyZ2T0j7+UspyLhy9manUnt/cXBGxP+UKqUs+02ATyTptnT2SdG+wsx4t/+qik03LEuV8GQmEY38zGTozUBy0NGH9Oqo79G/4tq49ZGQAnOCfxj2S3wAkgoY70Qbq+LNFuvux8xe6mCvFmT/Y1DcbJrIN2ZHwC5mIjjElsWgqBNAaVmQltCBokiOIma+XdXiaxpjUy1LOrcQi+FPHWtGqqNdMkxtiUuvjP+xYSkWkl2PBXrASgc6qTfSLTU6mA1ggpyz5Wg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WWhtsT8K9z8zGmNb8t/BUu3mY/6+GV/YCTTpk9JQh0A=; b=olahSlgBvvlUNPT3D9jGpxnWWlhKpa+kheooI7Cl6QVmrGZWFJ1UE1zV61tJURo+U70tfuZzL1nbqiK2VO8kDUUlpDFN+dz+5uFpEEqanR+LqS1Z1XqkvroDA0UtxLeS80+Gg7ismQCsnEs9/FejTCxF/C1vqlQg9M/C5Bc/iJf55NPVgeUwticBJw9b5pRtNl/om1SFR8Y/hKHRihU422aew9VnQ4wh40srtCwc5ylh88tIvvTYgK3JTEMOSmOn2UXWMpUU+K2ZnTb1ab6zO4kjiQN+zrssl5xKsQUXMcBrNEY6Osk5dOTy9obl0As1JhW6vZKcDBIhg/mGckz6KQ== Received: from CH5PR05CA0014.namprd05.prod.outlook.com (2603:10b6:610:1f0::24) by IA1PR12MB6115.namprd12.prod.outlook.com (2603:10b6:208:3e9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Mon, 25 Mar 2024 21:49:49 +0000 Received: from CH1PEPF0000AD80.namprd04.prod.outlook.com (2603:10b6:610:1f0:cafe::35) by CH5PR05CA0014.outlook.office365.com (2603:10b6:610:1f0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.12 via Frontend Transport; Mon, 25 Mar 2024 21:49:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by CH1PEPF0000AD80.mail.protection.outlook.com (10.167.244.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.10 via Frontend Transport; Mon, 25 Mar 2024 21:49:48 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 25 Mar 2024 14:49:39 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Mon, 25 Mar 2024 14:49:39 -0700 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Mon, 25 Mar 2024 14:49:38 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next 4/4] virtio_net: Remove rtnl lock protection of command buffers Date: Mon, 25 Mar 2024 16:49:11 -0500 Message-ID: <20240325214912.323749-5-danielj@nvidia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240325214912.323749-1-danielj@nvidia.com> References: <20240325214912.323749-1-danielj@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD80:EE_|IA1PR12MB6115:EE_ X-MS-Office365-Filtering-Correlation-Id: 1afa6839-6a34-425e-ab5f-08dc4d157e52 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k5C6zkAX2i0UzCB2KK8+Ew6Dq7PQQ4RyHd4MXwy61q5AO0brLWLAf6NZg9QnoeIZ2yD5DhdXMQeuUgSOZBS3px90RVVhmdYJ3SbUei8MuAxO/+EF8geG9DKToQLY2fHwZXSroBn8odR4FHLOO38x8U76TQnSFnWvcBqzsuraNSKT70EjerkNNOMEY+yc8AFaCvjbonw80CIC0ID8vuMN/rpypRXdeiK1PpGmYaV7CEiXz1LTctseYYO2wEg/XGWHbe70tD/mbFMhYMwVxJ8V9oodA3KB/4k0B7YYzwln2FkgOX/yuP8kk9J3p/Xx+IgM2sNrilMXfit8e3Wh01imFN8swiQHuFb1IkQK/6t5nJME2T8KISeVtWHCMNavPbFQX4XpIl7MKVK8AIAaxMMNVGZVX1ipYVDHZ0zWbkuLvalDtlwHCcdd2AsaHqT36hCGzxO35+ehWJEdZVaH5KI6/BPN0zfrJSkRjdMM4N9N/KuP1aIpkzHlxBDL+i5l7c4WyWAeZqGNUJeRhWnAW7yhGFaPQ4wgMXp8GaJHIlJ1FcM893F6wdcqDVcbOH1IuRrN2RTB4/FzApO7cZhZtKFC7sw0eNEnh7OQvHJRtwih1ELt+ebBimvoxL9Bpc1chtiOcUZZwA4iy4I7toSbCy/2XEuI9OpmDDYebm40/6lgO2AfLVKw1hngTmCAqiE+swVwkaOfcPc6NG6NdkoeyxHhAQU2gA+3U6nSbwESP3QPMCXCQ2QIwVYDNiFOW3wlhozp X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230031)(376005)(36860700004)(82310400014)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 21:49:48.7204 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1afa6839-6a34-425e-ab5f-08dc4d157e52 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD80.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6115 X-Patchwork-Delegate: kuba@kernel.org The rtnl lock is no longer needed to protect the control buffer and command VQ. Signed-off-by: Daniel Jurgens Reviewed-by: Jiri Pirko --- drivers/net/virtio_net.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 41f8dc16ff38..d09ea20b16be 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -2639,14 +2639,12 @@ static void virtnet_stats(struct net_device *dev, static void virtnet_ack_link_announce(struct virtnet_info *vi) { - rtnl_lock(); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_ANNOUNCE, VIRTIO_NET_CTRL_ANNOUNCE_ACK, NULL)) dev_warn(&vi->dev->dev, "Failed to ack link announce.\n"); - rtnl_unlock(); } -static int _virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs) +static int virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs) { struct virtio_net_ctrl_mq *mq __free(kfree) = NULL; struct scatterlist sg; @@ -2677,16 +2675,6 @@ static int _virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs) return 0; } -static int virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs) -{ - int err; - - rtnl_lock(); - err = _virtnet_set_queues(vi, queue_pairs); - rtnl_unlock(); - return err; -} - static int virtnet_close(struct net_device *dev) { struct virtnet_info *vi = netdev_priv(dev); @@ -3268,7 +3256,7 @@ static int virtnet_set_channels(struct net_device *dev, return -EINVAL; cpus_read_lock(); - err = _virtnet_set_queues(vi, queue_pairs); + err = virtnet_set_queues(vi, queue_pairs); if (err) { cpus_read_unlock(); goto err; @@ -3558,14 +3546,11 @@ static void virtnet_rx_dim_work(struct work_struct *work) struct dim_cq_moder update_moder; int i, qnum, err; - if (!rtnl_trylock()) - return; - /* Each rxq's work is queued by "net_dim()->schedule_work()" * in response to NAPI traffic changes. Note that dim->profile_ix * for each rxq is updated prior to the queuing action. * So we only need to traverse and update profiles for all rxqs - * in the work which is holding rtnl_lock. + * in the work. */ for (i = 0; i < vi->curr_queue_pairs; i++) { rq = &vi->rq[i]; @@ -3587,8 +3572,6 @@ static void virtnet_rx_dim_work(struct work_struct *work) dim->state = DIM_START_MEASURE; } } - - rtnl_unlock(); } static int virtnet_coal_params_supported(struct ethtool_coalesce *ec) @@ -4036,7 +4019,7 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog, synchronize_net(); } - err = _virtnet_set_queues(vi, curr_qp + xdp_qp); + err = virtnet_set_queues(vi, curr_qp + xdp_qp); if (err) goto err; netif_set_real_num_rx_queues(dev, curr_qp + xdp_qp); @@ -4852,7 +4835,7 @@ static int virtnet_probe(struct virtio_device *vdev) virtio_device_ready(vdev); - _virtnet_set_queues(vi, vi->curr_queue_pairs); + virtnet_set_queues(vi, vi->curr_queue_pairs); /* a random MAC address has been assigned, notify the device. * We don't fail probe if VIRTIO_NET_F_CTRL_MAC_ADDR is not there