From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.174 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796175046; b=QHSq53mP4aO6qPuFSZEMLiNxQ0Vc8aOaQYV/w9Wvjh5Rgl3oGeYjleRwvzwFARiBCxAi 2630b5FQFxN1acGjHxSBetdYgG+fuBMpSGuRxWcPDR476EXL7O6YiOBea1PZih42Eqf6v NWGoj2fZ6AZSxGDlyQ8agoTRqs34Wz2llHW+SS02z6T05KsmAe9Z0r3JBviy/jW69ifdR c1P2PwzF4K1T1zXde0tGE2fK3GpqFugBt7gVl7UGmZstMP4zMxTzQl+2p/IpN1xYJbUYs 655Ri8wn7tiEi4gVo+edA/IM+MWckyL1wPGQD6Ch4L0uyqJVS1htOAqfaLk1BXXz6Ew== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796175046; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Received:Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=VcUZtXBpZV3hq1xptmeqiTmPBPnOG37CB0gnMZjEpPQ=; b=GPG0wQePV3NTZ/sYrF4bn+p0/Yp2MVUoKprxEYj1+1W/jxb9N1BHVHiRiRbU8ygW+KY+ 1+bssKs164GBkMYwaZ995bmsIUzVk0gw8cspgMhak/I9Y/o+bzlH580u0p+5KxJ52I+fW QfABQQbgWLlSvT9iXJLvU1Oe056PmYvaMAG7kOb0+vE90nXDEmE2BaqUCtG5bYX0ygUO+ 1fLn25GnzbbmBAFk4fcNm0XReLgISBpdZryq3bovGU+YiZmLHqZU3VK7wMrmVe802Qrd9 qqSgyBvyDfiMTBArS926Mb1zRrM3BbLRAmatZmlmGAJTBSkrqjchggRt/6ne5naNSYQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass header.d=ziepe.ca header.i=@ziepe.ca header.a=rsa-sha256 header.s=google header.b=RzGJBypn; arc=none smtp.remote-ip=209.85.160.174 Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA1DB606A322 for ; Wed, 2 Dec 2026 01:30:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DA1DB606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca 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=RzGJBypn Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-55d30c054dfso119539571cf.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=vger.kernel.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=RzGJBypnxqUv0oLWpqeWbyZhnXKki3Bbo0OWHBesxF1n3n2peOuFhjdqT9hvMklW7S 4JULiCC1zoups8kyhXvOvshQF502u6Y9a58zt2zFk/Ak+P1meJmuwbDADvI9ARfcMKBt gPJCBhz7lnlnPEv2SO4LQIUcwdDEnLvHpngOQlbQ3MgbJ8YwTK609NNYJQR1LwbNPsP2 Hu835z3vbSQlUmlc3Kmr10Vju6MOA2iHQDlcpIM4hM8uHrxboFB+9B+edZMOhWzhXYxq jBmxgfIyoHGVBrc7RGF3TlK8NgQpThjTnx9GF8/cAs5fAG5g3ms7t44u7aTNSfSb/mxx dKtA== 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=o9X8C8cCXr1kAE1JZYBKCjxoQ82mX23xYOmuc/d3dN0ZBtNXX7Mcl4Nepv29rsCnET +LmtOk/YQfa2O/o1S9Vu8SGi7sXTxAnIf3X2HJm/hBvfRjUQv8yUOkutusZV4kzTvc9n HbFQW6aMm6MWICrtZ57zXptAN+SdrqGhAPzbRCPDbNymBmU8fJUFjpn5h0xIs08Ny668 ukRg0zQQc+BdmrC9R1pDrVJPGXOUohlpVcED/wez+iK90IdeHgkh2C2MbM3T+ydNQDub 4+kLHNeMe79fSHz6ENYd6ZI1+Pn19W3Mukl51P8u0nxtJlTfWFMD5S5QACOLffXCRcCt 0K6A== X-Forwarded-Encrypted: i=1; AL+hErFD4lgPNG7qH7i8bDQtZT+ZJFbbcUSIfURumXpJTE4tJELktqDLtn2g9MdzDwz65rEgmLP224f48QoX3h0=@vger.kernel.org X-Gm-Message-State: APuU4Z+Rqigoml/pfIC3jqQC0Ecy2zElv6S5sny0OlZ+gXk5j8Kx7JIG jtjE+VmRlFRP1sDfRwEOc2Avr8IbMfktOBYpktyNFgn+3A3XyY6rzoqm/vJ7ZdOc68k= X-Gm-Gg: AZFdTZdtQcl5OUaRdJ5skX/gqxmp373kckSeCpP8QAmNn1U4XYU3hDYcXy4A87tHBid Jm8sX46/31GJ0NuvEw+i+I0/hBIEV1/n4IB63m5bvw7DVCqJr2Ak3Wo18S3rR0FzTouuFKa7gY4 hKNwfKgSaZNOzqNzl2USQPxqujffavRZcotFrb+49r2y3KEmE/xCysKwC5cOEtBNpBSK05ir/VZ zi+J3Dpr++pPvFiOY1+Z22ZLHEqDsPmoBSctYiPq2tP36GZG8AHSxz5D03p5rFc0AZcFu1vLrB+ n9POQaEtGmg2T6a1Bu8yiHonQy4P5HXewgjEOhfRoxuZvHX1T9vTR4H300qt8vK4ZNooGKwPCCn ULCPDAbwVqXOd/ZM+WvUb/WFQbcNSE0VupTDCxFmeF4ahruhePtpkvRgQFWKGhpRyfvWd37PJ48 17qGWWr/SHfO37VsM0Od3JkeJd8ecK+9OqM4HeTYU+FGV4c5W3acEiwGYMXNIwYU2B8S0AT0Nr4 V91mkwUjbsDAFnzXHAC/91tNTj4+iBVCrCSTnzoJ6iLpWARs2AXwlogJMILzRUwkxn2D2RbJLFE neEWT9DcHIHqj6vroqfZumnPrg== 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-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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