Skip to content

Commit 762a9f2

Browse files
committed
drm/xe/pf: Handle GuC migration data as part of PF control
Connect the helpers to allow save and restore of GuC migration data in stop_copy / resume device state. Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Link: https://patch.msgid.link/20251112132220.516975-17-michal.winiarski@intel.com Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
1 parent 642a30a commit 762a9f2

4 files changed

Lines changed: 94 additions & 18 deletions

File tree

drivers/gpu/drm/xe/xe_gt_sriov_pf_control.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,20 @@ static void pf_enter_vf_save_failed(struct xe_gt *gt, unsigned int vfid)
854854

855855
static int pf_handle_vf_save_data(struct xe_gt *gt, unsigned int vfid)
856856
{
857+
int ret;
858+
859+
if (xe_gt_sriov_pf_migration_save_data_pending(gt, vfid,
860+
XE_SRIOV_PACKET_TYPE_GUC)) {
861+
ret = xe_gt_sriov_pf_migration_guc_save(gt, vfid);
862+
if (ret)
863+
return ret;
864+
865+
xe_gt_sriov_pf_migration_save_data_complete(gt, vfid,
866+
XE_SRIOV_PACKET_TYPE_GUC);
867+
868+
return -EAGAIN;
869+
}
870+
857871
return 0;
858872
}
859873

