Skip to content

Commit cb7a3f9

Browse files
mwajdeczrodrigovivi
authored andcommitted
drm/xe/pf: Make sure PF is ready to configure VFs
The PF driver might be resumed just to configure VFs, but since it is doing some asynchronous GuC reconfigurations after fresh reset, we should wait until all pending works are completed. This is especially important in case of LMEM provisioning, since we also need to update the LMTT and send invalidation requests to all GuCs, which are expected to be already in the VGT mode. Fixes: 68ae022 ("drm/xe/pf: Force GuC virtualization mode") Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com> Cc: Jonathan Cavitt <jonathan.cavitt@intel.com> Link: https://lore.kernel.org/r/20250801142822.180530-3-michal.wajdeczko@intel.com (cherry picked from commit c6c8644) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent c286ce6 commit cb7a3f9

File tree

6 files changed

+63
-2
lines changed

6 files changed

+63
-2
lines changed

drivers/gpu/drm/xe/xe_gt_sriov_pf.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "xe_gt_sriov_pf_migration.h"
1717
#include "xe_gt_sriov_pf_service.h"
1818
#include "xe_gt_sriov_printk.h"
19+
#include "xe_guc_submit.h"
1920
#include "xe_mmio.h"
2021
#include "xe_pm.h"
2122

@@ -260,3 +261,27 @@ void xe_gt_sriov_pf_restart(struct xe_gt *gt)
260261
{
261262
pf_queue_restart(gt);
262263
}
264+
265+
static void pf_flush_restart(struct xe_gt *gt)
266+
{
267+
xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
268+
flush_work(&gt->sriov.pf.workers.restart);
269+
}
270+
271+
/**
272+
* xe_gt_sriov_pf_wait_ready() - Wait until per-GT PF SR-IOV support is ready.
273+
* @gt: the &xe_gt
274+
*
275+
* This function can only be called on PF.
276+
*
277+
* Return: 0 on success or a negative error code on failure.
278+
*/
279+
int xe_gt_sriov_pf_wait_ready(struct xe_gt *gt)
280+
{
281+
/* don't wait if there is another ongoing reset */
282+
if (xe_guc_read_stopped(&gt->uc.guc))
283+
return -EBUSY;
284+
285+
pf_flush_restart(gt);
286+
return 0;
287+
}

drivers/gpu/drm/xe/xe_gt_sriov_pf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ struct xe_gt;
1111
#ifdef CONFIG_PCI_IOV
1212
int xe_gt_sriov_pf_init_early(struct xe_gt *gt);
1313
int xe_gt_sriov_pf_init(struct xe_gt *gt);
14+
int xe_gt_sriov_pf_wait_ready(struct xe_gt *gt);
1415
void xe_gt_sriov_pf_init_hw(struct xe_gt *gt);
1516
void xe_gt_sriov_pf_sanitize_hw(struct xe_gt *gt, unsigned int vfid);
1617
void xe_gt_sriov_pf_stop_prepare(struct xe_gt *gt);

drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "xe_gt_sriov_pf_policy.h"
2323
#include "xe_gt_sriov_pf_service.h"
2424
#include "xe_pm.h"
25+
#include "xe_sriov_pf.h"
2526

2627
/*
2728
* /sys/kernel/debug/dri/0/
@@ -205,7 +206,8 @@ static int CONFIG##_set(void *data, u64 val) \
205206
return -EOVERFLOW; \
206207
\
207208
xe_pm_runtime_get(xe); \
208-
err = xe_gt_sriov_pf_config_set_##CONFIG(gt, vfid, val); \
209+
err = xe_sriov_pf_wait_ready(xe) ?: \
210+
xe_gt_sriov_pf_config_set_##CONFIG(gt, vfid, val); \
209211
xe_pm_runtime_put(xe); \
210212
\
211213
return err; \

drivers/gpu/drm/xe/xe_pci_sriov.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "xe_pci_sriov.h"
1313
#include "xe_pm.h"
1414
#include "xe_sriov.h"
15+
#include "xe_sriov_pf.h"
1516
#include "xe_sriov_pf_helpers.h"
1617
#include "xe_sriov_printk.h"
1718

@@ -138,6 +139,10 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
138139
xe_assert(xe, num_vfs <= total_vfs);
139140
xe_sriov_dbg(xe, "enabling %u VF%s\n", num_vfs, str_plural(num_vfs));
140141

142+
err = xe_sriov_pf_wait_ready(xe);
143+
if (err)
144+
goto out;
145+
141146
/*
142147
* We must hold additional reference to the runtime PM to keep PF in D0
143148
* during VFs lifetime, as our VFs do not implement the PM capability.
@@ -169,7 +174,7 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
169174
failed:
170175
pf_unprovision_vfs(xe, num_vfs);
171176
xe_pm_runtime_put(xe);
172-
177+
out:
173178
xe_sriov_notice(xe, "Failed to enable %u VF%s (%pe)\n",
174179
num_vfs, str_plural(num_vfs), ERR_PTR(err));
175180
return err;

drivers/gpu/drm/xe/xe_sriov_pf.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "xe_assert.h"
1111
#include "xe_device.h"
12+
#include "xe_gt_sriov_pf.h"
1213
#include "xe_module.h"
1314
#include "xe_sriov.h"
1415
#include "xe_sriov_pf.h"
@@ -102,6 +103,32 @@ int xe_sriov_pf_init_early(struct xe_device *xe)
102103
return 0;
103104
}
104105

106+
/**
107+
* xe_sriov_pf_wait_ready() - Wait until PF is ready to operate.
108+
* @xe: the &xe_device to test
109+
*
110+
* This function can only be called on PF.
111+
*
112+
* Return: 0 on success or a negative error code on failure.
113+
*/
114+
int xe_sriov_pf_wait_ready(struct xe_device *xe)
115+
{
116+
struct xe_gt *gt;
117+
unsigned int id;
118+
int err;
119+
120+
if (xe_device_wedged(xe))
121+
return -ECANCELED;
122+
123+
for_each_gt(gt, xe, id) {
124+
err = xe_gt_sriov_pf_wait_ready(gt);
125+
if (err)
126+
return err;
127+
}
128+
129+
return 0;
130+
}
131+
105132
/**
106133
* xe_sriov_pf_print_vfs_summary - Print SR-IOV PF information.
107134
* @xe: the &xe_device to print info from

drivers/gpu/drm/xe/xe_sriov_pf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct xe_device;
1515
#ifdef CONFIG_PCI_IOV
1616
bool xe_sriov_pf_readiness(struct xe_device *xe);
1717
int xe_sriov_pf_init_early(struct xe_device *xe);
18+
int xe_sriov_pf_wait_ready(struct xe_device *xe);
1819
void xe_sriov_pf_debugfs_register(struct xe_device *xe, struct dentry *root);
1920
void xe_sriov_pf_print_vfs_summary(struct xe_device *xe, struct drm_printer *p);
2021
#else

0 commit comments

Comments
 (0)