Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4823437rwd; Tue, 30 May 2023 10:21:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ycKJ5C5fqZ0JLI5TC6Wmgstr8qNS1Od6VweukXj6HYKkxe/flfMnR6NTxvn9a5emdDEYS X-Received: by 2002:a05:6a00:114c:b0:64a:fa71:a98f with SMTP id b12-20020a056a00114c00b0064afa71a98fmr3269184pfm.13.1685467270069; Tue, 30 May 2023 10:21:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1685467270; cv=pass; d=google.com; s=arc-20160816; b=eooTwe9idh/a0HYss/fvabzetaBs62Vn//voFxDSQSvCl+KNXiCFdflXZB/w66V81U T0CKCuJSC3yVxRAjuX7t32SyWOCkMNKC0D9N07I4CwqMbWnYj0nwD44MmkN8J4zs1SbN Trw3oIMmKW45k/q99OfVXUEfaXGM2SHHGUGWjY0RASgVb8jq0I0GrMhu7BpomiWZi7l7 aEsm/cv7CCY9AbsfErcDVjg/mS1FEN52ScpJf4BU316loGyjhzB0VyjxK9ZRUqKx20Rh 1EPJKchClA7arCj/mFOpfPPJyhCttK7EWEqi7H0YLmXDNCPPqjjBgov0ZfUvdbeJwqE0 KPPw== 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=FnQ+otSSfLDIG5Qm67owXe7vXRLXAAgVbPNUL0lVrik=; b=zzR1PxRPWlvW9Cyp8WlLRvmkGLQQe75MzJsEuxh1oAyB8mLbNeitRxRByA9TgFE7R7 LPhVgI5orrYSnJINKJ3PVg2idOr1UOtJSeHnmOXhxq2s6BRS8QZRZOWBAcFvuBmOYcyE /z61WXpp73OXKD1J+xoNI9p8kPjmGX0QQl1YWfj9RqFq7kuDBEf3KYmojtpIdXKamtVY pstIEhYn4qzi+BCFcw5hrknx+fU64TLOeX6LO5kWSiq8KdgifwdBffdyVKMplAbbJ53n 91T4TUWmg+fBFWyRKLZb6b8mPVEihy2lSPDco9qz9K47A91BCmWkiQc8JEHTKd1TM7ue wh+g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=DgwHVI6Q; 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 r15-20020a638f4f000000b005347d133470si11629117pgn.385.2023.05.30.10.20.55; Tue, 30 May 2023 10:21:10 -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=DgwHVI6Q; 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 S231231AbjE3RIl (ORCPT + 99 others); Tue, 30 May 2023 13:08:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbjE3RIj (ORCPT ); Tue, 30 May 2023 13:08:39 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2061.outbound.protection.outlook.com [40.107.92.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68236A3; Tue, 30 May 2023 10:08:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bx5kHwLXiQo0WSVUVTLtfn6HTP8p1GEATXOUtozYcevx+U9etdhULEnekooPvMoun7mTW7QGeNDo/3PXFUKkkWyqwKq1wsXC1ejOfdZv2aDcSXXVc1SxrG1phyQ20OyTTU2KPJArPBPND0CaIwJmcWIU9qFl98F+7uDarwL2H693z3XZtDWtmNWr+EMgMvoU030dAyGzZYIYTh9A8S8p+0i1Oo92AqBtA66PeONFRyiKPB2HKbSTfcrZ3QSHOO1F0ZycQS4Q8Rr71wjlf0kA8kVHOrWzTVGUfnMfySRxL2t131qf/NQ4SMncZzXM1tiTTtaJ5k9yt8mhMV7QbZFxmg== 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=FnQ+otSSfLDIG5Qm67owXe7vXRLXAAgVbPNUL0lVrik=; b=JOhvtVQQAALdL17dEAdUHyDQ6viXW44css8z1OfpyLMO58tgqZh1itQrfRyQ+3ZeVKncSbRA/DsDxdQ5rKg9obfS3OWGJmg8wJFPetHbsY/TAHKWA/U5laVVHxwysKEKCG5yJmnE5i8iG+b1MKXrwZGkU0u1gJpVIHYHCk+qnKBjZhwsq/KRMoSLckDv17fYvXEjsHzxO07XByN3o2qGinG0a8TJZj3NBcl7fqMb7h7Ve3xzjYRu/WmwkmX+ItzrBgCOcqNAEqpy50mZOJyyR1d1Kv6m/nLwn9ENiy3XDFLM1KI7P1gQHS6a2EiVx3X7zB8Tgfyzmmi4nsL1yr4hNg== 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=FnQ+otSSfLDIG5Qm67owXe7vXRLXAAgVbPNUL0lVrik=; b=DgwHVI6QDbnoleF3Xo+qNu2RKF2oTV5ONqM5Nmd10g+OTIwJ+au8WcFVsUhi/h4UF8391ED/moJBTnAaKNwh37Izmo+AyIF6KoocXpBdWcfdRRujk7jPc3RDvUuHfn6RgAsSYmYb9ewrzhXD3hPw5LK0nzgRPmAkwPIipMnpSSKOYcoRiVQL7RM8oiMOxbXrdKj0FHiSk4hsU9gXhCf7Z0zdL9AosGnvMFil9ogA7u6ERSUd9EYTHgCkROi7H00nHKb1aRDS94ec9a5IsLC9vuUBbfon89MxWCwMi4YLGV2pwbkrTOJXzyGkgzf0m4BbV8s4hkObLsanF9gZRaJVzQ== 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 PH7PR12MB8054.namprd12.prod.outlook.com (2603:10b6:510:27f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Tue, 30 May 2023 17:08:36 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab%6]) with mapi id 15.20.6433.017; Tue, 30 May 2023 17:08:36 +0000 Date: Tue, 30 May 2023 14:08:34 -0300 From: Jason Gunthorpe To: "Tian, Kevin" Cc: Jacob Pan , LKML , "iommu@lists.linux.dev" , Lu Baolu , Joerg Roedel , Robin Murphy , Jean-Philippe Brucker , "dmaengine@vger.kernel.org" , "vkoul@kernel.org" , Will Deacon , David Woodhouse , "Raj, Ashok" , "Liu, Yi L" , "Yu, Fenghua" , "Jiang, Dave" , "Luck, Tony" , "Zanussi, Tom" , "Ranganathan, Narayan" Subject: Re: [PATCH v7 3/4] iommu/vt-d: Add set_dev_pasid callback for dma domain Message-ID: References: <20230523173451.2932113-1-jacob.jun.pan@linux.intel.com> <20230523173451.2932113-4-jacob.jun.pan@linux.intel.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: YT4PR01CA0437.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:10d::10) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|PH7PR12MB8054:EE_ X-MS-Office365-Filtering-Correlation-Id: d95cecad-4f16-4bf4-38c9-08db61308141 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CGMWSPrPL8LTHkleQl7CMheaZptbeIRw3CADJvIuPo03aGQK1S08NFbzrTvAzxoJS04JlLqaYTBmaEsNLa7YL6Cb0CtKe0XDCUzmliDkoNWXYOEh6I01pCUSEmUYUXJ/lI4aE9UZ3JYLX2dNRgjM4VEBBDCBuE464s6bGLVQ/jKcXCw3d0gLLKiHNrKRHzCxjkdb7QeDxsZ1OEroSdEMubbXb0ra7BKwPItcjAbkySr8SWE7s9O7pzx5WMlj/GQNluHWDhVvXj7ULiUY1K21gSB3pGjKFE7l6t5SVyE/u1FKF82Ay7O7gUzByoTMhY2TjkV5+Moh7k0SsbbvCcxgI2K3Vz7CfMVmydYbmIEYre4gFHk4D3P7SOGZdoEa+Upd4MObT4JsI0+VoChnjlI0LeMLNS7Py4Pj6U2qOlTHCeRkbLSzqPJ2ZigdBW7XYre9914BpJUeDNtV7w1Z2UDANLRmD4VySX2+PPAnpB/OWNgDQ8mElXWFAHqAIKQtuunRS/h6VARdfQFJaUwBq3SCv/RRKc7lYFqbiXse0ltDMAeJ8NXZUFEx2ClFckUXyuEc 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)(346002)(39860400002)(396003)(366004)(376002)(136003)(451199021)(86362001)(36756003)(478600001)(54906003)(4326008)(316002)(66946007)(66556008)(66476007)(6916009)(6486002)(8936002)(8676002)(5660300002)(41300700001)(7416002)(2906002)(38100700002)(2616005)(6512007)(6506007)(26005)(186003)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?29OcSqrffcCtpINESYyUeWZL9pkQZa/vb60L2ypZ6a7BtW2YU+tfCjr6438v?= =?us-ascii?Q?1Mqbi6BmZJ+HuWgF9JjFowZ0p6O9+PKSP4EEdysMDjuzbKNx/Ce8jQ+BGLjq?= =?us-ascii?Q?Bu1m4oROXb6TSo/YwSGgSjuEjVk5t5WVpCehIprHXya9SBo/PRytxxJgqtdG?= =?us-ascii?Q?NaqtGad+X1KO2hAC5Kr1l+YAXnr/UotawaW38pGO8Nh6rWK7AWOR6mDuGbgz?= =?us-ascii?Q?sGSCEz5TZFTcWBOUeEPnwr0UfRsB9BYThIQu/d/CuPhnTD0dcCn5JUEZ01Vt?= =?us-ascii?Q?Ho1mND144F2VY5qq9Q1HF5dAKFXg3wkADtr6TcJTxUajQ5lXUAfwvp91Qoah?= =?us-ascii?Q?Db3NmDWkO4pTaRcF68YFVNsjZjyLloeXygs+8b9pwscLnCY5UQRMgTVhvrp8?= =?us-ascii?Q?pYIKukYWe4Gx6jHXKeilLqNTNHZIfykgEWwyokH0QpfPch2yZvs0mh7Re0ro?= =?us-ascii?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8cYZO5+8BQMoe8j2dLY7AGKP?= =?us-ascii?Q?ci+R3p/P9XqyMRciyKEXN9Irgmb07dl8gKKt7IIWm5inPZAc35TCEtCNADYP?= =?us-ascii?Q?364FdBIS9FF1Mn2BABA20tr7zhDu8nsvWgGIFPS8qi1OMDQUR6rHSFUl0oKP?= =?us-ascii?Q?8b1YnGVXbDZvSgRBj6Sew77UP8lJKAZ1d/ew3KrCqiGiq8og1NBTpcTds47U?= =?us-ascii?Q?ZAhxkmweCbAEoEQ9z+nKu3pHzG+eL5ddp1hpevMv?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: d95cecad-4f16-4bf4-38c9-08db61308141 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 17:08:35.9689 (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: rd6WOy694REP123c78GQdXCuNO3BMob1ae0pERCKxFpc10G8TnYNAY6JGrnv4uJK X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8054 X-Spam-Status: No, score=-1.3 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 > > + /* > > + * The SVA implementation needs to stop mm notification, drain the > > + * pending page fault requests before tearing down the pasid entry. > > + * The VT-d spec (section 6.2.3.1) also recommends that software > > + * could use a reserved domain id for all first-only and pass-through > > + * translations. Hence there's no need to call > > domain_detach_iommu() > > + * in the sva domain case. > > + */ > > It's probably clearer to say: Is this what is going on ?? > /* > * SVA domain requires special treatment before tearing down the pasid > * entry: > * 1) pasid is stored in mm instead of in dev_pasid; Why? The mm pasid should not be used by any driver code, the PASID the SVA is hooked to does NOT have to be the mm PASID. > * 2) all SVA domains share a reserved domain id per recommendation > * from VT-d spec (section 6.2.3.1) so domain_detach_iommu() is > * not required; The DID should be managed and allocated for the S2 pointer and the flushing logic should work genericly by tracking the S2's being used and flushing their DIDs when all the S2s fall out of use. The special identity S2 just gets a static DID that never falls out of use. Jason