Commit 0cfab4cb authored by Huang, Sean Z's avatar Huang, Sean Z Committed by Rodrigo Vivi
Browse files

drm/i915/pxp: Enable PXP power management



During the power event S3+ sleep/resume, hardware will lose all the
encryption keys for every hardware session, even though the
session state might still be marked as alive after resume. Therefore,
we should consider the session as dead on suspend and invalidate all the
objects. The session will be automatically restarted on the first
protected submission on resume.

v2: runtime suspend also invalidates the keys
v3: fix return codes, simplify rpm ops (Chris), use the new worker func
v4: invalidate the objects on suspend, don't re-create the arb sesson on
resume (delayed to first submission).
v5: move irq changes back to irq patch (Rodrigo)
v6: drop invalidation in runtime suspend (Rodrigo)

Signed-off-by: default avatarHuang, Sean Z <sean.z.huang@intel.com>
Signed-off-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210924191452.1539378-13-alan.previn.teres.alexis@intel.com
parent 32271ecd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -283,6 +283,7 @@ i915-$(CONFIG_DRM_I915_PXP) += \
	pxp/intel_pxp.o \
	pxp/intel_pxp_cmd.o \
	pxp/intel_pxp_irq.o \
	pxp/intel_pxp_pm.o \
	pxp/intel_pxp_session.o \
	pxp/intel_pxp_tee.o

+15 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include "intel_rc6.h"
#include "intel_rps.h"
#include "intel_wakeref.h"
#include "pxp/intel_pxp_pm.h"

#define I915_GT_SUSPEND_IDLE_TIMEOUT (HZ / 2)

@@ -264,6 +265,8 @@ int intel_gt_resume(struct intel_gt *gt)

	intel_uc_resume(&gt->uc);

	intel_pxp_resume(&gt->pxp);

	user_forcewake(gt, false);

out_fw:
@@ -297,6 +300,8 @@ void intel_gt_suspend_prepare(struct intel_gt *gt)
{
	user_forcewake(gt, true);
	wait_for_suspend(gt);

	intel_pxp_suspend(&gt->pxp, false);
}

static suspend_state_t pm_suspend_target(void)
@@ -348,6 +353,7 @@ void intel_gt_suspend_late(struct intel_gt *gt)

void intel_gt_runtime_suspend(struct intel_gt *gt)
{
	intel_pxp_suspend(&gt->pxp, true);
	intel_uc_runtime_suspend(&gt->uc);

	GT_TRACE(gt, "\n");
@@ -355,11 +361,19 @@ void intel_gt_runtime_suspend(struct intel_gt *gt)

int intel_gt_runtime_resume(struct intel_gt *gt)
{
	int ret;

	GT_TRACE(gt, "\n");
	intel_gt_init_swizzling(gt);
	intel_ggtt_restore_fences(gt->ggtt);

	return intel_uc_runtime_resume(&gt->uc);
	ret = intel_uc_runtime_resume(&gt->uc);
	if (ret)
		return ret;

	intel_pxp_resume(&gt->pxp);

	return 0;
}

static ktime_t __intel_gt_get_awake_time(const struct intel_gt *gt)
+2 −0
Original line number Diff line number Diff line
@@ -67,6 +67,8 @@
#include "gt/intel_gt_pm.h"
#include "gt/intel_rc6.h"

#include "pxp/intel_pxp_pm.h"

#include "i915_debugfs.h"
#include "i915_drv.h"
#include "i915_ioc32.h"
+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include "gt/intel_gt_types.h"
#include "i915_irq.h"
#include "i915_reg.h"
#include "intel_runtime_pm.h"

/**
 * intel_pxp_irq_handler - Handles PXP interrupts.
+46 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: MIT
/*
 * Copyright(c) 2020 Intel Corporation.
 */

#include "intel_pxp.h"
#include "intel_pxp_irq.h"
#include "intel_pxp_pm.h"
#include "intel_pxp_session.h"

void intel_pxp_suspend(struct intel_pxp *pxp, bool runtime)
{
	if (!intel_pxp_is_enabled(pxp))
		return;

	pxp->arb_is_valid = false;

	/*
	 * Contexts using protected objects keep a runtime PM reference, so we
	 * can only runtime suspend when all of them have been either closed
	 * or banned. Therefore, there is no need to invalidate in that
	 * scenario.
	 */
	if (!runtime)
		intel_pxp_invalidate(pxp);

	intel_pxp_fini_hw(pxp);

	pxp->hw_state_invalidated = false;
}

void intel_pxp_resume(struct intel_pxp *pxp)
{
	if (!intel_pxp_is_enabled(pxp))
		return;

	/*
	 * The PXP component gets automatically unbound when we go into S3 and
	 * re-bound after we come out, so in that scenario we can defer the
	 * hw init to the bind call.
	 */
	if (!pxp->pxp_component)
		return;

	intel_pxp_init_hw(pxp);
}
Loading