mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Zhang, Baoli" <baoli.zhang@linux.intel.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] drm/i915/display: Let the drivers free the KMS objects
Date: Tue, 17 Nov 2026 09:41:43 +0800	[thread overview]
Message-ID: <5ed01aa4-1986-4db1-91b1-77dcc7f747e7@linux.intel.com> (raw)
In-Reply-To: <171277546a58621d8b771fd7043dad0fa0559da1@intel.com>


On 11/16/2026 4:39 PM, Jani Nikula wrote:
> On Mon, 16 Nov 2026, Baoli Zhang <baoli.zhang@linux.intel.com> wrote:
>> 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>
> Please don't add new display calls to i915 or xe core drivers. The
> direction must be the opposite, there needs to be fewer calls. Move the
> functionality in existing higher level display functions.
>
> I see that patch 3/3 then changes i915 and xe to behave differently
> here. That's also the wrong direction. We need to make the drivers
> behave more similarly. Can't have one driver make some calls, and the
> other not.
>
> The approach here makes future changes harder.
>
> BR,
> Jani.
Sure, thanks Jani.  will have the v2 version based on your comments.
>> ---
>>   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;

  reply	other threads:[~2026-11-17  1:41 UTC|newest]

Thread overview: 6+ 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 ` [PATCH 2/3] drm/i915/display: Let the drivers free the KMS objects Baoli Zhang
2026-11-16  8:39   ` Jani Nikula
2026-11-17  1:41     ` Zhang, Baoli [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=5ed01aa4-1986-4db1-91b1-77dcc7f747e7@linux.intel.com \
    --to=baoli.zhang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    /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®