From: Jani Nikula Date: Wed, 24 Sep 2025 16:43:35 +0000 (+0300) Subject: drm/xe/stolen: convert compat static inlines to proper functions X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=33c8d948bc87658e8d9ed1dfd05dfbbb417d3e75;p=thirdparty%2Fkernel%2Flinux.git drm/xe/stolen: convert compat static inlines to proper functions Add display/xe_stolen.c as the implementation for the stolen interface exposed to display. This allows hiding the implementation details that shouldn't be exposed to display. Reviewed-by: Ville Syrjälä Link: https://lore.kernel.org/r/8e807c6aafc6151b18df08dda20053516813e001.1758732183.git.jani.nikula@intel.com Signed-off-by: Jani Nikula --- diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile index d9c6cf0f189ef..ac65722e5d38a 100644 --- a/drivers/gpu/drm/xe/Makefile +++ b/drivers/gpu/drm/xe/Makefile @@ -214,6 +214,7 @@ xe-$(CONFIG_DRM_XE_DISPLAY) += \ display/xe_hdcp_gsc.o \ display/xe_panic.o \ display/xe_plane_initial.o \ + display/xe_stolen.o \ display/xe_tdf.o # SOC code shared with i915 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 be249f51231d0..10f110b9bf77d 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 @@ -6,106 +6,40 @@ #ifndef _I915_GEM_STOLEN_H_ #define _I915_GEM_STOLEN_H_ -#include "xe_ttm_stolen_mgr.h" -#include "xe_res_cursor.h" -#include "xe_validation.h" +#include struct xe_bo; +struct xe_device; struct intel_stolen_node { struct xe_bo *bo; }; -static inline int i915_gem_stolen_insert_node_in_range(struct xe_device *xe, - struct intel_stolen_node *node, - u32 size, u32 align, - u32 start, u32 end) -{ - struct xe_bo *bo; - int err = 0; - u32 flags = XE_BO_FLAG_PINNED | XE_BO_FLAG_STOLEN; - - if (start < SZ_4K) - start = SZ_4K; - - if (align) { - size = ALIGN(size, align); - start = ALIGN(start, align); - } - - bo = xe_bo_create_pin_range_novm(xe, xe_device_get_root_tile(xe), - size, start, end, ttm_bo_type_kernel, flags); - if (IS_ERR(bo)) { - err = PTR_ERR(bo); - bo = NULL; - return err; - } - - node->bo = bo; - - return err; -} - -static inline int i915_gem_stolen_insert_node(struct xe_device *xe, - struct intel_stolen_node *node, - u32 size, u32 align) -{ - /* Not used on xe */ - WARN_ON(1); - - return -ENODEV; -} - -static inline void i915_gem_stolen_remove_node(struct xe_device *xe, - struct intel_stolen_node *node) -{ - xe_bo_unpin_map_no_vm(node->bo); - node->bo = NULL; -} - -static inline bool i915_gem_stolen_initialized(struct xe_device *xe) -{ - return ttm_manager_type(&xe->ttm, XE_PL_STOLEN); -} +int i915_gem_stolen_insert_node_in_range(struct xe_device *xe, + struct intel_stolen_node *node, + u32 size, u32 align, + u32 start, u32 end); -static inline bool i915_gem_stolen_node_allocated(const struct intel_stolen_node *node) -{ - return node->bo; -} +int i915_gem_stolen_insert_node(struct xe_device *xe, + struct intel_stolen_node *node, + u32 size, u32 align); -static inline u32 i915_gem_stolen_node_offset(struct intel_stolen_node *node) -{ - struct xe_res_cursor res; +void i915_gem_stolen_remove_node(struct xe_device *xe, + struct intel_stolen_node *node); - xe_res_first(node->bo->ttm.resource, 0, 4096, &res); - return res.start; -} +bool i915_gem_stolen_initialized(struct xe_device *xe); -/* Used for < gen4. These are not supported by Xe */ -static inline u64 i915_gem_stolen_area_address(const struct xe_device *xe) -{ - WARN_ON(1); +bool i915_gem_stolen_node_allocated(const struct intel_stolen_node *node); - return 0; -} +u32 i915_gem_stolen_node_offset(struct intel_stolen_node *node); -/* Used for gen9 specific WA. Gen9 is not supported by Xe */ -static inline u64 i915_gem_stolen_area_size(const struct xe_device *xe) -{ - WARN_ON(1); +u64 i915_gem_stolen_area_address(const struct xe_device *xe); - return 0; -} +u64 i915_gem_stolen_area_size(const struct xe_device *xe); -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); -} +u64 i915_gem_stolen_node_address(struct xe_device *xe, + struct intel_stolen_node *node); -static inline u64 i915_gem_stolen_node_size(const struct intel_stolen_node *node) -{ - return node->bo->ttm.base.size; -} +u64 i915_gem_stolen_node_size(const struct intel_stolen_node *node); #endif diff --git a/drivers/gpu/drm/xe/display/xe_stolen.c b/drivers/gpu/drm/xe/display/xe_stolen.c new file mode 100644 index 0000000000000..ab156a9f2c26b --- /dev/null +++ b/drivers/gpu/drm/xe/display/xe_stolen.c @@ -0,0 +1,99 @@ +// SPDX-License-Identifier: MIT +/* Copyright © 2025 Intel Corporation */ + +#include "gem/i915_gem_stolen.h" +#include "xe_res_cursor.h" +#include "xe_ttm_stolen_mgr.h" +#include "xe_validation.h" + +int i915_gem_stolen_insert_node_in_range(struct xe_device *xe, + struct intel_stolen_node *node, + u32 size, u32 align, + u32 start, u32 end) +{ + struct xe_bo *bo; + int err = 0; + u32 flags = XE_BO_FLAG_PINNED | XE_BO_FLAG_STOLEN; + + if (start < SZ_4K) + start = SZ_4K; + + if (align) { + size = ALIGN(size, align); + start = ALIGN(start, align); + } + + bo = xe_bo_create_pin_range_novm(xe, xe_device_get_root_tile(xe), + size, start, end, ttm_bo_type_kernel, flags); + if (IS_ERR(bo)) { + err = PTR_ERR(bo); + bo = NULL; + return err; + } + + node->bo = bo; + + return err; +} + +int i915_gem_stolen_insert_node(struct xe_device *xe, + struct intel_stolen_node *node, + u32 size, u32 align) +{ + /* Not used on xe */ + WARN_ON(1); + + return -ENODEV; +} + +void i915_gem_stolen_remove_node(struct xe_device *xe, + struct intel_stolen_node *node) +{ + xe_bo_unpin_map_no_vm(node->bo); + node->bo = NULL; +} + +bool i915_gem_stolen_initialized(struct xe_device *xe) +{ + return ttm_manager_type(&xe->ttm, XE_PL_STOLEN); +} + +bool i915_gem_stolen_node_allocated(const struct intel_stolen_node *node) +{ + return node->bo; +} + +u32 i915_gem_stolen_node_offset(struct intel_stolen_node *node) +{ + struct xe_res_cursor res; + + xe_res_first(node->bo->ttm.resource, 0, 4096, &res); + return res.start; +} + +/* Used for < gen4. These are not supported by Xe */ +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 */ +u64 i915_gem_stolen_area_size(const struct xe_device *xe) +{ + WARN_ON(1); + + return 0; +} + +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); +} + +u64 i915_gem_stolen_node_size(const struct intel_stolen_node *node) +{ + return node->bo->ttm.base.size; +}