summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMichal Wajdeczko <michal.wajdeczko@intel.com>2024-05-14 21:00:12 +0200
committerMichal Wajdeczko <michal.wajdeczko@intel.com>2024-05-16 18:04:44 +0200
commitc4f5ded082bb9433b180dbfbb8352f92e319149b (patch)
tree85b94fdac896cf86333a563b9e6b59cdc0aa2b2e /drivers
parent629df234bfe73dacb4bb0daa4bc2c14824dba159 (diff)
downloadlwn-c4f5ded082bb9433b180dbfbb8352f92e319149b.tar.gz
lwn-c4f5ded082bb9433b180dbfbb8352f92e319149b.zip
drm/xe/pf: Allow configuration of VF thresholds over debugfs
Initial values of all thresholds used by the GuC to monitor VF's activity is zero (disabled) and we need to explicitly configure them per each VF. Expose additional attributes over debugfs. Definitions of all attributes are generated so we will not need to make any changes if new thresholds would be added to the set. Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240514190015.2172-6-michal.wajdeczko@intel.com
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c72
1 files changed, 72 insertions, 0 deletions
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 5102035faa7e..eb71c2009c34 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c
@@ -197,6 +197,71 @@ DEFINE_SRIOV_GT_CONFIG_DEBUGFS_ATTRIBUTE(dbs, u32, "%llu\n");
DEFINE_SRIOV_GT_CONFIG_DEBUGFS_ATTRIBUTE(exec_quantum, u32, "%llu\n");
DEFINE_SRIOV_GT_CONFIG_DEBUGFS_ATTRIBUTE(preempt_timeout, u32, "%llu\n");
+/*
+ * /sys/kernel/debug/dri/0/
+ * ├── gt0
+ * │   ├── pf
+ * │   │   ├── threshold_cat_error_count
+ * │   │   ├── threshold_doorbell_time_us
+ * │   │   ├── threshold_engine_reset_count
+ * │   │   ├── threshold_guc_time_us
+ * │   │   ├── threshold_irq_time_us
+ * │   │   ├── threshold_page_fault_count
+ * │   ├── vf1
+ * │   │   ├── threshold_cat_error_count
+ * │   │   ├── threshold_doorbell_time_us
+ * │   │   ├── threshold_engine_reset_count
+ * │   │   ├── threshold_guc_time_us
+ * │   │   ├── threshold_irq_time_us
+ * │   │   ├── threshold_page_fault_count
+ */
+
+static int set_threshold(void *data, u64 val, enum xe_guc_klv_threshold_index index)
+{
+ struct xe_gt *gt = extract_gt(data);
+ unsigned int vfid = extract_vfid(data);
+ struct xe_device *xe = gt_to_xe(gt);
+ int err;
+
+ if (val > (u32)~0ull)
+ return -EOVERFLOW;
+
+ xe_pm_runtime_get(xe);
+ err = xe_gt_sriov_pf_config_set_threshold(gt, vfid, index, val);
+ xe_pm_runtime_put(xe);
+
+ return err;
+}
+
+static int get_threshold(void *data, u64 *val, enum xe_guc_klv_threshold_index index)
+{
+ struct xe_gt *gt = extract_gt(data);
+ unsigned int vfid = extract_vfid(data);
+
+ *val = xe_gt_sriov_pf_config_get_threshold(gt, vfid, index);
+ return 0;
+}
+
+#define DEFINE_SRIOV_GT_THRESHOLD_DEBUGFS_ATTRIBUTE(THRESHOLD, INDEX) \
+ \
+static int THRESHOLD##_set(void *data, u64 val) \
+{ \
+ return set_threshold(data, val, INDEX); \
+} \
+ \
+static int THRESHOLD##_get(void *data, u64 *val) \
+{ \
+ return get_threshold(data, val, INDEX); \
+} \
+ \
+DEFINE_DEBUGFS_ATTRIBUTE(THRESHOLD##_fops, THRESHOLD##_get, THRESHOLD##_set, "%llu\n")
+
+/* generate all threshold attributes */
+#define define_threshold_attribute(TAG, NAME, ...) \
+ DEFINE_SRIOV_GT_THRESHOLD_DEBUGFS_ATTRIBUTE(NAME, MAKE_XE_GUC_KLV_THRESHOLD_INDEX(TAG));
+MAKE_XE_GUC_KLV_THRESHOLDS_SET(define_threshold_attribute)
+#undef define_threshold_attribute
+
static void pf_add_config_attrs(struct xe_gt *gt, struct dentry *parent, unsigned int vfid)
{
xe_gt_assert(gt, gt == extract_gt(parent));
@@ -217,6 +282,13 @@ static void pf_add_config_attrs(struct xe_gt *gt, struct dentry *parent, unsigne
&exec_quantum_fops);
debugfs_create_file_unsafe("preempt_timeout_us", 0644, parent, parent,
&preempt_timeout_fops);
+
+ /* register all threshold attributes */
+#define register_threshold_attribute(TAG, NAME, ...) \
+ debugfs_create_file_unsafe("threshold_" #NAME, 0644, parent, parent, \
+ &NAME##_fops);
+ MAKE_XE_GUC_KLV_THRESHOLDS_SET(register_threshold_attribute)
+#undef register_threshold_attribute
}
/*