drm/xe/vf: Move LMEM config to tile layer

The LMEM VF provision is tile-layer-specific information. Move the LMEM
configuration to the tile layer accordingly.

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Link: https://lore.kernel.org/r/20251008214532.3442967-14-matthew.brost@intel.com
This commit is contained in:
Matthew Brost 2025-10-08 14:45:11 -07:00
parent cc9b24c6bb
commit c6d00c60c4
7 changed files with 71 additions and 30 deletions

View File

@ -27,6 +27,7 @@
#include "xe_sriov_vf_ccs_types.h"
#include "xe_step_types.h"
#include "xe_survivability_mode_types.h"
#include "xe_tile_sriov_vf_types.h"
#include "xe_validation.h"
#if IS_ENABLED(CONFIG_DRM_XE_DEBUG)
@ -193,6 +194,8 @@ struct xe_tile {
struct {
/** @sriov.vf.ggtt_balloon: GGTT regions excluded from use. */
struct xe_ggtt_node *ggtt_balloon[2];
/** @sriov.vf.self_config: VF configuration data */
struct xe_tile_sriov_vf_selfconfig self_config;
} vf;
} sriov;

View File

@ -471,10 +471,10 @@ static int vf_get_ggtt_info(struct xe_gt *gt)
static int vf_get_lmem_info(struct xe_gt *gt)
{
struct xe_gt_sriov_vf_selfconfig *config = &gt->sriov.vf.self_config;
struct xe_tile *tile = gt_to_tile(gt);
struct xe_guc *guc = &gt->uc.guc;
char size_str[10];
u64 size;
u64 size, lmem_size;
int err;
xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt)));
@ -483,18 +483,19 @@ static int vf_get_lmem_info(struct xe_gt *gt)
if (unlikely(err))
return err;
if (config->lmem_size && config->lmem_size != size) {
lmem_size = xe_tile_sriov_vf_lmem(tile);
if (lmem_size && lmem_size != size) {
xe_gt_sriov_err(gt, "Unexpected LMEM reassignment: %lluM != %lluM\n",
size / SZ_1M, config->lmem_size / SZ_1M);
size / SZ_1M, lmem_size / SZ_1M);
return -EREMCHG;
}
string_get_size(size, 1, STRING_UNITS_2, size_str, sizeof(size_str));
xe_gt_sriov_dbg_verbose(gt, "LMEM %lluM %s\n", size / SZ_1M, size_str);
config->lmem_size = size;
xe_tile_sriov_vf_lmem_store(tile, size);
return config->lmem_size ? 0 : -ENODATA;
return size ? 0 : -ENODATA;
}
static int vf_get_submission_cfg(struct xe_gt *gt)
@ -591,23 +592,6 @@ u16 xe_gt_sriov_vf_guc_ids(struct xe_gt *gt)
return gt->sriov.vf.self_config.num_ctxs;
}
/**
* xe_gt_sriov_vf_lmem - VF LMEM configuration.
* @gt: the &xe_gt
*
* This function is for VF use only.
*
* Return: size of the LMEM assigned to VF.
*/
u64 xe_gt_sriov_vf_lmem(struct xe_gt *gt)
{
xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt)));
xe_gt_assert(gt, gt->sriov.vf.guc_version.major);
xe_gt_assert(gt, gt->sriov.vf.self_config.lmem_size);
return gt->sriov.vf.self_config.lmem_size;
}
/**
* xe_gt_sriov_vf_ggtt - VF GGTT configuration.
* @gt: the &xe_gt
@ -1064,6 +1048,7 @@ void xe_gt_sriov_vf_print_config(struct xe_gt *gt, struct drm_printer *p)
{
struct xe_gt_sriov_vf_selfconfig *config = &gt->sriov.vf.self_config;
struct xe_device *xe = gt_to_xe(gt);
u64 lmem_size;
char buf[10];
xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt)));
@ -1078,8 +1063,9 @@ void xe_gt_sriov_vf_print_config(struct xe_gt *gt, struct drm_printer *p)
drm_printf(p, "GGTT shift on last restore:\t%lld\n", config->ggtt_shift);
if (IS_DGFX(xe) && xe_gt_is_main_type(gt)) {
string_get_size(config->lmem_size, 1, STRING_UNITS_2, buf, sizeof(buf));
drm_printf(p, "LMEM size:\t%llu (%s)\n", config->lmem_size, buf);
lmem_size = xe_tile_sriov_vf_lmem(gt_to_tile(gt));
string_get_size(lmem_size, 1, STRING_UNITS_2, buf, sizeof(buf));
drm_printf(p, "LMEM size:\t%llu (%s)\n", lmem_size, buf);
}
drm_printf(p, "GuC contexts:\t%u\n", config->num_ctxs);

View File

@ -20,8 +20,6 @@ struct xe_gt_sriov_vf_selfconfig {
u64 ggtt_size;
/** @ggtt_shift: difference in ggtt_base on last migration */
s64 ggtt_shift;
/** @lmem_size: assigned size of the LMEM. */
u64 lmem_size;
/** @num_ctxs: assigned number of GuC submission context IDs. */
u16 num_ctxs;
/** @num_dbs: assigned number of GuC doorbells IDs. */

