|
5 | 5 |
|
6 | 6 | #include <drm/drm_managed.h> |
7 | 7 |
|
| 8 | +#include "regs/xe_guc_regs.h" |
8 | 9 | #include "regs/xe_regs.h" |
9 | 10 |
|
| 11 | +#include "xe_gt.h" |
10 | 12 | #include "xe_gt_sriov_pf.h" |
11 | 13 | #include "xe_gt_sriov_pf_config.h" |
12 | 14 | #include "xe_gt_sriov_pf_control.h" |
@@ -89,6 +91,56 @@ void xe_gt_sriov_pf_init_hw(struct xe_gt *gt) |
89 | 91 | xe_gt_sriov_pf_service_update(gt); |
90 | 92 | } |
91 | 93 |
|
| 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 | + |
92 | 144 | /** |
93 | 145 | * xe_gt_sriov_pf_restart - Restart SR-IOV support after a GT reset. |
94 | 146 | * @gt: the &xe_gt |
|
0 commit comments