Commit c1464a89 authored by Jani Nikula's avatar Jani Nikula

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: default avatarJouni Högander <jouni.hogander@intel.com>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230830085127.2416842-1-jani.nikula@intel.com
parent 7ce8ac49
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "intel_display_types.h" #include "intel_display_types.h"
#include "intel_fb.h" #include "intel_fb.h"
#include "intel_fbc.h" #include "intel_fbc.h"
#include "intel_frontbuffer.h"
#include "intel_sprite.h" #include "intel_sprite.h"
/* Primary plane formats for gen <= 3 */ /* Primary plane formats for gen <= 3 */
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "intel_de.h" #include "intel_de.h"
#include "intel_display_types.h" #include "intel_display_types.h"
#include "intel_drrs.h" #include "intel_drrs.h"
#include "intel_frontbuffer.h"
#include "intel_panel.h" #include "intel_panel.h"
/** /**
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "intel_display_types.h" #include "intel_display_types.h"
#include "intel_dpt.h" #include "intel_dpt.h"
#include "intel_fb.h" #include "intel_fb.h"
#include "intel_frontbuffer.h"
#define check_array_bounds(i915, a, i) drm_WARN_ON(&(i915)->drm, (i) >= ARRAY_SIZE(a)) #define check_array_bounds(i915, a, i) drm_WARN_ON(&(i915)->drm, (i) >= ARRAY_SIZE(a))
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
* cancelled as soon as busyness is detected. * cancelled as soon as busyness is detected.
*/ */
#include "gem/i915_gem_object_frontbuffer.h"
#include "i915_drv.h" #include "i915_drv.h"
#include "intel_display_trace.h" #include "intel_display_trace.h"
#include "intel_display_types.h" #include "intel_display_types.h"
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <drm/drm_fourcc.h> #include <drm/drm_fourcc.h>
#include "gem/i915_gem_internal.h" #include "gem/i915_gem_internal.h"
#include "gem/i915_gem_object_frontbuffer.h"
#include "gem/i915_gem_pm.h" #include "gem/i915_gem_pm.h"
#include "gt/intel_gpu_commands.h" #include "gt/intel_gpu_commands.h"
#include "gt/intel_ring.h" #include "gt/intel_ring.h"
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "intel_display.h" #include "intel_display.h"
#include "intel_display_types.h" #include "intel_display_types.h"
#include "intel_fb.h" #include "intel_fb.h"
#include "intel_frontbuffer.h"
#include "intel_plane_initial.h" #include "intel_plane_initial.h"
static bool static bool
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "intel_display_types.h" #include "intel_display_types.h"
#include "intel_dp.h" #include "intel_dp.h"
#include "intel_dp_aux.h" #include "intel_dp_aux.h"
#include "intel_frontbuffer.h"
#include "intel_hdmi.h" #include "intel_hdmi.h"
#include "intel_psr.h" #include "intel_psr.h"
#include "intel_psr_regs.h" #include "intel_psr_regs.h"
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "intel_de.h" #include "intel_de.h"
#include "intel_display_types.h" #include "intel_display_types.h"
#include "intel_fb.h" #include "intel_fb.h"
#include "intel_frontbuffer.h"
#include "intel_sprite.h" #include "intel_sprite.h"
static void i9xx_plane_linear_gamma(u16 gamma[8]) static void i9xx_plane_linear_gamma(u16 gamma[8])
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "intel_display_types.h" #include "intel_display_types.h"
#include "intel_fb.h" #include "intel_fb.h"
#include "intel_fbc.h" #include "intel_fbc.h"
#include "intel_frontbuffer.h"
#include "intel_psr.h" #include "intel_psr.h"
#include "skl_scaler.h" #include "skl_scaler.h"
#include "skl_universal_plane.h" #include "skl_universal_plane.h"
......
...@@ -6,11 +6,10 @@ ...@@ -6,11 +6,10 @@
#include <drm/drm_cache.h> #include <drm/drm_cache.h>
#include "display/intel_frontbuffer.h"
#include "i915_config.h" #include "i915_config.h"
#include "i915_drv.h" #include "i915_drv.h"
#include "i915_gem_clflush.h" #include "i915_gem_clflush.h"
#include "i915_gem_object_frontbuffer.h"
#include "i915_sw_fence_work.h" #include "i915_sw_fence_work.h"
#include "i915_trace.h" #include "i915_trace.h"
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
*/ */
#include "display/intel_display.h" #include "display/intel_display.h"
#include "display/intel_frontbuffer.h"
#include "gt/intel_gt.h" #include "gt/intel_gt.h"
#include "i915_drv.h" #include "i915_drv.h"
...@@ -16,6 +15,7 @@ ...@@ -16,6 +15,7 @@
#include "i915_gem_lmem.h" #include "i915_gem_lmem.h"
#include "i915_gem_mman.h" #include "i915_gem_mman.h"
#include "i915_gem_object.h" #include "i915_gem_object.h"
#include "i915_gem_object_frontbuffer.h"
#include "i915_vma.h" #include "i915_vma.h"
#define VTD_GUARD (168u * I915_GTT_PAGE_SIZE) /* 168 or tile-row PTE padding */ #define VTD_GUARD (168u * I915_GTT_PAGE_SIZE) /* 168 or tile-row PTE padding */
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "i915_gem_dmabuf.h" #include "i915_gem_dmabuf.h"
#include "i915_gem_mman.h" #include "i915_gem_mman.h"
#include "i915_gem_object.h" #include "i915_gem_object.h"
#include "i915_gem_object_frontbuffer.h"
#include "i915_gem_ttm.h" #include "i915_gem_ttm.h"
#include "i915_memcpy.h" #include "i915_memcpy.h"
#include "i915_trace.h" #include "i915_trace.h"
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <drm/drm_file.h> #include <drm/drm_file.h>
#include <drm/drm_device.h> #include <drm/drm_device.h>
#include "display/intel_frontbuffer.h"
#include "intel_memory_region.h" #include "intel_memory_region.h"
#include "i915_gem_object_types.h" #include "i915_gem_object_types.h"
#include "i915_gem_gtt.h" #include "i915_gem_gtt.h"
...@@ -810,27 +809,6 @@ int i915_gem_object_wait_priority(struct drm_i915_gem_object *obj, ...@@ -810,27 +809,6 @@ int i915_gem_object_wait_priority(struct drm_i915_gem_object *obj,
unsigned int flags, unsigned int flags,
const struct i915_sched_attr *attr); const struct i915_sched_attr *attr);
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);
}
int i915_gem_object_read_from_page(struct drm_i915_gem_object *obj, u64 offset, void *dst, int size); int i915_gem_object_read_from_page(struct drm_i915_gem_object *obj, u64 offset, void *dst, int size);
bool i915_gem_object_is_shmem(const struct drm_i915_gem_object *obj); bool i915_gem_object_is_shmem(const struct drm_i915_gem_object *obj);
...@@ -891,71 +869,4 @@ static inline int i915_gem_object_userptr_validate(struct drm_i915_gem_object *o ...@@ -891,71 +869,4 @@ static inline int i915_gem_object_userptr_validate(struct drm_i915_gem_object *o
#endif #endif
/**
* 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 #endif
/* 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
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "gt/intel_gt.h" #include "gt/intel_gt.h"
#include "i915_drv.h" #include "i915_drv.h"
#include "i915_gem_object.h" #include "i915_gem_object.h"
#include "i915_gem_object_frontbuffer.h"
#include "i915_gem_region.h" #include "i915_gem_region.h"
#include "i915_gem_tiling.h" #include "i915_gem_tiling.h"
#include "i915_scatterlist.h" #include "i915_scatterlist.h"
......
...@@ -40,12 +40,12 @@ ...@@ -40,12 +40,12 @@
#include <drm/drm_vma_manager.h> #include <drm/drm_vma_manager.h>
#include "display/intel_display.h" #include "display/intel_display.h"
#include "display/intel_frontbuffer.h"
#include "gem/i915_gem_clflush.h" #include "gem/i915_gem_clflush.h"
#include "gem/i915_gem_context.h" #include "gem/i915_gem_context.h"
#include "gem/i915_gem_ioctls.h" #include "gem/i915_gem_ioctls.h"
#include "gem/i915_gem_mman.h" #include "gem/i915_gem_mman.h"
#include "gem/i915_gem_object_frontbuffer.h"
#include "gem/i915_gem_pm.h" #include "gem/i915_gem_pm.h"
#include "gem/i915_gem_region.h" #include "gem/i915_gem_region.h"
#include "gem/i915_gem_userptr.h" #include "gem/i915_gem_userptr.h"
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "display/intel_display.h" #include "display/intel_display.h"
#include "display/intel_frontbuffer.h" #include "display/intel_frontbuffer.h"
#include "gem/i915_gem_lmem.h" #include "gem/i915_gem_lmem.h"
#include "gem/i915_gem_object_frontbuffer.h"
#include "gem/i915_gem_tiling.h" #include "gem/i915_gem_tiling.h"
#include "gt/intel_engine.h" #include "gt/intel_engine.h"
#include "gt/intel_engine_heartbeat.h" #include "gt/intel_engine_heartbeat.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment