Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/xe/pf: Use GuC Buffer Cache during policy provisioning

Start using GuC buffer cache for the SRIOV policy configuration
actions. This is a required step before we could declare SRIOV
PF as being a reclaim safe.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250124185247.676-1-michal.wajdeczko@intel.com

+24 -26
+24 -26
drivers/gpu/drm/xe/xe_gt_sriov_pf_policy.c
··· 10 10 #include "xe_gt_sriov_pf_helpers.h" 11 11 #include "xe_gt_sriov_pf_policy.h" 12 12 #include "xe_gt_sriov_printk.h" 13 + #include "xe_guc_buf.h" 13 14 #include "xe_guc_ct.h" 14 15 #include "xe_guc_klv_helpers.h" 15 16 #include "xe_pm.h" ··· 35 34 * Return: number of KLVs that were successfully parsed and saved, 36 35 * negative error code on failure. 37 36 */ 38 - static int pf_send_policy_klvs(struct xe_gt *gt, const u32 *klvs, u32 num_dwords) 37 + static int pf_send_policy_klvs(struct xe_gt *gt, struct xe_guc_buf buf, u32 num_dwords) 39 38 { 40 - const u32 bytes = num_dwords * sizeof(u32); 41 - struct xe_tile *tile = gt_to_tile(gt); 42 - struct xe_device *xe = tile_to_xe(tile); 43 39 struct xe_guc *guc = &gt->uc.guc; 44 - struct xe_bo *bo; 45 - int ret; 46 40 47 - bo = xe_bo_create_pin_map(xe, tile, NULL, 48 - ALIGN(bytes, PAGE_SIZE), 49 - ttm_bo_type_kernel, 50 - XE_BO_FLAG_VRAM_IF_DGFX(tile) | 51 - XE_BO_FLAG_GGTT); 52 - if (IS_ERR(bo)) 53 - return PTR_ERR(bo); 54 - 55 - xe_map_memcpy_to(xe, &bo->vmap, 0, klvs, bytes); 56 - 57 - ret = guc_action_update_vgt_policy(guc, xe_bo_ggtt_addr(bo), num_dwords); 58 - 59 - xe_bo_unpin_map_no_vm(bo); 60 - 61 - return ret; 41 + return guc_action_update_vgt_policy(guc, xe_guc_buf_flush(buf), num_dwords); 62 42 } 63 43 64 44 /* 65 45 * Return: 0 on success, -ENOKEY if some KLVs were not updated, -EPROTO if reply was malformed, 66 46 * negative error code on failure. 67 47 */ 68 - static int pf_push_policy_klvs(struct xe_gt *gt, u32 num_klvs, 69 - const u32 *klvs, u32 num_dwords) 48 + static int pf_push_policy_buf_klvs(struct xe_gt *gt, u32 num_klvs, 49 + struct xe_guc_buf buf, u32 num_dwords) 70 50 { 71 51 int ret; 72 52 73 - xe_gt_assert(gt, num_klvs == xe_guc_klv_count(klvs, num_dwords)); 74 - 75 - ret = pf_send_policy_klvs(gt, klvs, num_dwords); 53 + ret = pf_send_policy_klvs(gt, buf, num_dwords); 76 54 77 55 if (ret != num_klvs) { 78 56 int err = ret < 0 ? ret : ret < num_klvs ? -ENOKEY : -EPROTO; 79 57 struct drm_printer p = xe_gt_info_printer(gt); 58 + void *klvs = xe_guc_buf_cpu_ptr(buf); 80 59 81 60 xe_gt_sriov_notice(gt, "Failed to push %u policy KLV%s (%pe)\n", 82 61 num_klvs, str_plural(num_klvs), ERR_PTR(err)); ··· 65 84 } 66 85 67 86 return 0; 87 + } 88 + 89 + /* 90 + * Return: 0 on success, -ENOBUFS if there is no free buffer for the indirect data, 91 + * negative error code on failure. 92 + */ 93 + static int pf_push_policy_klvs(struct xe_gt *gt, u32 num_klvs, 94 + const u32 *klvs, u32 num_dwords) 95 + { 96 + CLASS(xe_guc_buf_from_data, buf)(&gt->uc.guc.buf, klvs, num_dwords * sizeof(u32)); 97 + 98 + xe_gt_assert(gt, num_klvs == xe_guc_klv_count(klvs, num_dwords)); 99 + 100 + if (!xe_guc_buf_is_valid(buf)) 101 + return -ENOBUFS; 102 + 103 + return pf_push_policy_buf_klvs(gt, num_klvs, buf, num_dwords); 68 104 } 69 105 70 106 static int pf_push_policy_u32(struct xe_gt *gt, u16 key, u32 value)