]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/pf: Prepare for new threshold KLVs
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 16 Dec 2025 21:48:58 +0000 (22:48 +0100)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Wed, 17 Dec 2025 22:42:44 +0000 (23:42 +0100)
We want to extend our macro-based KLV list definitions with new
information about the version from which given KLV is supported.
Prepare our code generators to emit dedicated version check if
a KLV was defined with the version information.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Acked-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20251216214902.1429-4-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c
drivers/gpu/drm/xe/xe_guc_klv_thresholds_set_types.h

index 59c5c6b4d994515993157e04b766394f4c2d04ac..6e8507c24986ffc546c14e2d86e0c171cd3439ce 100644 (file)
@@ -269,7 +269,8 @@ static u32 encode_config_ggtt(u32 *cfg, const struct xe_gt_sriov_config *config,
 }
 
 /* Return: number of configuration dwords written */
-static u32 encode_config(u32 *cfg, const struct xe_gt_sriov_config *config, bool details)
+static u32 encode_config(struct xe_gt *gt, u32 *cfg, const struct xe_gt_sriov_config *config,
+                        bool details)
 {
        u32 n = 0;
 
@@ -303,9 +304,11 @@ static u32 encode_config(u32 *cfg, const struct xe_gt_sriov_config *config, bool
        cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_PREEMPT_TIMEOUT);
        cfg[n++] = config->preempt_timeout;
 
-#define encode_threshold_config(TAG, ...) ({                                   \
-       cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_THRESHOLD_##TAG);                    \
-       cfg[n++] = config->thresholds[MAKE_XE_GUC_KLV_THRESHOLD_INDEX(TAG)];    \
+#define encode_threshold_config(TAG, NAME, VER...) ({                                  \
+       if (IF_ARGS(GUC_FIRMWARE_VER_AT_LEAST(&gt->uc.guc, VER), true, VER)) {          \
+               cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_THRESHOLD_##TAG);                    \
+               cfg[n++] = config->thresholds[MAKE_XE_GUC_KLV_THRESHOLD_INDEX(TAG)];    \
+       }                                                                               \
 });
 
        MAKE_XE_GUC_KLV_THRESHOLDS_SET(encode_threshold_config);
@@ -328,7 +331,7 @@ static int pf_push_full_vf_config(struct xe_gt *gt, unsigned int vfid)
                return -ENOBUFS;
 
        cfg = xe_guc_buf_cpu_ptr(buf);
-       num_dwords = encode_config(cfg, config, true);
+       num_dwords = encode_config(gt, cfg, config, true);
        xe_gt_assert(gt, num_dwords <= max_cfg_dwords);
 
        if (xe_gt_is_media_type(gt)) {
@@ -2518,7 +2521,7 @@ ssize_t xe_gt_sriov_pf_config_save(struct xe_gt *gt, unsigned int vfid, void *bu
                        ret = -ENOBUFS;
                } else {
                        config = pf_pick_vf_config(gt, vfid);
-                       ret = encode_config(buf, config, false) * sizeof(u32);
+                       ret = encode_config(gt, buf, config, false) * sizeof(u32);
                }
        }
        mutex_unlock(xe_gt_sriov_pf_master_mutex(gt));
@@ -2551,11 +2554,13 @@ static int pf_restore_vf_config_klv(struct xe_gt *gt, unsigned int vfid,
                return pf_provision_preempt_timeout(gt, vfid, value[0]);
 
        /* auto-generate case statements */
-#define define_threshold_key_to_provision_case(TAG, ...)                               \
+#define define_threshold_key_to_provision_case(TAG, NAME, VER...)                      \
        case MAKE_GUC_KLV_VF_CFG_THRESHOLD_KEY(TAG):                                    \
                BUILD_BUG_ON(MAKE_GUC_KLV_VF_CFG_THRESHOLD_LEN(TAG) != 1u);             \
                if (len != MAKE_GUC_KLV_VF_CFG_THRESHOLD_LEN(TAG))                      \
                        return -EBADMSG;                                                \
+               if (IF_ARGS(!GUC_FIRMWARE_VER_AT_LEAST(&gt->uc.guc, VER), false, VER))  \
+                       return -EKEYREJECTED;                                           \
                return pf_provision_threshold(gt, vfid,                                 \
                                              MAKE_XE_GUC_KLV_THRESHOLD_INDEX(TAG),     \
                                              value[0]);
index 0fd863609848dcf8612733d012d68336269017dc..ece9eed5d7c5a9062f4463056ab3f1a6af79c28b 100644 (file)
@@ -21,6 +21,7 @@
 #include "xe_gt_sriov_pf_monitor.h"
 #include "xe_gt_sriov_pf_policy.h"
 #include "xe_gt_sriov_pf_service.h"
+#include "xe_guc.h"
 #include "xe_pm.h"
 #include "xe_sriov_pf.h"
 #include "xe_sriov_pf_provision.h"
@@ -301,9 +302,11 @@ static void pf_add_config_attrs(struct xe_gt *gt, struct dentry *parent, unsigne
                                   &sched_priority_fops);
 
        /* register all threshold attributes */
-#define register_threshold_attribute(TAG, NAME, ...) \
-       debugfs_create_file_unsafe("threshold_" #NAME, 0644, parent, parent, \
-                                  &NAME##_fops);
+#define register_threshold_attribute(TAG, NAME, VER...) ({                             \
+       if (IF_ARGS(GUC_FIRMWARE_VER_AT_LEAST(&gt->uc.guc, VER), true, VER))            \
+               debugfs_create_file_unsafe("threshold_" #NAME, 0644, parent, parent,    \
+                                          &NAME##_fops);                               \
+});
        MAKE_XE_GUC_KLV_THRESHOLDS_SET(register_threshold_attribute)
 #undef register_threshold_attribute
 }
index 0a028c94756d9847aea47646c27c6bbb445c6ff4..5f84da3d10d31420c878660c033e173a0117a6ca 100644 (file)
  * ABI and the associated &NAME, that may be used in code or debugfs/sysfs::
  *
  *     define(TAG, NAME)
+ *
+ * If required, KLVs can be labeled with GuC firmware version that added them::
+ *
+ *     define(TAG, NAME, MAJOR, MINOR)
+ *     define(TAG, NAME, MAJOR, MINOR, PATCH)
  */
 #define MAKE_XE_GUC_KLV_THRESHOLDS_SET(define)         \
        define(CAT_ERR, cat_error_count)                \