Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2622195rdb; Tue, 12 Sep 2023 07:28:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1MKrs1QIa9jsZAEXSG6XIJRzRzpba1trs2Ltgi0tuC4CA5SOEj0A05lpi7fFc3FxEoSZ2 X-Received: by 2002:a17:90a:6b86:b0:25e:d727:6fb4 with SMTP id w6-20020a17090a6b8600b0025ed7276fb4mr10240743pjj.2.1694528923834; Tue, 12 Sep 2023 07:28:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1694528923; cv=pass; d=google.com; s=arc-20160816; b=C4X7j6ALxzD+vvTuCYMsaAsE/K3sfJ53ZZb3s5mj/YFiN5LWEUdV1wqh8L/EpI+9Pv W7oQva7eGWcjnfUDo1j7EtMADeCzJkTQcnSdHuN4Pk2WR/G3Qp/6Jl85JxDdxh+/bPBw aSs1agrsMTH49oGH52NKPqOGKJlEd3YhqbctpW1dfFBBYYLUr2se7llEaUkxxz4687Yf NbfZept/6Ykhv6kIeMIWo+7uvifFDhXQIcbIhBfzYQ3fbFhKJjs8orFaYn9rnhCJAvwZ 3ITcrsNotvX4W654BarPnjVVQVyp/5Mf0/zv2sPCwxZxmGWWuKKF19T6+Lu7Nn+LTI/o l4/Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BCeSvy0nChMIti0ZnBRuBRUFtl31nAh7dJm/MoH4xA4=; fh=OYX0w70bKWLTZnZNUmTcUjb/vh12yoS1IlKGBW8yXc0=; b=l2rO5+EtPOpO3PJwhiGpmu7dXRJmi5LS5oUYkc0oIkMfrqnoMBntEKxjs4snw2Gfuz /0Ac6yvFFClV0uMRaO7L1FWvmZ90TTjLIaPrNV2WcgdZmKxX/B4MYFtsu/1aXv6STUnW V9BJTW5XvygDwWzd0LJC4ynEk50fkjzRf4QPuamZPSP4ljTv/7WeOpC2IgqLxebvtVd+ DZCK4E7AHkHgillvYhLs6bc6C8QrRJRSHMoVIU/L4jxqEsK6Rqsz347oTt2U/r7BLdOi WZsrLEmoYuKcZKVFBTMEZuIBhA3riThwdbekF85wQS15OIOT61SCevZbWh1tPLWWoAYg YxtQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=cAKboH7l; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id pi6-20020a17090b1e4600b00273e2978b8fsi7608643pjb.32.2023.09.12.07.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 07:28:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=cAKboH7l; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 9FE428201B33; Tue, 12 Sep 2023 06:03:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235478AbjILNDG (ORCPT + 99 others); Tue, 12 Sep 2023 09:03:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235428AbjILNCv (ORCPT ); Tue, 12 Sep 2023 09:02:51 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A21031993; Tue, 12 Sep 2023 06:02:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CU2Qs/Y+0hNfucwN+34cCL5zoMqAkfs+aT4+bnbhjlKa1NY2kk8Zv/A8RoEB55NYRgqXL8/ksQOzlilZ/RUp9fOwqYUJ11GgabgcrMRlE3L1aUXd1l97WYd68xiNAH7M69flB50F5zJsRJp8Vnm2AsoDYVCPIR1PVZe8xf93Z8T+oJs6fohvYuPV7xb4Hu8Tu0IypwzEm5QHOqMIpO3ZScO8OIUsikokpXixRIcksQZlTR2DIF1jwoT7cFtRMsuVJKsf1dV9dt2kF5iOfdR8CvAE4pUFxHu6UT+xrTKl+SV7Cy1xB+11L1M0GTzPRHDxEfKLd+2iNDpTGMFy9KZLeQ== 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=BCeSvy0nChMIti0ZnBRuBRUFtl31nAh7dJm/MoH4xA4=; b=Q7kD0uBiEAIJQ/z1TcsIXDZKcjPi1rF0wG9H7lEXNU52//Y+1b6gyYjBER0HOe6kbUibZy8U5viu6mzxzZ8cij5vzDuJCA5SrCN6E7RwOAxuSeAPrMcNFZCzRdRLVXDYtRLPufPsZ2YcXHkVN37apUUYRFZMSDNhxaiJ6ftAkdm/vxmpfTdc9yEwq+ViDLJSGz0rp4zdhA7L9RCxyF2B1jWwiw3hbUWick9vhB1c6xlHWedIZKoDbcapq3whtgGq3pjCPHcAucDXru6MgW8YOLWq/N4ZuRY+HAYvzktS/vKdyQDMdO0jOmk1Q/JRzY3xEjiRQdNOb6LEsHyVy6TvyA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=redhat.com 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 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=BCeSvy0nChMIti0ZnBRuBRUFtl31nAh7dJm/MoH4xA4=; b=cAKboH7lwjTFzyaKLLTva1tcXDZrWeu5NeOmks+qTjjA5bXo63jqSZ5SBDXItIEDsqyuM7rU0M4DyEOGGIX4wBEcuc1AbXyTtYr6E1StCzJN/pdp0fiqQ6sIFtpwhNiqSrFw26aSE1/7IbErgZ7C9jCwb9h+gVmVlvGkpqW+Fj3p+6Hhi76ETeWNt8ZlSQxTEUB8UAuhYrOhTcqsTv3dmoVBF5SOCKEKP0mAQJAX2KFsenPzrK+Ug9b3ylyWg7PZw9hbk9trLVUbQVvetOad23+zJbNX6udpU809Dl/fmxQ3mWusubUKIPay4lYOrYZNY8IWPdOZikY5PqX6qWUdMw== Received: from SJ0PR03CA0254.namprd03.prod.outlook.com (2603:10b6:a03:3a0::19) by IA0PR12MB7626.namprd12.prod.outlook.com (2603:10b6:208:438::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.35; Tue, 12 Sep 2023 13:02:24 +0000 Received: from CO1PEPF000042AB.namprd03.prod.outlook.com (2603:10b6:a03:3a0:cafe::c8) by SJ0PR03CA0254.outlook.office365.com (2603:10b6:a03:3a0::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.37 via Frontend Transport; Tue, 12 Sep 2023 13:02:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1PEPF000042AB.mail.protection.outlook.com (10.167.243.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.17 via Frontend Transport; Tue, 12 Sep 2023 13:02:24 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 12 Sep 2023 06:02:06 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 12 Sep 2023 06:02:06 -0700 Received: from c-237-113-220-225.mtl.labs.mlnx (10.127.8.12) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 12 Sep 2023 06:02:03 -0700 From: Dragos Tatulea To: Jason Wang , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Si-Wei Liu , "Michael S . Tsirkin" , Saeed Mahameed , , CC: Dragos Tatulea , Parav Pandit , Xuan Zhuo , Subject: [PATCH 06/16] vdpa/mlx5: Take cvq iotlb lock during refresh Date: Tue, 12 Sep 2023 16:01:16 +0300 Message-ID: <20230912130132.561193-7-dtatulea@nvidia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230912130132.561193-1-dtatulea@nvidia.com> References: <20230912130132.561193-1-dtatulea@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AB:EE_|IA0PR12MB7626:EE_ X-MS-Office365-Filtering-Correlation-Id: 145c4461-2c01-42f0-ebb4-08dbb390820a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5LUCawOLE4uhv70DYg3J231RtpypVoc3XBS2NgqCIcf7N9yxkXAZFwqghPTKfJfdeRw08Zys44R8cXACpX3/qDwWkSltuR/USVX0QicJZbsljo+WoXDY+WckOKU1NwALvNhTQyBZZvaHE+QFwxqStk8dyTepp72i1rp2om3a+FDK+APo5Uv1sFxBrkYmPSTc9cfDTDCdvj2k+ZZcFUQ/CoUO7p5LTwUChacQpQnsB5aOQH9yxWfyQepgcBy5USPEF0N1JkthIfOMXGRqCaJCvu3zG+eN/zcJZ3JkBlrXDszTYNq8erECNr2HTC1VsVRcvv5JK6/yHdEUbEHQxX9TFwcNrJdJqOWog7jCqXBeCsk6YtyhD0C3FS3MAwmL13aN1RYywzwXSB3c0bdNMbtlrC3Z9UkWwd5It6Jxx7hnJrJDSbdyxRBW0kw+xu6Lu79JB6XX3eAcEeMUJesX1Z/rVXMhIcn0X9xYc3QEAlDnjE6gHC0t62NA/Rf5ozRYH4EDBqR3V14GAJMg0OJsUpaqdGJ5zixPLH/Patl5ZGXaR915sN7dU3GivaH/N63rmi2bqIzUxwO9g0lI5KCmN7X4UTAZRDYWnNuOw3Rz+66A8N4VdaFkFcJyJtRPKNkSiPsV1LpR4bziOaNVK2auESbvHYnPpy9HjnlxtikmVGGgcRhRO6gpakOgDNIZH2hlc7LbSxJG0IDUatB8uiVHyp2e1x4BOAsC237r4c6p9lRHSGYolPuNgC4Pk0O7eYJCP7iJv5dVAQ1kIFdRrRN7X05j9Li3lIzOnxIIoYrWuJPpv0c= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(396003)(136003)(376002)(346002)(82310400011)(451199024)(1800799009)(186009)(46966006)(40470700004)(36840700001)(2906002)(70206006)(40480700001)(26005)(1076003)(336012)(426003)(41300700001)(316002)(54906003)(110136005)(8676002)(70586007)(478600001)(966005)(4326008)(5660300002)(8936002)(6666004)(40460700003)(36756003)(36860700001)(66574015)(47076005)(2616005)(83380400001)(7636003)(86362001)(82740400003)(356005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2023 13:02:24.0223 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 145c4461-2c01-42f0-ebb4-08dbb390820a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7626 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 12 Sep 2023 06:03:12 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email The reslock is taken while refresh is called but iommu_lock is more specific to this resource. So take the iommu_lock during cvq iotlb refresh. Based on Eugenio's patch [0]. [0] https://lore.kernel.org/lkml/20230112142218.725622-4-eperezma@redhat.com/ Suggested-by: Eugenio PĂ©rez Signed-off-by: Dragos Tatulea --- drivers/vdpa/mlx5/core/mr.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/mlx5/core/mr.c b/drivers/vdpa/mlx5/core/mr.c index fcb6ae32e9ed..587300e7c18e 100644 --- a/drivers/vdpa/mlx5/core/mr.c +++ b/drivers/vdpa/mlx5/core/mr.c @@ -590,11 +590,19 @@ int mlx5_vdpa_update_cvq_iotlb(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb, unsigned int asid) { + int err; + if (mvdev->group2asid[MLX5_VDPA_CVQ_GROUP] != asid) return 0; + spin_lock(&mvdev->cvq.iommu_lock); + prune_iotlb(mvdev); - return dup_iotlb(mvdev, iotlb); + err = dup_iotlb(mvdev, iotlb); + + spin_unlock(&mvdev->cvq.iommu_lock); + + return err; } int mlx5_vdpa_create_dma_mr(struct mlx5_vdpa_dev *mvdev) -- 2.41.0