Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Danilo Krummrich <dakr@kernel.org>
To: Rob Clark <robdclark@gmail.com>
Cc: dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org,
	linux-arm-msm@vger.kernel.org,
	Connor Abbott <cwabbott0@gmail.com>,
	Rob Clark <robdclark@chromium.org>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 02/40] drm/gpuvm: Allow VAs to hold soft reference to BOs
Date: Thu, 15 May 2025 17:30:16 +0200	[thread overview]
Message-ID: <aCYIiJpMe1ljGxqz@pollux> (raw)
In-Reply-To: <CAF6AEGsm6JgK6QQe7se6bzv6QLnm-sxsJRmv=r3OWKhf6rfOSA@mail.gmail.com>

On Thu, May 15, 2025 at 07:59:16AM -0700, Rob Clark wrote:

Thanks for the detailed explanation!

> On Thu, May 15, 2025 at 2:00 AM Danilo Krummrich <dakr@kernel.org> wrote:
> >
> > On Wed, May 14, 2025 at 10:53:16AM -0700, Rob Clark wrote:
> > > From: Rob Clark <robdclark@chromium.org>
> > >
> > > Eases migration for drivers where VAs don't hold hard references to
> > > their associated BO, avoiding reference loops.
> > >
> > > In particular, msm uses soft references to optimistically keep around
> > > mappings until the BO is distroyed.  Which obviously won't work if the
> > > VA (the mapping) is holding a reference to the BO.
> >
> > Ick! This is all complicated enough. Allow drivers to bypass the proper
> > reference counting for GEM objects in the context of VM_BO structures seems like
> > an insane footgun.
> >
> > I don't understand why MSM would need weak references here. Why does msm need
> > that, but nouveau, Xe, panthor, PowerVR do not?
> 
> Most of those drivers were designed (and had their UABI designed) with
> gpuvm, or at least sparse, in mind from the get go.  I'm not sure
> about nouveau, but I guess it just got lucky that it's UABI semantics
> fit having the VMA hold a reference to the BO.
> 
> Unfortunately, msm pre-dates sparse.. and in the beginning there was
> only a single global VM, multiple VMs was something retrofitted ~6yrs
> (?) back.  For existing msm, the VMA(s) are implicitly torn down when
> the GEM obj is freed.  This won't work with the VMA(s) holding hard
> references to the BO.

Ok, that makes sense to me, but why can't this be changed? I don't see how the
uAPI would be affected, this is just an implementation detail, no?

> When userspace opts-in to "VM_BIND" mode, which it has to do before
> the VM is created, then we don't set this flag, the VMA holds a hard
> reference to the BO as it does with other drivers.  But consider this
> use-case, which is perfectly valid for old (existing) userspace:
> 
> 1) Userspace creates a BO
> 2) Submits rendering referencing the BO
> 3) Immediately closes the BO handle, without waiting for the submit to complete
> 
> In this case, the submit holds a reference to the BO which holds a
> reference to the VMA. 

Can't you just instead create the VMAs, which hold a reference to the VM_BO,
which holds a reference to the BO, then drop the drop the original BO reference
and finally, when everything is completed, remove all VMAs of the VM_BO?

This should do exactly the same *and* be conformant with GPUVM design.

> Everything is torn down gracefully when the
> submit completes.  But if the VMA held a hard reference to the BO then
> you'd have a reference loop.
> 
> So there really is no other way to use gpuvm _and_ maintain backwards
> compatibility with the semantics of the pre-VM_BIND UAPI without this
> flag.

Again, how is this important for maintaining backwards compatibility with the
uAPI? This all seems like a driver internal implementation detail to me.

So, is there a technical reason, or is it more that it would be more effort on
the driver end to rework things accordingly?

