From b6500640acbcc93a371be3a253a558db81132e6b Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Wed, 24 Sep 2025 19:43:32 +0300 Subject: [PATCH] drm/xe/stolen: convert compat stolen macros to inline functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Improve type safety. Allows getting rid of a __maybe_unused annotation too. Reviewed-by: Ville Syrjälä Link: https://lore.kernel.org/r/1ec1fa59e0e54da49a1ec4fd1d535288066db502.1758732183.git.jani.nikula@intel.com Signed-off-by: Jani Nikula --- drivers/gpu/drm/i915/display/intel_fbc.c | 2 +- .../compat-i915-headers/gem/i915_gem_stolen.h | 39 +++++++++++++++---- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_fbc.c b/drivers/gpu/drm/i915/display/intel_fbc.c index 6a7357fa89dbc..cc67de6c06cff 100644 --- a/drivers/gpu/drm/i915/display/intel_fbc.c +++ b/drivers/gpu/drm/i915/display/intel_fbc.c @@ -797,7 +797,7 @@ 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 __maybe_unused *i915 = to_i915(display->drm); + struct drm_i915_private *i915 = to_i915(display->drm); u64 end; /* The FBC hardware for BDW/SKL doesn't have access to the stolen 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 b45575b153227..2c77457837e49 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 @@ -62,8 +62,15 @@ static inline void i915_gem_stolen_remove_node(struct xe_device *xe, node->bo = NULL; } -#define i915_gem_stolen_initialized(xe) (!!ttm_manager_type(&(xe)->ttm, XE_PL_STOLEN)) -#define i915_gem_stolen_node_allocated(node) (!!((node)->bo)) +static inline bool i915_gem_stolen_initialized(struct xe_device *xe) +{ + return ttm_manager_type(&xe->ttm, XE_PL_STOLEN); +} + +static inline bool i915_gem_stolen_node_allocated(const struct intel_stolen_node *node) +{ + return node->bo; +} static inline u32 i915_gem_stolen_node_offset(struct intel_stolen_node *node) { @@ -74,12 +81,30 @@ static inline u32 i915_gem_stolen_node_offset(struct intel_stolen_node *node) } /* Used for < gen4. These are not supported by Xe */ -#define i915_gem_stolen_area_address(xe) (!WARN_ON(1)) +static inline u64 i915_gem_stolen_area_address(const struct xe_device *xe) +{ + WARN_ON(1); + + return 0; +} + /* Used for gen9 specific WA. Gen9 is not supported by Xe */ -#define i915_gem_stolen_area_size(xe) (!WARN_ON(1)) +static inline u64 i915_gem_stolen_area_size(const struct xe_device *xe) +{ + WARN_ON(1); + + return 0; +} -#define i915_gem_stolen_node_address(xe, node) (xe_ttm_stolen_gpu_offset(xe) + \ - i915_gem_stolen_node_offset(node)) -#define i915_gem_stolen_node_size(node) ((u64)((node)->bo->ttm.base.size)) +static inline u64 i915_gem_stolen_node_address(struct xe_device *xe, + struct intel_stolen_node *node) +{ + return xe_ttm_stolen_gpu_offset(xe) + i915_gem_stolen_node_offset(node); +} + +static inline u64 i915_gem_stolen_node_size(const struct intel_stolen_node *node) +{ + return node->bo->ttm.base.size; +} #endif -- 2.47.3