mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-23 05:56:14 -04:00
drm/i915: add minimal i915_gem_object_frontbuffer.h
Split out frontbuffer related declarations and static inlines from gem/i915_gem_object.h into new gem/i915_gem_object_frontbuffer.h. The main goal is to reduce header interdependencies. With gem/i915_gem_object.h including display/intel_frontbuffer.h, modification of the latter causes a whopping 300+ objects to be rebuilt, while many of the source files actually needing it aren't explicitly including it at all. After the change, only 21 objects depend on display/intel_frontbuffer.h, directly or indirectly. Cc: Jouni Högander <jouni.hogander@intel.com> Reviewed-by: Jouni Högander <jouni.hogander@intel.com> Signed-off-by: Jani Nikula <jani.nikula@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230830085127.2416842-1-jani.nikula@intel.com
This commit is contained in:
103
drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.h
Normal file
103
drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/* SPDX-License-Identifier: MIT */
|
||||
/*
|
||||
* Copyright © 2023 Intel Corporation
|
||||
*/
|
||||
|
||||
#ifndef __I915_GEM_OBJECT_FRONTBUFFER_H__
|
||||
#define __I915_GEM_OBJECT_FRONTBUFFER_H__
|
||||
|
||||
#include <linux/kref.h>
|
||||
#include <linux/rcupdate.h>
|
||||
|
||||
#include "display/intel_frontbuffer.h"
|
||||
#include "i915_gem_object_types.h"
|
||||
|
||||
void __i915_gem_object_flush_frontbuffer(struct drm_i915_gem_object *obj,
|
||||
enum fb_op_origin origin);
|
||||
void __i915_gem_object_invalidate_frontbuffer(struct drm_i915_gem_object *obj,
|
||||
enum fb_op_origin origin);
|
||||
|
||||
static inline void
|
||||
i915_gem_object_flush_frontbuffer(struct drm_i915_gem_object *obj,
|
||||
enum fb_op_origin origin)
|
||||
{
|
||||
if (unlikely(rcu_access_pointer(obj->frontbuffer)))
|
||||
__i915_gem_object_flush_frontbuffer(obj, origin);
|
||||
}
|
||||
|
||||
static inline void
|
||||
i915_gem_object_invalidate_frontbuffer(struct drm_i915_gem_object *obj,
|
||||
enum fb_op_origin origin)
|
||||
{
|
||||
if (unlikely(rcu_access_pointer(obj->frontbuffer)))
|
||||
__i915_gem_object_invalidate_frontbuffer(obj, origin);
|
||||
}
|
||||
|
||||
/**
|
||||
* i915_gem_object_get_frontbuffer - Get the object's frontbuffer
|
||||
* @obj: The object whose frontbuffer to get.
|
||||
*
|
||||
* Get pointer to object's frontbuffer if such exists. Please note that RCU
|
||||
* mechanism is used to handle e.g. ongoing removal of frontbuffer pointer.
|
||||
*
|
||||
* Return: pointer to object's frontbuffer is such exists or NULL
|
||||
*/
|
||||
static inline struct intel_frontbuffer *
|
||||
i915_gem_object_get_frontbuffer(const struct drm_i915_gem_object *obj)
|
||||
{
|
||||
struct intel_frontbuffer *front;
|
||||
|
||||
if (likely(!rcu_access_pointer(obj->frontbuffer)))
|
||||
return NULL;
|
||||
|
||||
rcu_read_lock();
|
||||
do {
|
||||
front = rcu_dereference(obj->frontbuffer);
|
||||
if (!front)
|
||||
break;
|
||||
|
||||
if (unlikely(!kref_get_unless_zero(&front->ref)))
|
||||
continue;
|
||||
|
||||
if (likely(front == rcu_access_pointer(obj->frontbuffer)))
|
||||
break;
|
||||
|
||||
intel_frontbuffer_put(front);
|
||||
} while (1);
|
||||
rcu_read_unlock();
|
||||
|
||||
return front;
|
||||
}
|
||||
|
||||
/**
|
||||
* i915_gem_object_set_frontbuffer - Set the object's frontbuffer
|
||||
* @obj: The object whose frontbuffer to set.
|
||||
* @front: The frontbuffer to set
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Return: pointer to frontbuffer which was set.
|
||||
*/
|
||||
static inline struct intel_frontbuffer *
|
||||
i915_gem_object_set_frontbuffer(struct drm_i915_gem_object *obj,
|
||||
struct intel_frontbuffer *front)
|
||||
{
|
||||
struct intel_frontbuffer *cur = front;
|
||||
|
||||
if (!front) {
|
||||
RCU_INIT_POINTER(obj->frontbuffer, NULL);
|
||||
} else if (rcu_access_pointer(obj->frontbuffer)) {
|
||||
cur = rcu_dereference_protected(obj->frontbuffer, true);
|
||||
kref_get(&cur->ref);
|
||||
} else {
|
||||
drm_gem_object_get(intel_bo_to_drm_bo(obj));
|
||||
rcu_assign_pointer(obj->frontbuffer, front);
|
||||
}
|
||||
|
||||
return cur;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user