]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/vf: Move LMEM config to tile layer
authorMatthew Brost <matthew.brost@intel.com>
Wed, 8 Oct 2025 21:45:11 +0000 (14:45 -0700)
committerMatthew Brost <matthew.brost@intel.com>
Thu, 9 Oct 2025 10:22:31 +0000 (03:22 -0700)
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
drivers/gpu/drm/xe/xe_device_types.h
drivers/gpu/drm/xe/xe_gt_sriov_vf.c
drivers/gpu/drm/xe/xe_gt_sriov_vf_types.h
drivers/gpu/drm/xe/xe_tile_sriov_vf.c
drivers/gpu/drm/xe/xe_tile_sriov_vf.h
drivers/gpu/drm/xe/xe_tile_sriov_vf_types.h [new file with mode: 0644]
drivers/gpu/drm/xe/xe_vram.c

index 989244418950179e2d3445f6ceb3e0000b67e4a7..54d4034659cb9f8cacb349aa5c4d9f0cdf6ec061 100644 (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;
 
index 737243fd3d40a16ff63ba56ca645eb163f978b2d..ace670a16f53a52b12400441c7508285a53848fb 100644 (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);
index e753646debc4d1f9a5b25d8941543e794bf0bd82..aff76051c9bbd3cbb047c3cc7f25afa0e0bfb648 100644 (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. */
index f221dbed16f091a46e9232e70ac7b28075e2f776..02430a53da9f24615920f35425754681b6bed6df 100644 (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;
+}
index 93eb043171e8398882a01a7ec85e72a659b16acc..86d750a57530294e9f44fcee3bd7b00a4c6244fc 100644 (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
diff --git a/drivers/gpu/drm/xe/xe_tile_sriov_vf_types.h b/drivers/gpu/drm/xe/xe_tile_sriov_vf_types.h
new file mode 100644 (file)
index 0000000..c3790b4
--- /dev/null
@@ -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
index 7adfccf68e4c8a5fed8a3bd6b8ab0952def63131..70bcbb1888678b760ec3c0103ad9be79d2337f14 100644 (file)
 #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;