Commit da3799c9 authored by Matthew Brost's avatar Matthew Brost Committed by Rodrigo Vivi
Browse files

drm/xe: Use GuC to do GGTT invalidations for the GuC firmware



Only the GuC should be issuing TLB invalidations if it is enabled. Part
of this patch is sanitize the device on driver unload to ensure we do
not send GuC based TLB invalidations during driver unload.

Signed-off-by: default avatarMatthew Brost <matthew.brost@intel.com>
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: default avatarNiranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
parent 74a8b2c6
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -215,6 +215,16 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
	return ERR_PTR(err);
}

static void xe_device_sanitize(struct drm_device *drm, void *arg)
{
	struct xe_device *xe = arg;
	struct xe_gt *gt;
	u8 id;

	for_each_gt(gt, xe, id)
		xe_gt_sanitize(gt);
}

int xe_device_probe(struct xe_device *xe)
{
	struct xe_gt *gt;
@@ -274,6 +284,10 @@ int xe_device_probe(struct xe_device *xe)

	xe_debugfs_register(xe);

	err = drmm_add_action_or_reset(&xe->drm, xe_device_sanitize, xe);
	if (err)
		return err;

	return 0;

err_irq_shutdown:
+10 −2
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#include "xe_device.h"
#include "xe_bo.h"
#include "xe_gt.h"
#include "xe_gt_tlb_invalidation.h"
#include "xe_map.h"
#include "xe_mmio.h"
#include "xe_wopcm.h"
@@ -200,10 +201,17 @@ void xe_ggtt_invalidate(struct xe_gt *gt)
	 * therefore flushing WC buffers.  Is that really true here?
	 */
	xe_mmio_write32(gt, GFX_FLSH_CNTL_GEN6.reg, GFX_FLSH_CNTL_EN);
	if (xe_device_guc_submission_enabled(gt_to_xe(gt))) {

	if (gt->uc.guc.submission_state.enabled) {
		int seqno;

		seqno = xe_gt_tlb_invalidation_guc(gt);
		XE_WARN_ON(seqno <= 0);
		if (seqno > 0)
			xe_gt_tlb_invalidation_wait(gt, seqno);
	} else if (xe_device_guc_submission_enabled(gt_to_xe(gt))) {
		struct xe_device *xe = gt_to_xe(gt);

		/* TODO: also use vfunc here */
		if (xe->info.platform == XE_PVC) {
			xe_mmio_write32(gt, PVC_GUC_TLB_INV_DESC1.reg,
					PVC_GUC_TLB_INV_DESC1_INVALIDATE);
+13 −0
Original line number Diff line number Diff line
@@ -196,6 +196,15 @@ static int gt_ttm_mgr_init(struct xe_gt *gt)
	return 0;
}

void xe_gt_sanitize(struct xe_gt *gt)
{
	/*
	 * FIXME: if xe_uc_sanitize is called here, on TGL driver will not
	 * reload
	 */
	gt->uc.guc.submission_state.enabled = false;
}

static void gt_fini(struct drm_device *drm, void *arg)
{
	struct xe_gt *gt = arg;
@@ -662,6 +671,8 @@ static int gt_reset(struct xe_gt *gt)

	drm_info(&xe->drm, "GT reset started\n");

	xe_gt_sanitize(gt);

	xe_device_mem_access_get(gt_to_xe(gt));
	err = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
	if (err)
@@ -742,6 +753,8 @@ int xe_gt_suspend(struct xe_gt *gt)
	if (!xe_device_guc_submission_enabled(gt_to_xe(gt)))
		return -ENODEV;

	xe_gt_sanitize(gt);

	xe_device_mem_access_get(gt_to_xe(gt));
	err = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
	if (err)
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ int xe_gt_suspend(struct xe_gt *gt);
int xe_gt_resume(struct xe_gt *gt);
void xe_gt_reset_async(struct xe_gt *gt);
void xe_gt_migrate_wait(struct xe_gt *gt);
void xe_gt_sanitize(struct xe_gt *gt);

struct xe_gt *xe_find_full_gt(struct xe_gt *gt);

+1 −1
Original line number Diff line number Diff line
@@ -240,7 +240,7 @@ static int handle_pagefault(struct xe_gt *gt, struct pagefault *pf)
		goto retry_userptr;

	if (!ret) {
		ret = xe_gt_tlb_invalidation(gt, NULL, vma);
		ret = xe_gt_tlb_invalidation_vma(gt, NULL, vma);
		if (ret >= 0)
			ret = 0;
	}
Loading