Commit 30d137dd authored by Tomasz Lis's avatar Tomasz Lis Committed by Michał Winiarski
Browse files

drm/xe/vf: Rebase MEMIRQ structures for all contexts after migration



All contexts require an update of state data, as the data includes
GGTT references to memirq-related buffers.

Default contexts need these references updated as well, because they
are not refreshed when a new context is created from them.

The way we write to vram requires scratch buffer to be used
before the whole block is memcopied. Since using kalloc() within
specific recovery functions would lead to unintended relations
between locks, we are allocating the buffer earlier, before
any locks are taken. The same buffer will be used for other steps
of the recovery.

v2: Update addresses by xe_lrc_write_ctx_reg() rather than
  set_memory_based_intr()
v3: Renamed parameter, reordered parameters in some functs
v4: Check if have MEMIRQ, move `xe_gt*` funct to proper file
v5: Revert back to requiring scratch buffer, but allocate it
  earlier this time

Signed-off-by: default avatarTomasz Lis <tomasz.lis@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Michal Winiarski <michal.winiarski@intel.com>
Acked-by: default avatarSatyanarayana K V P <satyanarayana.k.v.p@intel.com>
Reviewed-by: default avatarMichal Winiarski <michal.winiarski@intel.com>
Link: https://lore.kernel.org/r/20250802031045.1127138-6-tomasz.lis@intel.com


Signed-off-by: default avatarMichał Winiarski <michal.winiarski@intel.com>
parent b46ef766
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -1081,11 +1081,14 @@ int xe_exec_queue_last_fence_test_dep(struct xe_exec_queue *q, struct xe_vm *vm)
 * xe_exec_queue_contexts_hwsp_rebase - Re-compute GGTT references
 * within all LRCs of a queue.
 * @q: the &xe_exec_queue struct instance containing target LRCs
 * @scratch: scratch buffer to be used as temporary storage
 */
void xe_exec_queue_contexts_hwsp_rebase(struct xe_exec_queue *q)
void xe_exec_queue_contexts_hwsp_rebase(struct xe_exec_queue *q, void *scratch)
{
	int i;

	for (i = 0; i < q->width; ++i)
	for (i = 0; i < q->width; ++i) {
		xe_lrc_update_memirq_regs_with_address(q->lrc[i], q->hwe, scratch);
		xe_lrc_update_hwctx_regs_with_address(q->lrc[i]);
	}
}
+1 −1
Original line number Diff line number Diff line
@@ -90,6 +90,6 @@ int xe_exec_queue_last_fence_test_dep(struct xe_exec_queue *q,
				      struct xe_vm *vm);
void xe_exec_queue_update_run_ticks(struct xe_exec_queue *q);

void xe_exec_queue_contexts_hwsp_rebase(struct xe_exec_queue *q);
void xe_exec_queue_contexts_hwsp_rebase(struct xe_exec_queue *q, void *scratch);

#endif
+14 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include "xe_guc.h"
#include "xe_guc_hxg_helpers.h"
#include "xe_guc_relay.h"
#include "xe_lrc.h"
#include "xe_mmio.h"
#include "xe_sriov.h"
#include "xe_sriov_vf.h"
@@ -750,6 +751,19 @@ int xe_gt_sriov_vf_connect(struct xe_gt *gt)
	return err;
}

/**
 * xe_gt_sriov_vf_default_lrcs_hwsp_rebase - Update GGTT references in HWSP of default LRCs.
 * @gt: the &xe_gt struct instance
 */
void xe_gt_sriov_vf_default_lrcs_hwsp_rebase(struct xe_gt *gt)
{
	struct xe_hw_engine *hwe;
	enum xe_hw_engine_id id;

	for_each_hw_engine(hwe, gt, id)
		xe_default_lrc_update_memirq_regs_with_address(hwe);
}

/**
 * xe_gt_sriov_vf_migrated_event_handler - Start a VF migration recovery,
 *   or just mark that a GuC is ready for it.
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ void xe_gt_sriov_vf_guc_versions(struct xe_gt *gt,
int xe_gt_sriov_vf_query_config(struct xe_gt *gt);
int xe_gt_sriov_vf_connect(struct xe_gt *gt);
int xe_gt_sriov_vf_query_runtime(struct xe_gt *gt);
void xe_gt_sriov_vf_default_lrcs_hwsp_rebase(struct xe_gt *gt);
int xe_gt_sriov_vf_notify_resfix_done(struct xe_gt *gt);
void xe_gt_sriov_vf_migrated_event_handler(struct xe_gt *gt);

+3 −2
Original line number Diff line number Diff line
@@ -2510,14 +2510,15 @@ void xe_guc_submit_print(struct xe_guc *guc, struct drm_printer *p)
 * xe_guc_contexts_hwsp_rebase - Re-compute GGTT references within all
 * exec queues registered to given GuC.
 * @guc: the &xe_guc struct instance
 * @scratch: scratch buffer to be used as temporary storage
 */
void xe_guc_contexts_hwsp_rebase(struct xe_guc *guc)
void xe_guc_contexts_hwsp_rebase(struct xe_guc *guc, void *scratch)
{
	struct xe_exec_queue *q;
	unsigned long index;

	mutex_lock(&guc->submission_state.lock);
	xa_for_each(&guc->submission_state.exec_queue_lookup, index, q)
		xe_exec_queue_contexts_hwsp_rebase(q);
		xe_exec_queue_contexts_hwsp_rebase(q, scratch);
	mutex_unlock(&guc->submission_state.lock);
}
Loading