Files
cubelinux-kernel/drivers/gpu/drm/xe/display/xe_stolen.c
T
Greg Kroah-Hartman 598cf27219 Linux 6.19.3
Link: https://lore.kernel.org/r/20260217200002.683975158@linuxfoundation.org
Tested-by: Florian Fainelli <florian.fainelli@broadcom.com>
Tested-by: Takeshi Ogasawara <takeshi.ogasawara@futuring-girl.com>
Tested-by: Peter Schneider <pschneider1968@googlemail.com>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: Salvatore Bonaccorso <carnil@debian.org>
Tested-by: Brett A C Sheffield <bacs@librecast.net>
Tested-by: Mark Brown <broonie@kernel.org>
Tested-by: Luna Jernberg <droidbittin@gmail.com>
Tested-by: Ronald Warsow <rwarsow@gmx.de>
Tested-by: Justin M. Forbes <jforbes@fedoraproject.org>
Tested-by: Ron Economos <re@w6rz.net>
Tested-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-02-19 16:33:27 +01:00

124 lines
2.4 KiB
C

// 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"
struct intel_stolen_node {
struct xe_device *xe;
struct xe_bo *bo;
};
int i915_gem_stolen_insert_node_in_range(struct intel_stolen_node *node, u64 size,
unsigned int align, u64 start, u64 end)
{
struct xe_device *xe = node->xe;
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 intel_stolen_node *node, u64 size, unsigned int align)
{
/* Not used on xe */
WARN_ON(1);
return -ENODEV;
}
void i915_gem_stolen_remove_node(struct intel_stolen_node *node)
{
xe_bo_unpin_map_no_vm(node->bo);
node->bo = NULL;
}
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);
}
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(struct drm_device *drm)
{
WARN_ON(1);
return 0;
}
/* Used for gen9 specific WA. Gen9 is not supported by Xe */
u64 i915_gem_stolen_area_size(struct drm_device *drm)
{
WARN_ON(1);
return 0;
}
u64 i915_gem_stolen_node_address(struct intel_stolen_node *node)
{
struct xe_device *xe = node->xe;
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;
}
struct intel_stolen_node *i915_gem_stolen_node_alloc(struct drm_device *drm)
{
struct xe_device *xe = to_xe_device(drm);
struct intel_stolen_node *node;
node = kzalloc(sizeof(*node), GFP_KERNEL);
if (!node)
return NULL;
node->xe = xe;
return node;
}
void i915_gem_stolen_node_free(const struct intel_stolen_node *node)
{
kfree(node);
}