@@ -892,6 +906,7 @@ static void pf_exit_vf_save_wait_data(struct xe_gt *gt, unsigned int vfid)
892906
static bool pf_enter_vf_save_wip(struct xe_gt *gt, unsigned int vfid)
893907
{
894908
if (pf_enter_vf_state(gt, vfid, XE_GT_SRIOV_STATE_SAVE_WIP)) {
909+
xe_gt_sriov_pf_migration_save_init(gt, vfid);
895910
pf_enter_vf_wip(gt, vfid);
896911
pf_enter_vf_state(gt, vfid, XE_GT_SRIOV_STATE_SAVE_PROCESS_DATA);
897912
pf_queue_vf(gt, vfid);
@@ -1079,12 +1094,21 @@ static void pf_enter_vf_restore_failed(struct xe_gt *gt, unsigned int vfid)
10791094
static int pf_handle_vf_restore_data(struct xe_gt *gt, unsigned int vfid)
10801095
{
10811096
struct xe_sriov_packet *data = xe_gt_sriov_pf_migration_restore_consume(gt, vfid);
1097+
int ret = 0;
10821098

1083-
xe_gt_sriov_notice(gt, "Skipping VF%u unknown data type: %d\n", vfid, data->hdr.type);
1099+
switch (data->hdr.type) {
1100+
case XE_SRIOV_PACKET_TYPE_GUC:
1101+
ret = xe_gt_sriov_pf_migration_guc_restore(gt, vfid, data);
1102+
break;
1103+
default:
1104+
xe_gt_sriov_notice(gt, "Skipping VF%u unknown data type: %d\n",
1105+
vfid, data->hdr.type);
1106+
break;
1107+
}
10841108

10851109
xe_sriov_packet_free(data);
10861110

1087-
return 0;
1111+
return ret;
10881112
}
10891113

10901114
static bool pf_handle_vf_restore(struct xe_gt *gt, unsigned int vfid)

drivers/gpu/drm/xe/xe_gt_sriov_pf_migration.c

Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -177,23 +177,10 @@ static int pf_save_vf_guc_mig_data(struct xe_gt *gt, unsigned int vfid)
177177
return ret;
178178
}
179179

180-
/**
181-
* xe_gt_sriov_pf_migration_guc_size() - Get the size of VF GuC migration data.
182-
* @gt: the &xe_gt
183-
* @vfid: the VF identifier
184-
*
185-
* This function is for PF only.
186-
*
187-
* Return: size in bytes or a negative error code on failure.
188-
*/
189-
ssize_t xe_gt_sriov_pf_migration_guc_size(struct xe_gt *gt, unsigned int vfid)
180+
static ssize_t pf_migration_guc_size(struct xe_gt *gt, unsigned int vfid)
190181
{
191182
ssize_t size;
192183

193-
xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
194-
xe_gt_assert(gt, vfid != PFID);
195-
xe_gt_assert(gt, vfid <= xe_sriov_pf_get_totalvfs(gt_to_xe(gt)));
196-
197184
if (!pf_migration_supported(gt))
198185
return -ENOPKG;
199186

@@ -281,12 +268,19 @@ int xe_gt_sriov_pf_migration_guc_restore(struct xe_gt *gt, unsigned int vfid,
281268
ssize_t xe_gt_sriov_pf_migration_size(struct xe_gt *gt, unsigned int vfid)
282269
{
283270
ssize_t total = 0;
271+
ssize_t size;
284272

285273
xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
286274
xe_gt_assert(gt, vfid != PFID);
287275
xe_gt_assert(gt, vfid <= xe_sriov_pf_get_totalvfs(gt_to_xe(gt)));
288276

289-
/* Nothing to query yet - will be updated once per-GT migration data types are added */
277+
size = pf_migration_guc_size(gt, vfid);
278+
if (size < 0)
279+
return size;
280+
if (size > 0)
281+
size += sizeof(struct xe_sriov_packet_hdr);
282+
total += size;
283+
290284
return total;
291285
}
292286

@@ -333,6 +327,53 @@ void xe_gt_sriov_pf_migration_ring_free(struct xe_gt *gt, unsigned int vfid)
333327
xe_sriov_packet_free(data);
334328
}
335329

330+
static void pf_migration_save_data_todo(struct xe_gt *gt, unsigned int vfid,
331+
enum xe_sriov_packet_type type)
332+
{
333+
set_bit(type, &pf_pick_gt_migration(gt, vfid)->save.data_remaining);
334+
}
335+
336+
/**
337+
* xe_gt_sriov_pf_migration_save_init() - Initialize per-GT migration related data.
338+
* @gt: the &xe_gt
339+
* @vfid: the VF identifier (can't be 0)
340+
*/
341+
void xe_gt_sriov_pf_migration_save_init(struct xe_gt *gt, unsigned int vfid)
342+
{
343+
struct xe_gt_sriov_migration_data *migration = pf_pick_gt_migration(gt, vfid);
344+
345+
migration->save.data_remaining = 0;
346+
347+
xe_gt_assert(gt, pf_migration_guc_size(gt, vfid) > 0);
348+
pf_migration_save_data_todo(gt, vfid, XE_SRIOV_PACKET_TYPE_GUC);
349+
}
350+
351+
/**
352+
* xe_gt_sriov_pf_migration_save_data_pending() - Check if migration data type needs to be saved.
353+
* @gt: the &xe_gt
354+
* @vfid: the VF identifier (can't be 0)
355+
* @type: the &xe_sriov_packet_type of data to be checked
356+
*
357+
* Return: true if the data needs saving, otherwise false.
358+
*/
359+
bool xe_gt_sriov_pf_migration_save_data_pending(struct xe_gt *gt, unsigned int vfid,
360+
enum xe_sriov_packet_type type)
361+
{
362+
return test_bit(type, &pf_pick_gt_migration(gt, vfid)->save.data_remaining);
363+
}
364+
365+
/**
366+
* xe_gt_sriov_pf_migration_save_data_complete() - Complete migration data type save.
367+
* @gt: the &xe_gt
368+
* @vfid: the VF identifier (can't be 0)
369+
* @type: the &xe_sriov_packet_type to be marked as completed.
370+
*/
371+
void xe_gt_sriov_pf_migration_save_data_complete(struct xe_gt *gt, unsigned int vfid,
372+
enum xe_sriov_packet_type type)
373+
{
374+
clear_bit(type, &pf_pick_gt_migration(gt, vfid)->save.data_remaining);
375+
}
376+
336377
/**
337378
* xe_gt_sriov_pf_migration_save_produce() - Add VF save data packet to migration ring.
338379
* @gt: the &xe_gt

drivers/gpu/drm/xe/xe_gt_sriov_pf_migration.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
struct xe_gt;
1212
struct xe_sriov_packet;
13+
enum xe_sriov_packet_type;
1314

1415
/* TODO: get this information by querying GuC in the future */
1516
#define XE_GT_SRIOV_PF_MIGRATION_GUC_DATA_MAX_SIZE SZ_8M
1617

1718
int xe_gt_sriov_pf_migration_init(struct xe_gt *gt);
18-
ssize_t xe_gt_sriov_pf_migration_guc_size(struct xe_gt *gt, unsigned int vfid);
1919
int xe_gt_sriov_pf_migration_guc_save(struct xe_gt *gt, unsigned int vfid);
2020
int xe_gt_sriov_pf_migration_guc_restore(struct xe_gt *gt, unsigned int vfid,
2121
struct xe_sriov_packet *data);
@@ -26,6 +26,12 @@ bool xe_gt_sriov_pf_migration_ring_empty(struct xe_gt *gt, unsigned int vfid);
2626
bool xe_gt_sriov_pf_migration_ring_full(struct xe_gt *gt, unsigned int vfid);
2727
void xe_gt_sriov_pf_migration_ring_free(struct xe_gt *gt, unsigned int vfid);
2828

29+
void xe_gt_sriov_pf_migration_save_init(struct xe_gt *gt, unsigned int vfid);
30+
bool xe_gt_sriov_pf_migration_save_data_pending(struct xe_gt *gt, unsigned int vfid,
31+
enum xe_sriov_packet_type type);
32+
void xe_gt_sriov_pf_migration_save_data_complete(struct xe_gt *gt, unsigned int vfid,
33+
enum xe_sriov_packet_type type);
34+
2935
int xe_gt_sriov_pf_migration_save_produce(struct xe_gt *gt, unsigned int vfid,
3036
struct xe_sriov_packet *data);
3137
struct xe_sriov_packet *

drivers/gpu/drm/xe/xe_gt_sriov_pf_migration_types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
struct xe_gt_sriov_migration_data {
1717
/** @ring: queue containing VF save / restore migration data */
1818
struct ptr_ring ring;
19+
/** @save: structure for currently processed save migration data */
20+
struct {
21+
/** @save.data_remaining: bitmap of migration types that need to be saved */
22+
unsigned long data_remaining;
23+
} save;
1924
};
2025

2126
#endif

0 commit comments

Comments
 (0)