drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.h

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.h

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.h
Extension
.h
Size
2734 bytes
Lines
97
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct i915_frontbuffer {
	struct intel_frontbuffer base;
	struct drm_i915_gem_object *obj;
	struct i915_active write;
	struct rcu_head rcu;
	struct kref ref;
};

void __i915_gem_object_frontbuffer_flush(struct drm_i915_gem_object *obj,
					 enum fb_op_origin origin);
void __i915_gem_object_frontbuffer_invalidate(struct drm_i915_gem_object *obj,
					      enum fb_op_origin origin);

static inline void
i915_gem_object_frontbuffer_flush(struct drm_i915_gem_object *obj,
				  enum fb_op_origin origin)
{
	if (unlikely(rcu_access_pointer(obj->frontbuffer)))
		__i915_gem_object_frontbuffer_flush(obj, origin);
}

static inline void
i915_gem_object_frontbuffer_invalidate(struct drm_i915_gem_object *obj,
				       enum fb_op_origin origin)
{
	if (unlikely(rcu_access_pointer(obj->frontbuffer)))
		__i915_gem_object_frontbuffer_invalidate(obj, origin);
}

struct i915_frontbuffer *i915_gem_object_frontbuffer_get(struct drm_i915_gem_object *obj);
void i915_gem_object_frontbuffer_ref(struct i915_frontbuffer *front);
void i915_gem_object_frontbuffer_put(struct i915_frontbuffer *front);

static inline void i915_gem_object_frontbuffer_track(struct i915_frontbuffer *_old,
						     struct i915_frontbuffer *_new,
						     unsigned int frontbuffer_bits)
{
	struct intel_frontbuffer *old = _old ? &_old->base : NULL;
	struct intel_frontbuffer *new = _new ? &_new->base : NULL;

	intel_frontbuffer_track(old, new, frontbuffer_bits);
}

/**
 * i915_gem_object_frontbuffer_lookup - Look up the object's frontbuffer
 * @obj: The object whose frontbuffer to look up.
 *
 * 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 i915_frontbuffer *
i915_gem_object_frontbuffer_lookup(const struct drm_i915_gem_object *obj)
{
	struct i915_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;

		i915_gem_object_frontbuffer_put(front);
	} while (1);
	rcu_read_unlock();

	return front;
}

extern const struct intel_display_frontbuffer_interface i915_display_frontbuffer_interface;

#endif

Annotation

Implementation Notes