Skip to content

Commit abe59c5

Browse files
mwajdeczgregkh
authored andcommitted
drm/xe/pf: Sanitize VF scratch registers on FLR
[ Upstream commit 13a48a0 ] Some VF accessible registers (like GuC scratch registers) must be explicitly reset during the FLR. While this is today done by the GuC firmware, according to the design, this should be responsibility of the PF driver, as future platforms may require more registers to be reset. Likewise GuC, the PF can access VFs registers by adding some platform specific offset to the original register address. Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240902192953.1792-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 fc38c24 commit abe59c5

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

drivers/gpu/drm/xe/xe_gt_sriov_pf.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55

66
#include <drm/drm_managed.h>
77

8+
#include "regs/xe_guc_regs.h"
89
#include "regs/xe_regs.h"
910

11+
#include "xe_gt.h"
1012
#include "xe_gt_sriov_pf.h"
1113
#include "xe_gt_sriov_pf_config.h"
1214
#include "xe_gt_sriov_pf_control.h"
@@ -89,6 +91,56 @@ void xe_gt_sriov_pf_init_hw(struct xe_gt *gt)
8991
xe_gt_sriov_pf_service_update(gt);
9092
}
9193

94+
static u32 pf_get_vf_regs_stride(struct xe_device *xe)
95+
{
96+
return GRAPHICS_VERx100(xe) > 1200 ? 0x400 : 0x1000;
97+
}
98+
99+
static struct xe_reg xe_reg_vf_to_pf(struct xe_reg vf_reg, unsigned int vfid, u32 stride)
100+
{
101+
struct xe_reg pf_reg = vf_reg;
102+
103+
pf_reg.vf = 0;
104+
pf_reg.addr += stride * vfid;
105+
106+
return pf_reg;
107+
}
108+
109+
static void pf_clear_vf_scratch_regs(struct xe_gt *gt, unsigned int vfid)
110+
{
111+
u32 stride = pf_get_vf_regs_stride(gt_to_xe(gt));
112+
struct xe_reg scratch;
113+
int n, count;
114+
115+
if (xe_gt_is_media_type(gt)) {
116+
count = MED_VF_SW_FLAG_COUNT;
117+
for (n = 0; n < count; n++) {
118+
scratch = xe_reg_vf_to_pf(MED_VF_SW_FLAG(n), vfid, stride);
119+
xe_mmio_write32(gt, scratch, 0);
120+
}
121+
} else {
122+
count = VF_SW_FLAG_COUNT;
123+
for (n = 0; n < count; n++) {
124+
scratch = xe_reg_vf_to_pf(VF_SW_FLAG(n), vfid, stride);
125+
xe_mmio_write32(gt, scratch, 0);
126+
}
127+
}
128+
}
129+
130+
/**
131+
* xe_gt_sriov_pf_sanitize_hw() - Reset hardware state related to a VF.
132+
* @gt: the &xe_gt
133+
* @vfid: the VF identifier
134+
*
135+
* This function can only be called on PF.
136+
*/
137+
void xe_gt_sriov_pf_sanitize_hw(struct xe_gt *gt, unsigned int vfid)
138+
{
139+
xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
140+
141+
pf_clear_vf_scratch_regs(gt, vfid);
142+
}
143+
92144
/**
93145
* xe_gt_sriov_pf_restart - Restart SR-IOV support after a GT reset.
94146
* @gt: the &xe_gt

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
void xe_gt_sriov_pf_init_hw(struct xe_gt *gt);
14+
void xe_gt_sriov_pf_sanitize_hw(struct xe_gt *gt, unsigned int vfid);
1415
void xe_gt_sriov_pf_restart(struct xe_gt *gt);
1516
#else
1617
static inline int xe_gt_sriov_pf_init_early(struct xe_gt *gt)

drivers/gpu/drm/xe/xe_gt_sriov_pf_control.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "xe_device.h"
1111
#include "xe_gt.h"
12+
#include "xe_gt_sriov_pf.h"
1213
#include "xe_gt_sriov_pf_config.h"
1314
#include "xe_gt_sriov_pf_control.h"
1415
#include "xe_gt_sriov_pf_helpers.h"
@@ -1008,7 +1009,7 @@ static bool pf_exit_vf_flr_reset_mmio(struct xe_gt *gt, unsigned int vfid)
10081009
if (!pf_exit_vf_state(gt, vfid, XE_GT_SRIOV_STATE_FLR_RESET_MMIO))
10091010
return false;
10101011

1011-
/* XXX: placeholder */
1012+
xe_gt_sriov_pf_sanitize_hw(gt, vfid);
10121013

10131014
pf_enter_vf_flr_send_finish(gt, vfid);
10141015
return true;

0 commit comments

Comments
 (0)