Commit c6d00c60 authored by Matthew Brost's avatar Matthew Brost
Browse files

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: default avatarMatthew Brost <matthew.brost@intel.com>
Reviewed-by: default avatarMichal Wajdeczko <michal.wajdeczko@intel.com>
Link: https://lore.kernel.org/r/20251008214532.3442967-14-matthew.brost@intel.com
parent cc9b24c6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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;

+11 −25
Original line number Diff line number Diff line
@@ -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);
+0 −2
Original line number Diff line number Diff line
@@ -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. */
+33 −0
Original line number Diff line number Diff line
@@ -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;
}
+2 −0
Original line number Diff line number Diff line
@@ -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
Loading