All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Huang, Sean Z" <sean.z.huang@intel.com>
To: Intel-gfx@lists.freedesktop.org
Subject: [Intel-gfx] [RFC-v3 04/26] drm/i915/pxp: set KCR reg init during the boot time
Date: Tue,  1 Dec 2020 15:33:49 -0800	[thread overview]
Message-ID: <20201201233411.21858-5-sean.z.huang@intel.com> (raw)
In-Reply-To: <20201201233411.21858-1-sean.z.huang@intel.com>

Set the KCR init during the boot time, which is required by
hardware, to allow us doing further protection operation such
as sending commands to GPU or TEE

Signed-off-by: Huang, Sean Z <sean.z.huang@intel.com>
---
 drivers/gpu/drm/i915/Makefile           |  3 +-
 drivers/gpu/drm/i915/pxp/intel_pxp.c    | 11 ++++++-
 drivers/gpu/drm/i915/pxp/intel_pxp_sm.c | 38 +++++++++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_sm.h | 20 +++++++++++++
 4 files changed, 70 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_sm.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_sm.h

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 99efac469cc2..131bd8921565 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -257,7 +257,8 @@ i915-y += i915_perf.o
 # Protected execution platform (PXP) support
 i915-$(CONFIG_DRM_I915_PXP) += \
 	pxp/intel_pxp.o \
-	pxp/intel_pxp_context.o
+	pxp/intel_pxp_context.o \
+	pxp/intel_pxp_sm.o
 
 # Post-mortem debug and GPU hang state capture
 i915-$(CONFIG_DRM_I915_CAPTURE_ERROR) += i915_gpu_error.o
diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp.c b/drivers/gpu/drm/i915/pxp/intel_pxp.c
index 769bfd9bc6b8..d74a32b29716 100644
--- a/drivers/gpu/drm/i915/pxp/intel_pxp.c
+++ b/drivers/gpu/drm/i915/pxp/intel_pxp.c
@@ -6,6 +6,7 @@
 #include "i915_drv.h"
 #include "intel_pxp.h"
 #include "intel_pxp_context.h"
+#include "intel_pxp_sm.h"
 
 static void intel_pxp_write_irq_mask_reg(struct drm_i915_private *i915, u32 mask)
 {
@@ -77,6 +78,8 @@ static void intel_pxp_irq_work(struct work_struct *work)
 
 int intel_pxp_init(struct drm_i915_private *i915)
 {
+	int ret;
+
 	if (!i915)
 		return -EINVAL;
 
@@ -92,13 +95,19 @@ int intel_pxp_init(struct drm_i915_private *i915)
 		return -EFAULT;
 	}
 
+	ret = pxp_sm_set_kcr_init_reg(i915);
+	if (ret) {
+		drm_err(&i915->drm, "Failed to set kcr init reg\n");
+		return ret;
+	}
+
 	INIT_WORK(&i915->pxp.irq_work, intel_pxp_irq_work);
 
 	i915->pxp.handled_irr = (PXP_IRQ_VECTOR_DISPLAY_PXP_STATE_TERMINATED |
 				 PXP_IRQ_VECTOR_DISPLAY_APP_TERM_PER_FW_REQ |
 				 PXP_IRQ_VECTOR_PXP_DISP_STATE_RESET_COMPLETE);
 
-	return 0;
+	return ret;
 }
 
 void intel_pxp_uninit(struct drm_i915_private *i915)
diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_sm.c b/drivers/gpu/drm/i915/pxp/intel_pxp_sm.c
new file mode 100644
index 000000000000..a2c9c71d2372
--- /dev/null
+++ b/drivers/gpu/drm/i915/pxp/intel_pxp_sm.c
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#include "gt/intel_context.h"
+#include "gt/intel_engine_pm.h"
+
+#include "intel_pxp.h"
+#include "intel_pxp_sm.h"
+#include "intel_pxp_context.h"
+
+static int pxp_reg_write(struct drm_i915_private *i915, u32 offset, u32 regval)
+{
+	intel_wakeref_t wakeref;
+
+	if (!i915)
+		return -EINVAL;
+
+	with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
+		i915_reg_t reg_offset = {offset};
+
+		intel_uncore_write(&i915->uncore, reg_offset, regval);
+	}
+
+	return 0;
+}
+
+int pxp_sm_set_kcr_init_reg(struct drm_i915_private *i915)
+{
+	int ret;
+
+	ret = pxp_reg_write(i915, KCR_INIT.reg, KCR_INIT_ALLOW_DISPLAY_ME_WRITES);
+	if (ret)
+		drm_err(&i915->drm, "Failed to write()\n");
+
+	return ret;
+}
diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_sm.h b/drivers/gpu/drm/i915/pxp/intel_pxp_sm.h
new file mode 100644
index 000000000000..d061f395aa16
--- /dev/null
+++ b/drivers/gpu/drm/i915/pxp/intel_pxp_sm.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#ifndef __INTEL_PXP_SM_H__
+#define __INTEL_PXP_SM_H__
+
+#include "i915_drv.h"
+#include "i915_reg.h"
+
+/* KCR register definitions */
+#define KCR_INIT            _MMIO(0x320f0)
+#define KCR_INIT_MASK_SHIFT (16)
+/* Setting KCR Init bit is required after system boot */
+#define KCR_INIT_ALLOW_DISPLAY_ME_WRITES (BIT(14) | (BIT(14) << KCR_INIT_MASK_SHIFT))
+
+int pxp_sm_set_kcr_init_reg(struct drm_i915_private *i915);
+
+#endif /* __INTEL_PXP_SM_H__ */
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2020-12-01 23:35 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-01 23:33 [Intel-gfx] [RFC-v3 00/26] Introduce Intel PXP component Huang, Sean Z
2020-12-01 23:33 ` [Intel-gfx] [RFC-v3 01/26] drm/i915/pxp: " Huang, Sean Z
2020-12-01 23:33 ` [Intel-gfx] [RFC-v3 02/26] drm/i915/pxp: Enable PXP irq worker and callback stub Huang, Sean Z
2020-12-01 23:33 ` [Intel-gfx] [RFC-v3 03/26] drm/i915/pxp: Add PXP context for logical hardware states Huang, Sean Z
2020-12-01 23:33 ` Huang, Sean Z [this message]
2020-12-01 23:33 ` [Intel-gfx] [RFC-v3 05/26] drm/i915/pxp: Implement ioctl action to set the user space context Huang, Sean Z
2020-12-01 23:33 ` [Intel-gfx] [RFC-v3 06/26] drm/i915/pxp: Add PXP-related registers into allowlist Huang, Sean Z
2020-12-01 23:33 ` [Intel-gfx] [RFC-v3 07/26] drm/i915/pxp: Read register to check hardware session state Huang, Sean Z
2020-12-01 23:33 ` [Intel-gfx] [RFC-v3 08/26] drm/i915/pxp: Implement funcs to get/set PXP tag Huang, Sean Z
2020-12-01 23:33 ` [Intel-gfx] [RFC-v3 09/26] drm/i915/pxp: Implement ioctl action to reserve session slot Huang, Sean Z
2020-12-01 23:33 ` [Intel-gfx] [RFC-v3 10/26] drm/i915/pxp: Implement ioctl action to set session in play Huang, Sean Z
2020-12-01 23:33 ` [Intel-gfx] [RFC-v3 11/26] drm/i915/pxp: Func to send hardware session termination Huang, Sean Z
2020-12-01 23:33 ` [Intel-gfx] [RFC-v3 12/26] drm/i915/pxp: Implement ioctl action to terminate the session Huang, Sean Z
2020-12-01 23:33 ` [Intel-gfx] [RFC-v3 13/26] drm/i915/pxp: Enable ioctl action to query PXP tag Huang, Sean Z
2020-12-01 23:33 ` [Intel-gfx] [RFC-v3 14/26] drm/i915/pxp: Destroy all type0 sessions upon teardown Huang, Sean Z
2020-12-01 23:34 ` [Intel-gfx] [RFC-v3 15/26] drm/i915/pxp: Termiante the session upon app crash Huang, Sean Z
2020-12-01 23:34 ` [Intel-gfx] [RFC-v3 16/26] drm/i915/pxp: Enable PXP power management Huang, Sean Z
2020-12-01 23:34 ` [Intel-gfx] [RFC-v3 17/26] drm/i915/pxp: Implement funcs to create the TEE channel Huang, Sean Z
2020-12-01 23:34 ` [Intel-gfx] [RFC-v3 18/26] drm/i915/pxp: Implement ioctl action to send TEE commands Huang, Sean Z
2020-12-01 23:34 ` [Intel-gfx] [RFC-v3 19/26] drm/i915/pxp: Create the arbitrary session after boot Huang, Sean Z
2020-12-01 23:34 ` [Intel-gfx] [RFC-v3 20/26] drm/i915/pxp: Add i915 trace logs for PXP operations Huang, Sean Z
2020-12-01 23:34 ` [Intel-gfx] [RFC-v3 21/26] drm/i915/pxp: Expose session state for display protection flip Huang, Sean Z
2020-12-01 23:34 ` [Intel-gfx] [RFC-v3 22/26] mei: pxp: export pavp client to me client bus Huang, Sean Z
2020-12-01 23:34 ` [Intel-gfx] [RFC-v3 23/26] drm/i915/uapi: introduce drm_i915_gem_create_ext Huang, Sean Z
2020-12-01 23:34 ` [Intel-gfx] [RFC-v3 24/26] drm/i915/pxp: User interface for Protected buffer Huang, Sean Z
2020-12-01 23:34 ` [Intel-gfx] [RFC-v3 25/26] drm/i915/pxp: Add plane decryption support Huang, Sean Z
2020-12-01 23:34 ` [Intel-gfx] [RFC-v3 26/26] drm/i915/pxp: Enable the PXP ioctl for protected session Huang, Sean Z
2020-12-01 23:42 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for Introduce Intel PXP component (rev2) Patchwork
2020-12-01 23:57 [Intel-gfx] [RFC-v3 00/26] Introduce Intel PXP component Huang, Sean Z
2020-12-01 23:57 ` [Intel-gfx] [RFC-v3 04/26] drm/i915/pxp: set KCR reg init during the boot time Huang, Sean Z

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201201233411.21858-5-sean.z.huang@intel.com \
    --to=sean.z.huang@intel.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.