drm/{i915, xe}/stolen: convert stolen interface to struct drm_device

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

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://lore.kernel.org/r/bbfc2aeaeee3156e92d49c73983be05b6feeede2.1758732183.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
This commit is contained in:
Jani Nikula 2025-09-24 19:43:39 +03:00
parent 994c74ea5e
commit d3741f2c86
5 changed files with 25 additions and 21 deletions

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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);