]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/xe/pf: Assert LMEM provisioning is done only on DGFX
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Fri, 7 Jun 2024 15:31:55 +0000 (17:31 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Mon, 10 Jun 2024 10:14:23 +0000 (12:14 +0200)
The Local Memory (aka VRAM) is only available on DGFX platforms.
We shouldn't attempt to provision VFs with LMEM or attempt to
update the LMTT on non-DGFX platforms. Add missing asserts that
would enforce that and fix release code that could crash on iGFX
due to uninitialized LMTT.

Fixes: c063cce7df3a ("drm/xe/pf: Update the LMTT when freeing VF GT config")
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Piotr Piórkowski <piotr.piorkowski@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240607153155.1592-1-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c

index f49fc2917f9349eeaa56764fb59840c0fa15d15f..694671497f6e5bab6fd6ddf2f02db15f27f0719a 100644 (file)
@@ -1290,6 +1290,9 @@ static void pf_reset_vf_lmtt(struct xe_device *xe, unsigned int vfid)
        struct xe_tile *tile;
        unsigned int tid;
 
+       xe_assert(xe, IS_DGFX(xe));
+       xe_assert(xe, IS_SRIOV_PF(xe));
+
        for_each_tile(tile, xe, tid) {
                lmtt = &tile->sriov.pf.lmtt;
                xe_lmtt_drop_pages(lmtt, vfid);
@@ -1308,6 +1311,9 @@ static int pf_update_vf_lmtt(struct xe_device *xe, unsigned int vfid)
        unsigned int tid;
        int err;
 
+       xe_assert(xe, IS_DGFX(xe));
+       xe_assert(xe, IS_SRIOV_PF(xe));
+
        total = 0;
        for_each_tile(tile, xe, tid)
                total += pf_get_vf_config_lmem(tile->primary_gt, vfid);
@@ -1353,6 +1359,7 @@ fail:
 
 static void pf_release_vf_config_lmem(struct xe_gt *gt, struct xe_gt_sriov_config *config)
 {
+       xe_gt_assert(gt, IS_DGFX(gt_to_xe(gt)));
        xe_gt_assert(gt, !xe_gt_is_media_type(gt));
        lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt));
 
@@ -1371,6 +1378,7 @@ static int pf_provision_vf_lmem(struct xe_gt *gt, unsigned int vfid, u64 size)
        int err;
 
        xe_gt_assert(gt, vfid);
+       xe_gt_assert(gt, IS_DGFX(xe));
        xe_gt_assert(gt, !xe_gt_is_media_type(gt));
 
        size = round_up(size, pf_get_lmem_alignment(gt));
@@ -1838,11 +1846,14 @@ u32 xe_gt_sriov_pf_config_get_threshold(struct xe_gt *gt, unsigned int vfid,
 static void pf_release_vf_config(struct xe_gt *gt, unsigned int vfid)
 {
        struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
+       struct xe_device *xe = gt_to_xe(gt);
 
        if (!xe_gt_is_media_type(gt)) {
                pf_release_vf_config_ggtt(gt, config);
-               pf_release_vf_config_lmem(gt, config);
-               pf_update_vf_lmtt(gt_to_xe(gt), vfid);
+               if (IS_DGFX(xe)) {
+                       pf_release_vf_config_lmem(gt, config);
+                       pf_update_vf_lmtt(xe, vfid);
+               }
        }
        pf_release_config_ctxs(gt, config);
        pf_release_config_dbs(gt, config);