From: Baoli Zhang <baoli.zhang@linux.intel.com>
To: intel-xe@lists.freedesktop.org, intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
jani.nikula@linux.intel.com, rodrigo.vivi@intel.com,
joonas.lahtinen@linux.intel.com, tursulin@ursulin.net,
matthew.brost@intel.com, thomas.hellstrom@linux.intel.com,
matthew.auld@intel.com, airlied@gmail.com, simona@ffwll.ch,
andriy.shevchenko@linux.intel.com,
Baoli Zhang <baoli.zhang@linux.intel.com>,
Yanx L Liu <yanx.l.liu@intel.com>
Subject: [PATCH 2/3] drm/i915/display: Let the drivers free the KMS objects
Date: Mon, 16 Nov 2026 09:15:03 +0800 [thread overview]
Message-ID: <20261116011504.3910139-3-baoli.zhang@linux.intel.com> (raw)
In-Reply-To: <20261116011504.3910139-1-baoli.zhang@linux.intel.com>
intel_display_driver_remove_noirq() frees all the KMS objects through
drm_mode_config_cleanup(), while userspace may still hold the DRM fd
open with references to them, e.g. framebuffers it created. Such
objects must only be freed with the last reference to the DRM device.
As a first step, move drm_mode_config_cleanup() into the new
intel_display_driver_mode_config_cleanup() and call it from i915 and xe
right after intel_display_driver_remove_noirq(), so each driver can
then move it to the right place.
drm_mode_config_cleanup() now runs after the rest of the noirq teardown
(DP tunnel manager, overlay, GMBUS, workqueues and FBC). After the
previous patch the KMS object destroy callbacks no longer depend on any
of that.
No functional change intended.
Tested-by: Yanx L Liu <yanx.l.liu@intel.com>
Signed-off-by: Baoli Zhang <baoli.zhang@linux.intel.com>
---
drivers/gpu/drm/i915/display/intel_display_driver.c | 12 ++++++++++++
drivers/gpu/drm/i915/display/intel_display_driver.h | 1 +
drivers/gpu/drm/i915/i915_driver.c | 2 ++
drivers/gpu/drm/xe/display/xe_display.c | 2 ++
4 files changed, 17 insertions(+)
diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.c b/drivers/gpu/drm/i915/display/intel_display_driver.c
index d513cfc881069..62a4d95d78b53 100644
--- a/drivers/gpu/drm/i915/display/intel_display_driver.c
+++ b/drivers/gpu/drm/i915/display/intel_display_driver.c
@@ -160,6 +160,18 @@ static void intel_mode_config_cleanup(struct intel_display *display)
{
intel_atomic_global_obj_cleanup(display);
intel_encoder_remove_all(display);
+}
+
+/*
+ * Free the KMS objects, including the encoders torn down by
+ * intel_display_driver_remove_noirq(). Userspace can keep referring to them
+ * until the last reference to the DRM device is gone.
+ */
+void intel_display_driver_mode_config_cleanup(struct intel_display *display)
+{
+ if (!HAS_DISPLAY(display))
+ return;
+
drm_mode_config_cleanup(display->drm);
}
diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.h b/drivers/gpu/drm/i915/display/intel_display_driver.h
index 1ae2ad7e95f6c..88d9028e86e4b 100644
--- a/drivers/gpu/drm/i915/display/intel_display_driver.h
+++ b/drivers/gpu/drm/i915/display/intel_display_driver.h
@@ -23,6 +23,7 @@ void intel_display_driver_register(struct intel_display *display);
void intel_display_driver_remove(struct intel_display *display);
void intel_display_driver_remove_noirq(struct intel_display *display);
void intel_display_driver_remove_nogem(struct intel_display *display);
+void intel_display_driver_mode_config_cleanup(struct intel_display *display);
void intel_display_driver_unregister(struct intel_display *display);
void intel_display_driver_shutdown(struct intel_display *display);
void intel_display_driver_shutdown_late(struct intel_display *display);
diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index aeb7b24c81c8b..d29b37ab2833e 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -906,6 +906,7 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
intel_display_driver_remove(display);
intel_irq_uninstall(i915);
intel_display_driver_remove_noirq(display);
+ intel_display_driver_mode_config_cleanup(display);
goto out_cleanup_modeset;
out_cleanup_irq:
intel_irq_uninstall(i915);
@@ -951,6 +952,7 @@ void i915_driver_remove(struct drm_i915_private *i915)
intel_irq_uninstall(i915);
intel_display_driver_remove_noirq(display);
+ intel_display_driver_mode_config_cleanup(display);
i915_reset_error_state(i915);
i915_gem_driver_remove(i915);
diff --git a/drivers/gpu/drm/xe/display/xe_display.c b/drivers/gpu/drm/xe/display/xe_display.c
index 506f26e9c59a8..d33052a98d942 100644
--- a/drivers/gpu/drm/xe/display/xe_display.c
+++ b/drivers/gpu/drm/xe/display/xe_display.c
@@ -73,6 +73,7 @@ static void xe_display_fini_early(void *arg)
return;
intel_display_driver_remove_noirq(display);
+ intel_display_driver_mode_config_cleanup(display);
intel_display_driver_remove_nogem(display);
intel_display_power_cleanup(display);
}
@@ -110,6 +111,7 @@ int xe_display_init_early(struct xe_device *xe)
return devm_add_action_or_reset(xe->drm.dev, xe_display_fini_early, xe);
err_noirq:
intel_display_driver_remove_noirq(display);
+ intel_display_driver_mode_config_cleanup(display);
intel_display_power_cleanup(display);
return err;
--
2.43.0
next prev parent reply other threads:[~2026-11-16 1:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 1:15 [PATCH 0/3] drm/xe/display: Free the KMS objects on DRM device release, not on unbind Baoli Zhang
2026-11-16 1:15 ` [PATCH 1/3] drm/i915/display: Tear down encoder hardware state in a separate hook Baoli Zhang
2026-11-16 1:15 ` Baoli Zhang [this message]
2026-11-16 1:15 ` [PATCH 3/3] drm/xe/display: Free the KMS objects on DRM device release Baoli Zhang
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=20261116011504.3910139-3-baoli.zhang@linux.intel.com \
--to=baoli.zhang@linux.intel.com \
--cc=airlied@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tursulin@ursulin.net \
--cc=yanx.l.liu@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
all inboxes | Powered by JetHome®