Skip to content

Commit 45d30c8

Browse files
committed
drm/xe/vf: Track writes to inaccessible registers from VF
Only limited set of registers is accessible for the VF driver and the hardware will silently drop writes to inaccessible registers. To improve our VF driver lets intercept all such writes to warn about such unexpected writes on debug builds or optionally allow to provide some substitution (as a potential future extension). Signed-off-by: Michal Wajdeczko <[email protected]> Cc: Gustavo Sousa <[email protected]> Cc: Piotr Piórkowski <[email protected]> Reviewed-by: Piotr Piórkowski <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 86c5b70 commit 45d30c8

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

drivers/gpu/drm/xe/xe_gt_sriov_vf.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,32 @@ u32 xe_gt_sriov_vf_read32(struct xe_gt *gt, struct xe_reg reg)
892892
return rr->value;
893893
}
894894

895+
/**
896+
* xe_gt_sriov_vf_write32 - Handle a write to an inaccessible register.
897+
* @gt: the &xe_gt
898+
* @reg: the register to write
899+
* @val: value to write
900+
*
901+
* This function is for VF use only.
902+
* Currently it will trigger a WARN if running on debug build.
903+
*/
904+
void xe_gt_sriov_vf_write32(struct xe_gt *gt, struct xe_reg reg, u32 val)
905+
{
906+
u32 addr = xe_mmio_adjusted_addr(gt, reg.addr);
907+
908+
xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt)));
909+
xe_gt_assert(gt, !reg.vf);
910+
911+
/*
912+
* In the future, we may want to handle selected writes to inaccessible
913+
* registers in some custom way, but for now let's just log a warning
914+
* about such attempt, as likely we might be doing something wrong.
915+
*/
916+
xe_gt_WARN(gt, IS_ENABLED(CONFIG_DRM_XE_DEBUG),
917+
"VF is trying to write %#x to an inaccessible register %#x+%#x\n",
918+
val, reg.addr, addr - reg.addr);
919+
}
920+
895921
/**
896922
* xe_gt_sriov_vf_print_config - Print VF self config.
897923
* @gt: the &xe_gt

drivers/gpu/drm/xe/xe_gt_sriov_vf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ u32 xe_gt_sriov_vf_gmdid(struct xe_gt *gt);
2222
u16 xe_gt_sriov_vf_guc_ids(struct xe_gt *gt);
2323
u64 xe_gt_sriov_vf_lmem(struct xe_gt *gt);
2424
u32 xe_gt_sriov_vf_read32(struct xe_gt *gt, struct xe_reg reg);
25+
void xe_gt_sriov_vf_write32(struct xe_gt *gt, struct xe_reg reg, u32 val);
2526

2627
void xe_gt_sriov_vf_print_config(struct xe_gt *gt, struct drm_printer *p);
2728
void xe_gt_sriov_vf_print_runtime(struct xe_gt *gt, struct drm_printer *p);

drivers/gpu/drm/xe/xe_mmio.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ void xe_mmio_write32(struct xe_gt *gt, struct xe_reg reg, u32 val)
171171
u32 addr = xe_mmio_adjusted_addr(gt, reg.addr);
172172

173173
trace_xe_reg_rw(gt, true, addr, val, sizeof(val));
174-
writel(val, (reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + addr);
174+
175+
if (!reg.vf && IS_SRIOV_VF(gt_to_xe(gt)))
176+
xe_gt_sriov_vf_write32(gt, reg, val);
177+
else
178+
writel(val, (reg.ext ? tile->mmio_ext.regs : tile->mmio.regs) + addr);
175179
}
176180

177181
u32 xe_mmio_read32(struct xe_gt *gt, struct xe_reg reg)

0 commit comments

Comments
 (0)