[PATCH 0/3] drm/xe/display: Free the KMS objects on DRM device release, not on unbind
From: Baoli Zhang
Date: Sun Nov 15 2026 - 20:25:50 EST
Unbinding xe while a display server still has the DRM fd open gives
these warnings, and drm_fb_release() later walks the freed framebuffers
when the fd is closed:
WARNING: drivers/gpu/drm/drm_mode_config.c:571 at drm_mode_config_cleanup+0x2e7/0x300
xe 0000:00:02.0: [drm] drm_WARN_ON(!list_empty(&fb->filp_head))
WARNING: drivers/gpu/drm/drm_framebuffer.c:833 at drm_framebuffer_free+0x87/0xa0
Since 5b6937b65e45 ("drm/xe/display: move display fini stuff to devm")
xe frees the KMS objects on unbind, but they should only be freed with
the last reference to the DRM device. drm_mode_config_init() already
registers drm_mode_config_cleanup() as a drmm action, so xe can simply
stop calling it. The first two patches prepare the shared display code
for that, with no change for i915:
1: move the hardware teardown out of the encoder ->destroy() callbacks
into a new ->remove() hook, which still runs on unbind
2: move drm_mode_config_cleanup() out of
intel_display_driver_remove_noirq() into the drivers
3: the actual fix, xe stops calling it
i915 keeps freeing the KMS objects on unbind for now. It frees the
display structure from its ->release() callback, before the drmm
actions run, so it can't rely on drmm without further changes.
We hit this with the LTP-DDT test TELEMETRY_XS_FUNC_TELEM_DRIVER, which
unbinds xe, on PTL with RHEL 10.3 and a v6.18.60 kernel (the trace above
is from there). It doesn't reproduce on Ubuntu, and only reproduces on
the first run after boot. My guess is that GDM holds the device on RHEL
and doesn't get it back after the first unbind/rebind.
Yanx tested the series backported to v6.18.60, the warnings are gone.
On mainline it is build-tested only.
Baoli Zhang (3):
drm/i915/display: Tear down encoder hardware state in a separate hook
drm/i915/display: Let the drivers free the KMS objects
drm/xe/display: Free the KMS objects on DRM device release
drivers/gpu/drm/i915/display/g4x_dp.c | 8 ++++++--
drivers/gpu/drm/i915/display/intel_ddi.c | 16 +++++++++++-----
.../gpu/drm/i915/display/intel_display_driver.c | 15 ++++++++++++++-
.../gpu/drm/i915/display/intel_display_driver.h | 1 +
.../gpu/drm/i915/display/intel_display_types.h | 7 +++++++
drivers/gpu/drm/i915/display/intel_encoder.c | 9 +++++++++
drivers/gpu/drm/i915/display/intel_encoder.h | 1 +
drivers/gpu/drm/i915/display/intel_sdvo.c | 11 +++++++++--
drivers/gpu/drm/i915/i915_driver.c | 2 ++
drivers/gpu/drm/xe/display/xe_display.c | 4 ++++
10 files changed, 64 insertions(+), 10 deletions(-)
--
2.43.0