intel-xe.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: "Kasireddy, Vivek" <vivek.kasireddy@intel.com>
Cc: "Leon Romanovsky" <leonro@nvidia.com>,
	"Christian Koenig" <christian.koenig@amd.com>,
	"Sumit Semwal" <sumit.semwal@linaro.org>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Simona Vetter" <simona.vetter@ffwll.ch>,
	"Brost, Matthew" <matthew.brost@intel.com>,
	"Kim, Dongwon" <dongwon.kim@intel.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
	"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"linaro-mm-sig@lists.linaro.org" <linaro-mm-sig@lists.linaro.org>
Subject: Re: [RFC v2 0/8] dma-buf: Add support for mapping dmabufs via interconnects
Date: Thu, 30 Oct 2025 10:43:10 -0300	[thread overview]
Message-ID: <20251030134310.GR1018328@nvidia.com> (raw)
In-Reply-To: <IA0PR11MB7185E85E1CFAA04485768E30F8FBA@IA0PR11MB7185.namprd11.prod.outlook.com>

On Thu, Oct 30, 2025 at 06:17:11AM +0000, Kasireddy, Vivek wrote:
> It mostly looks OK to me but there are a few things that I want to discuss,
> after briefly looking at the patches in your branch:
> - I am wondering what is the benefit of the SGT compatibility stuff especially
> when Christian suggested that he'd like to see SGT usage gone from
> dma-buf

I think to get rid of SGT we do need to put it in a little well
defined box and then create alternatives and remove things using
SGT. This is a long journey, and I think this is the first step.

If SGT is some special case it will be harder to excise.

So the next steps would be to make all the exporters directly declare
a SGT and then remove the SGT related ops from dma_ops itself and
remove the compat sgt in the attach logic. This is not hard, it is all
simple mechanical work.

This way the only compat requirement is to automatically give an
import match list for a SGT only importer which is very little code in
the core.

The point is we make the SGT stuff nonspecial and fully aligned with
the mapping type in small steps. This way neither importer nor
exporter should have any special code to deal with interworking.

To remove SGT we'd want to teach the core code how to create some kind
of conversion mapping type, eg exporter uses SGT importer uses NEW so
the magic conversion mapping type does the adapatation.

In this way we can convert importers and exporters to use NEW in any
order and they still interwork with each other.

> eventually. Also, if matching fails, IMO, indicating that to the
> importer (allow_ic) and having both exporter/importer fallback to
> the current legacy mechanism would be simpler than the SGT
> compatibility stuff.

I don't want to have three paths in importers.

If the importer supports SGT it should declare it in a match and the
core code should always return a SGT match for the importer to use

The importer should not have to code 'oh it is sgt but it somehow a
little different' via an allow_ic type idea.
 
> - Also, I thought PCIe P2P (along with SGT) use-cases are already well handled
> by the existing map_dma_buf() and other interfaces. So, it might be confusing
> if the newer interfaces also provide a mechanism to handle P2P although a
> bit differently. I might be missing something here but shouldn't the existing
> allow_peer2peer and other related stuff be left alone?

P2P is part of SGT, it gets pulled into the SGT stuff as steps toward
isolating SGT properly. Again as we move things to use native SGT
exporters we would remove the exporter related allow_peer2peer items
when they become unused.
 
> - You are also adding custom attach/detach ops for each mapping_type. I think
> it makes sense to reuse existing attach/detach ops if possible and initiate the
> matching process from there, at-least initially.

I started there, but as soon as I went to adding PAL I realized the
attach/detach logic was completely different for each of the mapping
types. So this is looking alot simpler.

If the driver wants to share the same attach/detach ops for some of
its mapping types then it can just set the same function pointer to
all of them and pick up the mapping type from the attach->map_type.

> - Looks like your design doesn't call for a dma_buf_map_interconnect() or other
> similar helpers provided by dma-buf core that the importers can use. Is that
> because the return type would not be known to the core?

