Add _raw accessors for front->ref to avoid direct access from outside of intel_frontbuffer.c, in preparation for making struct intel_frontbuffer opaque. Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx> --- drivers/gpu/drm/i915/display/intel_frontbuffer.c | 10 ++++++++++ drivers/gpu/drm/i915/display/intel_frontbuffer.h | 3 +++ drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.h | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.c b/drivers/gpu/drm/i915/display/intel_frontbuffer.c index effb13e8a6bb..42defe2b7661 100644 --- a/drivers/gpu/drm/i915/display/intel_frontbuffer.c +++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.c @@ -77,6 +77,16 @@ void intel_frontbuffer_bits_or(struct intel_frontbuffer *front, unsigned int bit atomic_or(bits, &front->bits); } +bool intel_frontbuffer_get_unless_zero_raw(struct intel_frontbuffer *front) +{ + return kref_get_unless_zero(&front->ref); +} + +void intel_frontbuffer_get_raw(struct intel_frontbuffer *front) +{ + kref_get(&front->ref); +} + /** * frontbuffer_flush - flush frontbuffer * @i915: i915 device diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.h b/drivers/gpu/drm/i915/display/intel_frontbuffer.h index 827b0129da71..221f41096416 100644 --- a/drivers/gpu/drm/i915/display/intel_frontbuffer.h +++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.h @@ -79,6 +79,9 @@ void intel_frontbuffer_flip(struct drm_i915_private *i915, void intel_frontbuffer_put(struct intel_frontbuffer *front); +bool intel_frontbuffer_get_unless_zero_raw(struct intel_frontbuffer *front); +void intel_frontbuffer_get_raw(struct intel_frontbuffer *front); + struct intel_frontbuffer * intel_frontbuffer_get(struct drm_i915_gem_object *obj); 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 9fbf14867a2a..22df3c70c8a6 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.h +++ b/drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.h @@ -56,7 +56,7 @@ i915_gem_object_get_frontbuffer(const struct drm_i915_gem_object *obj) if (!front) break; - if (unlikely(!kref_get_unless_zero(&front->ref))) + if (unlikely(!intel_frontbuffer_get_unless_zero_raw(front))) continue; if (likely(front == rcu_access_pointer(obj->frontbuffer))) @@ -92,7 +92,7 @@ i915_gem_object_set_frontbuffer(struct drm_i915_gem_object *obj, drm_gem_object_put(intel_bo_to_drm_bo(obj)); } else if (rcu_access_pointer(obj->frontbuffer)) { cur = rcu_dereference_protected(obj->frontbuffer, true); - kref_get(&cur->ref); + intel_frontbuffer_get_raw(cur); } else { drm_gem_object_get(intel_bo_to_drm_bo(obj)); rcu_assign_pointer(obj->frontbuffer, front); -- 2.39.2