Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Cc: intel-xe@lists.freedesktop.org,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Matthew Auld" <matthew.auld@intel.com>,
	dri-devel@lists.freedesktop.org,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>
Subject: Re: [PATCH v3 0/3] drm, drm/xe: Protect against premature module unloads
Date: Fri, 25 Sep 2026 18:18:46 +0200	[thread overview]
Message-ID: <DLOJ7S2IZW0R.2BNLLO5M3YL7M@kernel.org> (raw)
In-Reply-To: <20260925133335.149679-1-thomas.hellstrom@linux.intel.com>

On Fri Sep 25, 2026 at 3:33 PM CEST, Thomas Hellström wrote:
> Driver and shared DRM helper code is increasingly relying on bare
> drm_device references (drm_dev_get()/drm_dev_put()) to keep a device's
> software state around, without also pairing that with a reference on
> the owning kernel module. Xe itself does this in several places, and
> so does drm_gpuvm for the lifetime of a GPU VM. None of these
> references currently prevent the owning module from being unloaded
> while they, or the teardown work they can still trigger, are
> outstanding, meaning driver code can end up executing after its own
> module's text has already been freed.

Since you mention DRM GPUVM in a couple of places, how can this ever happen? It
wouldn't make sense to keep a VM alive beyond driver unbind. I.e. it can't make
its drm_device reference count reach module unload in the first place.

Besides that, can you please remind me whether there are any other reasons than
the release() callback why a DRM device must not outlive module unload?

I don't think the correct solution is to constrain module unload. The release()
callback shouldn't really do anything other than free the memory of the
drm_device allocation. All other resources a driver may have should be released
on driver unbind.

There may be shared resources, such as e.g. a common workqueue, but those are
module level things that have nothing to do with the DRM device.

I am aware that a few drivers implement release(), but TBH it looks pretty
broken. qxl_drm_release() is a great example, and it already calls it out
itself.

> This series closes that gap for xe:
>
> - Patch 1 adds core DRM infrastructure allowing a driver to wait for
>   its outstanding device-release callbacks to finish before
>   proceeding with module unload.

Please see above; I also wonder why Xe cares in the first place. Xe doesn't
implement release(), no?

> - Patch 2 makes xe use this infrastructure to hold up module unload
>   until every xe_device instance has actually been released, rather
>   than only until the module's own refcount happens to reach zero,
>   with a diagnostic if this ends up taking an unexpectedly long time.
>
> - Patch 3 fixes a related, previously unprotected case where the
>   teardown of a GPU VM or its address space mappings can be deferred
>   to run at an arbitrary later time, including after module unload has
>   already completed.

Huh? GPUVM tracks the GPU's VA space mappings, but after driver unbind there's
no access to the GPU to manage anything anymore. How can this even work?

Thanks,
Danilo

  parent reply	other threads:[~2026-09-25 16:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25 13:33 [PATCH v3 0/3] drm, drm/xe: Protect against premature module unloads Thomas Hellström
2026-09-25 13:33 ` [PATCH v3 1/3] drm: Provide a drm_dev_release_barrier() function to wait for device release callbacks Thomas Hellström
2026-09-25 13:33 ` [PATCH v3 2/3] drm/xe: Don't unload the driver until all drm devices are freed Thomas Hellström
2026-09-25 13:33 ` [PATCH v3 3/3] drm/xe: Route deferred xe_vma/xe_vm teardown off system_dfl_wq Thomas Hellström
2026-09-25 19:56   ` Matthew Brost
2026-09-25 20:18     ` Matthew Brost
2026-09-28  8:50       ` Thomas Hellström
2026-09-25 13:42 ` ✓ CI.KUnit: success for drm, drm/xe: Protect against premature module unloads (rev3) Patchwork
2026-09-25 14:29 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-25 16:18 ` Danilo Krummrich [this message]
2026-09-28  8:46   ` [PATCH v3 0/3] drm, drm/xe: Protect against premature module unloads Thomas Hellström
2026-09-28 10:13     ` Danilo Krummrich
2026-09-28 12:13       ` Thomas Hellström
2026-09-28 13:03         ` Danilo Krummrich
2026-09-28 13:37           ` Thomas Hellström
2026-10-03 14:08             ` Danilo Krummrich
2026-09-25 22:05 ` ✓ Xe.CI.FULL: success for drm, drm/xe: Protect against premature module unloads (rev3) Patchwork

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=DLOJ7S2IZW0R.2BNLLO5M3YL7M@kernel.org \
    --to=dakr@kernel.org \
    --cc=alexander.deucher@amd.com \
    --cc=aliceryhl@google.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=thomas.hellstrom@linux.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