From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: intel-xe@lists.freedesktop.org
Subject: [PATCH 06/10] drm/i915/frontbuffef: Split fb_tracking.lock into two
Date: Mon, 6 Oct 2025 19:46:44 +0300 [thread overview]
Message-ID: <20251006164648.6761-7-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20251006164648.6761-1-ville.syrjala@linux.intel.com>
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
Our fb_tracking.lock is serving a double duty:
- protects fb_tracking.busy_bits
- provides the write-side protection for obj->frontbuffer
Split obj->frontbuffer role into a separate lock so that
we can clean up the current mess with the frontbuffer lifetime
management.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
drivers/gpu/drm/i915/display/intel_display_core.h | 4 ++++
drivers/gpu/drm/i915/display/intel_display_driver.c | 1 +
drivers/gpu/drm/i915/display/intel_frontbuffer.c | 10 +++++-----
drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.h | 2 +-
4 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h b/drivers/gpu/drm/i915/display/intel_display_core.h
index fa43636b89fa..13576d07c999 100644
--- a/drivers/gpu/drm/i915/display/intel_display_core.h
+++ b/drivers/gpu/drm/i915/display/intel_display_core.h
@@ -141,6 +141,10 @@ struct intel_dpll_global {
};
struct intel_frontbuffer_tracking {
+ /* protects obj->frontbuffer (write-side) */
+ spinlock_t frontbuffer_lock;
+
+ /* protects busy_bits */
spinlock_t lock;
/*
diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.c b/drivers/gpu/drm/i915/display/intel_display_driver.c
index f84a0b26b7a6..ac684f8c5d40 100644
--- a/drivers/gpu/drm/i915/display/intel_display_driver.c
+++ b/drivers/gpu/drm/i915/display/intel_display_driver.c
@@ -184,6 +184,7 @@ void intel_display_driver_early_probe(struct intel_display *display)
if (!HAS_DISPLAY(display))
return;
+ spin_lock_init(&display->fb_tracking.frontbuffer_lock);
spin_lock_init(&display->fb_tracking.lock);
mutex_init(&display->backlight.lock);
mutex_init(&display->audio.mutex);
diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.c b/drivers/gpu/drm/i915/display/intel_frontbuffer.c
index 99c9e5bac78d..11c74aa99ab9 100644
--- a/drivers/gpu/drm/i915/display/intel_frontbuffer.c
+++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.c
@@ -210,7 +210,7 @@ static void frontbuffer_retire(struct i915_active *ref)
}
static void frontbuffer_release(struct kref *ref)
- __releases(&to_intel_display(front->obj->dev)->fb_tracking.lock)
+ __releases(&to_intel_display(front->obj->dev)->fb_tracking.frontbuffer_lock)
{
struct intel_frontbuffer *ret, *front =
container_of(ref, typeof(*front), ref);
@@ -223,7 +223,7 @@ static void frontbuffer_release(struct kref *ref)
ret = intel_bo_set_frontbuffer(obj, NULL);
drm_WARN_ON(display->drm, ret);
- spin_unlock(&display->fb_tracking.lock);
+ spin_unlock(&display->fb_tracking.frontbuffer_lock);
i915_active_fini(&front->write);
kfree_rcu(front, rcu);
@@ -252,9 +252,9 @@ intel_frontbuffer_get(struct drm_gem_object *obj)
I915_ACTIVE_RETIRE_SLEEPS);
INIT_WORK(&front->flush_work, intel_frontbuffer_flush_work);
- spin_lock(&display->fb_tracking.lock);
+ spin_lock(&display->fb_tracking.frontbuffer_lock);
cur = intel_bo_set_frontbuffer(obj, front);
- spin_unlock(&display->fb_tracking.lock);
+ spin_unlock(&display->fb_tracking.frontbuffer_lock);
if (cur != front)
kfree(front);
return cur;
@@ -264,7 +264,7 @@ void intel_frontbuffer_put(struct intel_frontbuffer *front)
{
kref_put_lock(&front->ref,
frontbuffer_release,
- &to_intel_display(front->obj->dev)->fb_tracking.lock);
+ &to_intel_display(front->obj->dev)->fb_tracking.frontbuffer_lock);
}
/**
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.h b/drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.h
index b6dc3d1b9bb1..84f82c2289a8 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.h
@@ -77,7 +77,7 @@ i915_gem_object_get_frontbuffer(const struct drm_i915_gem_object *obj)
* Set object's frontbuffer pointer. If frontbuffer is already set for the
* object keep it and return it's pointer to the caller. Please note that RCU
* mechanism is used to handle e.g. ongoing removal of frontbuffer pointer. This
- * function is protected by i915->display->fb_tracking.lock
+ * function is protected by i915->display->fb_tracking.frontbuffer_lock
*
* Return: pointer to frontbuffer which was set.
*/
--
2.49.1
next prev parent reply other threads:[~2025-10-06 16:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-06 16:46 [PATCH 00/10] drm/i915/frontbuffer: Fix the intel_frontbuffer lifetime mess Ville Syrjala
2025-10-06 16:46 ` [PATCH 01/10] drm/i915/overlay: Drop the DIRTYFB flush Ville Syrjala
2025-10-06 16:46 ` [PATCH 02/10] drm/i915/overlay: Switchj to intel_frontbuffer_flip() Ville Syrjala
2025-10-06 16:46 ` [PATCH 03/10] drm/i915/frontbuffer: Nuke intel_frontbuffer_flip_{prepare, complete}() Ville Syrjala
2025-10-06 16:46 ` [PATCH 04/10] drm/i915/frontbuffer: Turn intel_bo_flush_if_display() into a frontbuffer operation Ville Syrjala
2025-10-06 16:46 ` [PATCH 05/10] drm/i915/frontbuffer: Handle the dirtyfb cache flush inside intel_frontbuffer_flush() Ville Syrjala
2025-10-06 16:46 ` Ville Syrjala [this message]
2025-10-06 16:46 ` [PATCH 07/10] drm/i915/frontbuffer: Extract intel_frontbuffer_ref() Ville Syrjala
2025-10-06 16:46 ` [PATCH 08/10] drm/i915/frontbuffer: Add intel_frontbuffer::display Ville Syrjala
2025-10-06 16:46 ` [PATCH 09/10] drm/i915/frontbuffer: Fix intel_frontbuffer lifetime handling Ville Syrjala
2025-10-06 16:46 ` [PATCH 10/10] drm/i915/gem: s/i915_gem_object_get_frontbuffer/i915_gem_object_frontbuffer_lookup/ Ville Syrjala
2025-10-06 17:27 ` [PATCH 00/10] drm/i915/frontbuffer: Fix the intel_frontbuffer lifetime mess Jani Nikula
2025-10-06 19:39 ` ✓ i915.CI.BAT: success for " Patchwork
2025-10-07 15:24 ` ✓ i915.CI.Full: " 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=20251006164648.6761-7-ville.syrjala@linux.intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.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