Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36917420rwd; Tue, 11 Jul 2023 07:17:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlH+HwGATgDhICPNQMaUigqhClyruV0XQPK2rm2qncBhbpCKpB248G8dkXhBJHDbADElHrAo X-Received: by 2002:a05:6402:406:b0:51d:d1c0:63f7 with SMTP id q6-20020a056402040600b0051dd1c063f7mr21810702edv.4.1689085051096; Tue, 11 Jul 2023 07:17:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1689085051; cv=pass; d=google.com; s=arc-20160816; b=s2jtbos9PjddTVv/i02ivOBO03NnaoEJMCpSLFYH8VUhBfcDtJBuIdx7SozM86tSe0 I82vFkEGkkzyPqBjtTh/p2m84m6qyX38VfxI0my0f5pcxmK2U+uBGdKHNXXebJn1YQwo JlIB3Bl4ybRfbAwfnQGCkOjLPtVlOMoKFz4tNz7Sx2UTeU0lAcWJrGpBwgTjIMhb2TDJ mYfGQnzyeWO2u78GctrIAwIKxz1GrGls26w2yra27CS4e9uZ/P3pDigNZjf9DcNnde39 ZPhMysrn+abFwZASsMug82fsQ18PuO0wpasoc/15OnkpEQhNz+wiFumgupcwV0JpHV2L rPbQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1iJxDcQdGxA5wBQulnfCsiVXVjoHU0XeMw/1lyau40s=; fh=n6k1x1VAtOjVhIEt9up0Ohq8AaeJO3d0u5zGMvCWNmE=; b=PqwphITn6vqbRIhLCef0dcS7iSTee8Lb5KNR8atR4rNzrjDp8BCUZ1UcTwuGsyQg/P xCOiSr7SMpSi3++WwnB3L9sk59iwGsINAxrOQxFo18A2y/z62X4yLt6QK39DVWWAii9B ZPLwHcCsoGKsrHcyNgoGlHFkCOSCtq/LPlS8hsbTW9IcocKPbfpiPf1lcnX4uBEUpS3j UN/ZQaKTafW1S8XZuAsO71d13QDMZv91dUsciJ9ZuCip/iTnYW0L3I5gywMCx6W55Tet 4kqbNrxfPyHqtImvFziclp8rH7aznIimfsVHA3G2z/a19tVl4bupL6QUjkgJz8F4VQr+ 8UcA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=tRcNHTWl; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bm20-20020a0564020b1400b0051d8c395a66si2024633edb.53.2023.07.11.07.17.06; Tue, 11 Jul 2023 07:17:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=tRcNHTWl; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232504AbjGKNyC (ORCPT + 99 others); Tue, 11 Jul 2023 09:54:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbjGKNyA (ORCPT ); Tue, 11 Jul 2023 09:54:00 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2052.outbound.protection.outlook.com [40.107.223.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B778BBC for ; Tue, 11 Jul 2023 06:53:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C/wF36jzXvpk2IDxg9JPEyKFLZt3q/oFUWkNqx1l8oFhZ4BTPbiGy9VVcPgKsaVTZafBxCP8HC5Bge2K1eFcj2GWrxXTq+GzikPZzuUB9gNaXn0GO+Cp+hrMZ75MN8+eag131Smqoi6hTWBYqtrmmpc/lhnTBkotEFtP98MTWx3L4BgpWn0HrK3b7I4NY2yhplo/5k+ALGbJo89H06pDLwnMXCxSSmUIr93A4+j3ZGRPTwj7W+or7edDZQhhm5QiyiePe3QqLuybDlk7FY8z1g8331lHrTAGiDNfNZgALNWRHC/MavgWYcyaMm6xJWZ+0dz3Hy9BGYQTpJ2mIq8JcQ== 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=1iJxDcQdGxA5wBQulnfCsiVXVjoHU0XeMw/1lyau40s=; b=R9AfY/m65Ih8uD4wQ2rBR2dM0hFFYENMkBoDIXAmi6/7E0P2OhGmXDlDhpIQ9Kmqid8f2tUgs4qvjQvMPfW0Zlsukaw2miSDodQAo8CHQPny3HmYQXET+KSd6np/p5dNqALVORCJNrp341hEskfVGsnV55deTTGaq6eQ3NCq/SVXMsbkVjp3JwlfWY6YSYiOfm9nP7V2Ce/neUTmS/bnwSjadhmMTYtGINb+QgJSo7MO7o7W2TykJyC9QP0ZIL80yawClujhiitwomyGNccfrdoi/e2iv5uEIo/4BnimfAP+NJcNfF4A9WYvaew1slcxGlm9oETVzN7ZZT4wasQRJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=1iJxDcQdGxA5wBQulnfCsiVXVjoHU0XeMw/1lyau40s=; b=tRcNHTWlgr+PIrxd8B349YmB0Z455SLZIEEj9qarCe/v4c0t81qnS6E/bfe55BjnXec3/GGV5+kesurJgaF7CrE9h/0LV7KiL+aTl2zAY9KPaxuP7XiC6Z57Z5MMo54dqpi3wGfsXxpcVwerM9P2bGDvCh0rpDeVh3erlaOya9Jzw+Os44EEZ/utSq0hXghvSELFStPyWQiHP2mNOpUqmGYW/XKvlAPVP8ovK9P8PSaeUtXlwZAQ6ReDWbWVo70GLNWWJ++wEpzJqxD4OgXI27skmC90T9sZj5hy+yztEFByFIcYhzMUrxKY8w7HydJcGqNDwDYR7MGnD4ykcQ9JjQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by MN2PR12MB4285.namprd12.prod.outlook.com (2603:10b6:208:1d7::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30; Tue, 11 Jul 2023 13:53:57 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::69c1:5d87:c73c:cc55]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::69c1:5d87:c73c:cc55%4]) with mapi id 15.20.6565.028; Tue, 11 Jul 2023 13:53:57 +0000 Date: Tue, 11 Jul 2023 10:53:53 -0300 From: Jason Gunthorpe To: "Zhang, Tina" Cc: Michael Shavit , Will Deacon , Robin Murphy , Joerg Roedel , "jean-philippe@linaro.org" , "nicolinc@nvidia.com" , "baolu.lu@linux.intel.com" , "linux-arm-kernel@lists.infradead.org" , "iommu@lists.linux.dev" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2 14/18] iommu/arm-smmu-v3: Support domains with shared CDs Message-ID: References: <20230606120854.4170244-1-mshavit@google.com> <20230606120854.4170244-15-mshavit@google.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: BYAPR06CA0055.namprd06.prod.outlook.com (2603:10b6:a03:14b::32) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|MN2PR12MB4285:EE_ X-MS-Office365-Filtering-Correlation-Id: a0167975-bd24-40c1-519e-08db8216457f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zB6xkr8Y40OU8h80L2iH5bkyipuAwOWE2nNjZpPCqL3dnxmlvaTXsPEl0V2xW/is9rtimoggV29K0ECEea6hzm2ZA2fgZIFOYUbzDVW9zd7Z/nwOa4if3Uk2diFoc8w8FgT6yg5NkqGzC64QChd7qoviiXmscT/rbaq9iQdJPBnGjkreCgKiR3u8erHHjw61Foi/X/2kEjOUjEBPUDMXZXTIIp/knneV9mIQGc6PtI93NCD27unw/5C2HvLFPwMDTMCdpHi7AsecUttc/kqCrB27rrRdRF98A9Qv7tGE0OnuAl/Oa5y3W/niqNCV5SBNCFiysMlZS7NZgHPtA9yLZPXaxqcvPfHC50/dU2MQp6HeznOhWRHbYrjJQHtJyHxFUq9dOqbBf2lRcPUrvkkFsKMgxY7pcn8jFdqWL9dORUj2CaFY8ow+V9ZBNWiCPQ9uLtYu63ha8C7ZURZjZOhkjmcF6R+TNg6tl5DR7F1o72PEBqqUCWzoTumNX1Iv0+ziGBY/SzCKDDy0Z6Ptvldg4NTqZk8L13VHEZvdChk+JDSlHdpFXGNy0m8Th3Hh6a0q X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(346002)(396003)(39860400002)(376002)(136003)(451199021)(38100700002)(86362001)(36756003)(6666004)(6486002)(54906003)(26005)(186003)(6506007)(6512007)(478600001)(2616005)(2906002)(316002)(7416002)(66556008)(5660300002)(6916009)(66946007)(66476007)(8936002)(8676002)(83380400001)(4744005)(4326008)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?IW2RfSB8uNtnj4dl2cSsBazoUVRhEnJNi9sRIhZtZp3lswwnfFidzncflzld?= =?us-ascii?Q?k+3kZX4ZutZthF4/XOmnGBLXoHqyeGX8kQy+FDZQTEovDxiUWdxnpTadIhHY?= =?us-ascii?Q?l4tWUfsKSaxZaAp+POQOBfcqvLwV78J9UIVN9tMqKMOiserfsP92rP7VzLC8?= =?us-ascii?Q?//FVKnFZXVm2SjOW5FgIOuzQfV4mKMaR3IUZiBSevKr0YAB7IrGYriE6rrS8?= =?us-ascii?Q?diGVWjPJGgEGOjJEIHn8osogqXlGl5ztPYKEoQ/G3xYRd1sr5zigNJD4zso6?= =?us-ascii?Q?Kj84+yaL0ZUQsh0gLA6wMukkX7sjnV099tenv+UwQrWeMYwz60ajvTsyDCV4?= =?us-ascii?Q?kB8IJJUOWdWDghwKgnJK2fO/Roa+aWjutoZBUzRR6EZwlV6bjUFufhM6vOcF?= =?us-ascii?Q?ABsLSv+Mzc8K2CUHVadHuoMA802Gb/YEA8DARY1BlLqC0e3P4YpPLgkmOC4s?= =?us-ascii?Q?oHNggIXbe3UK5fhVvd+8/rPwH2O1fPxOe9PRlocWXWQWUQDBd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3u1SFDnr0VhP8GB1V8FHMtw1LjujsHl1l+jmUEPpAahelg2ZCmUVP?= =?us-ascii?Q?OxM/wOn9enyrGRy7QdZeFBJ84+8UVGo+5wfObjdzATZbZNwUG5sknkMkBQBM?= =?us-ascii?Q?wER8kBVaQA71yC8RNdbSRlUW/++myv4FcBTNDJFN/Cr/9sLbasxXRad/fWM8?= =?us-ascii?Q?t6Tqzoobiv7Faj5TuEMoKeviXLh7WxYSEhV2OFfZ?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0167975-bd24-40c1-519e-08db8216457f X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2023 13:53:57.5641 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2VnXAWSrmVJWbsaQeAKA4+qLSTbt68FiCM8tOaZzc0zcQ7C6bdpowc4mXVCF+L7W X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4285 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 11, 2023 at 12:26:56AM +0000, Zhang, Tina wrote: > The motivation is mainly to for performance optimization for vIOMMU, > though it could also benefit native world. > > Currently, in invalidate_range() callback implemented by VT-d > driver, due to lacking sva_domain knowledge (i.e., > intel_invalidate_range() doesn't know which IOMMUs' IOTLB should be > invalidated), intel_invalidate_range() just performs IOMMU IOTLB per > device and that leads to superfluous IOTLB invalidations. You get the sva_domain from container_of on the notifier The sva_domain has a list of all the devices and iommu's that it is connected to The driver optimizes the invalidations based on the list. The core code de-duplicates the sva domain so there is usually only one. If someone creates two SVA domains then the driver is less optimal, oh well. The driver should not look inside the mm_struct and certainly should never try to get a "SVA domain" from it. Jason