From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99233606A320 for ; Tue, 1 Dec 2026 09:33:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=k2Gs+A5t Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5AB7A10F6CE; Tue, 1 Dec 2026 09:33:50 +0000 (UTC) Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011020.outbound.protection.outlook.com [40.93.194.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 69D4A10F6CE; Tue, 1 Dec 2026 09:33:44 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RiVGcZ7ibtQWpkg3WsqKh6PNuR362rJaZTFtsxBgcfhkKuSda7jQRMzX1JCVf4TGkT0AtbYpxJEWSqX69Lc8QDKBkqRsKY0f5trUtBw/wItdMTiQTyMqtXfssqIuv4ONEvpQW2SSoq2F2KHcg01HW/V37UYVx6nfMnb5LoBIfP5v2s58umfdC7lh3PisEP2XX+rqDKYE/HvmADol2V9GS9ApUHcV/X7hrjQHYYO0L/WeF+eQEOLRuKMkFaaQORKMrAXt/82IhlfvQ7BRqI3KAsFA0pPSC4DOIr9buCTG6/jWs9xgFZ9YVbaWGAR57uYVGMBxZgYsmoxQy6KS/mB21w== 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=GosMNPbVkO0nkLs9oix5qeOXhC3yBWeViVqL7dIT5nM=; b=E0hmz3tPtmgAuvQcR2aDlvoLMkdjR7B4AFvC8KwYG0IXycrEAzHQ88SpLuItcFJfWyNFDRzfa3dz047vXZ6m57X1iUPnTzWC2Yvf2k0JE8l6X/aqpiqkLKGC6LkYnFEgChMlNyMk3knCRDjVodPs7Tcwcp6youM0qk0QOf788XPlp0h0ifkyVWLrAefDzrUalqC9rzS4vLjxwY5WHXpOwwhifT/StUZsLwjBAJWEM7PlUTvxN5wDZT9co+TUh9n80407z1wL3Yu5b/E4RGw5jvd6SXjwvUwE2c6fmOwd80Ikv8kPAEUyQKTC0R1X0NxGRMXSCmlP0dOtwjNMTZT0hQ== 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=GosMNPbVkO0nkLs9oix5qeOXhC3yBWeViVqL7dIT5nM=; b=k2Gs+A5tOSB1L58maT5qMdkGpLTjwsdPafqj1K5rNbdrAsEvDkmMZzfJ+kysUddGy0WVTSPqfrwMldN03tDtcLyow33xi2m/7mgL0uAdVniPxcCcNxVj1+ioc0nbn8jckJP/08wP/H3uGAroxSuOTJBzi0Iq33OWHyK49K/UDYT+P/2dLjhC9cQ2Ek/3ozCW6+s0phsunFzYchMYjgUS0fs0gaM3/Zl6ueoijGcNAZ6ZCRShzE3M8tlRD06vrsbZoQpvzG+23BRY4xM+CjwGLaVdA7D7xr6Xjl1RhOInKKOE4ZWPgsLP0D6xkC03gJCsNgDB2eEcjH8zKXPyjRuHnw== 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 AT6PR12MB026552.namprd12.prod.outlook.com (2603:10b6:170:116::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.13; Tue, 1 Dec 2026 09:33:36 +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; Tue, 1 Dec 2026 09:33:35 +0000 Date: Tue, 1 Dec 2026 20:33:29 +1100 From: Alistair Popple To: Christian =?utf-8?B?S8O2bmln?= Cc: Dave Airlie , Jason Gunthorpe , 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: <63eb7b6e-e0a8-4443-a434-0301ed59beae@amd.com> <79d62f9a-cea8-4149-a673-7ef86942410d@amd.com> <20261127125753.GS246011@ziepe.ca> <20f5fb10-b71a-40f9-bbb2-f99b4002bf08@amd.com> Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20f5fb10-b71a-40f9-bbb2-f99b4002bf08@amd.com> X-ClientProxiedBy: SY6PR01CA0039.ausprd01.prod.outlook.com (2603:10c6:10:e9::8) To SA3PR12MB598757.namprd12.prod.outlook.com (2603:10b6:806:52d::14) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA3PR12MB598757:EE_|AT6PR12MB026552:EE_ X-MS-Office365-Filtering-Correlation-Id: fffb7ca5-1a8d-4159-a91a-08df4f8e2c54 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|1800799024|23010399003|7416014|376014|10067099003|56012099006|261028144727099003|261026121527099003|261026140227099003|261102123227099003|261022105027099003|261021121427099003|261022075727099003|261102130727099003|261009223027099003|18002099003|22082099003|11063799006|4143699003|3023799007; X-Microsoft-Antispam-Message-Info: vHFPJ8Mw1VRPoDee8IPk+tv+UhfQ999MVZb5gEX/CMgCGtRMPsEpWwGqwh1qtV401vZz3iw06phVlARfvbm/culdAr7dhOjtObJbNbJVHCeCWjZgXfmUSWVytxcowCoafgVGEvF45gEo4xalyQeBBIf8qIa/G4snl620umNXi6Wx2Mj9hdBtj07HECbReBIoN8n5cVIREozwONW8QfbraoswDfrDkLLAeh15hRrxH8TRCZXWU7jrIYTcI4xgXotIUIqfXjxim70ku6/jttyBpLx2Bftybb/GZz5EfKOjVDwuD3i7ZsssPsPJx7DKBekyo3aR8NRTcSDBHK0G3FeL/7cRGPbGRNrsjwEj3grVBlSWvMlo5GlFQLT3O6NTBZGpHUl12GL5Lq84Yeg95gFVcRDDjAcSnffbmpniZiTo7q+Fd6EZtXiY+Bk2rZx399ZOHm89GX16RPEmE1Bk6m5j96iq5Uu+1V9h3ABuhmHB+oYMk87bH6KGeOQ+qaIzAF2T29TCZCWTp9tevhPnQ+aLS7L9/nrNxkQ9l9ofhBTS2dmU18wCU09JsE7xEKdI9xVg7Y7XjgWUwfxF+IwGSIarFN1KwP5G4C8oreGeZLcNtdg4tXfop13ciry9hHAFXlXYNkqYM+Qf2SV21WVSGSxVaMwYBwodA34966E0Fma/hvw= 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)(7416014)(376014)(10067099003)(56012099006)(261028144727099003)(261026121527099003)(261026140227099003)(261102123227099003)(261022105027099003)(261021121427099003)(261022075727099003)(261102130727099003)(261009223027099003)(18002099003)(22082099003)(11063799006)(4143699003)(3023799007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?K2n+pw5TEp79laVtMlmcbpN6EOy1tlmzgx3Wg097aE0hU/ZSqcoNLfr3CL?= =?iso-8859-1?Q?L/CgSgHWqVtVSrd3i/cBaqR9+bybqa/crjgb9HSPFkip5VAy+htMDaUjym?= =?iso-8859-1?Q?0LSnPEzLp+jkzrBkErsHgzgWCreSpAgfPccqAUjoVT4/v6MxaKPMQr7cet?= =?iso-8859-1?Q?vgUA7jvA/AqShVhhFqOE8XuzLzZXT2vf4OkS20ibjG9zEmibK3ly9muWGd?= =?iso-8859-1?Q?ydpEN7R6CLkXwJFBdHgRwcrfrjtvQtGav2pXmkoVhI2f3c282VWhElLsNf?= =?iso-8859-1?Q?4Jhdlc0XYEtMpZ5dhiSN3lvANLMemOhtLJnPKYH9Pd2pgWsHNt42Wzbecb?= =?iso-8859-1?Q?W1I5fuVqOXes817RElRB6bU7pbiSPgfjlQMqTuAAPtO10EyRCBPmjCerUk?= =?iso-8859-1?Q?5UI3kwxCmEVQbyLZ1fLVyFCEaVIsWnbpEc4jReuso4OWx2K6hBCmZ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59yu7Y/laGbnR914QefxzklXqdFuvInWZDqGxylJyf?= =?iso-8859-1?Q?0NZGJAVmwk594NXNlYqldyCHb7nmhLsaXouJVOlHZMH1ag5tXE7RxM5Z6V?= =?iso-8859-1?Q?BQcIt0dBovvJTVjn6K/P/OnaJo3m8MDGnL/lGo0m/xkfqjKrnQD9AgTCfG?= =?iso-8859-1?Q?1QvMYIbKb1NwwdoDLh0Ax1YbtZ3JFSPJXxAEJ7luaYohE8coaK0OQwbp62?= =?iso-8859-1?Q?25jJZ1+CXOB9ZLHHUZsx2W1aoMLJF6W6ZuflZcATkfrT3tpDQlivXkPznD?= =?iso-8859-1?Q?kjQCuVYO3DqmBmfGq1BqsinDIaa6ERjei3QMpIO9NTAlcq2tKBdnxDRwUz?= =?iso-8859-1?Q?MthgOcZRLrKYdsSF+KCPthfy8c154TdzLUXhfZBxQYyu+88xeDUAQlKIhf?= =?iso-8859-1?Q?jsO9SNDFOgFjnqaNEcUffnOk/GZM32fU8HPUc+85d3lJ0q+Jws5WliCx7Y?= =?iso-8859-1?Q?ER12Yy010g=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: fffb7ca5-1a8d-4159-a91a-08df4f8e2c54 X-MS-Exchange-CrossTenant-AuthSource: SA3PR12MB598757.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 09:33:35.8969 (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: cu38r3Siy3C6XjUnk9zBChb3o8OO9dG+syobvDtFNmu69kfgMlr+yPDWcQzSdGGiirM3ZewcWqGnJ2zZePDWWg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AT6PR12MB026552 X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Intel-xe" X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On 2026-12-01 at 19:11 +1100, Christian König wrote... > Hi guys, Hi! > On 12/1/26 08:13, Alistair Popple wrote: > > On 2026-12-01 at 15:05 +1100, Dave Airlie wrote... > >>> The problem is I can't figure out how to build that low level API. > > Seconded. > > I can give you quite a bunch of requirements based on what the high level DMA-buf API and uAPI has on functionality and based on what I have seen on use cases in the wild. I think a bunch of requirements would be helpful, because they've kind of been scattered across threads at this point and I concluded it was kind of impossible to build given the constraints. In particular the one thing that PCIe P2P, IOMMUFD, KVM, etc. all need is the physical address. That is the vendor agnostic thing below but providing that has been consistently NACKed and I can't see how you can make any low level API work without having the physical address. I know in the past you've suggested passing all the importer context through to the exporter, but that is also a complete non-starter. It lets arbitrary drivers implement the mapping wrong and likely get all the life-times, which belong to the importer, wrong. So until we can solve that I'm not really seeing much of way forward here. > But I can't say either what the low level API needs to look like and one of the major reasons I want DMA-buf separated from that low level API is that it seems like this needs a different field of expertise and responsibilities. I get it, and I do appreciate the expertise provided here. However if DMA-buf is supposed to be some separate mechanism just for passing pointer types between exporter/importer with some lifetime and location negotiation rules it shouldn't also be seeking to impose constraints on what information those types actually contain. That is none of it's business and is up to what the low level API needs. If the low level API needs importer context and physical addresses to do anything useful then so be it. > >>> > >>> The current low level DMA API can't correctly handle PCIe P2P, or IOMMUFD, or > >>> the KVM/confidential compute use-cases (I'm less familiar with those). It can > >>> only handle creating a DMA mapping for system memory for a specific importing > >>> device. > >>> > >>> So I assume you are talking about some new API. Following Dave's lead lets call > >>> that shared_buf_map(). That would need to take some importing device context > >>> so that it could dispatch to the correct mapping code and a list of physical > >>> locations the exporter needs mapped. > >>> > >>> At a high level something like: > >>> > >>> struct dma_addr_list *shared_buf_map(import_context, location_list); > >>> > >>> Where the import_context is some importer specific struct opaque to the exporter > >>> and the location list is a list of either PCIe MMIO or system RAM physical > >>> addresses. > >>> > >>> Every exporter ->map_dma_buf() should call shared_buf_map() instead of > >>> open-coding their own mapping code, as I think we all agree we don't want that > >>> open-coded. > >>> > >>> Placement selection can be dealt with as a separate topic, so setting that > >>> aside means passing in the same location list regardless of importing device. > >>> shared_buf_map() then has to dispatch to the correct mapping generation code - > >>> either DMA API, PCIe peer-to-peer API, IOMMUFD API, KVM API or maybe some other > >>> importing device/driver specific API. > > That sounds totally sane to me, yes. Ok. The problem is how this shared_buf_map() gets the importer context. It would be easy enough to make work if an impoter could call eg. shared_buf_map(import_type, attachment) or something like that, but I got the impression from the middle-layer discussion that that would be undesirable and get NACKed because only exporter should call that. So not sure how to actually make that work, unless my impression there is wrong. > >>> > >>> I could see how that could be made to work, but it seems more complex than > >>> a dma_buf exporter op that returns a list of physical locations and a helper > >>> library that importers call to do the mapping into whatever importer specific > >>> context is needed. Instead you would have to add importer specific callbacks > >>> that the shared_buf_map code could call along with plumbing the importer context > >>> through. > > I've thought about that as well for a while but came to the conclusion that we most likely want some more differentiation here. > > On the one hand we have the vendor agnostic things like PCI P2P, IOMMU, IOVAs, bus addresses, CPU physical addresses etc... which a vendor agnostic API should be dealing with. Right - I'd like to tackle the vendor agnostic things, as they provide the most value. Vendor specific things have already been hacked up to work in all sorts of horrible ways, which is why I want to fix this so I can at least remove some of the horrid hacks from our code. > On the other hand we have vendor specific things like XGMI, GDS/GWS/OA, I2C, I2S, doorbells, which only specific drivers understand. > > The problem is now that those things at least partially overlap, for example a doorbell which is ringed by a PCI P2P write. I'd argue that a doorbell rung by a PCI P2P write isn't any different than any other PCI P2P access. The data in these buffers doesn't change the type from a buffer sharing perspective, the type of data in these buffers is always up to some other layer (eg. userspace), so I don't see the overlap. > >> > >> This is where I got to thinking it might end up, not that we have an > >> export function that actually exports anything, but merely advertises > >> this provider has an object with this fd and it can export it in these > >> ways. > >> > >> Then on import we'd have to go into the exporter and setup the object > >> that gets shared between that specific importer/exporter combination > >> and not always have a singular export, but one per import, that I > >> suppose could be refcounted per export if lots of importers wanted the > >> same thing. > > Yes that is a requirement of ROCm as well and we have hacked around such things massively with the KFD and all the rat tail of consequences seen by it. I should introduce you to RM :-) Thanks. - Alistair > > That sounds reasonably complex. Do you have a vague plan, ideally in the form > > of data-structures/API definitions, that would help explain what it would look > > like? > > > > For now I have sent a simplified RFC series - > > https://lore.kernel.org/dri-devel/20261201-dmabuf_shared_buf_v1_xe_rc5-v1-0-b672717c7fc9@nvidia.com/T/#t - that drops the placement > > bits and implements the rough plan I outlined in > > https://lore.kernel.org/dri-devel/awZ_Os1pXelOGaFP@nvdebian.thelocal/ . I'm not > > sure it addresses everything, but I'd be interested in getting feedback on what > > it gets right and what specifically needs fixing/changing, and how, to satisfy > > the design constraints. > > > > Thanks. > > > > - Alistair > > > >> Now maybe we can't call this dma-buf, but I think dma-buf is a subset of this. > > I would say that DMA-buf is the high level API which allows importers and exporters to exchange the data structures of the low level API. > > Christian. > > >> > >> Dave. >