Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2456059pxp; Fri, 18 Mar 2022 10:50:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDyXeezmg8eel7miXjdm51VQpwxYC3lS0zsdSMReeQ20nkFBvZVLPNCpED/FAI7GiCgrmU X-Received: by 2002:a17:907:1c17:b0:6df:b257:cba4 with SMTP id nc23-20020a1709071c1700b006dfb257cba4mr4419114ejc.102.1647625817272; Fri, 18 Mar 2022 10:50:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1647625817; cv=pass; d=google.com; s=arc-20160816; b=B+PP0tq960lN71EKoQOhsde9umQo9okYvQBffX5wNh4AcaeyGDrT0A/3pWUr/WIIZU yaH1rh70XdlD0hCQpCUX5uhxPdeKFNePdXvcsPtLiFkxSv6Jzl76bDCm9RP5/7mQreR5 1WZZDSFFVKh/GJGn5bV7wFfdO48sapY7IVikHqcvl+PHOpZyamuarDDqqoCth5yIP4WL HxMXFI3HQjeiCIrVRg5HsMGVV/NPN72lZHiiQ6oJEf0JcLwTHb+dsN50MQNkZyC8VHfA sIchnuiiNdrSoSH6/KVjcZQcWcAL+ehnzPQbvsBJI/+VrJ2z1VCQ6yZLP9w8kzIKeQHn 4/xg== 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=9w/1SJOx0qRWQGhfqGCQee1pOI7uIk7nwKFcS6C8w5E=; b=0q6Zife2Y/0dIkXcAqu46aPz2l4ySikO+xBvQwyVuLsqLH3nKgpN9jxSRvurkZFZsB cNU05SSZhJ1/nYSvyxehEiOXFs7XYvujSLoM/cen63ejHtDVWEoteXOys7u9zvvoRPeA PsWQFNtgUtASyuM50xf3DOV2g07o9ZCMo8QITP6XB0frxSY+fblgEzFnqyxgy4oGP+yt 8sFoCNXU7t0pHvSeYVwx5horLlzkyvgPmqF6IP9zQItWINRrzi0LifXk3q5d/PiniuQK SD6lGhismnGSGzzreNklPGe50/HdVevAHk3B+jqdVxMwFAzOrvPTN8k5uuIk84z/gy9k nlRg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=E8u1aSQ3; 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 u9-20020a50a409000000b00418ef086c3asi4325509edb.123.2022.03.18.10.49.49; Fri, 18 Mar 2022 10:50:17 -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=E8u1aSQ3; 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 S236760AbiCRNv2 (ORCPT + 99 others); Fri, 18 Mar 2022 09:51:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230290AbiCRNv1 (ORCPT ); Fri, 18 Mar 2022 09:51:27 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2087.outbound.protection.outlook.com [40.107.237.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27B3C6469 for ; Fri, 18 Mar 2022 06:50:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hnWrkR+rQ1DrhvScoe7h3UB4+LLLHwSpW6oyr1yTuX2ACr3/Fx3mvy39ZG54SYSZWROhvLto4+mXUSAhkVMNwXN8JXE7pG82a6wNLWXqGbJyNUAy/3kiZZMAm30GX6/n0BVZ7RSappWAft8Ca4LDoh0z5N75nVyqMh9UvgIpjOKPJDfx7pAw6oGCJ33etlC+Kg4eDUMnYRH/7N6WyszYx3wthF6noueyy0v3x3WSbMUjvLukZmKE9dTAi9tFOSDe3InAHY0jzUEx3Lyg7ENBTG8s8tSBsZ7mx4fmg2R6jtjrBJis686Qg3bdUSF8xTKctHLvUKrTtP+y01yn0rBGCQ== 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=9w/1SJOx0qRWQGhfqGCQee1pOI7uIk7nwKFcS6C8w5E=; b=L8FRFwlecunGTbdxT/qCpfw+hIZcyE0xze5rDQ/zx9IE/X3sK5J4gOPjdsd6O1QdFYYI+VYDGuBWE0M6rp0l5lmESWkgF8a8J6axXNbxuQJix1C8J6svEHcur2wuGjuoOZrKWgxjBd51zNkelGCs7pnLqXcwz00/NC0otNE7JKYD0XA5y3a66QVWJpNITf45EZOqVu7fFwsCIkDp4L2JNTMXl94CgfPDJ19/oohFCFPiiuOzSlGlSo4SaTwubKK0q1bCJWxeFv+ztGPcBdkKMl9qr1qOs0IZF30v0aU2JyYBRRO2blOHsJRmrvE29YiVIum9AkiRQkfsm6qzwe/PrQ== 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=9w/1SJOx0qRWQGhfqGCQee1pOI7uIk7nwKFcS6C8w5E=; b=E8u1aSQ3z9zsl5FG6315D9IskkbkWkZGPjH2V3fq+DpsTeeZDyJfykgZeHLOZ78pd86lCE+ESucWkI7UIdBCNqniwU/vLWZwTK7rp1jOEoPWSWgmezFDg6ZnrM5WoqQZ7EajNbSYdcndWtv19qFjnQc5WiQFaLh+oy5uHk1wQlcs7DmZaQwJDEkChBXAkEEfHB6SmewQfnssAR13EfZX0JsHcjOI1ukP8ofDuDc8s/sfTj/Vn2kWtqGW4WHfyOoQH1YnPYtZThdlaQnMX1wO+TwLl9fFHt4IeLAqQ/IfTKJ84YkRGsZ8P0lytIOgDO3JTX6J/G2BDm2BZSAT1my2ng== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from MN2PR12MB4192.namprd12.prod.outlook.com (2603:10b6:208:1d5::15) by DM4PR12MB5102.namprd12.prod.outlook.com (2603:10b6:5:391::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.14; Fri, 18 Mar 2022 13:50:04 +0000 Received: from MN2PR12MB4192.namprd12.prod.outlook.com ([fe80::11a0:970a:4c24:c70c]) by MN2PR12MB4192.namprd12.prod.outlook.com ([fe80::11a0:970a:4c24:c70c%5]) with mapi id 15.20.5081.018; Fri, 18 Mar 2022 13:50:04 +0000 Date: Fri, 18 Mar 2022 10:50:03 -0300 From: Jason Gunthorpe To: Lu Baolu Cc: "Tian, Kevin" , Jean-Philippe Brucker , Jacob Pan , "iommu@lists.linux-foundation.org" , LKML , Joerg Roedel , Christoph Hellwig , Jean-Philippe Brucker , "Pan, Jacob jun" , "Raj, Ashok" , "Kumar, Sanjay K" , "Jiang, Dave" , "Luck, Tony" , "Zanussi, Tom" , "Williams, Dan J" , "Liu, Yi L" Subject: Re: [PATCH v2 2/8] iommu: Add attach/detach_dev_pasid domain ops Message-ID: <20220318135003.GM11336@nvidia.com> References: <20220315050713.2000518-1-jacob.jun.pan@linux.intel.com> <20220315050713.2000518-3-jacob.jun.pan@linux.intel.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: BL1PR13CA0378.namprd13.prod.outlook.com (2603:10b6:208:2c0::23) To MN2PR12MB4192.namprd12.prod.outlook.com (2603:10b6:208:1d5::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 360a625f-e594-4ea9-0221-08da08e63446 X-MS-TrafficTypeDiagnostic: DM4PR12MB5102:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /vC1wVRV3LDIvG/cuWtaaygLr7z4qYk5H9SlX9OhEgkP5/22OagVcr8wxSHFonTY/qOKRPmTK8eNIDq64CHr2fD84aoA9m8IYlc/Jc5VxifOiAs6E2hwfR7AxbaXdkJ2wAEaJlDm3zlkLJP8AHhOBu36ZEVQYF1AUodisiiJa0g7WABjFIr3H3MNZaaW0usoVLpey6/vSSGel1N/tviNeL6ZxQp2NgVDW41dkcrJtudQ68/X0evwhOUxwfmQRm68pRDuX4gXTZ2f1qPHKAHB4Iu7XPvw5xmPZt8TI1Uu/3NbpDizPtoTdss9AnjhWKOeyoidr7ol/QtbUp0LG88TCKI03W/bAK4I2sEV6ikZtNGCMQJBd6IdckpApgBJbfG6gf96SbP+AkEqX7VGEVgbda7WdEf8nL28Q0TzqdpYM3oXeTSqSM+hx00j5vbpE1xWriELXcCpiou9kH9g/JJ2/1jEDDRjz5Qy0++TIDZuhgfR7qty1ons2pCU0zBo8IApGww8GmUuyav5jdnqgqLeqcRrNAhg42fWEB4aKAZVo6Zdi/QOsqzXTrgSNchM92pa5HuA+VawKlagNkHpXpOJSxO4n1a3qN8C7lFHklIWoTiL/cdZK+s+QKtX2Ye3aURhfLi4BrFL4tTwduezENRDCw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB4192.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(36756003)(8936002)(7416002)(5660300002)(83380400001)(4326008)(38100700002)(33656002)(508600001)(2616005)(6486002)(66946007)(186003)(26005)(1076003)(8676002)(66476007)(86362001)(53546011)(6506007)(2906002)(6512007)(54906003)(316002)(6916009)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?u+B6yhfNPh8Kfk5woqgJcJE1p4sdDFKJQ1ZQCJXLZdkxcw3tMvkF5tfQrPuz?= =?us-ascii?Q?9Ykoa8jdRN6Kg6LNzqIaavuT21ocH9zwNLgUDM/5CdmgVT42r+QID4JERadf?= =?us-ascii?Q?U5J0WS21ipJiq8kgX4J2am4F4vzyWPFHYWm56HVfnGC3UpUc4iwd0Ptllt4V?= =?us-ascii?Q?WYyhDn5vBBlsksK3mqACXIJGQmqp9kIChtfJ9GOsLi4EFT5CnxVVZQOIM3g3?= =?us-ascii?Q?dMQmVYi1lDSWh2iO7S6YE03tWXQFmSRI5MBJyJB7rcAk3dJJwmD2G1SVBPqN?= =?us-ascii?Q?jgGt2FsNZU3l4oxEzdo4huGj7OJ6PuRG4D8Bfxlf60YvUs/SV6oJT1O+lzcx?= =?us-ascii?Q?agVN6ApszxVoDp4NCXel9pk6hCmQ2yHpMNBkkIgZxoRK8JkSp3aK81Lakg1r?= =?us-ascii?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P8f6e1BVN35?= =?us-ascii?Q?11ImZbvdLXxvThtk5ihDqrVfIPIBJYmQ66DpLAPpdmSooDlxMXfGoS7D18L6?= =?us-ascii?Q?gmbUHeRq95KWN+URt/dMsHRocL9BMtnYPOkYTb3H5x9du3rRqqV5s3MSHtlY?= =?us-ascii?Q?e6I209m2j4pp2Wv/dBB2NDOs9UuGVL5n?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 360a625f-e594-4ea9-0221-08da08e63446 X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4192.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2022 13:50:04.2599 (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: OyBR38Tv/KbXXZqdXG9HwRwmqP65f8zKAVTPmuF837quk8mSdzs43lWKl9kzftf8 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5102 X-Spam-Status: No, score=-2.6 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 autolearn=ham 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 Fri, Mar 18, 2022 at 08:01:04PM +0800, Lu Baolu wrote: > On 2022/3/15 19:49, Tian, Kevin wrote: > > > From: Jean-Philippe Brucker > > > Sent: Tuesday, March 15, 2022 7:27 PM > > > > > > On Mon, Mar 14, 2022 at 10:07:06PM -0700, Jacob Pan wrote: > > > > From: Lu Baolu > > > > > > > > An IOMMU domain represents an address space which can be attached by > > > > devices that perform DMA within a domain. However, for platforms with > > > > PASID capability the domain attachment needs be handled at device+PASID > > > > level. There can be multiple PASIDs within a device and multiple devices > > > > attached to a given domain. > > > > This patch introduces a new IOMMU op which support device, PASID, and > > > > IOMMU domain attachment. The immediate use case is for PASID capable > > > > devices to perform DMA under DMA APIs. > > > > > > > > Signed-off-by: Lu Baolu > > > > Signed-off-by: Jacob Pan > > > > include/linux/iommu.h | 6 ++++++ > > > > 1 file changed, 6 insertions(+) > > > > > > > > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > > > > index 369f05c2a4e2..fde5b933dbe3 100644 > > > > +++ b/include/linux/iommu.h > > > > @@ -227,6 +227,8 @@ struct iommu_iotlb_gather { > > > > * @aux_get_pasid: get the pasid given an aux-domain > > > > * @sva_bind: Bind process address space to device > > > > * @sva_unbind: Unbind process address space from device > > > > + * @attach_dev_pasid: attach an iommu domain to a pasid of device > > > > + * @detach_dev_pasid: detach an iommu domain from a pasid of device > > > Isn't that operation "assign a PASID to a domain" instead? In patch 5, > > > the domain is already attached to the device, so set_domain_pasid() might > > > be clearer and to the point. If the IOMMU driver did the allocation we > > > could also avoid patch 1. > > iiuc this API can also work for future SIOV usage where each mdev attached > > to the domain has its own pasid. "assigning a PASID to a domain" sounds > > like going back to the previous aux domain approach which has one PASID > > per domain and that PASID is used on all devices attached to the aux domain... > > > > This also works for SVA as far as I can see. The sva_bind essentially is > to attach an SVA domain to the PASID of a device. The sva_bind/unbind > ops could be removed with these two new callbacks. As we talked before I would like to see 'sva bind' go away and be replaced with: domain = alloc_sva_iommu_domain(device, current) attach_dev_pasid_domain(domain, device, pasid) Which composes better with everything else. SVA is just a special kind of iommu_domain Jason