Make the stolen interface agnostic to i915/xe, and pass struct
drm_device instead.

Signed-off-by: Jani Nikula <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_fbc.c            | 13 +++++--------
 drivers/gpu/drm/i915/gem/i915_gem_stolen.c          | 12 +++++++++---
 drivers/gpu/drm/i915/gem/i915_gem_stolen.h          |  6 +++---
 .../xe/compat-i915-headers/gem/i915_gem_stolen.h    |  7 +++----
 drivers/gpu/drm/xe/display/xe_stolen.c              |  8 +++++---
 5 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_fbc.c 
b/drivers/gpu/drm/i915/display/intel_fbc.c
index 0d837527aaab..4edb4342833e 100644
--- a/drivers/gpu/drm/i915/display/intel_fbc.c
+++ b/drivers/gpu/drm/i915/display/intel_fbc.c
@@ -377,14 +377,13 @@ static void i8xx_fbc_nuke(struct intel_fbc *fbc)
 static void i8xx_fbc_program_cfb(struct intel_fbc *fbc)
 {
        struct intel_display *display = fbc->display;
-       struct drm_i915_private *i915 = to_i915(display->drm);
 
        drm_WARN_ON(display->drm,
-                   range_end_overflows_t(u64, 
i915_gem_stolen_area_address(i915),
+                   range_end_overflows_t(u64, 
i915_gem_stolen_area_address(display->drm),
                                          
i915_gem_stolen_node_offset(fbc->compressed_fb),
                                          U32_MAX));
        drm_WARN_ON(display->drm,
-                   range_end_overflows_t(u64, 
i915_gem_stolen_area_address(i915),
+                   range_end_overflows_t(u64, 
i915_gem_stolen_area_address(display->drm),
                                          
i915_gem_stolen_node_offset(fbc->compressed_llb),
                                          U32_MAX));
        intel_de_write(display, FBC_CFB_BASE,
@@ -798,7 +797,6 @@ static u64 intel_fbc_cfb_base_max(struct intel_display 
*display)
 
 static u64 intel_fbc_stolen_end(struct intel_display *display)
 {
-       struct drm_i915_private *i915 = to_i915(display->drm);
        u64 end;
 
        /* The FBC hardware for BDW/SKL doesn't have access to the stolen
@@ -807,7 +805,7 @@ static u64 intel_fbc_stolen_end(struct intel_display 
*display)
         * underruns, even if that range is not reserved by the BIOS. */
        if (display->platform.broadwell ||
            (DISPLAY_VER(display) == 9 && !display->platform.broxton))
-               end = i915_gem_stolen_area_size(i915) - 8 * 1024 * 1024;
+               end = i915_gem_stolen_area_size(display->drm) - 8 * 1024 * 1024;
        else
                end = U64_MAX;
 
@@ -861,7 +859,6 @@ static int intel_fbc_alloc_cfb(struct intel_fbc *fbc,
                               unsigned int size, int min_limit)
 {
        struct intel_display *display = fbc->display;
-       struct drm_i915_private *i915 = to_i915(display->drm);
        int ret;
 
        drm_WARN_ON(display->drm,
@@ -893,7 +890,7 @@ static int intel_fbc_alloc_cfb(struct intel_fbc *fbc,
        if (i915_gem_stolen_node_allocated(fbc->compressed_llb))
                i915_gem_stolen_remove_node(fbc->compressed_llb);
 err:
-       if (i915_gem_stolen_initialized(i915))
+       if (i915_gem_stolen_initialized(display->drm))
                drm_info_once(display->drm,
                              "not enough stolen space for compressed buffer 
(need %d more bytes), disabling. Hint: you may be able to increase stolen 
memory size in the BIOS to avoid this.\n", size);
        return -ENOSPC;
@@ -1435,7 +1432,7 @@ static int intel_fbc_check_plane(struct 
intel_atomic_state *state,
        if (!fbc)
                return 0;
 
-       if (!i915_gem_stolen_initialized(i915)) {
+       if (!i915_gem_stolen_initialized(display->drm)) {
                plane_state->no_fbc_reason = "stolen memory not initialised";
                return 0;
        }
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c 
b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
index b2812ec79d19..e73b369c3347 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
@@ -1024,18 +1024,24 @@ bool i915_gem_object_is_stolen(const struct 
drm_i915_gem_object *obj)
        return obj->ops == &i915_gem_object_stolen_ops;
 }
 
-bool i915_gem_stolen_initialized(const struct drm_i915_private *i915)
+bool i915_gem_stolen_initialized(struct drm_device *drm)
 {
+       struct drm_i915_private *i915 = to_i915(drm);
+
        return drm_mm_initialized(&i915->mm.stolen);
 }
 
-u64 i915_gem_stolen_area_address(const struct drm_i915_private *i915)
+u64 i915_gem_stolen_area_address(struct drm_device *drm)
 {
+       struct drm_i915_private *i915 = to_i915(drm);
+
        return i915->dsm.stolen.start;
 }
 
-u64 i915_gem_stolen_area_size(const struct drm_i915_private *i915)
+u64 i915_gem_stolen_area_size(struct drm_device *drm)
 {
+       struct drm_i915_private *i915 = to_i915(drm);
+
        return resource_size(&i915->dsm.stolen);
 }
 
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_stolen.h 
b/drivers/gpu/drm/i915/gem/i915_gem_stolen.h
index c670736f09e1..7b0386002ed4 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_stolen.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_stolen.h
@@ -34,9 +34,9 @@ bool i915_gem_object_is_stolen(const struct 
drm_i915_gem_object *obj);
 
 #define I915_GEM_STOLEN_BIAS SZ_128K
 
-bool i915_gem_stolen_initialized(const struct drm_i915_private *i915);
-u64 i915_gem_stolen_area_address(const struct drm_i915_private *i915);
-u64 i915_gem_stolen_area_size(const struct drm_i915_private *i915);
+bool i915_gem_stolen_initialized(struct drm_device *drm);
+u64 i915_gem_stolen_area_address(struct drm_device *drm);
+u64 i915_gem_stolen_area_size(struct drm_device *drm);
 
 u64 i915_gem_stolen_node_address(const struct intel_stolen_node *node);
 
diff --git a/drivers/gpu/drm/xe/compat-i915-headers/gem/i915_gem_stolen.h 
b/drivers/gpu/drm/xe/compat-i915-headers/gem/i915_gem_stolen.h
index 7bdf73fad8bf..42927326e567 100644
--- a/drivers/gpu/drm/xe/compat-i915-headers/gem/i915_gem_stolen.h
+++ b/drivers/gpu/drm/xe/compat-i915-headers/gem/i915_gem_stolen.h
@@ -10,7 +10,6 @@
 
 struct drm_device;
 struct intel_stolen_node;
-struct xe_device;
 
 int i915_gem_stolen_insert_node_in_range(struct intel_stolen_node *node,
                                         u32 size, u32 align,
@@ -20,15 +19,15 @@ int i915_gem_stolen_insert_node(struct intel_stolen_node 
*node, u32 size, u32 al
 
 void i915_gem_stolen_remove_node(struct intel_stolen_node *node);
 
-bool i915_gem_stolen_initialized(struct xe_device *xe);
+bool i915_gem_stolen_initialized(struct drm_device *drm);
 
 bool i915_gem_stolen_node_allocated(const struct intel_stolen_node *node);
 
 u32 i915_gem_stolen_node_offset(struct intel_stolen_node *node);
 
-u64 i915_gem_stolen_area_address(const struct xe_device *xe);
+u64 i915_gem_stolen_area_address(struct drm_device *drm);
 
-u64 i915_gem_stolen_area_size(const struct xe_device *xe);
+u64 i915_gem_stolen_area_size(struct drm_device *drm);
 
 u64 i915_gem_stolen_node_address(struct intel_stolen_node *node);
 
diff --git a/drivers/gpu/drm/xe/display/xe_stolen.c 
b/drivers/gpu/drm/xe/display/xe_stolen.c
index c1afe70454d1..d7af731d9c90 100644
--- a/drivers/gpu/drm/xe/display/xe_stolen.c
+++ b/drivers/gpu/drm/xe/display/xe_stolen.c
@@ -56,8 +56,10 @@ void i915_gem_stolen_remove_node(struct intel_stolen_node 
*node)
        node->bo = NULL;
 }
 
-bool i915_gem_stolen_initialized(struct xe_device *xe)
+bool i915_gem_stolen_initialized(struct drm_device *drm)
 {
+       struct xe_device *xe = to_xe_device(drm);
+
        return ttm_manager_type(&xe->ttm, XE_PL_STOLEN);
 }
 
@@ -75,7 +77,7 @@ u32 i915_gem_stolen_node_offset(struct intel_stolen_node 
*node)
 }
 
 /* Used for < gen4. These are not supported by Xe */
-u64 i915_gem_stolen_area_address(const struct xe_device *xe)
+u64 i915_gem_stolen_area_address(struct drm_device *drm)
 {
        WARN_ON(1);
 
@@ -83,7 +85,7 @@ u64 i915_gem_stolen_area_address(const struct xe_device *xe)
 }
 
 /* Used for gen9 specific WA. Gen9 is not supported by Xe */
-u64 i915_gem_stolen_area_size(const struct xe_device *xe)
+u64 i915_gem_stolen_area_size(struct drm_device *drm)
 {
        WARN_ON(1);
 
-- 
2.47.3

Reply via email to