From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 03E9C606A325 for ; Mon, 30 Nov 2026 05:04:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=nHbvGbjB; dkim=pass (2048-bit key, unprotected) header.d=ziepe.ca header.i=@ziepe.ca header.a=rsa-sha256 header.s=google header.b=NvMTNniS DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=hpgxxji67KrMZBTg6jUjcNbfY5cNwEwJL3jB25wL4Zo=; b=nHbvGbjBTIdJzRmaheHPkinoLt H3zXAwm1w59DMmYOJVc1cN2CXl8E8YAf+QmrYi+rCjjCQkEKxSQC+BI4EZWdgOSNVW4AjMWEFDScE VYVZJqEaHTJdzn3+r+ySsJY7GBjGAHGxs/zn7JLyzTESzff+tRjS805kYRP4YAvNQatxY2/CFogJa fu5qCrg4FQeBX40emg6YZl7P1wLNelAMR9O3TQJtkq6sdwlHQmAbUaq3id2BYNwGrc3QOG1t97n2a gZSN2fwRPMSYZ06UykDlPoLLzLS1m5LYjfvATUIaEZv5OTiimdtYLkbtv4OAP3H1Ekw4fIHybgFyP 6SXpONtg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXtZK-00000003F3o-1plN; Mon, 30 Nov 2026 05:04:50 +0000 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xWvWX-0000000GCwL-09VM for linux-nvme@lists.infradead.org; Fri, 27 Nov 2026 12:57:58 +0000 Received: by mail-qt1-x830.google.com with SMTP id d75a77b69052e-55dc111ae86so15898221cf.1 for ; Fri, 27 Nov 2026 04:57:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1795784275; x=1796389075; darn=lists.infradead.org; h=in-reply-to:content-transfer-encoding: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=hpgxxji67KrMZBTg6jUjcNbfY5cNwEwJL3jB25wL4Zo=; b=NvMTNniSpaCixyUi2i2tuLdHmkkK37PdscQNpU9F59E82RQLkHeH0BPIjQ/B+QlYVb gIo6e4dDg9RvIVB8dGXG9l9gtko6xI2BcLAsllGrfJ/YLneqEKKdsONmDFyn/7xN+k3n F3Lp4xnf6vlX8J1drfe+v82vcrJ9gfzdes+Y4gatJE5WmQ2nANimoo1HVQ8u29Py9PvJ hAo8Qw291qt1faHHWTVODvJenDMMvUGNFiHEA26vSARp13qIWhj6tjayWBl1PakGLK9M 6khRMrVw2ACfevFzbYxDlru7fu4o8c10RAcxNtUfHwW3jFRcPMK5kH5HIvlLhWbQLokm mJ0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795784276; x=1796389076; h=in-reply-to:content-transfer-encoding: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=hpgxxji67KrMZBTg6jUjcNbfY5cNwEw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tZwE5MR8TD7a8ltT62cwzsnI67coedSfKq8qf8XUkOPQ3kYda+PE/4ShzArdMg00Avchjv2QKNT zVNlC+fuQFWx8w0MVwwSiZoCNT7Amzsrxb4h9hF7msDlNoEmGqEk2AKtrxw8KBDEPc8XHwakevW WIXcAw== X-Received: by 2002:a05:622a:48d:b0:55d:3689:913 with SMTP id d75a77b69052e-55d76aad14fmr455567241cf.77.1795784275571; Fri, 27 Nov 2026 04:57:55 -0800 (PST) Received: from ziepe.ca ([142.177.118.84]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-55dbeae112bsm55627651cf.8.2026.11.27.04.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Nov 2026 04:57:55 -0800 (PST) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1xWvWT-00000006hYF-3LIW; Fri, 27 Nov 2026 08:57:53 -0400 Date: Fri, 27 Nov 2026 08:57:53 -0400 From: Jason Gunthorpe To: Christian =?utf-8?B?S8O2bmln?= Cc: Dave Airlie , 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: <20261127125753.GS246011@ziepe.ca> References: <20261120-dma_mapping_type_v4-v3-0-c0183a409bdf@nvidia.com> <20261120-dma_mapping_type_v4-v3-3-c0183a409bdf@nvidia.com> <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> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <79d62f9a-cea8-4149-a673-7ef86942410d@amd.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261127_045757_132827_A096DFD9 X-CRM114-Status: GOOD ( 26.45 ) X-Spam-Score: -2.1 (--) X-Mailman-Approved-At: Sun, 29 Nov 2026 21:04:48 -0800 X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" X-Spam-Status: No, score=-5.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, 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 Fri, Nov 27, 2026 at 09:04:15AM +0100, Christian König wrote: > If we somehow prevent the CPU physical address from being casted to > a struct page and/or used with vmf_insert_pfn/page/dma_map_page > etc.. then there is not much of a problem with passing around > physical addresses. I already offered that in v1 of the series using limits on EXPORT_SYMBOL and you NAK'd it too. > > If we need to shared object backings and have clearly typed and > > negotiated on what the backing contains then we should allow it. > > However I mostly agree on the mapping thing, I'd want drivers to > > negotiate and natively support whatever backings they can rather than > > having an intermediate trying to handle the conversions Not saying the > > Yes, exactly that's my concern as well. We need to avoid this middle > layer trap. You avoid middle layers by having reasonable subsystem helpers for things to use to build their stuff, especially to encapsulate common patterns. These helpers are part of the subsystem, or in a related subysstem helper library. In Linux terms middle layer almost always means something wrapping a function pointer callback into a driver and enforcing specific actions on top of that. The recommended counter is to have the driver perform the actions with helpers and not wrapper the ops. It particularly came from the block world where they stuck something like SCSI after the block ops but before the driver. It is hard to see that DMABUF is anywhere close to a middle layer. This is also why we don't understand your remarks about dma_buf_phys_vec_to_sgt(). Of course it belongs in dmabuf, it produces the dmabuf spec'd mangled scatterlist that only dmabuf uses. Where else would you put this code? > > code doing the conversions can't be a helper, bit it shouldn't ever be > > autoamtic or outside driver control. I think you do want it automatic, if an exporter is new and makes, say, a dma_addr_t[] and the importer is old and wants a sgt, why should we be open coding anything in every driver to deal with this? You can argue if it is automatic because the driver called a very general helper or automatic because the helper is wrapping a callback, but that should be a fairly minor quibble not a huge thread full of NAKs. Ultimately DMABUF has a fairly simple flow: 1) Allow importer/exporter to negotiate what kind of interconnect they want to use (PCI, ualink, etc) 2) Give the exporter enough information about the interconect path to make a placement decision 3) Describe the exporter's buffer so any mappings/translation/etc can be setup for the importer 4) Program the importers HW. Many of these have very common patterns, like PCI GPUs always make the same kind of VRAM placement decision in #2 based on P2P support. This should all be in helpers under the dmabuf umbrella and not open coded. Jason