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 B88EA606A322 for ; Wed, 2 Dec 2026 01:30:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.a=rsa-sha256 header.s=google header.b=TOGWh+QB Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B1F1910E30A; Wed, 2 Dec 2026 01:30:52 +0000 (UTC) Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by gabe.freedesktop.org (Postfix) with ESMTPS id A777F10E498 for ; Wed, 2 Dec 2026 01:30:45 +0000 (UTC) Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-55d30c054dfso119539581cf.0 for ; Tue, 01 Dec 2026 17:30:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1796175044; x=1796779844; darn=lists.freedesktop.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=VcUZtXBpZV3hq1xptmeqiTmPBPnOG37CB0gnMZjEpPQ=; b=TOGWh+QBwcxNJo/Jt2i1iD3Eke3WIhsmpn1cqF2Xjki0LZjlbKBbG2fBEZGkQckIRr yzyN8lgUP1vRi40kdnQ7uROTqZg53dIn1ln16OJB7+lV8NIXYSCLK8gCj85r7+yxmYfg YSmfB7nE9/YQw9RO9bf7Eo7r9MnTDbs7rsojTOBD8QFilwSRMTwWv+FoDTBiCE86gxRx p34QVhiiLN+H8oFeEENECOW4NKQcwR0m5e9vLdDYsN8NZt+KvyxJudVJtLvCLCUu3+gY 0dzuRMtoV7V582ABrUOVeM/8Yp7WjaJ9teB8mb1WEBLuhM3R7SQWq8Xp3NK9o8hPg0BS /EkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796175044; x=1796779844; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=VcUZtXBpZV3hq1xptmeqiTmPBPnOG37CB0gnMZjEpPQ=; b=oyG5SlcCW0SyQ5vBF0OG/WsKB+kuE0/yRvsCUx2uWwUTYK9fNa3w0zhJd3NiTKEMi9 RcUJ6n++NInmL/p0aQ/ddiBZzw7LdeAOKmdn/nxc3BY7BoH4GLlrdEEfwsrCW3PAj386 3+Wf4XMGsNkZMESdSLZZaE4F2lmfztTkUYos2Iyr0yxm00uVT/fABh5tFJfK9rYtabWj gRpv8kH8VLU20u/VxHQFv4epXpF8AkSt8LJwP9N52n9nFpn0jiBQBCyHZEPz5Zejwisy kZcx9hIHZ9Bh7k5rD4HKIdjc3JToAkMuawB/PMzghoH8XiKKvATZQ4Pnc/drI0CZ2IFy 0eOw== X-Forwarded-Encrypted: i=1; AL+hErEXQVC2U/0BvZi6Tx/CS/PYlYbI8tNj+pDxFpy0VAq5VlFzueB0OZCX/7zbGL19Nx585t2nLNhDmlg=@lists.freedesktop.org X-Gm-Message-State: APuU4Z8LuOkPfA8sjnP0D8S0Bd4DYIQQLYlW2NjxTwzEmBfKlnCnB92N G4NMG8xWy85pxk4BRQ8IFSPyJBFbQsDDcH6LAOEg2gerUn6Bt3GcKaHiJnIWFDAODRE= X-Gm-Gg: AZFdTZfhrUOY52PWTcj7JuiRlYPXLFqo4xhGW7lR8++9kqg9H1sCEPXsRFhNPy8qPEs eP4rvfiv8t0CMRScrAaWCsIAKn17pzNSa5pkppIfRIr2HD9/73UxdFFQrHoxHlfClcaAQEZk3mU 0La7pfe2wlaJ9xUyx1m85Lwvqb8yKq+/vYx48VR6ebzjwXB3ytlfO+4H+8tAYafTghkJQLOBFA8 EFk5EklNQIm5mm61yahDT262HOQCuLT03eqJrBnpcRZyH6T+REki4KGMbb54HtkMqebX7nxebgZ 07Bb6aymv5Dy/o/KYpPT4MbzU+E7KUaSv/hPKDk5hYXycoWuX95OaYoV1fS5OB4rdpVAr2c4mt8 4pBqpDo9+TuuEi8G2TIkHGOYHETWxj7rTmHrYzQUnvrCqZynXEIPR6Wmc7c2t8/QMFAHrBlXBS6 0N5RmRvrKAaObS6zLy6iylz6tJ5gAYwAJJxUGUfSETIv+E7qOT+/jXIg8WgkbwOFND9qmCKD4lN +EDMLrUxlqDcPsmvvDWNAM22BscDvuP5kPdLa3IeIwdCe2ZgyuIOf4hr0WkslWP9y5sKgv5ZcAL vztOGHFoHz0V+r7jycyxb5RBJQ== X-Received: by 2002:a05:622a:ab0a:10b0:55d:bd82:16b3 with SMTP id d75a77b69052e-55dbd821b79mr299151141cf.77.1796175044341; Tue, 01 Dec 2026 17:30:44 -0800 (PST) Received: from ziepe.ca ([142.177.118.84]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-9217efd0637sm181779596d6.42.2026.12.01.17.30.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 17:30:43 -0800 (PST) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1xYZBD-00000002Dzt-0J13; Tue, 01 Dec 2026 21:30:43 -0400 Date: Tue, 1 Dec 2026 21:30:43 -0400 From: Jason Gunthorpe To: Dave Airlie Cc: Christian =?utf-8?B?S8O2bmln?= , Alistair Popple , 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: <20261202013043.GC351887@ziepe.ca> References: <79d62f9a-cea8-4149-a673-7ef86942410d@amd.com> <20261127125753.GS246011@ziepe.ca> <20f5fb10-b71a-40f9-bbb2-f99b4002bf08@amd.com> <53a32383-4cf6-42ac-bbd5-476e69a3be5f@amd.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "dri-devel" X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 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.. 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. > This directly conflicts with Jason's idea that I'm not giving > exporters the importers iommu_domain. I think we have to break this > deadlock to move forward. 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. > 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. 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. > 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. But if that end up being the only thing that we disagree on then fine, but no giving it directly to any DRM drivers. Jason