Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4658368rwl; Tue, 28 Mar 2023 09:32:04 -0700 (PDT) X-Google-Smtp-Source: AKy350Zx9uKvFddTLn+6gC1kXSzS2IXr4ZSpSme3wvUHK/zRPUgqji8zkkyKct5AsxT7RACn4OaA X-Received: by 2002:a17:907:c01a:b0:932:3d1b:b69d with SMTP id ss26-20020a170907c01a00b009323d1bb69dmr17942343ejc.47.1680021124336; Tue, 28 Mar 2023 09:32:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1680021124; cv=pass; d=google.com; s=arc-20160816; b=gOvpAaphxJhMmU0bFcTW97OUV7gy3MvvUH7dSx0bKEVtCTWNOoGASSHOn21nioXgCJ 9Qg2Wu//Xc4j5UYh9qsd3soaefBPxAjgyR57Hf/+Oy5q7uvUKgGZcMvviXxJAiNNdEWh tSRoD0cubbBpiFeTBQBpx7Iy3UuO/yDv927j5pKz9zcgMq61O6IjKf+XOHI+ylvgXMct +wGfMtfH79PlgVrKfAWkPDift4rOsugONR4bZqQv6HpxE5wgOcFmwazPNdS0VidO3s4f gZCZxabJhAnV96AcAd2lQlhhJnSAOKpegLxyzk18riD7UbpYOqgxRSaqqAMiZoQwaZld YdUw== 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=//38Z9gw6I263jS+fzakIhfANt9YEcn5GVjlfJ2/nB8=; b=fwHjEveQmXVxyhJUYRZtiAUeQj0YTk0lyqqx1VAYaQIVZjXe+cRn/0bIbWCF7QUw3i 8CK9Kuu3inarnzg4A+6bbpI8oWnFIw4cKlco+ENkbx0OxKLDxzDRay1vRgO8o75bwPqu 6GoFU40Q5wMhKNJpIiS2vMZsSkUYFkbAjxXJ19KLkw4ITfEzHj43s8HyO4L2OqWkVa4W k2yk+aOiOoVECXU3ckLlH6cDxwpe9JPTYfBjywLfGOLJCARmJGz+l4aHB3oNOo48DRdS hlbiwEuk2NFO9VhVIyqWIUvaR3hyTvNZ9zoBjfALcW493uyOZWjrDjdWDSQKmV5vWTwq QQ8A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=fyi1WY2x; 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 jg10-20020a170907970a00b009334769adc2si32791521ejc.457.2023.03.28.09.31.10; Tue, 28 Mar 2023 09:32:04 -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=fyi1WY2x; 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 S233194AbjC1QTY (ORCPT + 99 others); Tue, 28 Mar 2023 12:19:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233159AbjC1QTT (ORCPT ); Tue, 28 Mar 2023 12:19:19 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2084.outbound.protection.outlook.com [40.107.243.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 965F710241; Tue, 28 Mar 2023 09:19:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gdnP2y1lc6oCyj/91Qzwb3dSXTOOnV5UxDILTumyldkVgcqwiHufFDXu0IvhNnOfeswfys5OX5SPohIG7nIaqp4OtcQB9pyD2lhPP/g7gU3blz/CNbAZFyPsXeltLw8Kde7cQxU9QMMXMlIYcLdwMx1QS0CRJTXp8ZlUYkSgxu1249nZEnmUO19OyRjCVy8kAdeM4rGeQXrnmXB79PhSyesxEgEz95QTQ8ag+9/sUK8AxEpyYxdvvpBZm1mjoaMwNgANs5aghc8IHb0fpOsSDEDWerF7jStEyeIcW0Z0GiOjXOtjM+wvCKjlCjt5+hk2hfW9jme5XDGEmf4CQIcQBQ== 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=//38Z9gw6I263jS+fzakIhfANt9YEcn5GVjlfJ2/nB8=; b=dCt/0RpWgvHp5BQvuKPpA9tNtBeQ+cbJjoeDL+qExmV7iiHOoOh5tV2NWKzxC1DeqTGEqly19tf6zO/WXF1NxxQdN98GuMgDTHEKwcz0pgVaNhTsgqtdsQc1pUW9Rq7vGGYfe9uBanVAAs6U3WMeQbT2bHDXEz0HFeUCKQD2zT3zfIHmPGbiLDJpyEY6wpsb3wyKIgAvuYQBuyxyq9YCoWMMiu43TI8VquEzxEk9C8oRWC7/Kv/Qt+KXuQ1KtilLKaLjlS9YhWOHnW9zfn8CzuGSgl+n0jSapAiwSFhbs5P2upV57M5ZfxHeGnxVO3RkziuM4KsE4TT2LFf1RWRZCQ== 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=//38Z9gw6I263jS+fzakIhfANt9YEcn5GVjlfJ2/nB8=; b=fyi1WY2xug+FS+ZoF+/R1iYAsz3EvePUsmEvAac+B3nqmWW9qCeS5TB1UhvwQg0gFmnx3VsBUhV355fD/il9QJcWQr/3Gm5S8Pan4WaEfc1k7kgWihqeatuJCPj8GlqSmBirsXew5pe3JPKBaHWdjTZqHL17yyzQYzXFydSRysUmpoa7IX6yMbDLL2qXfr8doVFxat74f4OJCJpLOMLAI5jMPDreyKjnENWgtgrcYTV2O6BJ0Qbqp1PddOVKlGaYAx+RlHBPzcexuZm5ex7hiGVDVnIxmpnOa+mfMFraGCBe3tzaJ+alQMHSh2cr+1GlfcFrcmU+o6HqYQS3wmlR0w== 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 DS7PR12MB8289.namprd12.prod.outlook.com (2603:10b6:8:d8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.41; Tue, 28 Mar 2023 16:19:14 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::ef6d:fdf6:352f:efd1]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::ef6d:fdf6:352f:efd1%3]) with mapi id 15.20.6178.037; Tue, 28 Mar 2023 16:19:14 +0000 Date: Tue, 28 Mar 2023 13:19:11 -0300 From: Jason Gunthorpe To: Jacob Pan Cc: "Tian, Kevin" , Baolu Lu , LKML , "iommu@lists.linux.dev" , Joerg Roedel , "dmaengine@vger.kernel.org" , "vkoul@kernel.org" , Robin Murphy , Will Deacon , David Woodhouse , "Raj, Ashok" , "Liu, Yi L" , "Yu, Fenghua" , "Jiang, Dave" , "Luck, Tony" , "Zanussi, Tom" Subject: Re: [PATCH v2 7/8] iommu: Export iommu_get_dma_domain Message-ID: References: <20230327232138.1490712-1-jacob.jun.pan@linux.intel.com> <20230327232138.1490712-8-jacob.jun.pan@linux.intel.com> <20230328084822.4b46e649@jacob-builder> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230328084822.4b46e649@jacob-builder> X-ClientProxiedBy: BYAPR21CA0020.namprd21.prod.outlook.com (2603:10b6:a03:114::30) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|DS7PR12MB8289:EE_ X-MS-Office365-Filtering-Correlation-Id: 41227b94-e5d4-4b9d-fae1-08db2fa82bc9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zVPSAqgj2yUKyQdPvs1CskrK71rQ8N6S3IA7wBaDCMxetFZH3iAsNYexBQ6ppQtmI76iS4DE7XiCd0dtzTsxeFbry2bN+PNSDh84aV+gtOr2cobXwXtgt0ZF4KlnqFD8T70giE/dkkyCkLr7brjeFHraCChJmP75V1pwcU9P7W89zjtLypefP4F03ceZKLxdhy09gbVA812K6yooFUUEf5B8H1pFgeKXJD9/GAdoN3UQ4wiW4Qc6NHE7mW59TO3WT9kA0QNtgBuJs/KGI55XUZeyc7mM1qmA5xhA9mQlmQxoVbNhy538fFq89L7h2oE4KbfDT9hfzxNnPhqMnX82FrlNk9dit9zGo/PjAJ/nRX23gAMwTYv/wU+lknfa0O+7pZC9jd3DCg1mMbGwWdcT3kzdEZ/DJMntrVHrk8/n7oGPRKvgG7uRDUWTtAJZ6jJQMFshk2bXFPJLA7sbIcEhbJBRnDo4TBOolVdDk8pc3yMG+LNQswnfmixA8dj4cJAtcyvgwtioS8UoWss5191W8TuTQXDfOTTj5VzgIgRG88R/KwZAuHgaApQwApDARsgn 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)(376002)(366004)(346002)(136003)(396003)(39860400002)(451199021)(86362001)(36756003)(2906002)(26005)(6916009)(6666004)(2616005)(83380400001)(6486002)(478600001)(66476007)(4326008)(316002)(6512007)(66556008)(8676002)(66946007)(7416002)(186003)(8936002)(54906003)(6506007)(4744005)(5660300002)(41300700001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Y6xMrueGo1P4YOAw9OdkFX905+rV3U3p8NY2/5dC/PXWlSbOg/Dr2Ftq+PjW?= =?us-ascii?Q?wGKHgjmxiA2JwJPnyP76wwLVKkPETUUsrwvX4sRZekCNcmpaxbfBI1SVQNir?= =?us-ascii?Q?y8Sq1z1VZCOUC8qJmBS4OQ1R1nOsC4ESniIWTmXQAZA5VXQJpA3bBY48I2SS?= =?us-ascii?Q?Oe+nTfNE2GvCpl7IRPnkJfM9fhyv25gMqK26uUDYV3tN5pY6jMIxOhxxcizs?= =?us-ascii?Q?Li1/VskhFLLPwta0k/atKqk04rH9nsTeF7boyXMqZ65ot/8Fr0aug0Y+dnMc?= =?us-ascii?Q?e/jIHub3CIN28Cu+5O043u1elvZ3ooushFf2GxBvK6IM8ajS+zQG5OczXd1+?= =?us-ascii?Q?YFH3/VZh80mtF4TPbZiesBU7T9Sr664x5Cwq+Ww/74ZI3INq3afPzgEnNSNt?= =?us-ascii?Q?O5M0tuggvmB8sIzl0MzfiP7vywpUKLrMz6b+V6aW6eqSEXAqlfoXC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fJX6k0y640i/c6zipkp+78LBRbNrgRWdtaU?= =?us-ascii?Q?PBcNSRbvke7lW2SqyLVm6x3OWhxdr/bF/9O0pt3rYQ3h6HL0fWOv1B18zuQS?= =?us-ascii?Q?tHKUkeXbcw4QQRl7NzinvQV+r4dCRWArJQ4vEUbYQOLXfPPZ9UpLUnc2tfQ0?= =?us-ascii?Q?QMv5rF7u7UIWAaOhpsBx50y8up2UYSO4VlyWoOckTDffmUvjFq5khxlecQuP?= =?us-ascii?Q?3x9ZpRgd7FhBNkIHv7MfdayvR/wzSLGcdmyRpYer?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 41227b94-e5d4-4b9d-fae1-08db2fa82bc9 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2023 16:19:14.0600 (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: 32O/DbFoVENXqefh5t4bi5eW4130IPaZV57AEs9ZbZnhFDn6cDo23yyzGPAPzRAI X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8289 X-Spam-Status: No, score=-0.2 required=5.0 tests=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 autolearn=unavailable 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, Mar 28, 2023 at 08:48:22AM -0700, Jacob Pan wrote: > > Agree. The kernel driver managing the device wants to get the current > > domain of the device then iommu_get_domain_for_dev() is the right > > interface. It knows the domain is the dma domain. > This goes back to v1 then :) > > I thought the comments from v1 is that we don't want to check the domain > type is DMA domain returned by iommu_get_domain_for_dev() > > If the driver "knows" the domain is dma domain, why can't it use > iommu_get_dma_domain()? seems paradoxical. Huh? The DMA API operates on the current domain of the device, be it IDENTITY or UNMANAGED. You have to copy whatever the current domain is to the PASID and you should definately not check if it is DMA or something. Jason