From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C960361DCA for ; Tue, 18 Nov 2025 14:59:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763477980; cv=none; b=YeMgJ3iNUV4Si19mwePItV6hnzfxFPPO6czH3o1g87jwuxsir/eRlrcABxuypjoYUxMBCAgORxkUVzTXnt062vmI/PXX4hlARq9MNuL+8YsPaoZOu/rh4yQWDDTQ/ZhuXwtyZadja+1JcoSuEy7zRCNs6TTZoNQu5MvxlicikgI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763477980; c=relaxed/simple; bh=yCZWg4HDLfx+KlOFPmT2qV/mW2ZLzgnFX5/2HTcppS4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=r14ro7gb3MJ/6mjTOaXzu9xP0A9QRheOnxyrmU6oKxFOcnvsGR2hkWoqPC0lTkSVlZnapVamjWNLlIjlzsmP9wLBWW8pWxfG4sYCp2OA8GEOnIVtYIaTJZtFGRZcCdOS54ER18Ubpcr3T666oam8kBTlntusjiYHk+EaMLy+XHI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=er7kMnPx; arc=none smtp.client-ip=209.85.160.175 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.b="er7kMnPx" Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-4ee1879e6d9so31914701cf.1 for ; Tue, 18 Nov 2025 06:59:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1763477977; x=1764082777; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=6zUAnqwUQ7mMEKfAAq0Pm8CCEggD/qceLgK2oNv/WhY=; b=er7kMnPxEnnCHS03TpdmRNrOEitAyOOf8yVpFrYKaO+QdD8Th6DRFAFJNqEIuj+t69 i3f+yxOyp798g3jbaoQjk07GnCnqdj5omEQnf9sTu3i8ICNIXiITPWnZRwTO73YgkhSw G+W8mmVFGfL7fxxdcjvsiduCOzpOyNVUc7SMCU0pEkmD5vMkSmVDG45JPMxihPOMmzHM OghNRBvgE/XQ1m1fHbyXTiBlLMO83ID+CXl5vDLmGpVUpJ7SOqCmcJCx0T4Z19Wx4o/3 lpXsu1BmgEjN4bdCvRm5QYQrK+YyCz4CdL0yMNwjN88Fw3wxnC9nYPXagRHr7e3oo8Pj OZzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763477977; x=1764082777; h=in-reply-to:content-transfer-encoding:content-disposition :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; bh=6zUAnqwUQ7mMEKfAAq0Pm8CCEggD/qceLgK2oNv/WhY=; b=fmeikDwTM2wZNl3fFeGU/5+YxL2oKryH/ANA4bnRbdueC4NXxR9ajqeE8sZ67Smhkr d1c9Q2sOaWbkZCbx4N2YhgVRNzouXty6L96f6bfCH8w+iVNDNvJVfm36/SJH2lBGOFcI NYnGYWAcNJ3LQ3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Received: by 2002:a05:622a:1a08:b0:4ee:1563:2829 with SMTP id d75a77b69052e-4ee15632a6bmr144570871cf.72.1763477977218; Tue, 18 Nov 2025 06:59:37 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-47-55-120-4.dhcp-dynamic.fibreop.ns.bellaliant.net. [47.55.120.4]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4ee275abad5sm34184941cf.14.2025.11.18.06.59.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 06:59:36 -0800 (PST) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1vLNB9-00000000NQI-239J; Tue, 18 Nov 2025 10:59:35 -0400 Date: Tue, 18 Nov 2025 10:59:35 -0400 From: Jason Gunthorpe To: Christian =?utf-8?B?S8O2bmln?= Cc: Alex Williamson , Leon Romanovsky , Bjorn Helgaas , Logan Gunthorpe , Jens Axboe , Robin Murphy , Joerg Roedel , Will Deacon , Marek Szyprowski , Andrew Morton , Jonathan Corbet , Sumit Semwal , Kees Cook , "Gustavo A. R. Silva" , Ankit Agrawal , Yishai Hadas , Shameer Kolothum , Kevin Tian , Krishnakant Jaju , Matt Ochs , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, iommu@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, kvm@vger.kernel.org, linux-hardening@vger.kernel.org, Alex Mastro , Nicolin Chen , Vivek Kasireddy Subject: Re: [PATCH v7 00/11] vfio/pci: Allow MMIO regions to be exported through dma-buf Message-ID: <20251118145935.GI17968@ziepe.ca> References: <20251106-dmabuf-vfio-v7-0-2503bf390699@nvidia.com> <20251110134218.5e399b0f.alex@shazbot.org> <20251117083620.4660081a.alex@shazbot.org> <20251117171619.GB17968@ziepe.ca> <3599880e-5b50-4bad-949b-0d3b1fb25f3f@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3599880e-5b50-4bad-949b-0d3b1fb25f3f@amd.com> On Tue, Nov 18, 2025 at 03:37:41PM +0100, Christian König wrote: > Skimming over it my only concern is patch #6 which adds the helper > to the common DMA-buf code and that in turn would need an in-deep > review which I currently don't have time for. I think you should trust Leon on the implementation. He knows what he is doing here when it comes to the DMA API, since he made all the patches so far to use it. Please consider just reviewing the exported function signature: +struct sg_table *dma_buf_map(struct dma_buf_attachment *attach, + struct p2pdma_provider *provider, + struct dma_buf_phys_vec *phys_vec, + size_t nr_ranges, size_t size, + enum dma_data_direction dir) If issues are discovered inside the implementation later on then Leon will be available to fix them. The code is intended to implement that basic function signature which can be thought of as dma_map_resource() done correctly for PCI devices. > So if we could keep those inside the VFIO driver for now I think > that should be good to go. That was several versions ago. Christoph is very strongly against this, he wants to see the new DMA API used by wrapper functions in subsytems related to how the subsystem's data structures work rather than proliferate into drivers. I agree with this, so we need to go in this direction. Other options, like put the code in the DMA API area, are also not going to be agreed because we really don't want this weird DMABUF use of no-struct page scatterlist to leak out beyond DMABUF. So, this is the start of a DMA mapping helper API for DMABUF related data structures, it introduces a simplified mapping entry point for drivers that only use MMIO. As I said I expect this API surface to progress as other DRM drivers are updated (hopefully DRM community will take on this), but there is nothing wrong with starting by having a basic entry point for a narrow use case. Thanks, Jason