]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/xe/vf: Use single check when calling VF CCS functions
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Mon, 8 Sep 2025 12:30:21 +0000 (14:30 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 9 Sep 2025 09:27:46 +0000 (11:27 +0200)
All xe_sriov_vf_ccs() functions but init() expect to be called
when initialization was successful and CCS handling is ready.

Update IS_VF_CCS_READY macro and use it as single entry guard.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
Link: https://lore.kernel.org/r/20250908123025.747-5-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_bo.c
drivers/gpu/drm/xe/xe_gt_debugfs.c
drivers/gpu/drm/xe/xe_pm.c
drivers/gpu/drm/xe/xe_sriov_vf_ccs.c
drivers/gpu/drm/xe/xe_sriov_vf_ccs.h
drivers/gpu/drm/xe/xe_sriov_vf_ccs_types.h

index f03f7432c6fa530e1bcc5d3a72c269f907668f25..4efc1c8d15b84e888814d7cd91b4dceecb2f8ca2 100644 (file)
@@ -974,11 +974,11 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict,
         * CCS meta data is migrated from TT -> SMEM. So, let us detach the
         * BBs from BO as it is no longer needed.
         */
-       if (IS_VF_CCS_BB_VALID(xe, bo) && old_mem_type == XE_PL_TT &&
+       if (IS_VF_CCS_READY(xe) && old_mem_type == XE_PL_TT &&
            new_mem->mem_type == XE_PL_SYSTEM)
                xe_sriov_vf_ccs_detach_bo(bo);
 
-       if (IS_SRIOV_VF(xe) &&
+       if (IS_VF_CCS_READY(xe) &&
            ((move_lacks_source && new_mem->mem_type == XE_PL_TT) ||
             (old_mem_type == XE_PL_SYSTEM && new_mem->mem_type == XE_PL_TT)) &&
            handle_system_ccs)
@@ -994,7 +994,7 @@ out:
                if (timeout < 0)
                        ret = timeout;
 
-               if (IS_VF_CCS_BB_VALID(xe, bo))
+               if (IS_VF_CCS_READY(xe))
                        xe_sriov_vf_ccs_detach_bo(bo);
 
                xe_tt_unmap_sg(xe, ttm_bo->ttm);
@@ -1518,7 +1518,7 @@ static void xe_ttm_bo_delete_mem_notify(struct ttm_buffer_object *ttm_bo)
        if (!xe_bo_is_xe_bo(ttm_bo))
                return;
 
-       if (IS_VF_CCS_BB_VALID(ttm_to_xe_device(ttm_bo->bdev), bo))
+       if (IS_VF_CCS_READY(ttm_to_xe_device(ttm_bo->bdev)))
                xe_sriov_vf_ccs_detach_bo(bo);
 
        /*
index 5aa1eded278d1726e2fb3143db9ac840608c9f3f..f6f2c14b642dc5e8928f32318c8b72c943480b55 100644 (file)
@@ -31,6 +31,7 @@
 #include "xe_reg_whitelist.h"
 #include "xe_sa.h"
 #include "xe_sriov.h"
+#include "xe_sriov_vf_ccs.h"
 #include "xe_tuning.h"
 #include "xe_uc_debugfs.h"
 #include "xe_wa.h"
index 6eea4190bbd2ca615f085711e90b3d3b28c44d7d..a303ed5780b4ba9b007d6ba38fc47b62affdd991 100644 (file)
@@ -213,7 +213,7 @@ int xe_pm_resume(struct xe_device *xe)
 
        xe_pxp_pm_resume(xe->pxp);
 
-       if (IS_SRIOV_VF(xe))
+       if (IS_VF_CCS_READY(xe))
                xe_sriov_vf_ccs_register_context(xe);
 
        drm_dbg(&xe->drm, "Device resumed\n");
@@ -598,7 +598,7 @@ int xe_pm_runtime_resume(struct xe_device *xe)
 
        xe_pxp_pm_resume(xe->pxp);
 
-       if (IS_SRIOV_VF(xe))
+       if (IS_VF_CCS_READY(xe))
                xe_sriov_vf_ccs_register_context(xe);
 
 out:
index b01bb3660fb1fbe2e604e6a6ca4310bc64269b8e..30aea958a3373772bf52cc56834e335d2a462cdc 100644 (file)
@@ -220,8 +220,7 @@ int xe_sriov_vf_ccs_register_context(struct xe_device *xe)
        struct xe_tile_vf_ccs *ctx;
        int err;
 
-       if (!IS_VF_CCS_READY(xe))
-               return 0;
+       xe_assert(xe, IS_VF_CCS_READY(xe));
 
        for_each_ccs_rw_ctx(ctx_id) {
                ctx = &tile->sriov.vf.ccs[ctx_id];
@@ -331,8 +330,7 @@ int xe_sriov_vf_ccs_attach_bo(struct xe_bo *bo)
        struct xe_bb *bb;
        int err = 0;
 
-       if (!IS_VF_CCS_READY(xe))
-               return 0;
+       xe_assert(xe, IS_VF_CCS_READY(xe));
 
        tile = xe_device_get_root_tile(xe);
 
@@ -363,7 +361,9 @@ int xe_sriov_vf_ccs_detach_bo(struct xe_bo *bo)
        enum xe_sriov_vf_ccs_rw_ctxs ctx_id;
        struct xe_bb *bb;
 
-       if (!IS_VF_CCS_READY(xe))
+       xe_assert(xe, IS_VF_CCS_READY(xe));
+
+       if (!IS_VF_CCS_BB_VALID(xe, bo))
                return 0;
 
        for_each_ccs_rw_ctx(ctx_id) {
index 1f1baf685fec6b49c1cefe81dd5e2e739b26a2fb..f0e1189b417ae399123439d9722ca81ec71e5c4d 100644 (file)
@@ -6,6 +6,10 @@
 #ifndef _XE_SRIOV_VF_CCS_H_
 #define _XE_SRIOV_VF_CCS_H_
 
+#include "xe_device_types.h"
+#include "xe_sriov.h"
+#include "xe_sriov_vf_ccs_types.h"
+
 struct xe_device;
 struct xe_bo;
 
@@ -14,4 +18,15 @@ int xe_sriov_vf_ccs_attach_bo(struct xe_bo *bo);
 int xe_sriov_vf_ccs_detach_bo(struct xe_bo *bo);
 int xe_sriov_vf_ccs_register_context(struct xe_device *xe);
 
+static inline bool xe_sriov_vf_ccs_ready(struct xe_device *xe)
+{
+       xe_assert(xe, IS_SRIOV_VF(xe));
+       return xe->sriov.vf.ccs.initialized;
+}
+
+#define IS_VF_CCS_READY(xe) ({ \
+       struct xe_device *xe__ = (xe); \
+       IS_SRIOV_VF(xe__) && xe_sriov_vf_ccs_ready(xe__); \
+       })
+
 #endif
index 0df6b4130e7c0a2573daa8483742411934d84fa3..79092e386c4a5bc784d2ab23a73b48e3047d90c4 100644 (file)
@@ -9,12 +9,6 @@
 #define for_each_ccs_rw_ctx(id__) \
        for ((id__) = 0; (id__) < XE_SRIOV_VF_CCS_CTX_COUNT; (id__)++)
 
-#define IS_VF_CCS_READY(xe) ({ \
-               struct xe_device *___xe = (xe); \
-               xe_assert(___xe, IS_SRIOV_VF(___xe)); \
-               ___xe->sriov.vf.ccs.initialized; \
-               })
-
 enum xe_sriov_vf_ccs_rw_ctxs {
        XE_SRIOV_VF_CCS_READ_CTX,
        XE_SRIOV_VF_CCS_WRITE_CTX,