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.52.42 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796109192; b=yRv//vwBGlI2zm62xatZt+QfFqfzjC+avYeR7UOpvMtlDSx2x7naP8tTqioYUFplQI9N kStz4sTUdTJyT+NB0y6s3b9aa3qGjYm7cjUZ0jkzG+RVvh9U8ZvkJEr1A1oRpr5/kBm/X FQOD/JLtAPXHKkq5uzDmKjiPcZ++HAVGd17u8i0x8LPr0jn0ovSMsbcyKNfIfA+Ai8A0H N8CWtZMPptNA0OWg5onqVVCTDXhQ1jqGn01Snp7ivdPo8AXUjRN9cImFl9E6lbS2TiQxj d0clB7UYKGn8U8oAUOkGWHfpCje1XtilwzHwrIklgNk30nOo7ABYuear/TXtuVwUGrg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796109192; 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=1fRcFTq6RPTh5qA25K0UhgTH5P0nCknghouOqFEQ4jY=; b=y/DCi0nEL23U4yT+i/bwStuOPWcTuo5cfMZzIy27oTH9vM/dDzjNxbyGsaWgkMcFHihp la0yX+IuvrjtuZqtKCy2/dIpSx2K61HgSrFHhhFDvYF8jFrFYiOq8dc50tmtOsxhX3ZwJ /mtca89kUjzSn8FOIjm0ZDp3D+EG1ztMfV3+sv14HdYI148LT/+V3jUQ85gIij6JaRH7p sRnBAcyP3vdldwahJANoipajD89cRDUoKlwv+bRDbzs50e/nOpcCjA4u/eFX+ekluniMC d0+lClOSuFvM50XCnB1gzZVH9zxaEa1HCNG6fAQ6gVvAqUrLtmhaixj9Z1mnzbFTMUg== 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=tFq0CMip; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.52.42 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011042.outbound.protection.outlook.com [52.101.52.42]) (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 1E189606A682; Tue, 1 Dec 2026 07:13:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1E189606A682 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=tFq0CMip ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dD3EXnqdK6sZp07x43e20kbMKu65Yvq2wt4k/F1I4so9SNLk+Wc66KZjb0GOb7W5FjTV6o1JgDltolELZ02BVvM5LSwIpEsbva3RTDLT4pmeD/Y2ouJMqu0YiECCQ9tyN1u6YyNf9D78YfEeCJBhGfzUtbqNV9wn6amUnLZqbZURFHdK07DVwcchrtUX6tqjBlowvoxLQKUY3/WGKvbyVpVEC8XemuG2pjjZAa1XjquBwoo0CIEDlrJaER9fKnJsU+OSFho5FEJZE4kannHEKaLws2ez2vrEhbjEEt8CzpnQ9BgGCbOhXeR/Tav1reduvA5GhldrPbeWHW4zB461gQ== 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=1fRcFTq6RPTh5qA25K0UhgTH5P0nCknghouOqFEQ4jY=; b=wLA/nfCK0axBSk14mZq+agZLoabCyV1nLpEnZXCsrc5ZKKnBMatp9SnZRwQrGRsG/fU0ZL4LJEHW4WMkpKBP8GU4UeEajZH1YsDR+LzRvGisj5RX4nzdOy4CvRgssC+6SGFN+xuXRuzLHmOz1XBouoMSH9+G4w46S5Sglu3z62l70nSj8Bj7JLVomvuHWrcL9Z75GlcVrGLPlVtjw+cS9V+uoQuuZMAZfZKEtEvxJh72HnVyJp64uUfpWheyOI3YhNBkeCw2OVXRtWJmibR8VbRb/E7T+r0Qlu4btnnVnZ+HspqPkdodoBBW6EsBZ/ayd38LBvt+adXQDbdPWAO8Ag== 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=1fRcFTq6RPTh5qA25K0UhgTH5P0nCknghouOqFEQ4jY=; b=tFq0CMipgN3C7stVOytmR/t2Vytgy8KlSE+6wI2hAAOTAMG5mJ9wU7r2RVxtv6/VHI4Ukjtu/GDOXNagNtemIhj6GezAIIjvfjD6qvNXG2oQZzYHSh2NlMWT4YXir9qDEpd7zMST3yPsy3fH+kRY4JG45On5tjyEhfKt1wN9XhtZt/t+l0eAZvIeyROzGI3S/9bq0z9Z9A6ys98K0U33DzSYHyDphVTdRJNmZPiVpLZMsxUV3WWa6t4fJUArPKOdkR9ERSL+yDCypsX6s5vVH6jUF3DwoXiampU9VsTYTFDMlVAZXM8oYwg4+m13QaE3BBYjj4fWj01YvP9EW/lAmg== 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 MW4PR12MB6803.namprd12.prod.outlook.com (2603:10b6:303:20e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.12; Tue, 1 Dec 2026 07:13:07 +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 07:13:06 +0000 Date: Tue, 1 Dec 2026 18:13:01 +1100 From: Alistair Popple To: Dave Airlie Cc: Christian =?utf-8?B?S8O2bmln?= , 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: <20261123165716.GM179082@ziepe.ca> <7ac7edd0-5c38-440a-b26a-21bcbb6f4702@amd.com> <63eb7b6e-e0a8-4443-a434-0301ed59beae@amd.com> <79d62f9a-cea8-4149-a673-7ef86942410d@amd.com> <20261127125753.GS246011@ziepe.ca> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: SY5P282CA0079.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:201::10) To DS4PR12MB634945.namprd12.prod.outlook.com (2603:10b6:8:514::7) 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_|MW4PR12MB6803:EE_ X-MS-Office365-Filtering-Correlation-Id: 0623b753-f0b8-483c-1159-08df4f7a8be2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|23010399003|1800799024|7416014|376014|10067099003|56012099006|261026121527099003|261026140227099003|261021121427099003|261028144727099003|261022105027099003|261102130727099003|261102123227099003|261009223027099003|22082099003|18002099003|11063799006|4143699003|3023799007; X-Microsoft-Antispam-Message-Info: jFc0gcHFyvNBbgMl2kvB6GH7XFF1RHHAiyiVfHu7dKRST7aadmx+ZnkhusZ/jYukJNZf8lZaydZ9XHCinHtnOqqeSHwlcUENhtupntKx/Uw/g7D2Hw2UUI9HBCkFBfLp65Upsasl6mbgWFAue6mMwSAup2XhLgCXtGvzpR53tlEHMYt9UCi8G2S7drhRsge8e5CEdF3dbhJNhVhLP7slv/lCT1X/HGE1TC3yHGxxchzgjQ4FhXQmsvJL/Fi7zDaNl2gZD8BGvFWsIudWhrB403dhbcdJXFu7/1Fn4FUhaGKqSRm7eXwiXWeuUH2p2YhshfgDZg9v74V9ZFE4QHp+wSUGIBhYFO3MjbWOs1L9gUTZaQ2KpFXHpbh1MNbLyH00CTP2dLdF9KJMN2TScKBgBlOgoRm6Pi9J0NFgPCEneJPypK0/PYUkoc8qFNeW/SxrGCULGsai6sqYfLuMTzVR3xxBBSMoz08mEyWJHtQnB0DYIfxwfnA0omzPuu5q71uMJiH/k+hBZq21kZzBZUK0iSjL2SKZDpdGDKcZfmHHLzT0FSERS3aFEKKu1XuCZGXK5CdOqA8BhdN42jGeMFoAu7Q4pcXF2ho9rSmXhrbCJxdGEELvv+XuEmcJYBZVcPGKs7E/8B1ORWx/sU9XGoEdQa3y7nGossKGS+a8NcqPqnE= 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)(23010399003)(1800799024)(7416014)(376014)(10067099003)(56012099006)(261026121527099003)(261026140227099003)(261021121427099003)(261028144727099003)(261022105027099003)(261102130727099003)(261102123227099003)(261009223027099003)(22082099003)(18002099003)(11063799006)(4143699003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?RqQoS5c8UPRG93CQ0GnxpfTmu4JmGYwttjIDHzL5BA/kOE+iP4AYqHv4QpF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8I3v/YwiPSpfcflsY0u1Mgbxu?= =?us-ascii?Q?ahFJuUpvdsYBsCGDRXRSyeDDBMqx1wIvzmDttQIlyYhAkwEVN+apgmbeLZKV?= =?us-ascii?Q?+WjzK6WmnDcoHudy0AYTT9LFu7Jl19aPtS5d3UxW3lDur9D69nkpjGlJeNtX?= =?us-ascii?Q?eSeZNyjJIuTZNKsvy7n7pGbEwFPQfguCvP+9HoDNbsnL7mO65xVvNzLHA1XT?= =?us-ascii?Q?pyJj4xmm6nLW9iwSN+/3yY/HN1AmC4tSbGoFlhBf65J4MkJyOJTH3/92Sowl?= =?us-ascii?Q?Y4/1nh6tz3NfZDnexWBhU4hsZl3WJ3gaJk7Zqo7ojZaIugtTTra/19dtNCni?= =?us-ascii?Q?JPewjYXLlX7AmFOnhvqEMNu3K3dQmQteuEdBDku7QuP05YE6z3BCLqY6JWNb?= =?us-ascii?Q?Vy7yKx24bM6hyX5dN7ycqZlhBZHq7GqMqP8y8z/p8c/shn/DVNVgt87StOiV?= =?us-ascii?Q?Nm5IKZvMbdWoLjrETmiYwIGXjhMhEjOdMRFFTmeURcIWNDrWHG2XnGnjOeqL?= =?us-ascii?Q?A17HPgXHgXYP245lh25NxcPWCXfDI5tHK5R9s6wpUPRKLHQpUTvLKa5NL7Gw?= =?us-ascii?Q?vbHIl/jGeu/ED61F9aQ3JatwNfNFtmc1ov4SbEv+oZ5MX8A9vGZI+mzOCIbo?= =?us-ascii?Q?msHOHiYGa6X0//MDonJfrVvpd1ndlvm88G/PEMfpAJbMimp+vvBrj6ZJBpZO?= =?us-ascii?Q?lWW9Ji6nfJzEvJB7xh0OTZTXBpCOhkY8EfhqrziWEtsYB8yQENjSPIZe4XrC?= =?us-ascii?Q?b0LvtkZ4uP0ODiBKYow/ZUd/w0Qo83am3KGXdovtUz76bG++fZJI+I8o9Nmq?= =?us-ascii?Q?wgilkO2JEQ=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0623b753-f0b8-483c-1159-08df4f7a8be2 X-MS-Exchange-CrossTenant-AuthSource: DS4PR12MB634945.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 07:13:06.7818 (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: CO8YBErpiuszv/7KKFlkyA0YERlgURdfdN2QUg/OJ7nXJxUD//SfZM51qZwnDv2SMXMe6yNQTFSsSoWfSmpoZg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6803 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. > > > > 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. > > > > 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. > > 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. 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. > > Dave.