I don't want to have a single shared 'map' operation, that is the
whole point of this design. Each mapping type has its own ops, own
types, own function signatures that the client calls directly.

No more type confusion or trying to abuse phys_addr_t, dma_addr_t, or
scatterlist for in appropriate things. If your driver wants something
special, like IOV, then give it proper clear types so it is
understandable.

> - And, just to confirm, with your design if I want to add a new interconnect/
> mapping_type (not just IOV but in general), all that is needed is to provide custom
> attach/detach, match ops and one or more ops to map/unmap the address list
> right? Does this mean that the role of dma-buf core would be limited to just
> match and the exporters are expected to do most of the heavy lifting and
> checking for stuff like dynamic importers, resv lock held, etc?

I expect the core code would continue to provide wrappers and helpers
to call the ops that can do any required common stuff.

However, keep in mind, when the importer moves to use mapping type it
also must be upgraded to use the dynamic importer flow as this API
doesn't support non-dynamic importers using mapping type.

I will add some of these remarks to the commit messages..

Thanks!
Jason

  reply	other threads:[~2025-10-30 13:43 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-27  4:44 [RFC v2 0/8] dma-buf: Add support for mapping dmabufs via interconnects Vivek Kasireddy
2025-10-27  4:44 ` [RFC v2 1/8] dma-buf: Add support for map/unmap APIs for interconnects Vivek Kasireddy
2025-10-27 17:47   ` Jason Gunthorpe
2025-10-28  5:39     ` Kasireddy, Vivek
2025-10-28 12:21       ` Jason Gunthorpe
2025-10-27  4:44 ` [RFC v2 2/8] dma-buf: Add a helper to match interconnects between exporter/importer Vivek Kasireddy
2025-10-27 18:18   ` Jason Gunthorpe
2025-10-28  6:04     ` Kasireddy, Vivek
2025-10-27  4:44 ` [RFC v2 3/8] dma-buf: Create and expose IOV interconnect to all exporters/importers Vivek Kasireddy
2025-10-27  4:44 ` [RFC v2 4/8] vfio/pci/dmabuf: Add support for IOV interconnect Vivek Kasireddy
2025-10-28  2:00   ` Matthew Brost
2025-10-28  5:05     ` Kasireddy, Vivek
2025-10-27  4:44 ` [RFC v2 5/8] drm/xe/dma_buf: " Vivek Kasireddy
2025-10-27  4:44 ` [RFC v2 6/8] drm/xe/pf: Add a helper function to get a VF's backing object in LMEM Vivek Kasireddy
2025-10-27  4:44 ` [RFC v2 7/8] drm/xe/bo: Create new dma_addr array for dmabuf BOs associated with VFs Vivek Kasireddy
2025-10-27  4:44 ` [RFC v2 8/8] drm/xe/pt: Add an additional check for dmabuf BOs while doing bind Vivek Kasireddy
2025-10-29  0:27 ` [RFC v2 0/8] dma-buf: Add support for mapping dmabufs via interconnects Jason Gunthorpe
2025-10-29  9:25   ` Leon Romanovsky
2025-10-29 11:53     ` Jason Gunthorpe
2025-10-30  6:17   ` Kasireddy, Vivek
2025-10-30 13:43     ` Jason Gunthorpe [this message]
2025-10-31  5:15       ` Kasireddy, Vivek
2025-10-31  7:46         ` Christian König
2025-10-31 13:16           ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251030134310.GR1018328@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=christian.koenig@amd.com \
    --cc=dongwon.kim@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=leonro@nvidia.com \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-media@vger.kernel.org \
    --cc=matthew.brost@intel.com \
    --cc=simona.vetter@ffwll.ch \
    --cc=sumit.semwal@linaro.org \
    --cc=thomas.hellstrom@linux.intel.com \
    --cc=vivek.kasireddy@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).