Skip to content

Commit be77ce6

Browse files
mwajdeczgregkh
authored andcommitted
drm/xe/pf: Move VFs reprovisioning to worker
[ Upstream commit a4d1c5d ] Since the GuC is reset during GT reset, we need to re-send the entire SR-IOV provisioning configuration to the GuC. But since this whole configuration is protected by the PF master mutex and we can't avoid making allocations under this mutex (like during LMEM provisioning), we can't do this reprovisioning from gt-reset path if we want to be reclaim-safe. Move VFs reprovisioning to a async worker that we will start from the gt-reset path. Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com> Cc: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Michał Winiarski <michal.winiarski@intel.com> Reviewed-by: Stuart Summers <stuart.summers@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250125215505.720-1-michal.wajdeczko@intel.com Stable-dep-of: 81dccec ("drm/xe/pf: Prepare to stop SR-IOV support prior GT reset") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent abe59c5 commit be77ce6

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

drivers/gpu/drm/xe/xe_gt_sriov_pf.c

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
#include "xe_gt_sriov_pf_control.h"
1515
#include "xe_gt_sriov_pf_helpers.h"
1616
#include "xe_gt_sriov_pf_service.h"
17+
#include "xe_gt_sriov_printk.h"
1718
#include "xe_mmio.h"
19+
#include "xe_pm.h"
20+
21+
static void pf_worker_restart_func(struct work_struct *w);
1822

1923
/*
2024
* VF's metadata is maintained in the flexible array where:
@@ -40,6 +44,11 @@ static int pf_alloc_metadata(struct xe_gt *gt)
4044
return 0;
4145
}
4246

47+
static void pf_init_workers(struct xe_gt *gt)
48+
{
49+
INIT_WORK(&gt->sriov.pf.workers.restart, pf_worker_restart_func);
50+
}
51+
4352
/**
4453
* xe_gt_sriov_pf_init_early - Prepare SR-IOV PF data structures on PF.
4554
* @gt: the &xe_gt to initialize
@@ -64,6 +73,8 @@ int xe_gt_sriov_pf_init_early(struct xe_gt *gt)
6473
if (err)
6574
return err;
6675

76+
pf_init_workers(gt);
77+
6778
return 0;
6879
}
6980

@@ -141,6 +152,35 @@ void xe_gt_sriov_pf_sanitize_hw(struct xe_gt *gt, unsigned int vfid)
141152
pf_clear_vf_scratch_regs(gt, vfid);
142153
}
143154

155+
static void pf_restart(struct xe_gt *gt)
156+
{
157+
struct xe_device *xe = gt_to_xe(gt);
158+
159+
xe_pm_runtime_get(xe);
160+
xe_gt_sriov_pf_config_restart(gt);
161+
xe_gt_sriov_pf_control_restart(gt);
162+
xe_pm_runtime_put(xe);
163+
164+
xe_gt_sriov_dbg(gt, "restart completed\n");
165+
}
166+
167+
static void pf_worker_restart_func(struct work_struct *w)
168+
{
169+
struct xe_gt *gt = container_of(w, typeof(*gt), sriov.pf.workers.restart);
170+
171+
pf_restart(gt);
172+
}
173+
174+
static void pf_queue_restart(struct xe_gt *gt)
175+
{
176+
struct xe_device *xe = gt_to_xe(gt);
177+
178+
xe_gt_assert(gt, IS_SRIOV_PF(xe));
179+
180+
if (!queue_work(xe->sriov.wq, &gt->sriov.pf.workers.restart))
181+
xe_gt_sriov_dbg(gt, "restart already in queue!\n");
182+
}
183+
144184
/**
145185
* xe_gt_sriov_pf_restart - Restart SR-IOV support after a GT reset.
146186
* @gt: the &xe_gt
@@ -149,6 +189,5 @@ void xe_gt_sriov_pf_sanitize_hw(struct xe_gt *gt, unsigned int vfid)
149189
*/
150190
void xe_gt_sriov_pf_restart(struct xe_gt *gt)
151191
{
152-
xe_gt_sriov_pf_config_restart(gt);
153-
xe_gt_sriov_pf_control_restart(gt);
192+
pf_queue_restart(gt);
154193
}

drivers/gpu/drm/xe/xe_gt_sriov_pf_types.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,25 @@ struct xe_gt_sriov_metadata {
3131
struct xe_gt_sriov_pf_service_version version;
3232
};
3333

34+
/**
35+
* struct xe_gt_sriov_pf_workers - GT level workers used by the PF.
36+
*/
37+
struct xe_gt_sriov_pf_workers {
38+
/** @restart: worker that executes actions post GT reset */
39+
struct work_struct restart;
40+
};
41+
3442
/**
3543
* struct xe_gt_sriov_pf - GT level PF virtualization data.
44+
* @workers: workers data.
3645
* @service: service data.
3746
* @control: control data.
3847
* @policy: policy data.
3948
* @spare: PF-only provisioning configuration.
4049
* @vfs: metadata for all VFs.
4150
*/
4251
struct xe_gt_sriov_pf {
52+
struct xe_gt_sriov_pf_workers workers;
4353
struct xe_gt_sriov_pf_service service;
4454
struct xe_gt_sriov_pf_control control;
4555
struct xe_gt_sriov_pf_policy policy;

0 commit comments

Comments
 (0)