View File

@ -252,3 +252,36 @@ void xe_tile_sriov_vf_fixup_ggtt_nodes(struct xe_tile *tile, s64 shift)
mutex_unlock(&ggtt->lock);
}
/**
* xe_tile_sriov_vf_lmem - VF LMEM configuration.
* @tile: the &xe_tile
*
* This function is for VF use only.
*
* Return: size of the LMEM assigned to VF.
*/
u64 xe_tile_sriov_vf_lmem(struct xe_tile *tile)
{
struct xe_tile_sriov_vf_selfconfig *config = &tile->sriov.vf.self_config;
xe_tile_assert(tile, IS_SRIOV_VF(tile_to_xe(tile)));
return config->lmem_size;
}
/**
* xe_tile_sriov_vf_lmem_store - Store VF LMEM configuration
* @tile: the &xe_tile
* @lmem_size: VF LMEM size to store
*
* This function is for VF use only.
*/
void xe_tile_sriov_vf_lmem_store(struct xe_tile *tile, u64 lmem_size)
{
struct xe_tile_sriov_vf_selfconfig *config = &tile->sriov.vf.self_config;
xe_tile_assert(tile, IS_SRIOV_VF(tile_to_xe(tile)));
config->lmem_size = lmem_size;
}

View File

@ -14,5 +14,7 @@ int xe_tile_sriov_vf_prepare_ggtt(struct xe_tile *tile);
int xe_tile_sriov_vf_balloon_ggtt_locked(struct xe_tile *tile);
void xe_tile_sriov_vf_deballoon_ggtt_locked(struct xe_tile *tile);
void xe_tile_sriov_vf_fixup_ggtt_nodes(struct xe_tile *tile, s64 shift);
u64 xe_tile_sriov_vf_lmem(struct xe_tile *tile);
void xe_tile_sriov_vf_lmem_store(struct xe_tile *tile, u64 lmem_size);
#endif

View File

@ -0,0 +1,19 @@
/* SPDX-License-Identifier: MIT */
/*
* Copyright © 2025 Intel Corporation
*/
#ifndef _XE_TILE_SRIOV_VF_TYPES_H_
#define _XE_TILE_SRIOV_VF_TYPES_H_
#include <linux/types.h>
/**
* struct xe_tile_sriov_vf_selfconfig - VF configuration data.
*/
struct xe_tile_sriov_vf_selfconfig {
/** @lmem_size: assigned size of the LMEM. */
u64 lmem_size;
};
#endif

View File

@ -17,10 +17,10 @@
#include "xe_device.h"
#include "xe_force_wake.h"
#include "xe_gt_mcr.h"
#include "xe_gt_sriov_vf.h"
#include "xe_mmio.h"
#include "xe_module.h"
#include "xe_sriov.h"
#include "xe_tile_sriov_vf.h"
#include "xe_ttm_vram_mgr.h"
#include "xe_vram.h"
#include "xe_vram_types.h"
@ -238,9 +238,9 @@ static int tile_vram_size(struct xe_tile *tile, u64 *vram_size,
offset = 0;
for_each_tile(t, xe, id)
for_each_if(t->id < tile->id)
offset += xe_gt_sriov_vf_lmem(t->primary_gt);
offset += xe_tile_sriov_vf_lmem(t);
*tile_size = xe_gt_sriov_vf_lmem(gt);
*tile_size = xe_tile_sriov_vf_lmem(tile);
*vram_size = *tile_size;
*tile_offset = offset;