> Fortunately DRM_GPUVM_VA_WEAK_REF is minimally intrusive.  Otherwise I
> probably would have had to fork my own copy of gpuvm.
> 
> BR,
> -R

  reply	other threads:[~2025-05-15 15:30 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-14 17:53 [PATCH v4 00/40] drm/msm: sparse / "VM_BIND" support Rob Clark
2025-05-14 17:53 ` [PATCH v4 01/40] drm/gpuvm: Don't require obj lock in destructor path Rob Clark
2025-05-15  8:54   ` Danilo Krummrich
2025-05-15  9:06     ` Danilo Krummrich
2025-05-15 17:35       ` Rob Clark
2025-05-15 17:55         ` Danilo Krummrich
2025-05-15 21:57           ` Rob Clark
2025-05-16  9:01             ` Danilo Krummrich
2025-05-16 16:20               ` Rob Clark
2025-05-20 21:25                 ` Dave Airlie
2025-05-20 21:52                   ` Rob Clark
2025-05-20 22:31                     ` Dave Airlie
2025-05-20 22:56                       ` Rob Clark
2025-05-23  2:51                       ` Rob Clark
2025-05-23  6:28                         ` Danilo Krummrich
2025-05-14 17:53 ` [PATCH v4 02/40] drm/gpuvm: Allow VAs to hold soft reference to BOs Rob Clark
2025-05-15  9:00   ` Danilo Krummrich
2025-05-15 14:59     ` Rob Clark
2025-05-15 15:30       ` Danilo Krummrich [this message]
2025-05-15 17:34         ` Rob Clark
2025-05-15 17:51           ` Danilo Krummrich
2025-05-15 20:10             ` Rob Clark
2025-05-14 17:53 ` [PATCH v4 03/40] drm/gem: Add ww_acquire_ctx support to drm_gem_lru_scan() Rob Clark
2025-05-14 17:53 ` [PATCH v4 04/40] drm/sched: Add enqueue credit limit Rob Clark
2025-05-14 17:53 ` [PATCH v4 05/40] iommu/io-pgtable-arm: Add quirk to quiet WARN_ON() Rob Clark
2025-05-15 14:33   ` Will Deacon
2025-05-15 14:48     ` Rob Clark
2025-05-20 11:31       ` Will Deacon
2025-05-20 13:06         ` Robin Murphy
2025-05-20 14:06           ` Will Deacon
2025-05-14 17:53 ` [PATCH v4 06/40] drm/msm: Rename msm_file_private -> msm_context Rob Clark
2025-05-14 17:53 ` [PATCH v4 07/40] drm/msm: Improve msm_context comments Rob Clark
2025-05-14 17:53 ` [PATCH v4 08/40] drm/msm: Rename msm_gem_address_space -> msm_gem_vm Rob Clark
2025-05-14 17:53 ` [PATCH v4 09/40] drm/msm: Remove vram carveout support Rob Clark
2025-05-14 17:53 ` [PATCH v4 10/40] drm/msm: Collapse vma allocation and initialization Rob Clark
2025-05-14 17:53 ` [PATCH v4 11/40] drm/msm: Collapse vma close and delete Rob Clark
2025-05-14 17:53 ` [PATCH v4 12/40] drm/msm: Don't close VMAs on purge Rob Clark
2025-05-14 17:53 ` [PATCH v4 13/40] drm/msm: drm_gpuvm conversion Rob Clark
2025-05-14 17:53 ` [PATCH v4 14/40] drm/msm: Convert vm locking Rob Clark
2025-05-14 17:53 ` [PATCH v4 15/40] drm/msm: Use drm_gpuvm types more Rob Clark
2025-05-14 17:53 ` [PATCH v4 16/40] drm/msm: Split out helper to get iommu prot flags Rob Clark
2025-05-14 17:53 ` [PATCH v4 17/40] drm/msm: Add mmu support for non-zero offset Rob Clark
2025-05-14 17:53 ` [PATCH v4 18/40] drm/msm: Add PRR support Rob Clark
2025-05-14 17:53 ` [PATCH v4 19/40] drm/msm: Rename msm_gem_vma_purge() -> _unmap() Rob Clark
2025-05-14 17:53 ` [PATCH v4 20/40] drm/msm: Drop queued submits on lastclose() Rob Clark
2025-05-14 17:53 ` [PATCH v4 21/40] drm/msm: Lazily create context VM Rob Clark
2025-05-14 17:53 ` [PATCH v4 22/40] drm/msm: Add opt-in for VM_BIND Rob Clark
2025-05-14 17:53 ` [PATCH v4 23/40] drm/msm: Mark VM as unusable on GPU hangs Rob Clark
2025-05-14 17:53 ` [PATCH v4 24/40] drm/msm: Add _NO_SHARE flag Rob Clark
2025-05-14 17:53 ` [PATCH v4 25/40] drm/msm: Crashdump prep for sparse mappings Rob Clark
2025-05-14 17:53 ` [PATCH v4 26/40] drm/msm: rd dumping " Rob Clark
2025-05-14 17:53 ` [PATCH v4 27/40] drm/msm: Crashdec support for sparse Rob Clark
2025-05-14 17:53 ` [PATCH v4 28/40] drm/msm: rd dumping " Rob Clark
2025-05-14 17:53 ` [PATCH v4 29/40] drm/msm: Extract out syncobj helpers Rob Clark
2025-05-14 17:53 ` [PATCH v4 30/40] drm/msm: Use DMA_RESV_USAGE_BOOKKEEP/KERNEL Rob Clark
2025-05-14 17:53 ` [PATCH v4 31/40] drm/msm: Add VM_BIND submitqueue Rob Clark
2025-05-14 17:53 ` [PATCH v4 32/40] drm/msm: Support IO_PGTABLE_QUIRK_NO_WARN_ON Rob Clark
2025-05-14 17:53 ` [PATCH v4 33/40] drm/msm: Support pgtable preallocation Rob Clark
2025-05-14 17:53 ` [PATCH v4 34/40] drm/msm: Split out map/unmap ops Rob Clark
2025-05-14 17:53 ` [PATCH v4 35/40] drm/msm: Add VM_BIND ioctl Rob Clark
2025-05-14 17:53 ` [PATCH v4 36/40] drm/msm: Add VM logging for VM_BIND updates Rob Clark
2025-05-14 17:53 ` [PATCH v4 37/40] drm/msm: Add VMA unmap reason Rob Clark
2025-05-14 17:53 ` [PATCH v4 38/40] drm/msm: Add mmu prealloc tracepoint Rob Clark
2025-05-14 17:53 ` [PATCH v4 39/40] drm/msm: use trylock for debugfs Rob Clark
2025-05-14 17:53 ` [PATCH v4 40/40] drm/msm: Bump UAPI version Rob Clark
  -- strict thread matches above, loose matches on Subject: below --
2025-05-14 16:58 [PATCH v4 00/40] drm/msm: sparse / "VM_BIND" support Rob Clark
2025-05-14 16:59 ` [PATCH v4 02/40] drm/gpuvm: Allow VAs to hold soft reference to BOs Rob Clark

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=aCYIiJpMe1ljGxqz@pollux \
    --to=dakr@kernel.org \
    --cc=airlied@gmail.com \
    --cc=cwabbott0@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=robdclark@chromium.org \
    --cc=robdclark@gmail.com \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /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