From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 50D52D637DE for ; Tue, 16 Dec 2025 21:49:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 502D810E9A8; Tue, 16 Dec 2025 21:49:27 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="idfx5L/M"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 05DDC10E9A0; Tue, 16 Dec 2025 21:49:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1765921764; x=1797457764; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UKQwP+1Q/ExdLJyo/3cDnzPmxMLTsTFyu99fcj0UsaQ=; b=idfx5L/MqeIG6GabJ6+CNNU46mNAcu7BEmSGE4FD4j11tGNY6qdoG+8u NtBsWaqLJJE+06ufqsZ7zdhJ+50xdqQ3oyEM0X6OhTZVFJQxIrdzu2fwu 9fnAdbwJj48PQjZ1gkmsMMeIwLgbd5sdRMna74loOlNu4tEWNCzDSaV9O WfvWbkvec7O/ltwGTMVKWiM9tQb5MsWKmjJ7QjxycVY9AV7I2PGjjaM60 OKXv/SDCnwpikXOmNWIPN30v7pEjQf6kStCeur47gs/06NgtA1pQcoh9/ OjaiRsak59b8Ol74na39Xq2ZwvmYGO4OYwrlb0psyeQyndCDljtkx7Inx g==; X-CSE-ConnectionGUID: D5cU5Q+fS/GzQ4oS+J02Vg== X-CSE-MsgGUID: FxVaCA4sT3CJjnH98DtR/g== X-IronPort-AV: E=McAfee;i="6800,10657,11644"; a="67045823" X-IronPort-AV: E=Sophos;i="6.21,154,1763452800"; d="scan'208";a="67045823" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Dec 2025 13:49:24 -0800 X-CSE-ConnectionGUID: QQxPbyMiQfuPUkyPYM3JXw== X-CSE-MsgGUID: dJ0STyxJTH+MMT7uNXkDiw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,154,1763452800"; d="scan'208";a="198615350" Received: from mrbroom-desk1.ger.corp.intel.com (HELO mwajdecz-hp.clients.intel.com) ([10.246.20.17]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Dec 2025 13:49:22 -0800 From: Michal Wajdeczko To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: Michal Wajdeczko , Daniele Ceraolo Spurio , Matthew Brost Subject: [PATCH v3 3/4] drm/xe/pf: Prepare for new threshold KLVs Date: Tue, 16 Dec 2025 22:48:58 +0100 Message-ID: <20251216214902.1429-4-michal.wajdeczko@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251216214902.1429-1-michal.wajdeczko@intel.com> References: <20251216214902.1429-1-michal.wajdeczko@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" 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 Cc: Daniele Ceraolo Spurio Reviewed-by: Daniele Ceraolo Spurio Acked-by: Matthew Brost --- drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 19 ++++++++++++------- drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c | 9 ++++++--- .../drm/xe/xe_guc_klv_thresholds_set_types.h | 5 +++++ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c index 59c5c6b4d994..6e8507c24986 100644 --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c @@ -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(>->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(>->uc.guc, VER), false, VER)) \ + return -EKEYREJECTED; \ return pf_provision_threshold(gt, vfid, \ MAKE_XE_GUC_KLV_THRESHOLD_INDEX(TAG), \ value[0]); diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c index 0fd863609848..ece9eed5d7c5 100644 --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c @@ -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(>->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 } diff --git a/drivers/gpu/drm/xe/xe_guc_klv_thresholds_set_types.h b/drivers/gpu/drm/xe/xe_guc_klv_thresholds_set_types.h index 0a028c94756d..5f84da3d10d3 100644 --- a/drivers/gpu/drm/xe/xe_guc_klv_thresholds_set_types.h +++ b/drivers/gpu/drm/xe/xe_guc_klv_thresholds_set_types.h @@ -24,6 +24,11 @@ * 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) \ -- 2.47.1