Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+72
+72
drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c
··· 197 197 DEFINE_SRIOV_GT_CONFIG_DEBUGFS_ATTRIBUTE(exec_quantum, u32, "%llu\n"); 198 198 DEFINE_SRIOV_GT_CONFIG_DEBUGFS_ATTRIBUTE(preempt_timeout, u32, "%llu\n"); 199 199 200 + /* 201 + * /sys/kernel/debug/dri/0/ 202 + * ├── gt0 203 + * │   ├── pf 204 + * │   │   ├── threshold_cat_error_count 205 + * │   │   ├── threshold_doorbell_time_us 206 + * │   │   ├── threshold_engine_reset_count 207 + * │   │   ├── threshold_guc_time_us 208 + * │   │   ├── threshold_irq_time_us 209 + * │   │   ├── threshold_page_fault_count 210 + * │   ├── vf1 211 + * │   │   ├── threshold_cat_error_count 212 + * │   │   ├── threshold_doorbell_time_us 213 + * │   │   ├── threshold_engine_reset_count 214 + * │   │   ├── threshold_guc_time_us 215 + * │   │   ├── threshold_irq_time_us 216 + * │   │   ├── threshold_page_fault_count 217 + */ 218 + 219 + static int set_threshold(void *data, u64 val, enum xe_guc_klv_threshold_index index) 220 + { 221 + struct xe_gt *gt = extract_gt(data); 222 + unsigned int vfid = extract_vfid(data); 223 + struct xe_device *xe = gt_to_xe(gt); 224 + int err; 225 + 226 + if (val > (u32)~0ull) 227 + return -EOVERFLOW; 228 + 229 + xe_pm_runtime_get(xe); 230 + err = xe_gt_sriov_pf_config_set_threshold(gt, vfid, index, val); 231 + xe_pm_runtime_put(xe); 232 + 233 + return err; 234 + } 235 + 236 + static int get_threshold(void *data, u64 *val, enum xe_guc_klv_threshold_index index) 237 + { 238 + struct xe_gt *gt = extract_gt(data); 239 + unsigned int vfid = extract_vfid(data); 240 + 241 + *val = xe_gt_sriov_pf_config_get_threshold(gt, vfid, index); 242 + return 0; 243 + } 244 + 245 + #define DEFINE_SRIOV_GT_THRESHOLD_DEBUGFS_ATTRIBUTE(THRESHOLD, INDEX) \ 246 + \ 247 + static int THRESHOLD##_set(void *data, u64 val) \ 248 + { \ 249 + return set_threshold(data, val, INDEX); \ 250 + } \ 251 + \ 252 + static int THRESHOLD##_get(void *data, u64 *val) \ 253 + { \ 254 + return get_threshold(data, val, INDEX); \ 255 + } \ 256 + \ 257 + DEFINE_DEBUGFS_ATTRIBUTE(THRESHOLD##_fops, THRESHOLD##_get, THRESHOLD##_set, "%llu\n") 258 + 259 + /* generate all threshold attributes */ 260 + #define define_threshold_attribute(TAG, NAME, ...) \ 261 + DEFINE_SRIOV_GT_THRESHOLD_DEBUGFS_ATTRIBUTE(NAME, MAKE_XE_GUC_KLV_THRESHOLD_INDEX(TAG)); 262 + MAKE_XE_GUC_KLV_THRESHOLDS_SET(define_threshold_attribute) 263 + #undef define_threshold_attribute 264 + 200 265 static void pf_add_config_attrs(struct xe_gt *gt, struct dentry *parent, unsigned int vfid) 201 266 { 202 267 xe_gt_assert(gt, gt == extract_gt(parent)); ··· 282 217 &exec_quantum_fops); 283 218 debugfs_create_file_unsafe("preempt_timeout_us", 0644, parent, parent, 284 219 &preempt_timeout_fops); 220 + 221 + /* register all threshold attributes */ 222 + #define register_threshold_attribute(TAG, NAME, ...) \ 223 + debugfs_create_file_unsafe("threshold_" #NAME, 0644, parent, parent, \ 224 + &NAME##_fops); 225 + MAKE_XE_GUC_KLV_THRESHOLDS_SET(register_threshold_attribute) 226 + #undef register_threshold_attribute 285 227 } 286 228 287 229 /*