From patchwork Sat Oct 21 00:37:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 156376 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp54011vqx; Fri, 20 Oct 2023 17:38:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGS35mMHgz6yFap3ViK0eCYOLq+vZsaFGgac9CavuqQVDkRRF47BPokN+CplcrdsRIcZ0Zc X-Received: by 2002:a05:6808:2122:b0:3b2:dd03:12ff with SMTP id r34-20020a056808212200b003b2dd0312ffmr3872191oiw.8.1697848735148; Fri, 20 Oct 2023 17:38:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697848735; cv=pass; d=google.com; s=arc-20160816; b=L8Buerr3f4IsLwYdQqzRtwUqSjk3yBtNvbNQ8ElAJx8/gK4LxFnGjM62KA1H4wMZFO Z3qf0pWM3ddqzsC0j1ymCG2PK6hCD3cjkyVnSvVzSbVJeS4ZUrFUluONRVJZpN67Ot+r gS0qh0LZdyUlbul5Pd9d3YGxrqjttJcW5PBITHPdfLPeF4CmTZw0Hmpm7Edwe8vb6NuS kc14ShNkUhuu/WYK8UIFZCgQLX8Q0GgiDI8PS7grzUg6NeHSeTMtGzoXY76u3kBRJm56 ySP0ykJ6i3amLZdAetX03FfZxQj46UstsVZ84lRJbCICwU1ZV36BQqWQl3se9pCSmb2w fy5Q== 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=O62+6okMYox98i2Xpwmw9LZ8f7GEqBojjmF7ctQflQM=; fh=Mp0I4QMSWClOoCBLPqhNkiTulZD1Ga0izDeLQKPB/FQ=; b=IJgMJRZZhKrbYDeZtP+z7JWfCoxnOrPASOM6i4MldTK1GGnZHlP2WP0Gx+/tXpY2EV 2Wb/oJMa6/BgNdFj0RD1IWXf4u1LpCN0NGnhNtEAuh0UpZT3xQGISstp8ZGL6TordGWK 5btY7306HhPchQsWYG724Tu8jBwYyQlngwHishtTwmupxh1HTjU6QsTJqjLbKu7tQI7B W7J+gqdP4zIaZ9tTO9ss1YoblBWIiAf91UAj/MW9kJlNnO46qU2qF4i6PjZ3hsJwbDc2 NwlpKpQsjgLBr6aiyfKWv9510efPXscYpB0x2xpRMbXva6xAUyJH2vbiKcZ6iPOzQkXd cbzA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="JptZhB/l"; 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 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id b18-20020a170903229200b001bbb6f4cd6dsi2991436plh.334.2023.10.20.17.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 17:38:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="JptZhB/l"; 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 23.128.96.31 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 CC77A82FD7DE; Fri, 20 Oct 2023 17:38:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229614AbjJUAhu (ORCPT + 26 others); Fri, 20 Oct 2023 20:37:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232194AbjJUAht (ORCPT ); Fri, 20 Oct 2023 20:37:49 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2077.outbound.protection.outlook.com [40.107.220.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4590D5E for ; Fri, 20 Oct 2023 17:37:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cmfLJ2mbYgYSaEYUPmiRcawBzDSyOyGseCe+5zEuM0pJWUttXR8dI4gWKr8YE7NED28K70OCL1iGZ1b/WGy4KVAUiVPWQaVIdoIaIV8W8q0KfRvt/sc8XNBsLNL9tBMZ/4rqMSgklqSRF/9GoyNqNCVVVtof7uzBbgqauI1Na3HFog5lQ2xxstOV6FqnXaWwm90lBaTfFaRgQEVO7XaJrGxx0/37QosUKidPRLZxcrdIYqYsR/IsZDLVsRn6Jamqh6AQdW3xYhINn8EATK9EhcylZ0bAs/BYxZiId0n8qbNXgSFnuWOEAurIR8FhKG5G/cLzo/6gYkhwY+7rybwviQ== 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=O62+6okMYox98i2Xpwmw9LZ8f7GEqBojjmF7ctQflQM=; b=civi55JwHU/MiqSYwEQvdG/dCXnxUl33IlfuuIlJ9wrDpGQ8C29qY/StwfDs+E05qCtg0gp2feMHgUYE4T6yqKGwsE0a/S9x64OSO4lbM16JTDr4VJPYKKoTG/3WkKsVzY1uVaqbWq9+LMLTIy0eESmAGReLe2M0RHNiaxgGd9d/nplFH6YkxKlH53fLd5sBb9MYb0+/SpZSqk+jjSke96mUopRq1wCr7JIW0cjwmQWkc+3AZMLjURhWnE70Vwh+a5iSQrsnV/MqvQn6Swrcsr6ycZUni5e8J33g00W6NQ+UcpvNvoxmtVbxZE7Q5ZNxrQdyUZYEm4YJ9NEtzZPTIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=intel.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=O62+6okMYox98i2Xpwmw9LZ8f7GEqBojjmF7ctQflQM=; b=JptZhB/l3onB6YZx0b/iC5Y/OM1fNs8IOGoNz2chnoVqUVxYdFC8by1jHl7bDkeLrtCRMNcgZoo4o1ZK4Y8hNtpzOoMYyMY7vxPj81NGQCUrNz1ln+bNDJyswdEH12iinaZSNiwjvYDCKdLYMQtK9lEHElTldWt57H1cLmlc5ugouWmxGp+KsQ/BBM6voaG8bSSlOIl6uRDghHavzLt4h67Oc4J2JTAJBHMgPo3MJOXoTJzhFZmz1hUw22t/J8NoC5DiUOH4WVyFKKQpM343QT7N3chaQ39SbpiyAgtlejfYqcWEaUJX5PJwN4HhYPSRVg2/h8mqmzyFeTbAiVxvfQ== Received: from BL0PR03CA0015.namprd03.prod.outlook.com (2603:10b6:208:2d::28) by PH7PR12MB9254.namprd12.prod.outlook.com (2603:10b6:510:308::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.47; Sat, 21 Oct 2023 00:37:41 +0000 Received: from BL02EPF0001A0FB.namprd03.prod.outlook.com (2603:10b6:208:2d:cafe::4c) by BL0PR03CA0015.outlook.office365.com (2603:10b6:208:2d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.25 via Frontend Transport; Sat, 21 Oct 2023 00:37:40 +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 BL02EPF0001A0FB.mail.protection.outlook.com (10.167.242.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.22 via Frontend Transport; Sat, 21 Oct 2023 00:37:40 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) 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.41; Fri, 20 Oct 2023 17:37:24 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 20 Oct 2023 17:37:23 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Fri, 20 Oct 2023 17:37:23 -0700 From: Nicolin Chen To: , CC: , , , , , , Subject: [PATCH 1/2] iommufd/device: Drop enforce_cache_coherency in iommufd_device_do_replace Date: Fri, 20 Oct 2023 17:37:10 -0700 Message-ID: <5593200da9015fee7b2e8195c2998f36148d83de.1697848510.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A0FB:EE_|PH7PR12MB9254:EE_ X-MS-Office365-Filtering-Correlation-Id: be22294c-5fd4-4cce-6c46-08dbd1cdeea9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZSJp0yuFnabwZ5Xd/D81jAepc0xi94U2Y3a6HUfXnT1yisCpSC/BwyNeFJIlJ1PTGGbLeMMiBg7KnP4hQeHHgABJUfAT1IKRqHSijdRHVwqdpxFf/HXKRbMLhPzx9A3S2Yw7SksK7v/zDw8etTSmI6oo4/u0V+UO7qGnTnQetHXCKlfxqOeT8bEcYnq/6B06pH99M0glUBgXiDera7PPxgbCG6kcIBcZJMJnGK2nPI+P/DupgAShHmXlcQvMvWzA2ZEcTSr9DdAxuuh8V3vBv5zX1odSWTyB2BX6p5T52lSxNoCvv3vzyUQtJ5EiaMweqFQbs8CiPGTewtJG0mWFzepgqF2YI2qGDbfHrtwXHRx4AFfPORV7IzD1iL67Bo/zFvZwLqOtnus8iXvujLB+asSo3IxXdTtBYLa4bZeQL0xJOF/ahD6/U7S8kBxBV3UDEZUcspARUFakdV38jtxzeO3BJ0AvO+tVLiD6IIWjRC8eE4987CXnyuDUZlioY2a7d152vKbzquuuPiydseUC6YMxQmRpEka4emRkVuUjn7Ni+Fw2fmZS0Qjmf0BhQjT5/n/CTY2EQcGNvjSaSLsJZOSf9SP8sPPKIxyi4UgeHBiE7CFxc8PZhJiugbxl6l4tnWvSIKVbSoKC0px3Jv/XCTjFNqf0BTw75Cxb0ob18ZjrjECgkVbHB8eUcG8EIAUnNrj+gltCcRrfBFumk3s/7lg69D5W4NJTgB9ikJtRP53jjQOpaESawmgdEywAFRPvciEuO8vpPoXsFQUBvG7Lj97oegvDB9eXlpm4uJnbj8E= 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)(376002)(136003)(346002)(396003)(230922051799003)(186009)(64100799003)(1800799009)(451199024)(82310400011)(40470700004)(46966006)(36840700001)(426003)(2616005)(8676002)(6666004)(7696005)(4326008)(8936002)(966005)(47076005)(478600001)(336012)(83380400001)(26005)(36860700001)(86362001)(36756003)(70586007)(54906003)(316002)(110136005)(70206006)(82740400003)(2906002)(41300700001)(40460700003)(7636003)(40480700001)(5660300002)(356005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2023 00:37:40.3607 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be22294c-5fd4-4cce-6c46-08dbd1cdeea9 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: BL02EPF0001A0FB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9254 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 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]); Fri, 20 Oct 2023 17:38:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780323435220928694 X-GMAIL-MSGID: 1780323435220928694 According to the conversion in the following link: https://lore.kernel.org/linux-iommu/20231020135501.GG3952@nvidia.com/ The enforce_cache_coherency should be set/enforced in the hwpt allocation routine. The iommu driver in its attach_dev() op should decide whether to reject or not a device that doesn't match with the configuration of cache coherency. Drop the enforce_cache_coherency piece in replace(). Also move the remaining "num_devices++" piece closer to the refcount that uses this num_devices. Cc: stable@vger.kernel.org Fixes: e88d4ec154a8 ("iommufd: Add iommufd_device_replace()") Suggested-by: Tian, Kevin Signed-off-by: Nicolin Chen Reviewed-by: Lu Baolu --- drivers/iommu/iommufd/device.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c index e88fa73a45e6..c93f3478f808 100644 --- a/drivers/iommu/iommufd/device.c +++ b/drivers/iommu/iommufd/device.c @@ -429,16 +429,6 @@ iommufd_device_do_replace(struct iommufd_device *idev, return NULL; } - /* Try to upgrade the domain we have */ - list_for_each_entry(cur, &igroup->device_list, group_item) { - num_devices++; - if (cur->enforce_cache_coherency) { - rc = iommufd_hw_pagetable_enforce_cc(hwpt); - if (rc) - goto err_unlock; - } - } - old_hwpt = igroup->hwpt; if (hwpt->ioas != old_hwpt->ioas) { list_for_each_entry(cur, &igroup->device_list, group_item) { @@ -465,6 +455,8 @@ iommufd_device_do_replace(struct iommufd_device *idev, igroup->hwpt = hwpt; + list_for_each_entry(cur, &igroup->device_list, group_item) + num_devices++; /* * Move the refcounts held by the device_list to the new hwpt. Retain a * refcount for this thread as the caller will free it. From patchwork Sat Oct 21 00:37:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 156375 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp53929vqx; Fri, 20 Oct 2023 17:38:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF1CEzZjTVgtvllpAU0of+hz6gRdXKBGUDcAwwUEpdaI/Jq+iJVvVTaeBCsEy5XL8fSmmmk X-Received: by 2002:a17:90a:dc0d:b0:27d:a94e:607f with SMTP id i13-20020a17090adc0d00b0027da94e607fmr3204297pjv.43.1697848717810; Fri, 20 Oct 2023 17:38:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697848717; cv=pass; d=google.com; s=arc-20160816; b=GlN0BME9YIfJKl5OikHFi5/eMroszj+3YgKWEJK21NOBK7PibJAX0TIy5YOI7mlM0R aqL6hqyksE9f4p9bTrxdm/I40XNZJhnio6VVTCSeM/mrp5PmsVLCQyULuz58VgxagqE8 o4ruAQ9wltWZ5t6mNN2yrYmfVT5wNMSuc/qj9vAaEUGFimRskoak8YkGkWBNDIUHjwgX ZdnnIZfwUSwsWFfbWOJWYMvrLHRkcJ2RrROZSHGSnNbhSGidNIVEF9VfGkiUDv1i9Q+D BwNd3KpbNZE6IbwdZriGBQnuUWzmPOPvLjc/tDuoVonTijv1KJ1ZcIoMcwvzW3VkLBwl H39Q== 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=rJmaG/87YMY7FeaM0m3Ga3kSFFqzx4R2gWWnTIG/aMw=; fh=Mp0I4QMSWClOoCBLPqhNkiTulZD1Ga0izDeLQKPB/FQ=; b=vkm+pjcJ8ymt5Ol7hs9UhZK4hF5B6m0sFd31gR5QESjirazrQegv5ZEI/ts28qAq/L QrOxyIfLxYK3IddIrw6QitZN4u86IdGYwAQkzCaP63K2TZ/MLJDkFzdlZVCKMYxkXBrT 9FnrZXJVlqt93y7BecVxGtg4Lsaa45bC/ROyARCyofad5T0uB3nnbXSOpQ2Sv0/dOrxL Yq5ADMq/UoikS8CFZZj5gSODWe4mOnNuXUPd9lkXOk/ayxuRnDFrpItggg4TmyKkN5PM iucHhtaGnehax40f/OBGfYTbDQd6I8pLvJ+1kRxHe+dCWGGK0puPS5g20gSe2k7KTEEL Qlkg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=tQQcUcgg; 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 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id 3-20020a17090a034300b0027d567be2e5si2763547pjf.92.2023.10.20.17.38.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 17:38:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=tQQcUcgg; 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 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id A44F682B1A02; Fri, 20 Oct 2023 17:38:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230251AbjJUAhp (ORCPT + 26 others); Fri, 20 Oct 2023 20:37:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229614AbjJUAhn (ORCPT ); Fri, 20 Oct 2023 20:37:43 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2083.outbound.protection.outlook.com [40.107.244.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC8B4D5E for ; Fri, 20 Oct 2023 17:37:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d1DwBGfG/DiZyTsX1rny16gR1uevbUESyHVSa45VNMA4QwdPN1j4fqPG3yHNVoj92+32SAS+20VLcIu3z+IaQneIKRJlkAlwkwqCWGeh/Kb+32S+FtUEkoL5wpUXqORKEES/tMxfL3Rv76ByXKW59bOtgZowmh7Sk1pW2QxxlStfvaFQQ3wj4MZZSps0oS2unvWPBpqeYMQecex+FZkiBbiSKloEL27uWjSE14ChggmOGRdkTfp9o2Tq+1seakHp0f+5FJZHRtcl9zfi5sN1weZ2oLu3UxfzfMigdLwNoZ8kW9x8qYvuh+1tcF+CluWmJxDK9Nc4udp3zjt1GlrkFg== 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=rJmaG/87YMY7FeaM0m3Ga3kSFFqzx4R2gWWnTIG/aMw=; b=GEC5NV+fWLqbZqz/hDizPQlM9BvBC2h+L508k9h3vRK7+N5a10ldCE3ovvmr/7l4lwdxCNOp/DkE+3R5Ct0DLbMy+aLqO3Shnru8qPFSmTfe2oma7BkRbjOSu7Anme927S1dhRcW99NSw5sruWjfs/oPASjg6UEOTx/GnXcxlnnzuvEEvfPUtCPNuxcSDxBABAVQXqzCNLcyyKLeZaJAPsd1640UGDTuSJOC7ncWb9OBA6w+7nIznP0uXwoDJBBQysT6lXh/6+4eNR4ssXBDY8VC2z+IU6DRjhmTg9p1Rt3cyCZeqUQJ6yrZQdUUXcPcbM3rwINhLVIIuiiWcSTbWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=intel.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=rJmaG/87YMY7FeaM0m3Ga3kSFFqzx4R2gWWnTIG/aMw=; b=tQQcUcgg3lPJarZtJ9xEVmV6wqxRZdc0As1/Z9Vu+kY5YzFAqNfyh/KfHMhkik0hPOgukffFNtuRSZX4or9l+bl6eY7dqMYPMv8qUW8kMk6e6TTf5aEd3rA+Fp6XIFW2TuBrUqW18PHE8SEv2wj0bTCiXpuask1Hhi5rND6THVoJS9BfUlN5gUi1WEYfAgJzPtu/9YLWmLr7GEtkQY7feBNpnJa5d6X1kEzKIK3X+wZvwyOgkm2zRNmuPh1CQbhw6CEtfHKRn8LQcB8oto6Br5OvfUbwSRVmC6Gh8GZQhHjWDP+qkP1KpQOBTMOURSFN6bg+3G6PA2wfpOgCN9Y8/w== Received: from CYZPR05CA0016.namprd05.prod.outlook.com (2603:10b6:930:89::28) by PH7PR12MB6420.namprd12.prod.outlook.com (2603:10b6:510:1fc::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26; Sat, 21 Oct 2023 00:37:33 +0000 Received: from CY4PEPF0000E9D2.namprd03.prod.outlook.com (2603:10b6:930:89:cafe::c) by CYZPR05CA0016.outlook.office365.com (2603:10b6:930:89::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.8 via Frontend Transport; Sat, 21 Oct 2023 00:37:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CY4PEPF0000E9D2.mail.protection.outlook.com (10.167.241.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.22 via Frontend Transport; Sat, 21 Oct 2023 00:37:33 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 20 Oct 2023 17:37:25 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 20 Oct 2023 17:37:24 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Fri, 20 Oct 2023 17:37:24 -0700 From: Nicolin Chen To: , CC: , , , , , , Subject: [PATCH 2/2] iommufd/device: Drop enforce_cache_coherency in iommufd_hw_pagetable_attach Date: Fri, 20 Oct 2023 17:37:11 -0700 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D2:EE_|PH7PR12MB6420:EE_ X-MS-Office365-Filtering-Correlation-Id: a86818e0-018f-4ddd-4e15-08dbd1cdea8f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zW2ce2DoX+DjMhIYVgGm2i09jYhPGrl+J9kMX3RiYkx06PJCPon6Z2v0Ow5v6NHFoy/D8voBNvBG6OxxKoMJiKU2HrtGDTnoCW9WLPZ2qDEXPfiB1G8TE7Lg/ILMj8lrIxGTNgld7d3i+MsNiXNJwSv1hcF7xpwUvk+vKOehIc1SS1ntZViR07B9pusoD92rzyXrIiliiQSRQ6qNB0zUvUSRt4Hd0Qy2Pt+fRaH6hMNqtLYY/b21gf+fjNU1DuslSDRjUaVJXGAMoagi0kIIhq3QshkJwb1Bs+eBh4gQ4AOcY8BaguKz8f2qV961ZHj8B9DWAUehNrUiZ8RlcvCRpowvMrU/EXIXszIxf6tlWmt/zkX3lFwUIrjF2mL+TCdRYMucpuD8yHT5KsrUvhmnrjAqAS+4DEVffIzbUcSbVfEczrXBjZoLuFGq4eqEZ9fslurlWz121IlzyGbjsvL1ioF97+gU5cByovn0fmaOW4pm/oPxnGTJmOA0qffVdMnECLVJkxMKofyqNxLJw+MYrRLR0niAYPnXFR6AA/Wtnh8M61Fka4nmuCkaetEGXXJp8UTPEI/TwdQiaU/ahSB51gWr2j9vXvkr+tkIGG745xX5rHJ/+OeiRZ1v7mSPbe4XNSgETHXwkUmAW2bt7HOm2AinY5mU5B4U60QbjYK/uxAMrrcChsvDcTabTZdmn0Gx/Qc0EGfpW4ivgH7xRbNm7QEK9qITc8IwuxOs8Ez5tptzA7ujzKLGx33wFqBQ1i1nxZWmsbmK8aEIq/HDMRIt984pXmer8g2tZ5CylH84CdA= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(376002)(39860400002)(346002)(396003)(136003)(230922051799003)(451199024)(1800799009)(82310400011)(64100799003)(186009)(40470700004)(36840700001)(46966006)(86362001)(40460700003)(2906002)(5660300002)(8676002)(110136005)(70206006)(316002)(54906003)(478600001)(6666004)(70586007)(8936002)(966005)(36756003)(4326008)(41300700001)(47076005)(36860700001)(7696005)(2616005)(26005)(83380400001)(356005)(7636003)(336012)(82740400003)(426003)(40480700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2023 00:37:33.5724 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a86818e0-018f-4ddd-4e15-08dbd1cdea8f 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.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6420 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 lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Fri, 20 Oct 2023 17:38:32 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780323416926132332 X-GMAIL-MSGID: 1780323416926132332 According to the conversion in the following link: https://lore.kernel.org/linux-iommu/20231020135501.GG3952@nvidia.com/ The enforce_cache_coherency should be set/enforced in the hwpt allocation routine. The iommu driver in its attach_dev() op should decide whether to reject or not a device that doesn't match with the configuration of cache coherency. Drop the enforce_cache_coherency piece in attach(), so it will be called only in the allocation routine. Then, drop it in the header and mark it as a static function. Cc: stable@vger.kernel.org Fixes: 17bad52708b4 ("iommufd: Add enforced_cache_coherency to iommufd_hw_pagetable_alloc()") Suggested-by: Tian, Kevin Signed-off-by: Nicolin Chen Reviewed-by: Lu Baolu --- drivers/iommu/iommufd/device.c | 7 ------- drivers/iommu/iommufd/hw_pagetable.c | 2 +- drivers/iommu/iommufd/iommufd_private.h | 1 - 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c index c93f3478f808..557c10fd4a7f 100644 --- a/drivers/iommu/iommufd/device.c +++ b/drivers/iommu/iommufd/device.c @@ -337,13 +337,6 @@ int iommufd_hw_pagetable_attach(struct iommufd_hw_pagetable *hwpt, goto err_unlock; } - /* Try to upgrade the domain we have */ - if (idev->enforce_cache_coherency) { - rc = iommufd_hw_pagetable_enforce_cc(hwpt); - if (rc) - goto err_unlock; - } - rc = iopt_table_enforce_dev_resv_regions(&hwpt->ioas->iopt, idev->dev, &idev->igroup->sw_msi_start); if (rc) diff --git a/drivers/iommu/iommufd/hw_pagetable.c b/drivers/iommu/iommufd/hw_pagetable.c index 8b3d2875d642..b8bad5b16b5f 100644 --- a/drivers/iommu/iommufd/hw_pagetable.c +++ b/drivers/iommu/iommufd/hw_pagetable.c @@ -42,7 +42,7 @@ void iommufd_hw_pagetable_abort(struct iommufd_object *obj) iommufd_hw_pagetable_destroy(obj); } -int iommufd_hw_pagetable_enforce_cc(struct iommufd_hw_pagetable *hwpt) +static int iommufd_hw_pagetable_enforce_cc(struct iommufd_hw_pagetable *hwpt) { if (hwpt->enforce_cache_coherency) return 0; diff --git a/drivers/iommu/iommufd/iommufd_private.h b/drivers/iommu/iommufd/iommufd_private.h index 3064997a0181..60221e728e80 100644 --- a/drivers/iommu/iommufd/iommufd_private.h +++ b/drivers/iommu/iommufd/iommufd_private.h @@ -244,7 +244,6 @@ struct iommufd_hw_pagetable * iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas, struct iommufd_device *idev, u32 flags, bool immediate_attach); -int iommufd_hw_pagetable_enforce_cc(struct iommufd_hw_pagetable *hwpt); int iommufd_hw_pagetable_attach(struct iommufd_hw_pagetable *hwpt, struct iommufd_device *idev); struct iommufd_hw_pagetable *