Skip to content

Commit 4a43480

Browse files
committed
drm/xe: Move migration support to device-level struct
Upcoming changes will allow users to control VF state and obtain its migration data with a device-level granularity (not tile/gt). Change the data structures to reflect that and move the GT-level migration init to happen after device-level init. Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Link: https://patch.msgid.link/20251112132220.516975-3-michal.winiarski@intel.com Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
1 parent baf1258 commit 4a43480

8 files changed

Lines changed: 88 additions & 13 deletions

drivers/gpu/drm/xe/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ xe-$(CONFIG_PCI_IOV) += \
177177
xe_sriov_pf.o \
178178
xe_sriov_pf_control.o \
179179
xe_sriov_pf_debugfs.o \
180+
xe_sriov_pf_migration.o \
180181
xe_sriov_pf_provision.o \
181182
xe_sriov_pf_service.o \
182183
xe_sriov_pf_sysfs.o \

drivers/gpu/drm/xe/xe_gt_sriov_pf_migration.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "xe_guc.h"
1414
#include "xe_guc_ct.h"
1515
#include "xe_sriov.h"
16+
#include "xe_sriov_pf_migration.h"
1617

1718
/* Return: number of dwords saved/restored/required or a negative error code on failure */
1819
static int guc_action_vf_save_restore(struct xe_guc *guc, u32 vfid, u32 opcode,
@@ -115,8 +116,7 @@ static int pf_send_guc_restore_vf_state(struct xe_gt *gt, unsigned int vfid,
115116

116117
static bool pf_migration_supported(struct xe_gt *gt)
117118
{
118-
xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
119-
return gt->sriov.pf.migration.supported;
119+
return xe_sriov_pf_migration_supported(gt_to_xe(gt));
120120
}
121121

122122
static struct mutex *pf_migration_mutex(struct xe_gt *gt)
@@ -382,12 +382,6 @@ ssize_t xe_gt_sriov_pf_migration_write_guc_state(struct xe_gt *gt, unsigned int
382382
}
383383
#endif /* CONFIG_DEBUG_FS */
384384

385-
static bool pf_check_migration_support(struct xe_gt *gt)
386-
{
387-
/* XXX: for now this is for feature enabling only */
388-
return IS_ENABLED(CONFIG_DRM_XE_DEBUG);
389-
}
390-
391385
/**
392386
* xe_gt_sriov_pf_migration_init() - Initialize support for VF migration.
393387
* @gt: the &xe_gt
@@ -403,8 +397,6 @@ int xe_gt_sriov_pf_migration_init(struct xe_gt *gt)
403397

404398
xe_gt_assert(gt, IS_SRIOV_PF(xe));
405399

406-
gt->sriov.pf.migration.supported = pf_check_migration_support(gt);
407-
408400
if (!pf_migration_supported(gt))
409401
return 0;
410402

drivers/gpu/drm/xe/xe_gt_sriov_pf_migration_types.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ struct xe_gt_sriov_state_snapshot {
3030
* Used by the PF driver to maintain non-VF specific per-GT data.
3131
*/
3232
struct xe_gt_sriov_pf_migration {
33-
/** @supported: indicates whether the feature is supported */
34-
bool supported;
35-
3633
/** @snapshot_lock: protects all VFs snapshots */
3734
struct mutex snapshot_lock;
3835
};

drivers/gpu/drm/xe/xe_sriov_pf.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "xe_sriov.h"
1616
#include "xe_sriov_pf.h"
1717
#include "xe_sriov_pf_helpers.h"
18+
#include "xe_sriov_pf_migration.h"
1819
#include "xe_sriov_pf_service.h"
1920
#include "xe_sriov_pf_sysfs.h"
2021
#include "xe_sriov_printk.h"
@@ -102,6 +103,10 @@ int xe_sriov_pf_init_early(struct xe_device *xe)
102103
if (err)
103104
return err;
104105

106+
err = xe_sriov_pf_migration_init(xe);
107+
if (err)
108+
return err;
109+
105110
xe_guard_init(&xe->sriov.pf.guard_vfs_enabling, "vfs_enabling");
106111

107112
xe_sriov_pf_service_init(xe);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// SPDX-License-Identifier: MIT
2+
/*
3+
* Copyright © 2025 Intel Corporation
4+
*/
5+
6+
#include "xe_sriov.h"
7+
#include "xe_sriov_pf_migration.h"
8+
9+
/**
10+
* xe_sriov_pf_migration_supported() - Check if SR-IOV VF migration is supported by the device
11+
* @xe: the &xe_device
12+
*
13+
* Return: true if migration is supported, false otherwise
14+
*/
15+
bool xe_sriov_pf_migration_supported(struct xe_device *xe)
16+
{
17+
xe_assert(xe, IS_SRIOV_PF(xe));
18+
19+
return xe->sriov.pf.migration.supported;
20+
}
21+
22+
static bool pf_check_migration_support(struct xe_device *xe)
23+
{
24+
/* XXX: for now this is for feature enabling only */
25+
return IS_ENABLED(CONFIG_DRM_XE_DEBUG);
26+
}
27+
28+
/**
29+
* xe_sriov_pf_migration_init() - Initialize support for SR-IOV VF migration.
30+
* @xe: the &xe_device
31+
*
32+
* Return: 0 on success or a negative error code on failure.
33+
*/
34+
int xe_sriov_pf_migration_init(struct xe_device *xe)
35+
{
36+
xe_assert(xe, IS_SRIOV_PF(xe));
37+
38+
xe->sriov.pf.migration.supported = pf_check_migration_support(xe);
39+
40+
return 0;
41+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* SPDX-License-Identifier: MIT */
2+
/*
3+
* Copyright © 2025 Intel Corporation
4+
*/
5+
6+
#ifndef _XE_SRIOV_PF_MIGRATION_H_
7+
#define _XE_SRIOV_PF_MIGRATION_H_
8+
9+
#include <linux/types.h>
10+
11+
struct xe_device;
12+
13+
int xe_sriov_pf_migration_init(struct xe_device *xe);
14+
bool xe_sriov_pf_migration_supported(struct xe_device *xe);
15+
16+
#endif
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* SPDX-License-Identifier: MIT */
2+
/*
3+
* Copyright © 2025 Intel Corporation
4+
*/
5+
6+
#ifndef _XE_SRIOV_PF_MIGRATION_TYPES_H_
7+
#define _XE_SRIOV_PF_MIGRATION_TYPES_H_
8+
9+
#include <linux/types.h>
10+
11+
/**
12+
* struct xe_sriov_pf_migration - Xe device level VF migration data
13+
*/
14+
struct xe_sriov_pf_migration {
15+
/** @supported: indicates whether VF migration feature is supported */
16+
bool supported;
17+
};
18+
19+
#endif

drivers/gpu/drm/xe/xe_sriov_pf_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/types.h>
1111

1212
#include "xe_guard.h"
13+
#include "xe_sriov_pf_migration_types.h"
1314
#include "xe_sriov_pf_provision_types.h"
1415
#include "xe_sriov_pf_service_types.h"
1516

@@ -48,6 +49,9 @@ struct xe_device_pf {
4849
/** @provision: device level provisioning data. */
4950
struct xe_sriov_pf_provision provision;
5051

52+
/** @migration: device level migration data. */
53+
struct xe_sriov_pf_migration migration;
54+
5155
/** @service: device level service data. */
5256
struct xe_sriov_pf_service service;
5357

0 commit comments

Comments
 (0)