]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
drm/pagemap, drm/xe: Manage drm_pagemap provider lifetimes
authorThomas Hellström <thomas.hellstrom@linux.intel.com>
Fri, 19 Dec 2025 11:33:02 +0000 (12:33 +0100)
committerThomas Hellström <thomas.hellstrom@linux.intel.com>
Tue, 23 Dec 2025 08:36:55 +0000 (09:36 +0100)
commita26084328ac40c12096ef01482a7520346379453
tree788470775e49aa6ddfffb6792a0151f23875adf8
parent565477dbca6eca0cfa3f6fefede3f6eb1e6e09b3
drm/pagemap, drm/xe: Manage drm_pagemap provider lifetimes

If a device holds a reference on a foregin device's drm_pagemap,
and a device unbind is executed on the foreign device,
Typically that foreign device would evict its device-private
pages and then continue its device-managed cleanup eventually
releasing its drm device and possibly allow for module unload.
However, since we're still holding a reference on a drm_pagemap,
when that reference is released and the provider module is
unloaded we'd execute out of undefined memory.

Therefore keep a reference on the provider device and module until
the last drm_pagemap reference is gone.

Note that in theory, the drm_gpusvm_helper module may be unloaded
as soon as the final module_put() of the provider driver module is
executed, so we need to add a module_exit() function that waits
for the work item executing the module_put() has completed.

v2:
- Better commit message (Matt Brost)

Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Acked-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> # For merging through drm-xe.
Link: https://patch.msgid.link/20251219113320.183860-7-thomas.hellstrom@linux.intel.com
drivers/gpu/drm/drm_pagemap.c
drivers/gpu/drm/xe/xe_svm.c
include/drm/drm_pagemap.h