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

drm/xe/pf: Expose VF migration data size over debugfs

The size is normally used to make a decision on when to stop the device
(mainly when it's in a pre_copy state).

Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Link: https://patch.msgid.link/20251112132220.516975-10-michal.winiarski@intel.com
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>

+82
+21
drivers/gpu/drm/xe/xe_gt_sriov_pf_migration.c
··· 397 397 #endif /* CONFIG_DEBUG_FS */ 398 398 399 399 /** 400 + * xe_gt_sriov_pf_migration_size() - Total size of migration data from all components within a GT. 401 + * @gt: the &xe_gt 402 + * @vfid: the VF identifier (can't be 0) 403 + * 404 + * This function is for PF only. 405 + * 406 + * Return: total migration data size in bytes or a negative error code on failure. 407 + */ 408 + ssize_t xe_gt_sriov_pf_migration_size(struct xe_gt *gt, unsigned int vfid) 409 + { 410 + ssize_t total = 0; 411 + 412 + xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt))); 413 + xe_gt_assert(gt, vfid != PFID); 414 + xe_gt_assert(gt, vfid <= xe_sriov_pf_get_totalvfs(gt_to_xe(gt))); 415 + 416 + /* Nothing to query yet - will be updated once per-GT migration data types are added */ 417 + return total; 418 + } 419 + 420 + /** 400 421 * xe_gt_sriov_pf_migration_ring_empty() - Check if a migration ring is empty. 401 422 * @gt: the &xe_gt 402 423 * @vfid: the VF identifier
+2
drivers/gpu/drm/xe/xe_gt_sriov_pf_migration.h
··· 15 15 int xe_gt_sriov_pf_migration_save_guc_state(struct xe_gt *gt, unsigned int vfid); 16 16 int xe_gt_sriov_pf_migration_restore_guc_state(struct xe_gt *gt, unsigned int vfid); 17 17 18 + ssize_t xe_gt_sriov_pf_migration_size(struct xe_gt *gt, unsigned int vfid); 19 + 18 20 bool xe_gt_sriov_pf_migration_ring_empty(struct xe_gt *gt, unsigned int vfid); 19 21 bool xe_gt_sriov_pf_migration_ring_full(struct xe_gt *gt, unsigned int vfid); 20 22 void xe_gt_sriov_pf_migration_ring_free(struct xe_gt *gt, unsigned int vfid);
+28
drivers/gpu/drm/xe/xe_sriov_pf_debugfs.c
··· 284 284 .llseek = default_llseek, 285 285 }; 286 286 287 + static ssize_t size_read(struct file *file, char __user *ubuf, size_t count, loff_t *ppos) 288 + { 289 + struct dentry *dent = file_dentry(file)->d_parent; 290 + struct xe_device *xe = extract_xe(dent); 291 + unsigned int vfid = extract_vfid(dent); 292 + char buf[21]; 293 + ssize_t ret; 294 + int len; 295 + 296 + xe_pm_runtime_get(xe); 297 + ret = xe_sriov_pf_migration_size(xe, vfid); 298 + xe_pm_runtime_put(xe); 299 + if (ret < 0) 300 + return ret; 301 + 302 + len = scnprintf(buf, sizeof(buf), "%zd\n", ret); 303 + 304 + return simple_read_from_buffer(ubuf, count, ppos, buf, len); 305 + } 306 + 307 + static const struct file_operations size_vf_fops = { 308 + .owner = THIS_MODULE, 309 + .open = simple_open, 310 + .read = size_read, 311 + .llseek = default_llseek, 312 + }; 313 + 287 314 static void pf_populate_vf(struct xe_device *xe, struct dentry *vfdent) 288 315 { 289 316 debugfs_create_file("pause", 0200, vfdent, xe, &pause_vf_fops); ··· 320 293 debugfs_create_file("save", 0600, vfdent, xe, &save_vf_fops); 321 294 debugfs_create_file("restore", 0600, vfdent, xe, &restore_vf_fops); 322 295 debugfs_create_file("migration_data", 0600, vfdent, xe, &data_vf_fops); 296 + debugfs_create_file("migration_size", 0400, vfdent, xe, &size_vf_fops); 323 297 } 324 298 325 299 static void pf_populate_with_tiles(struct xe_device *xe, struct dentry *dent, unsigned int vfid)
+30
drivers/gpu/drm/xe/xe_sriov_pf_migration.c
··· 310 310 311 311 return produced; 312 312 } 313 + 314 + /** 315 + * xe_sriov_pf_migration_size() - Total size of migration data from all components within a device 316 + * @xe: the &xe_device 317 + * @vfid: the VF identifier (can't be 0) 318 + * 319 + * This function is for PF only. 320 + * 321 + * Return: total migration data size in bytes or a negative error code on failure. 322 + */ 323 + ssize_t xe_sriov_pf_migration_size(struct xe_device *xe, unsigned int vfid) 324 + { 325 + size_t size = 0; 326 + struct xe_gt *gt; 327 + ssize_t ret; 328 + u8 gt_id; 329 + 330 + xe_assert(xe, IS_SRIOV_PF(xe)); 331 + xe_assert(xe, vfid); 332 + 333 + for_each_gt(gt, xe, gt_id) { 334 + ret = xe_gt_sriov_pf_migration_size(gt, vfid); 335 + if (ret < 0) 336 + return ret; 337 + 338 + size += ret; 339 + } 340 + 341 + return size; 342 + }
+1
drivers/gpu/drm/xe/xe_sriov_pf_migration.h
··· 18 18 struct xe_sriov_packet *data); 19 19 struct xe_sriov_packet * 20 20 xe_sriov_pf_migration_save_consume(struct xe_device *xe, unsigned int vfid); 21 + ssize_t xe_sriov_pf_migration_size(struct xe_device *xe, unsigned int vfid); 21 22 wait_queue_head_t *xe_sriov_pf_migration_waitqueue(struct xe_device *xe, unsigned int vfid); 22 23 23 24 ssize_t xe_sriov_pf_migration_read(struct xe_device *xe, unsigned int vfid,