]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/xe/vf: Setup VRAM based on received config data
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Thu, 30 May 2024 13:35:27 +0000 (15:35 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Thu, 30 May 2024 21:50:31 +0000 (23:50 +0200)
VF drivers will obtain VRAM configuration from the GuC as part of
the VF self config. Use that configuration instead of trying to
read inaccessible registers.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240530133527.1328-6-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_gt_sriov_vf.c
drivers/gpu/drm/xe/xe_gt_sriov_vf.h
drivers/gpu/drm/xe/xe_vram.c

index da7c64f6285bd482fa5a33059ff54e552e2b6b00..41e46a00c01e89e28670f9d0518e10e5637fc29d 100644 (file)
@@ -478,6 +478,23 @@ 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;
+}
+
 static int vf_balloon_ggtt(struct xe_gt *gt)
 {
        struct xe_gt_sriov_vf_selfconfig *config = &gt->sriov.vf.self_config;
index 7a04bcaffe9fce17ad31ab50fa6e0a6f6269483a..0de7f8cbcfa6dfa16e76a8adbf5189be9091cc59 100644 (file)
@@ -20,6 +20,7 @@ int xe_gt_sriov_vf_prepare_ggtt(struct xe_gt *gt);
 
 u32 xe_gt_sriov_vf_gmdid(struct xe_gt *gt);
 u16 xe_gt_sriov_vf_guc_ids(struct xe_gt *gt);
+u64 xe_gt_sriov_vf_lmem(struct xe_gt *gt);
 u32 xe_gt_sriov_vf_read32(struct xe_gt *gt, struct xe_reg reg);
 
 void xe_gt_sriov_vf_print_config(struct xe_gt *gt, struct drm_printer *p);
index 6fa150643242fc7ff8049031cd0946743a18dcf9..5bcd59190353eab08190febcea5aa1f9c250bc5d 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_vram.h"
 
 #define BAR_SIZE_SHIFT 20
@@ -220,6 +222,22 @@ static int tile_vram_size(struct xe_tile *tile, u64 *vram_size,
        int err;
        u32 reg;
 
+       if (IS_SRIOV_VF(xe)) {
+               struct xe_tile *t;
+               int id;
+
+               offset = 0;
+               for_each_tile(t, xe, id)
+                       for_each_if(t->id < tile->id)
+                               offset += xe_gt_sriov_vf_lmem(t->primary_gt);
+
+               *tile_size = xe_gt_sriov_vf_lmem(gt);
+               *vram_size = *tile_size;
+               *tile_offset = offset;
+
+               return 0;
+       }
+
        err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
        if (err)
                return err;