mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-23 11:27:51 -04:00
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ä <ville.syrjala@linux.intel.com> Link: https://lore.kernel.org/r/8e807c6aafc6151b18df08dda20053516813e001.1758732183.git.jani.nikula@intel.com Signed-off-by: Jani Nikula <jani.nikula@intel.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 <linux/types.h>
|
||||
|
||||
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;
|
||||
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);
|
||||
|
||||
if (start < SZ_4K)
|
||||
start = SZ_4K;
|
||||
int i915_gem_stolen_insert_node(struct xe_device *xe,
|
||||
struct intel_stolen_node *node,
|
||||
u32 size, u32 align);
|
||||
|
||||
if (align) {
|
||||
size = ALIGN(size, align);
|
||||
start = ALIGN(start, align);
|
||||
}
|
||||
void i915_gem_stolen_remove_node(struct xe_device *xe,
|
||||
struct intel_stolen_node *node);
|
||||
|
||||
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;
|
||||
}
|
||||
bool i915_gem_stolen_initialized(struct xe_device *xe);
|
||||
|
||||
node->bo = bo;
|
||||
bool i915_gem_stolen_node_allocated(const struct intel_stolen_node *node);
|
||||
|
||||
return err;
|
||||
}
|
||||
u32 i915_gem_stolen_node_offset(struct intel_stolen_node *node);
|
||||
|
||||
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);
|
||||
u64 i915_gem_stolen_area_address(const struct xe_device *xe);
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
u64 i915_gem_stolen_area_size(const struct xe_device *xe);
|
||||
|
||||
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;
|
||||
}
|
||||
u64 i915_gem_stolen_node_address(struct xe_device *xe,
|
||||
struct intel_stolen_node *node);
|
||||
|
||||
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)
|
||||
{
|
||||
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 */
|
||||
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 */
|
||||
static inline u64 i915_gem_stolen_area_size(const struct xe_device *xe)
|
||||
{
|
||||
WARN_ON(1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
u64 i915_gem_stolen_node_size(const struct intel_stolen_node *node);
|
||||
|
||||
#endif
|
||||
|
||||
99
drivers/gpu/drm/xe/display/xe_stolen.c
Normal file
99
drivers/gpu/drm/xe/display/xe_stolen.c
Normal file
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user