From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.43.57 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796183660; b=Ta4pkjvnDiItHEtIJsqdfs0FA7q5n9fc6fMIpNVN15N7JqeH1Cuy9/za/nliC/B0UHYw 8LEVg+4nHs9qnj/1bNF8kMFKkZB4l3gF3Fuzp5etmkeKpRTvW9Bp2vuWIT2l0CXmxvedq efmcuqMjl+/Wfk5b0XoEuK9SPvIk63QQ/KvFb8CY4U8yYffBaJjyhNI5WVE+zCtDCWTP8 gksNY8flIQepp7C1SOThBpK1naC7U9igqkzLtjqSl1zsczr5TNdOvwc673jmE21o8XU0X PhIa34aRl1prrXEKrlU3hYrCBxfhBv5pqX2p/DCBki4QbGtqCk+FMjxF4DfoKWuAyBw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796183660; h=DMARC-Filter:DKIM-Signature:Received:Received:Date:From:To:Cc: Subject:Message-ID:References:Content-Type:Content-Disposition: In-Reply-To:X-ClientProxiedBy:MIME-Version:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=5t0QJv/aTaoGLIW1O9kDEonvL7C1n2vroCGam3BGtMA=; b=Caq1+2mojfFtUsVZzsajEJEiH+3R5dGPktB93FS5Qvyin6+iA3cEAKr4o0+4Q7JaMn/b 5QD9TM1uF+lNma2eJSR/Bz8DguWFI6/g05doL66hgOQJ3aj290Wsb4rxvslCD8qgYFD8R K4E11FWx7cDZpS7GIil+2ZEpIyjhBCEbDfFI32a8p5FCrkXemMzw3AMKYtjjJLz4hzqyi VRfZRfw2H/uQhc2bg3Y5PBRngEJzXNIfAhfLrN8Uj9yXNGLZrxmZNqeaWN35GrRnXbH/e 3+DoF4R6qKir9a7cjmER17+AyycVw6soxgdXRCdH4W3VjTUu4oSM0UvoX8cg2v6lcPw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=FAr6S74Z; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.43.57 Received: from SJ2PR03CU001.outbound.protection.outlook.com (mail-westusazon11012057.outbound.protection.outlook.com [52.101.43.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD678606A322; Wed, 2 Dec 2026 03:54:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BD678606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=FAr6S74Z ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CL3DXuQuFSCn+m8/gT4Y7gYio4CwzSwHfEtS71n3S7VuBU+u/ahlkTM7OkD4+Qbhuf0B274kEgLaMjTxcD5XBjdnuMrjgYwZwxBAE0NGanni8U8h/sC0dUtTNr6ihsf661Jv6jYo4nk7WC78VZIs65VEy6oxw+CyX033e4QdU2o/aCJBfVlCi3mk8Hannk4QeDGHmVTJ4ZU9ZYufH/6ZAXWe+Fs8PQ9Lv3WeRKb8Ay04eUrYLJgxg2Vtu1aJBUhaonCIawD9MsJwQI3h/vUUPsvj3gOdIZ2d+f82guxOUKtSaHesY9G7jcWek/Pne/tguvwEC50V/grfY92pj/XIJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=5t0QJv/aTaoGLIW1O9kDEonvL7C1n2vroCGam3BGtMA=; b=UxH/g6b8J4eN8Xuh2NF7FVGARNCYpVJOQNc4dMtZzrdYuEZEbJlUCJTsJ28ef6sSAwWtJwJe8XR2FIWuq2bPFikxVpWNuEpJ0jqHftF/AgeRb/Rv3Mm/lPCRB+W9cHmIgH9vSUJOR3lNpF8jwLW6DZ330M+hAYgfnwIsb6VfsMI7LFKae22htF1P/iChPpCccxrLMGiSu6X4itA6xsS3S79iG4AzI2xTL8KFvjX030PZAbkczKzwRSNu7wOvk57cAnznB69n0SlVvox+SAUfnUH65O45WEQEWY+QGFxzU4k1pPwXeP9tuT0p9Xg2rzP391Gyz3bIjHflw9+pUdmw2A== 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=5t0QJv/aTaoGLIW1O9kDEonvL7C1n2vroCGam3BGtMA=; b=FAr6S74ZrJ/RtEnP1MJwXphrA48PMo2k+AAgX3j6XxvWbGMsZbRU9L1Ohr57+rXrKIEBS6JDU1SuqlfB3Tnmlm27XCK87bQ0EJ6F5yGRgW+BKXPZGsg8ovr6VqDLUzrPtKa86hpkG53Rj2eVGbW157TunRolzDr3SwELV6d8r3beX+DKEBVEMv4f1HPCJXOtyb03wBn98hngkO2nc3QB4WSGbJOm9WBJ9w4HLfEvRl6Mwhf6vk+KNCC7r9+6dMkuzGZdaf5GEfOXEY8UJHpICHj/sb0FcBHPosgqyrXqRidt0KiValJtsA6+q2Di1VPs3/BIiPuJsPXtb76BBCdkdw== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SA3PR12MB598757.namprd12.prod.outlook.com (2603:10b6:806:52d::14) by IA0PPF12042BF6F.namprd12.prod.outlook.com (2603:10b6:20f:fc04::bc8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Wed, 2 Dec 2026 03:54:12 +0000 Received: from SA3PR12MB598757.namprd12.prod.outlook.com ([fe80::e206:100:5946:a777]) by SA3PR12MB598757.namprd12.prod.outlook.com ([fe80::e206:100:5946:a777%5]) with mapi id 15.21.0688.009; Wed, 2 Dec 2026 03:54:12 +0000 Date: Wed, 2 Dec 2026 14:54:07 +1100 From: Alistair Popple To: Dave Airlie Cc: Jason Gunthorpe , Christian =?utf-8?B?S8O2bmln?= , Sumit Semwal , Thomas =?utf-8?Q?Hellstr=C3=B6m?= , Simona Vetter , Matthew Brost , Vivek Kasireddy , Dongwon Kim , Kevin Tian , Xu Yilun , Karl Mehltretter , Baolu Lu , Felix Kuehling , Alex Deucher , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , linux-nvme@lists.infradead.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Mina Almasry , netdev@vger.kernel.org, Alexey Kardashevskiy , zhipingz@meta.com, treding@nvidia.com, jhubbard@nvidia.com, chaitanyak@nvidia.com, Leon Romanovsky Subject: Re: [PATCH v3 03/24] dma-buf: Add the SGT DMA mapping type Message-ID: References: <20f5fb10-b71a-40f9-bbb2-f99b4002bf08@amd.com> <53a32383-4cf6-42ac-bbd5-476e69a3be5f@amd.com> <20261202013043.GC351887@ziepe.ca> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: SY6PR01CA0006.ausprd01.prod.outlook.com (2603:10c6:10:e8::11) To SA3PR12MB598757.namprd12.prod.outlook.com (2603:10b6:806:52d::14) X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA3PR12MB598757:EE_|IA0PPF12042BF6F:EE_ X-MS-Office365-Filtering-Correlation-Id: 40b75961-5b0d-461d-41dc-08df5027ed06 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|23010399003|376014|7416014|22082099003|18002099003|10067099003|56012099006|261026121527099003|261026130827099003|261026140227099003|261028144727099003|261022105027099003|261022075727099003|261022113327099003|261022115727099003|261021130227099003|261021121427099003|261021135927099003|261021123027099003|261102123227099003|261102130727099003|20046099003|4143699003|5023799004|11063799006|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: gKioDzGII9gM44JQiAUFLKNNHSIXyYo0OnMivpsver6RM1hd67Sm3TC4rMkD6CYJrI570B8aNO/ezG/7yrj8oAXrX4dALXe14v5wzon2TA05Vc30AH19F3Oc9ysk7w2yQ65oyZ2QOJrg3MDDnxoyn1gjPv77OeVecGUksx9EP/S9tIeIRWMzqAfT7CfpJYv7KzaOTqowJ6/fws9LuvFSr5qbcp5NqtBrl2vvWHQQrxHfReapAOv3hVkvQpSi7JGdLnkBti94ghyRtohUvZ54GGmy4lZMK1tZWjWo+FHOn7CMsBOz3ihVtnAMzUWW3jt3SXsh4eiYEUV37MqtyOGN8MY8G5S7ACXUzLJ3WBQg26Kk/8LbYlpJPQDI1nQ4AG4G6cjMyQ1gdxjx/7RhuE5uLlU54+XQUQWl13cqX7Qsk9/9ufqe2guwom0ozWdZ2ar9mGQYV5TRAhIeM51UUxpuh3MuL21wIlA6kNMEFIUCc9hTasUkzW1iC0ApuGan6bnP0RiZyV/fAvvCEFusJBz4prl96FambTtLxWdJP8+9mdnLl1NHIGN0UiykgtYbel0HID3DEhy0TdbFP3O0CW/K3iGYY+FDFrNlR+2BEVOcVuWSnN8ZKt45JGOSNmbKa2+Aj0yEMTy3JNUYbu3LzuGMWZ3p35kKrqxHGBMmo3WSut4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA3PR12MB598757.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(23010399003)(376014)(7416014)(22082099003)(18002099003)(10067099003)(56012099006)(261026121527099003)(261026130827099003)(261026140227099003)(261028144727099003)(261022105027099003)(261022075727099003)(261022113327099003)(261022115727099003)(261021130227099003)(261021121427099003)(261021135927099003)(261021123027099003)(261102123227099003)(261102130727099003)(20046099003)(4143699003)(5023799004)(11063799006)(6133799003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-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-ascii?Q?q7Q/dokNqw=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 40b75961-5b0d-461d-41dc-08df5027ed06 X-MS-Exchange-CrossTenant-AuthSource: SA3PR12MB598757.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 03:54:12.1702 (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: XuJYzKXxdhwnE9Okzn0xJWq8RK6/mJCPObd3M/DFfZTvOHVruy3dzkXciocQzyq9ebOUW8BoOPd2ijXXpF7o+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PPF12042BF6F On 2026-12-02 at 12:41 +1100, Dave Airlie wrote... > On Wed, 2 Dec 2026 at 11:30, Jason Gunthorpe wrote: > > > > On Wed, Dec 02, 2026 at 10:47:28AM +1000, Dave Airlie wrote: > > > > > I think this is clearly where the divide is. I'm with Christian here, > > > the exporter allocate the resource, then it owns the lifetime of the > > > resource. In order for it to have complete ownership of the lifetime > > > of the resource it needs the ability to remove the resource from other > > > users (i.e. importers). If the exporter wasn't to free some pages, it > > > should have all the information necessary to do so but traversing a > > > list of places the object has been imported and a method to forcible > > > unlink it from that side. > > > > If you change iommu mappings without telling the driver you will > > create data corruption as new mappings can fall to places the device > > is still doing DMA. > > > > The driver MUST be involved in any reclaim/move/revoke process and > > DMABUF already has APIs for that. Managing this lifetime is one of the > > main things it does. > > > > I don't like this notion we can trust one side more than the other, it > > isn't like the exporter drivers are amazing clean things either. There > > is a reasonable level of nannying.. > > This isn't just about trust, it's about lifetime and ownership. If the > exporter owns the resource, the exporter should have all necessary > information to invalidate the resource and give it back to the system. It does - that is what the reclaim/move/revoke callbacks are for - to tell the importer to stop using the resource and invalidate any mappings it holds to the resource because it's about to give it back to the system. That necessarily has to live in the importer. Take for example PCIe P2P - there might not be any IOMMU involved, so the only way to tear down the mapping is to program some importing devices specific MMU (or stop work or whatever importer specific thing needs doing). > > Importers are expected to unmap. I think we have to consider any one > > that doesn't to be broken. You can't fix broken with more broken > > things like force DMA unmapping and hoping that there is an iommu, > > then hoping no corruption happens to crash the system. > > But we should allow the exporter to tell the imported to invalidate, > wait for a response and then have the exporter free it. What the > importer does in the invalidate is up to it, but the exporter controls > the resource lifetime and any things bound to it. If the importer > fails to invalidate the resource then that is a clear problem. But an > exporter can at least control all the mappings for the resource and > tear them down without leaking things. I think we may be conflating two things here - the importer contract and a method of enforcing it. The revoke contract is "importer invalidates and unbinds from the resource", and the design should assume that whatever implements that contract gets it correct including tearing down any access paths. Obviously nothing can enforce that the revoke code (or HW even!) is correct. So what I'm hearing is that the exporter should be unmapping as a defense against bad importers. I can definitely understand why that might be useful, especially as some kind of debug thing, but I don't think we should be basing the whole API design around the concept we can't trust importer to implement the contract correctly. Especially as that defense might not actually exist in a lot of cases anyway (eg. IOMMU disabled), in which case you have no choice but to trust the importer got things right. I also sense there might be a deeper belief that the mapping of a resource (ie. the IOVA) is something owned by the resource rather than the user of that resource. But there are actually two resources here, with different owners and related but different lifetimes - the physical memory and the IOVA (ie. the mapping to the physical memory). Obviously the physical memory lifetime is owned and controlled by the exporter. The IOVA forms part of the importers address space though, which is used for more than just DMABUF, and so belongs to the importer so it can control it's layout and lifetime. Otherwise how say could the importer later reassign an IOVA for a different use? It could call into the exporter to do the unmap, but then it has to trust that the exporter does the right thing. Which is exactly why Jason is saying we're implicitly trusting one side more than the other - we're saying we don't trust importers to manipulate their own address space correctly so lets have the exporter do it on behalf of the importer. Even though the exporter has nothing to do with the IOVA. It's worth pointing out this is how core-mm works too - it doesn't try and force unmap things itself. It fires an mmu_notifier when it's about to move the memory behind a mapping and whatever implements the notifier tears down any local mappings, whether they be in a device MMU or an IOMMU or both. > > > > I just saw someone in drivers/media do the most insane thing with the > > new DMA API, unbelievable. No matter what we build someone will find a > > creative way to abuse it. > > > > We need to have a 3rd party "Switzerland" if you want to keep this > > direction that limits the exposure of either side to the details. > > If I had rust for this I'd be happier, but we don't get a switzerland, > but we should at least be speaking in terms of ownership and lifetime > of resources and what can reasonable be defended against. Agreed, and I think the crux of the problem is we don't agree on what owns a mapping/IOVA of a resource. However I don't think we need Rust to have "Switzerland". We could create importer and exporter specific data-structures that only some core piece of code gets to see both sides of. But so far I've sensed push back against that idea. - Alistair > > > > > I think I'm still with Christian though. I think you need to export a > > > "dma-buf" with a list of supported both platform and device specific > > > types that it can be imported into. > > > > This was the entire idea behind the mapping type series, it came out > > of Intel asking for support for ualink. > > > > > for dma-buf the import meta-data is the struct device, the output > > > meta-data is a mapped sg for that device. > > > for PCI P2P, import meta-data might be just the PCI address of the > > > importer, snooping, atomic access?, maybe we validate it can be > > > reached, but then we return PCI BAR + offset/length lists. > > > > No, the output is always a dma_addr_t, the dma api natively supports > > P2P. You have to decorate it in a special flow to make it work. > > > > Also nothing uses PCI BAR + offset/length. If you want to make that > > you can in your own "Switzerland" but it is an unnatural > > interface in practice. > > Okay maybe on that one we can give in, I do think path + offset/length > lists might make sense for things like NVLINK/UALINK though were there > is more arbitrary path to the resource than just what is CPU visible, > but maybe dma_addr_t can encapsulate that, but for some things it > might still make sense. A lot of this ends up being just "path cookie" > + offset/length pairs of arbitary address that make sense for that > path. > > > Even the P2P permitted placement selection shouldn't be open coded in > > drivers, this is a bit tricky to do well and none of the DRM drivers > > get there. > > Because nobody has written the code to do it? > > > > > > for iommufd, import meta-data is the iommu_domain, the exporter maps, > > > and hands back the correct table of addresses > > > > FWIW it is a huge pita to make things work like this inside iommufd > > and if it gets messed up then iommufd will explode in a bad way. > > It is so much easier to feed through phys_addr_t since we already have > > this infrastructure. > > It's easier, but you don't respect lifetimes then. > > > But if that end up being the only thing that we disagree on then fine, > > but no giving it directly to any DRM drivers. > > Most likely DRM drivers or any exporter will just want to add it to > the mapping list and call a generic iommu interface to do the work. > The big thing being they can control undoing it later. > > Dave.