Skip to content

Commit 20cfef3

Browse files
committed
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>
1 parent 70e2fa9 commit 20cfef3

5 files changed

Lines changed: 82 additions & 0 deletions

File tree

drivers/gpu/drm/xe/xe_gt_sriov_pf_migration.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,27 @@ ssize_t xe_gt_sriov_pf_migration_write_guc_state(struct xe_gt *gt, unsigned int
396396
}
397397
#endif /* CONFIG_DEBUG_FS */
398398

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+
399420
/**
400421
* xe_gt_sriov_pf_migration_ring_empty() - Check if a migration ring is empty.
401422
* @gt: the &xe_gt

drivers/gpu/drm/xe/xe_gt_sriov_pf_migration.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ int xe_gt_sriov_pf_migration_init(struct xe_gt *gt);
1515
int xe_gt_sriov_pf_migration_save_guc_state(struct xe_gt *gt, unsigned int vfid);
1616
int xe_gt_sriov_pf_migration_restore_guc_state(struct xe_gt *gt, unsigned int vfid);
1717

18+
ssize_t xe_gt_sriov_pf_migration_size(struct xe_gt *gt, unsigned int vfid);
19+
1820
bool xe_gt_sriov_pf_migration_ring_empty(struct xe_gt *gt, unsigned int vfid);
1921
bool xe_gt_sriov_pf_migration_ring_full(struct xe_gt *gt, unsigned int vfid);
2022
void xe_gt_sriov_pf_migration_ring_free(struct xe_gt *gt, unsigned int vfid);

drivers/gpu/drm/xe/xe_sriov_pf_debugfs.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,33 @@ static const struct file_operations data_vf_fops = {
284284
.llseek = default_llseek,
285285
};
286286

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+
287314
static void pf_populate_vf(struct xe_device *xe, struct dentry *vfdent)
288315
{
289316
debugfs_create_file("pause", 0200, vfdent, xe, &pause_vf_fops);
@@ -293,6 +320,7 @@ static void pf_populate_vf(struct xe_device *xe, struct dentry *vfdent)
293320
debugfs_create_file("save", 0600, vfdent, xe, &save_vf_fops);
294321
debugfs_create_file("restore", 0600, vfdent, xe, &restore_vf_fops);
295322
debugfs_create_file("migration_data", 0600, vfdent, xe, &data_vf_fops);
323+
debugfs_create_file("migration_size", 0400, vfdent, xe, &size_vf_fops);
296324
}
297325

298326
static void pf_populate_with_tiles(struct xe_device *xe, struct dentry *dent, unsigned int vfid)

drivers/gpu/drm/xe/xe_sriov_pf_migration.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,33 @@ ssize_t xe_sriov_pf_migration_write(struct xe_device *xe, unsigned int vfid,
310310

311311
return produced;
312312
}
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+
}

drivers/gpu/drm/xe/xe_sriov_pf_migration.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ int xe_sriov_pf_migration_restore_produce(struct xe_device *xe, unsigned int vfi
1818
struct xe_sriov_packet *data);
1919
struct xe_sriov_packet *
2020
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);
2122
wait_queue_head_t *xe_sriov_pf_migration_waitqueue(struct xe_device *xe, unsigned int vfid);
2223

2324
ssize_t xe_sriov_pf_migration_read(struct xe_device *xe, unsigned int vfid,

0 commit comments

Comments
 (0)