Skip to contentSkip to conversation

Introduce Intel PXP component - Mesa single session

RFC Superseded Huang, Sean Z 3 participants 32 messages Dec 10, 2020 – Jan 19, 2021

Subsystems (6)

v4 of 23 Superseded Latest is v23 →

lore
Share & tools
lore
#0 lore raw

v4 cover Introduce Intel PXP component - Mesa single session

PXP is an i915 componment, that helps to establish the hardware protected session and manage the status of the alive software session, as well as its life cycle.

This patch series is to allow the kernel space to create and manage a single hardware session (a.k.a default session or arbitrary session). So Mesa can allocate the protected buffer, which is encrypted with the leverage of the arbitrary hardware session.

v2:
- modification based on code reivew feedbacks received
- passing pxp instead of i915 as funciton argument
- remove dead code only for multi-session
- move the pxp init call from i915_drv.c to intel_gt.c
- reove the tautology naming

v3:
- rebase to latest drm-tip

v4:
- Append the split non-mesa patch sereis (commit #14 - #21) into this patch series

Anshuman Gupta (1):
drm/i915/pxp: Add plane decryption support

Bommu Krishnaiah (2):
drm/i915/uapi: introduce drm_i915_gem_create_ext drm/i915/pxp: User interface for Protected buffer

Huang, Sean Z (17):
drm/i915/pxp: Introduce Intel PXP component drm/i915/pxp: set KCR reg init during the boot time drm/i915/pxp: Implement funcs to create the TEE channel drm/i915/pxp: Create the arbitrary session after boot drm/i915/pxp: Func to send hardware session termination drm/i915/pxp: Enable PXP irq worker and callback stub drm/i915/pxp: Destroy arb session upon teardown drm/i915/pxp: Enable PXP power management drm/i915/pxp: Expose session state for display protection flip drm/i915/pxp: Implement ioctl action to reserve session slots drm/i915/pxp: Implement ioctl action to set session in play drm/i915/pxp: Implement ioctl action to terminate the session drm/i915/pxp: Implement ioctl action to send TEE commands drm/i915/pxp: Enable ioctl action to query PXP tag drm/i915/pxp: Termiante the session upon app crash drm/i915/pxp: Add PXP-related registers into allowlist drm/i915/pxp: Enable the PXP ioctl for protected session

Vitaly Lubart (1):
mei: pxp: export pavp client to me client bus

 drivers/gpu/drm/i915/Kconfig                  |  19 +
 drivers/gpu/drm/i915/Makefile                 |  10 +
 drivers/gpu/drm/i915/display/intel_sprite.c   |  21 +-
 drivers/gpu/drm/i915/gem/i915_gem_context.c   |  15 +-
 drivers/gpu/drm/i915/gem/i915_gem_context.h   |  10 +
 .../gpu/drm/i915/gem/i915_gem_context_types.h |   2 +-
 .../gpu/drm/i915/gem/i915_gem_object_types.h  |   5 +
 drivers/gpu/drm/i915/gt/intel_gt.c            |   7 +
 drivers/gpu/drm/i915/gt/intel_gt_irq.c        |   4 +
 drivers/gpu/drm/i915/gt/intel_gt_pm.c         |   4 +
 drivers/gpu/drm/i915/gt/intel_gt_types.h      |   3 +
 drivers/gpu/drm/i915/i915_drv.c               |  11 +-
 drivers/gpu/drm/i915/i915_drv.h               |   6 +
 drivers/gpu/drm/i915/i915_gem.c               |  63 ++-
 drivers/gpu/drm/i915/i915_reg.h               |  10 +-
 drivers/gpu/drm/i915/intel_uncore.c           |  50 +-
 drivers/gpu/drm/i915/pxp/intel_pxp.c          | 284 ++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp.h          | 107 ++++
 drivers/gpu/drm/i915/pxp/intel_pxp_arb.c      | 226 ++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_arb.h      |  37 ++
 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c      | 328 ++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.h      |  22 +
 drivers/gpu/drm/i915/pxp/intel_pxp_context.c  |  32 ++
 drivers/gpu/drm/i915/pxp/intel_pxp_context.h  |  41 ++
 drivers/gpu/drm/i915/pxp/intel_pxp_pm.c       |  72 +++
 drivers/gpu/drm/i915/pxp/intel_pxp_pm.h       |  31 ++
 drivers/gpu/drm/i915/pxp/intel_pxp_sm.c       | 487 ++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_sm.h       |  55 ++
 drivers/gpu/drm/i915/pxp/intel_pxp_tee.c      | 227 ++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_tee.h      |  25 +
 drivers/misc/mei/Kconfig                      |   2 +
 drivers/misc/mei/Makefile                     |   1 +
 drivers/misc/mei/pxp/Kconfig                  |  13 +
 drivers/misc/mei/pxp/Makefile                 |   7 +
 drivers/misc/mei/pxp/mei_pxp.c                | 230 +++++++++
 drivers/misc/mei/pxp/mei_pxp.h                |  18 +
 include/drm/i915_component.h                  |   1 +
 include/drm/i915_pxp_tee_interface.h          |  45 ++
 include/uapi/drm/i915_drm.h                   | 138 +++++
 39 files changed, 2642 insertions(+), 27 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp.h
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_arb.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_arb.h
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.h
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_context.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_context.h
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_pm.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_pm.h
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_sm.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_sm.h
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_tee.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_tee.h
 create mode 100644 drivers/misc/mei/pxp/Kconfig
 create mode 100644 drivers/misc/mei/pxp/Makefile
 create mode 100644 drivers/misc/mei/pxp/mei_pxp.c
 create mode 100644 drivers/misc/mei/pxp/mei_pxp.h
 create mode 100644 include/drm/i915_pxp_tee_interface.h
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

RFC v4 1/21 drm/i915/pxp: Introduce Intel PXP component

PXP (Protected Xe Path) is an i915 componment, available on GEN12+, that helps to establish the hardware protected session and manage the status of the alive software session, as well as its life cycle.

This patch series is to allow the kernel space to create and manage a single hardware session (a.k.a default session or arbitrary session). So Mesa can allocate the protected buffer, which is encrypted with the leverage of the arbitrary hardware session.

---
 drivers/gpu/drm/i915/Kconfig                 | 19 +++++++++++++
 drivers/gpu/drm/i915/Makefile                |  5 ++++
 drivers/gpu/drm/i915/gt/intel_gt.c           |  7 +++++
 drivers/gpu/drm/i915/gt/intel_gt_types.h     |  3 ++
 drivers/gpu/drm/i915/pxp/intel_pxp.c         | 27 ++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp.h         | 29 ++++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_context.c | 27 ++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_context.h | 22 +++++++++++++++
 8 files changed, 139 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp.h
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_context.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_context.h
drivers/gpu/drm/i915/Kconfig +19 -0
index 1e1cb245fca7..a42b9b031455 100644
@@ -130,6 +130,25 @@ config DRM_I915_GVT_KVMGT
 	  Choose this option if you want to enable KVMGT support for
 	  Intel GVT-g.
 
+config DRM_I915_PXP
+	bool "Enable Intel PXP support for Intel Gen12+ platform"
+	depends on DRM_I915
+	select INTEL_MEI_PXP
+	default n
+	help
+	  This option selects INTEL_MEI_ME if it isn't already selected to
+	  enabled full PXP Services on Intel platforms.
+
+	  PXP (Protected Xe Path) is an i915 componment, available on GEN12+,
+	  that helps to establish the hardware protected session and manage
+	  the status of the alive software session, as well as its life cycle.
+
+	  This patch series is to allow the kernel space to create and
+	  manage a single hardware session (a.k.a default session or
+	  arbitrary session). So Mesa can allocate the protected buffer,
+	  which is encrypted with the leverage of the arbitrary hardware
+	  session.
+
 menu "drm/i915 Debugging"
 depends on DRM_I915
 depends on EXPERT
drivers/gpu/drm/i915/Makefile +5 -0
index e5574e506a5c..99efac469cc2 100644
@@ -254,6 +254,11 @@ i915-y += \
 
 i915-y += i915_perf.o
 
+# Protected execution platform (PXP) support
+i915-$(CONFIG_DRM_I915_PXP) += \
+	pxp/intel_pxp.o \
+	pxp/intel_pxp_context.o
+
 # Post-mortem debug and GPU hang state capture
 i915-$(CONFIG_DRM_I915_CAPTURE_ERROR) += i915_gpu_error.o
 i915-$(CONFIG_DRM_I915_SELFTEST) += \
drivers/gpu/drm/i915/gt/intel_gt.c +7 -0
index 44f1d51e5ae5..d8e20ede7326 100644
@@ -584,6 +584,12 @@ int intel_gt_init(struct intel_gt *gt)
 	if (err)
 		goto err_gt;
 
+	if (INTEL_GEN(gt->i915) >= 12) {
+		err = intel_pxp_init(&gt->pxp);
+		if (err)
+			goto err_gt;
+	}
+
 	goto out_fw;
 err_gt:
 	__intel_gt_disable(gt);
@@ -638,6 +644,7 @@ void intel_gt_driver_release(struct intel_gt *gt)
 	if (vm) /* FIXME being called twice on error paths :( */
 		i915_vm_put(vm);
 
+	intel_pxp_uninit(&gt->pxp);
 	intel_gt_pm_fini(gt);
 	intel_gt_fini_scratch(gt);
 	intel_gt_fini_buffer_pool(gt);
drivers/gpu/drm/i915/gt/intel_gt_types.h +3 -0
index 6d39a4a11bf3..05255632c2c0 100644
@@ -23,6 +23,7 @@
 #include "intel_rc6_types.h"
 #include "intel_rps_types.h"
 #include "intel_wakeref.h"
+#include "pxp/intel_pxp.h"
 
 struct drm_i915_private;
 struct i915_ggtt;
@@ -120,6 +121,8 @@ struct intel_gt {
 		/* Slice/subslice/EU info */
 		struct sseu_dev_info sseu;
 	} info;
+
+	struct intel_pxp pxp;
 };
 
 enum intel_gt_scratch_field {
drivers/gpu/drm/i915/pxp/intel_pxp.c new file +27 -0
new file mode 100644
index 000000000000..ba43b2c923c7
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright(c) 2020 Intel Corporation.
+ */
+#include "i915_drv.h"
+#include "intel_pxp.h"
+#include "intel_pxp_context.h"
+
+int intel_pxp_init(struct intel_pxp *pxp)
+{
+	struct intel_gt *gt = container_of(pxp, struct intel_gt, pxp);
+
+	/* PXP only available for GEN12+ */
+	if (INTEL_GEN(gt->i915) < 12)
+		return -ENODEV;
+
+	intel_pxp_ctx_init(&pxp->ctx);
+
+	drm_info(&gt->i915->drm, "Protected Xe Path (PXP) protected content support initialized\n");
+
+	return 0;
+}
+
+void intel_pxp_uninit(struct intel_pxp *pxp)
+{
+	intel_pxp_ctx_fini(&pxp->ctx);
+}
drivers/gpu/drm/i915/pxp/intel_pxp.h new file +29 -0
new file mode 100644
index 000000000000..7c3d49a6a3ab
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#ifndef __INTEL_PXP_H__
+#define __INTEL_PXP_H__
+
+#include "intel_pxp_context.h"
+
+struct intel_pxp {
+	struct pxp_context ctx;
+};
+
+#ifdef CONFIG_DRM_I915_PXP
+int intel_pxp_init(struct intel_pxp *pxp);
+void intel_pxp_uninit(struct intel_pxp *pxp);
+#else
+static inline int intel_pxp_init(struct intel_pxp *pxp)
+{
+	return 0;
+}
+
+static inline void intel_pxp_uninit(struct intel_pxp *pxp)
+{
+}
+#endif
+
+#endif /* __INTEL_PXP_PM_H__ */
drivers/gpu/drm/i915/pxp/intel_pxp_context.c new file +27 -0
new file mode 100644
index 000000000000..5ffaf55dc7df
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#include "intel_pxp_context.h"
+#include <linux/random.h>
+
+/**
+ * intel_pxp_ctx_init - To init a pxp context.
+ * @ctx: pointer to ctx structure.
+ */
+void intel_pxp_ctx_init(struct pxp_context *ctx)
+{
+	get_random_bytes(&ctx->id, sizeof(ctx->id));
+
+	mutex_init(&ctx->mutex);
+}
+
+/**
+ * intel_pxp_ctx_fini - To finish the pxp context.
+ * @ctx: pointer to ctx structure.
+ */
+void intel_pxp_ctx_fini(struct pxp_context *ctx)
+{
+	ctx->id = 0;
+}
drivers/gpu/drm/i915/pxp/intel_pxp_context.h new file +22 -0
new file mode 100644
index 000000000000..953a2e700931
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#ifndef __INTEL_PXP_CONTEXT_H__
+#define __INTEL_PXP_CONTEXT_H__
+
+#include <linux/mutex.h>
+
+/* struct pxp_context - Represents combined view of driver and logical HW states. */
+struct pxp_context {
+	/** @mutex: mutex to protect the pxp context */
+	struct mutex mutex;
+
+	int id;
+};
+
+void intel_pxp_ctx_init(struct pxp_context *ctx);
+void intel_pxp_ctx_fini(struct pxp_context *ctx);
+
+#endif /* __INTEL_PXP_CONTEXT_H__ */
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

Re: [Intel-gfx] [RFC-v4 01/21] drm/i915/pxp: Introduce Intel PXP component

Quoting Huang, Sean Z (2020-12-10 07:24:15)

Quoted 31 lines

PXP (Protected Xe Path) is an i915 componment, available on GEN12+, that helps to establish the hardware protected session and manage the status of the alive software session, as well as its life cycle.

This patch series is to allow the kernel space to create and manage a single hardware session (a.k.a default session or arbitrary session). So Mesa can allocate the protected buffer, which is encrypted with the leverage of the arbitrary hardware session.

---
 drivers/gpu/drm/i915/Kconfig                 | 19 +++++++++++++
 drivers/gpu/drm/i915/Makefile                |  5 ++++
 drivers/gpu/drm/i915/gt/intel_gt.c           |  7 +++++
 drivers/gpu/drm/i915/gt/intel_gt_types.h     |  3 ++
 drivers/gpu/drm/i915/pxp/intel_pxp.c         | 27 ++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp.h         | 29 ++++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_context.c | 27 ++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_context.h | 22 +++++++++++++++
 8 files changed, 139 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp.h
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_context.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_context.h
drivers/gpu/drm/i915/Kconfig +0 -0
index 1e1cb245fca7..a42b9b031455 100644

drivers/gpu/drm/i915/Kconfig config DRM_I915_GVT_KVMGT · line 136

Quoted 7 lines
drivers/gpu/drm/i915/Kconfig +4 -0
@@ -130,6 +130,25 @@ config DRM_I915_GVT_KVMGT
          Choose this option if you want to enable KVMGT support for
          Intel GVT-g.
 
+config DRM_I915_PXP
+       bool "Enable Intel PXP support for Intel Gen12+ platform"
+       depends on DRM_I915
+       select INTEL_MEI_PXP

Doesn't exist.

Kconfig dependency resolution is not recursive; you probably will need a depends on INTEL_MEI

drivers/gpu/drm/i915/Kconfig config DRM_I915_GVT_KVMGT · line 137

Quoted 1 line
drivers/gpu/drm/i915/Kconfig +1 -0
+       default n

So this is dead code then?
If the recommendation is not to enable it, and you don't even add it to CI for testing, what's it for?

drivers/gpu/drm/i915/Kconfig config DRM_I915_GVT_KVMGT · line 150

Quoted 13 lines
drivers/gpu/drm/i915/Kconfig +13 -0
+       help
+         This option selects INTEL_MEI_ME if it isn't already selected to
+         enabled full PXP Services on Intel platforms.
+
+         PXP (Protected Xe Path) is an i915 componment, available on GEN12+,
+         that helps to establish the hardware protected session and manage
+         the status of the alive software session, as well as its life cycle.
+
+         This patch series is to allow the kernel space to create and
+         manage a single hardware session (a.k.a default session or
+         arbitrary session). So Mesa can allocate the protected buffer,
+         which is encrypted with the leverage of the arbitrary hardware
+         session.

Mesa is but one user; the first but not last.

Quoted 25 lines
drivers/gpu/drm/i915/Kconfig +1 -0
+
 menu "drm/i915 Debugging"
 depends on DRM_I915
 depends on EXPERT
drivers/gpu/drm/i915/Makefile +5 -0
index e5574e506a5c..99efac469cc2 100644
@@ -254,6 +254,11 @@ i915-y += \
 
 i915-y += i915_perf.o
 
+# Protected execution platform (PXP) support
+i915-$(CONFIG_DRM_I915_PXP) += \
+       pxp/intel_pxp.o \
+       pxp/intel_pxp_context.o
+
 # Post-mortem debug and GPU hang state capture
 i915-$(CONFIG_DRM_I915_CAPTURE_ERROR) += i915_gpu_error.o
 i915-$(CONFIG_DRM_I915_SELFTEST) += \
drivers/gpu/drm/i915/gt/intel_gt.c +0 -0
index 44f1d51e5ae5..d8e20ede7326 100644

drivers/gpu/drm/i915/gt/intel_gt.c int intel_gt_init(struct intel_gt *gt) · line 587

Quoted 4 lines
drivers/gpu/drm/i915/gt/intel_gt.c +1 -0
@@ -584,6 +584,12 @@ int intel_gt_init(struct intel_gt *gt)
        if (err)
                goto err_gt;
 
+       if (INTEL_GEN(gt->i915) >= 12) {

Just call it.

drivers/gpu/drm/i915/gt/intel_gt.c int intel_gt_init(struct intel_gt *gt) · line 589

Quoted 2 lines
drivers/gpu/drm/i915/gt/intel_gt.c +2 -0
+               err = intel_pxp_init(&gt->pxp);
+               if (err)

Not an error; the system can survive without, and userspace can detect the feature.

drivers/gpu/drm/i915/gt/intel_gt.c void intel_gt_driver_release(struct intel_gt *gt) · line 647

Quoted 11 lines
drivers/gpu/drm/i915/gt/intel_gt.c +4 -0
+                       goto err_gt;
+       }
+
        goto out_fw;
 err_gt:
        __intel_gt_disable(gt);
@@ -638,6 +644,7 @@ void intel_gt_driver_release(struct intel_gt *gt)
        if (vm) /* FIXME being called twice on error paths :( */
                i915_vm_put(vm);
 
+       intel_pxp_uninit(&gt->pxp);

How often have we used uninit?

drivers/gpu/drm/i915/gt/intel_gt_types.h line 26

Quoted 12 lines
drivers/gpu/drm/i915/gt/intel_gt.c +0 -0
        intel_gt_pm_fini(gt);
        intel_gt_fini_scratch(gt);
        intel_gt_fini_buffer_pool(gt);
drivers/gpu/drm/i915/gt/intel_gt_types.h +1 -0
index 6d39a4a11bf3..05255632c2c0 100644
@@ -23,6 +23,7 @@
 #include "intel_rc6_types.h"
 #include "intel_rps_types.h"
 #include "intel_wakeref.h"
+#include "pxp/intel_pxp.h"

Only include the types from a types.h

Includes from other layers in their own section.

Quoted 19 lines
drivers/gpu/drm/i915/gt/intel_gt_types.h +2 -0
 struct drm_i915_private;
 struct i915_ggtt;
@@ -120,6 +121,8 @@ struct intel_gt {
                /* Slice/subslice/EU info */
                struct sseu_dev_info sseu;
        } info;
+
+       struct intel_pxp pxp;
 };
 
 enum intel_gt_scratch_field {
drivers/gpu/drm/i915/pxp/intel_pxp.c new file +1 -0
new file mode 100644
index 000000000000..ba43b2c923c7
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: MIT

drivers/gpu/drm/i915/pxp/intel_pxp.c line 11

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp.c new file +10 -0
+/*
+ * Copyright(c) 2020 Intel Corporation.
+ */
+#include "i915_drv.h"
+#include "intel_pxp.h"
+#include "intel_pxp_context.h"
+
+int intel_pxp_init(struct intel_pxp *pxp)
+{
+       struct intel_gt *gt = container_of(pxp, struct intel_gt, pxp);

You are not inside gt/, wise not to bake in such embedded assumptions. i.e. all the container_of(pxp)->i915->pxp will be far less fragile with a pxp->global = &gt->i915->pxp.

drivers/gpu/drm/i915/pxp/intel_pxp.c line 19

Quoted 7 lines
drivers/gpu/drm/i915/pxp/intel_pxp.c new file +7 -0
+       /* PXP only available for GEN12+ */
+       if (INTEL_GEN(gt->i915) < 12)
+               return -ENODEV;
+
+       intel_pxp_ctx_init(&pxp->ctx);
+
+       drm_info(&gt->i915->drm, "Protected Xe Path (PXP) protected content support initialized\n");

Reconsider; this should only be at most once per device.

Quoted 48 lines
drivers/gpu/drm/i915/pxp/intel_pxp.c new file +7 -0
+       return 0;
+}
+
+void intel_pxp_uninit(struct intel_pxp *pxp)
+{
+       intel_pxp_ctx_fini(&pxp->ctx);
+}
drivers/gpu/drm/i915/pxp/intel_pxp.h new file +29 -0
new file mode 100644
index 000000000000..7c3d49a6a3ab
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#ifndef __INTEL_PXP_H__
+#define __INTEL_PXP_H__
+
+#include "intel_pxp_context.h"
+
+struct intel_pxp {
+       struct pxp_context ctx;
+};
+
+#ifdef CONFIG_DRM_I915_PXP
+int intel_pxp_init(struct intel_pxp *pxp);
+void intel_pxp_uninit(struct intel_pxp *pxp);
+#else
+static inline int intel_pxp_init(struct intel_pxp *pxp)
+{
+       return 0;
+}
+
+static inline void intel_pxp_uninit(struct intel_pxp *pxp)
+{
+}
+#endif
+
+#endif /* __INTEL_PXP_PM_H__ */
drivers/gpu/drm/i915/pxp/intel_pxp_context.c new file +0 -0
new file mode 100644
index 000000000000..5ffaf55dc7df

drivers/gpu/drm/i915/pxp/intel_pxp_context.c line 7

Quoted 7 lines
drivers/gpu/drm/i915/pxp/intel_pxp_context.c new file +7 -0
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#include "intel_pxp_context.h"
+#include <linux/random.h>

System includes first.

drivers/gpu/drm/i915/pxp/intel_pxp_context.c line 15

Quoted 8 lines
drivers/gpu/drm/i915/pxp/intel_pxp_context.c new file +8 -0
+
+/**
+ * intel_pxp_ctx_init - To init a pxp context.
+ * @ctx: pointer to ctx structure.
+ */
+void intel_pxp_ctx_init(struct pxp_context *ctx)
+{
+       get_random_bytes(&ctx->id, sizeof(ctx->id));

As already stated, this randomisation does not add any security; and does not mean you can safely have multiple contexts without collision.

What you had in mind was an ida.

Quoted 48 lines
drivers/gpu/drm/i915/pxp/intel_pxp_context.c new file +12 -0
+
+       mutex_init(&ctx->mutex);
+}
+
+/**
+ * intel_pxp_ctx_fini - To finish the pxp context.
+ * @ctx: pointer to ctx structure.
+ */
+void intel_pxp_ctx_fini(struct pxp_context *ctx)
+{
+       ctx->id = 0;
+}
drivers/gpu/drm/i915/pxp/intel_pxp_context.h new file +22 -0
new file mode 100644
index 000000000000..953a2e700931
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#ifndef __INTEL_PXP_CONTEXT_H__
+#define __INTEL_PXP_CONTEXT_H__
+
+#include <linux/mutex.h>
+
+/* struct pxp_context - Represents combined view of driver and logical HW states. */
+struct pxp_context {
+       /** @mutex: mutex to protect the pxp context */
+       struct mutex mutex;
+
+       int id;
+};
+
+void intel_pxp_ctx_init(struct pxp_context *ctx);
+void intel_pxp_ctx_fini(struct pxp_context *ctx);
+
+#endif /* __INTEL_PXP_CONTEXT_H__ */
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

Re: [Intel-gfx] [RFC-v4 01/21] drm/i915/pxp: Introduce Intel PXP component

Hello Wilson,

Appreciate your code review feedback and apologize for the late replying.
I have made those modification as below and the change will reflect in the next version. (v10)

Best regards,
Sean

1.

Quoted 2 lines

So this is dead code then?
If the recommendation is not to enable it, and you don't even add it to CI for testing, what's it for?

Yes, I have changed it to default.

2.

Quoted 1 line

Mesa is but one user; the first but not last.

DONE

3.

Quoted 1 line

Just call it.

DONE

4.

Quoted 1 line

Not an error; the system can survive without, and userspace can detect the feature.

DONE

5.

Quoted 1 line

How often have we used uninit?

I expected uninit is called only when power of or i915 off, very rare chance.

6.

Quoted 1 line

Only include the types from a types.h

Got it, added intel_pxp_types.h accordingly

7.

Quoted 2 lines

You are not inside gt/, wise not to bake in such embedded assumptions.
i.e. all the container_of(pxp)>i915>pxp will be far less fragile with a pxp->global = &gt->i915->pxp.

I see, so container_of() isn't preferred, may I know if it's okay to keep the pointer of gt in the pxp init call, so later I can use pxp->gt->i915?

8.

Quoted 1 line

Reconsider; this should only be at most once per device.

It is called only for pxp init during the boot time. so hopefully I can still keep this log, but please let me know if you still suggest to remove it, thanks!

9.

Quoted 1 line

System includes first.

DONE

10.

Quoted 2 lines

As already stated, this randomisation does not add any security; and does not mean you can safely have multiple contexts without collision. What you had in mind was an ida.

Got it, I have removed the ctx.id, instead I just need ctx.inited bool

-----Original Message-----
From: Chris Wilson <[email protected]>
Sent: Thursday, December 10, 2020 12:41 AM
To: Huang, Sean Z <[email protected]>; [email protected]
Subject: Re: [Intel-gfx] [RFC-v4 01/21] drm/i915/pxp: Introduce Intel PXP component

Quoting Huang, Sean Z (2020-12-10 07:24:15)

Quoted 30 lines

PXP (Protected Xe Path) is an i915 componment, available on GEN12+, that helps to establish the hardware protected session and manage the status of the alive software session, as well as its life cycle.

This patch series is to allow the kernel space to create and manage a single hardware session (a.k.a default session or arbitrary session). So Mesa can allocate the protected buffer, which is encrypted with the leverage of the arbitrary hardware session.

---
 drivers/gpu/drm/i915/Kconfig                 | 19 +++++++++++++
 drivers/gpu/drm/i915/Makefile                |  5 ++++
 drivers/gpu/drm/i915/gt/intel_gt.c           |  7 +++++
 drivers/gpu/drm/i915/gt/intel_gt_types.h     |  3 ++
 drivers/gpu/drm/i915/pxp/intel_pxp.c         | 27 ++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp.h         | 29 ++++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_context.c | 27 ++++++++++++++++++  
drivers/gpu/drm/i915/pxp/intel_pxp_context.h | 22 +++++++++++++++
 8 files changed, 139 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp.h
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_context.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_context.h
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/Kconfig index 1e1cb245fca7..a42b9b031455 100644

drivers/gpu/drm/i915/Kconfig config DRM_I915_GVT_KVMGT · line 136

Quoted 7 lines
drivers/gpu/drm/i915/Kconfig +4 -0
@@ -130,6 +130,25 @@ config DRM_I915_GVT_KVMGT
          Choose this option if you want to enable KVMGT support for
          Intel GVT-g.
 
+config DRM_I915_PXP
+       bool "Enable Intel PXP support for Intel Gen12+ platform"
+       depends on DRM_I915
+       select INTEL_MEI_PXP

Doesn't exist.

Kconfig dependency resolution is not recursive; you probably will need a depends on INTEL_MEI

drivers/gpu/drm/i915/Kconfig config DRM_I915_GVT_KVMGT · line 137

Quoted 1 line
drivers/gpu/drm/i915/Kconfig +1 -0
+       default n

So this is dead code then?
If the recommendation is not to enable it, and you don't even add it to CI for testing, what's it for?

drivers/gpu/drm/i915/Kconfig config DRM_I915_GVT_KVMGT · line 150

Quoted 13 lines
drivers/gpu/drm/i915/Kconfig +13 -0
+       help
+         This option selects INTEL_MEI_ME if it isn't already selected to
+         enabled full PXP Services on Intel platforms.
+
+         PXP (Protected Xe Path) is an i915 componment, available on GEN12+,
+         that helps to establish the hardware protected session and manage
+         the status of the alive software session, as well as its life cycle.
+
+         This patch series is to allow the kernel space to create and
+         manage a single hardware session (a.k.a default session or
+         arbitrary session). So Mesa can allocate the protected buffer,
+         which is encrypted with the leverage of the arbitrary hardware
+         session.

Mesa is but one user; the first but not last.

Quoted 27 lines
drivers/gpu/drm/i915/Kconfig +1 -0
+
 menu "drm/i915 Debugging"
 depends on DRM_I915
 depends on EXPERT
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/Makefile index e5574e506a5c..99efac469cc2 100644

drivers/gpu/drm/i915/Makefile +5 -0
@@ -254,6 +254,11 @@ i915-y += \
 
 i915-y += i915_perf.o
 
+# Protected execution platform (PXP) support
+i915-$(CONFIG_DRM_I915_PXP) += \
+       pxp/intel_pxp.o \
+       pxp/intel_pxp_context.o
+
 # Post-mortem debug and GPU hang state capture
 i915-$(CONFIG_DRM_I915_CAPTURE_ERROR) += i915_gpu_error.o
 i915-$(CONFIG_DRM_I915_SELFTEST) += \ diff --git 

a/drivers/gpu/drm/i915/gt/intel_gt.c
b/drivers/gpu/drm/i915/gt/intel_gt.c
index 44f1d51e5ae5..d8e20ede7326 100644

drivers/gpu/drm/i915/gt/intel_gt.c int intel_gt_init(struct intel_gt *gt) · line 587

Quoted 4 lines
drivers/gpu/drm/i915/gt/intel_gt.c +1 -0
@@ -584,6 +584,12 @@ int intel_gt_init(struct intel_gt *gt)
        if (err)
                goto err_gt;
 
+       if (INTEL_GEN(gt->i915) >= 12) {

Just call it.

drivers/gpu/drm/i915/gt/intel_gt.c int intel_gt_init(struct intel_gt *gt) · line 589

Quoted 2 lines
drivers/gpu/drm/i915/gt/intel_gt.c +2 -0
+               err = intel_pxp_init(&gt->pxp);
+               if (err)

Not an error; the system can survive without, and userspace can detect the feature.

drivers/gpu/drm/i915/gt/intel_gt.c void intel_gt_driver_release(struct intel_gt *gt) · line 647

Quoted 11 lines
drivers/gpu/drm/i915/gt/intel_gt.c +4 -0
+                       goto err_gt;
+       }
+
        goto out_fw;
 err_gt:
        __intel_gt_disable(gt);
@@ -638,6 +644,7 @@ void intel_gt_driver_release(struct intel_gt *gt)
        if (vm) /* FIXME being called twice on error paths :( */
                i915_vm_put(vm);
 
+       intel_pxp_uninit(&gt->pxp);

How often have we used uninit?

drivers/gpu/drm/i915/gt/intel_gt_types.h line 26

Quoted 13 lines
drivers/gpu/drm/i915/gt/intel_gt.c +0 -0
        intel_gt_pm_fini(gt);
        intel_gt_fini_scratch(gt);
        intel_gt_fini_buffer_pool(gt); diff --git 

a/drivers/gpu/drm/i915/gt/intel_gt_types.h
b/drivers/gpu/drm/i915/gt/intel_gt_types.h
index 6d39a4a11bf3..05255632c2c0 100644

drivers/gpu/drm/i915/gt/intel_gt_types.h +1 -0
@@ -23,6 +23,7 @@
 #include "intel_rc6_types.h"
 #include "intel_rps_types.h"
 #include "intel_wakeref.h"
+#include "pxp/intel_pxp.h"

Only include the types from a types.h

Includes from other layers in their own section.

Quoted 19 lines
drivers/gpu/drm/i915/gt/intel_gt_types.h +2 -0
 struct drm_i915_private;
 struct i915_ggtt;
@@ -120,6 +121,8 @@ struct intel_gt {
                /* Slice/subslice/EU info */
                struct sseu_dev_info sseu;
        } info;
+
+       struct intel_pxp pxp;
 };
 
 enum intel_gt_scratch_field {
drivers/gpu/drm/i915/pxp/intel_pxp.c new file +0 -0
new file mode 100644
index 000000000000..ba43b2c923c7

drivers/gpu/drm/i915/pxp/intel_pxp.c line 10

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp.c new file +10 -0
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright(c) 2020 Intel Corporation.
+ */
+#include "i915_drv.h"
+#include "intel_pxp.h"
+#include "intel_pxp_context.h"
+
+int intel_pxp_init(struct intel_pxp *pxp) {
+       struct intel_gt *gt = container_of(pxp, struct intel_gt, pxp);

You are not inside gt/, wise not to bake in such embedded assumptions.
i.e. all the container_of(pxp)->i915->pxp will be far less fragile with a pxp->global = &gt->i915->pxp.

drivers/gpu/drm/i915/pxp/intel_pxp.c

Quoted 8 lines
drivers/gpu/drm/i915/pxp/intel_pxp.c new file +8 -0
+       /* PXP only available for GEN12+ */
+       if (INTEL_GEN(gt->i915) < 12)
+               return -ENODEV;
+
+       intel_pxp_ctx_init(&pxp->ctx);
+
+       drm_info(&gt->i915->drm, "Protected Xe Path (PXP) protected 
+ content support initialized\n");

Reconsider; this should only be at most once per device.

Quoted 43 lines
drivers/gpu/drm/i915/pxp/intel_pxp.c new file +5 -0
+       return 0;
+}
+
+void intel_pxp_uninit(struct intel_pxp *pxp) {
+       intel_pxp_ctx_fini(&pxp->ctx); }
drivers/gpu/drm/i915/pxp/intel_pxp.h new file +24 -0
new file mode 100644
index 000000000000..7c3d49a6a3ab
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#ifndef __INTEL_PXP_H__
+#define __INTEL_PXP_H__
+
+#include "intel_pxp_context.h"
+
+struct intel_pxp {
+       struct pxp_context ctx;
+};
+
+#ifdef CONFIG_DRM_I915_PXP
+int intel_pxp_init(struct intel_pxp *pxp); void 
+intel_pxp_uninit(struct intel_pxp *pxp); #else static inline int 
+intel_pxp_init(struct intel_pxp *pxp) {
+       return 0;
+}
+
+static inline void intel_pxp_uninit(struct intel_pxp *pxp) { } #endif
+
+#endif /* __INTEL_PXP_PM_H__ */
drivers/gpu/drm/i915/pxp/intel_pxp_context.c new file +0 -0
new file mode 100644
index 000000000000..5ffaf55dc7df

drivers/gpu/drm/i915/pxp/intel_pxp_context.c line 7

Quoted 7 lines
drivers/gpu/drm/i915/pxp/intel_pxp_context.c new file +7 -0
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#include "intel_pxp_context.h"
+#include <linux/random.h>

System includes first.

drivers/gpu/drm/i915/pxp/intel_pxp_context.c line 15

Quoted 7 lines
drivers/gpu/drm/i915/pxp/intel_pxp_context.c new file +7 -0
+
+/**
+ * intel_pxp_ctx_init - To init a pxp context.
+ * @ctx: pointer to ctx structure.
+ */
+void intel_pxp_ctx_init(struct pxp_context *ctx) {
+       get_random_bytes(&ctx->id, sizeof(ctx->id));

As already stated, this randomisation does not add any security; and does not mean you can safely have multiple contexts without collision.

What you had in mind was an ida.

Quoted 43 lines
drivers/gpu/drm/i915/pxp/intel_pxp_context.c new file +11 -0
+
+       mutex_init(&ctx->mutex);
+}
+
+/**
+ * intel_pxp_ctx_fini - To finish the pxp context.
+ * @ctx: pointer to ctx structure.
+ */
+void intel_pxp_ctx_fini(struct pxp_context *ctx) {
+       ctx->id = 0;
+}
drivers/gpu/drm/i915/pxp/intel_pxp_context.h new file +22 -1
new file mode 100644
index 000000000000..953a2e700931
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#ifndef __INTEL_PXP_CONTEXT_H__
+#define __INTEL_PXP_CONTEXT_H__
+
+#include <linux/mutex.h>
+
+/* struct pxp_context - Represents combined view of driver and 
+logical HW states. */ struct pxp_context {
+       /** @mutex: mutex to protect the pxp context */
+       struct mutex mutex;
+
+       int id;
+};
+
+void intel_pxp_ctx_init(struct pxp_context *ctx); void 
+intel_pxp_ctx_fini(struct pxp_context *ctx);
+
+#endif /* __INTEL_PXP_CONTEXT_H__ */
--

2.17.1

Quoted 5 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

RFC v4 2/21 drm/i915/pxp: set KCR reg init during the boot time

In reply to Huang, Sean Z

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.

---
 drivers/gpu/drm/i915/pxp/intel_pxp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/i915/pxp/intel_pxp.c +8 -0
index ba43b2c923c7..c4815950567d 100644
@@ -6,6 +6,12 @@
 #include "intel_pxp.h"
 #include "intel_pxp_context.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 intel_pxp_init(struct intel_pxp *pxp)
 {
 	struct intel_gt *gt = container_of(pxp, struct intel_gt, pxp);
@@ -16,6 +22,8 @@ int intel_pxp_init(struct intel_pxp *pxp)
 
 	intel_pxp_ctx_init(&pxp->ctx);
 
+	intel_uncore_write(gt->uncore, KCR_INIT, KCR_INIT_ALLOW_DISPLAY_ME_WRITES);
+
 	drm_info(&gt->i915->drm, "Protected Xe Path (PXP) protected content support initialized\n");
 
 	return 0;
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

Re: [Intel-gfx] [RFC-v4 02/21] drm/i915/pxp: set KCR reg init during the boot time

Quoting Huang, Sean Z (2020-12-10 07:24:16)

Quoted 15 lines

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.

---
 drivers/gpu/drm/i915/pxp/intel_pxp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/i915/pxp/intel_pxp.c +0 -0
index ba43b2c923c7..c4815950567d 100644

drivers/gpu/drm/i915/pxp/intel_pxp.c line 13

Quoted 8 lines
drivers/gpu/drm/i915/pxp/intel_pxp.c +5 -0
@@ -6,6 +6,12 @@
 #include "intel_pxp.h"
 #include "intel_pxp_context.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))

That's a regular masked register.

#define KCR_INIT_ALLOW_DISPLAY_ME_WRITES REG_BIT(14) intel_uncore_write(gt->uncore,

		   KCR_INIT, _MASKED_ENABLE(KCR_INIT_ALLOW_DISPLAY_ME_WRITES));
Quoted 21 lines
drivers/gpu/drm/i915/pxp/intel_pxp.c +3 -0
+
 int intel_pxp_init(struct intel_pxp *pxp)
 {
        struct intel_gt *gt = container_of(pxp, struct intel_gt, pxp);
@@ -16,6 +22,8 @@ int intel_pxp_init(struct intel_pxp *pxp)
 
        intel_pxp_ctx_init(&pxp->ctx);
 
+       intel_uncore_write(gt->uncore, KCR_INIT, KCR_INIT_ALLOW_DISPLAY_ME_WRITES);
+
        drm_info(&gt->i915->drm, "Protected Xe Path (PXP) protected content support initialized\n");
 
        return 0;
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw

Re: [Intel-gfx] [RFC-v4 02/21] drm/i915/pxp: set KCR reg init during the boot time

In reply to Huang, Sean Z

Quoting Huang, Sean Z (2020-12-10 07:24:16)

Quoted 28 lines

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.

---
 drivers/gpu/drm/i915/pxp/intel_pxp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/i915/pxp/intel_pxp.c +6 -0
index ba43b2c923c7..c4815950567d 100644
@@ -6,6 +6,12 @@
 #include "intel_pxp.h"
 #include "intel_pxp_context.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 intel_pxp_init(struct intel_pxp *pxp)
 {
        struct intel_gt *gt = container_of(pxp, struct intel_gt, pxp);

drivers/gpu/drm/i915/pxp/intel_pxp.c int intel_pxp_init(struct intel_pxp *pxp) · line 25

Quoted 4 lines
drivers/gpu/drm/i915/pxp/intel_pxp.c +1 -0
@@ -16,6 +22,8 @@ int intel_pxp_init(struct intel_pxp *pxp)
 
        intel_pxp_ctx_init(&pxp->ctx);
 
+       intel_uncore_write(gt->uncore, KCR_INIT, KCR_INIT_ALLOW_DISPLAY_ME_WRITES);

So this looks dangerous to leave enabled after driver unload? -Chris
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw

Re: [Intel-gfx] [RFC-v4 02/21] drm/i915/pxp: set KCR reg init during the boot time

Hi Wilson,

Thanks for bring up this. This is a necessary step during the booting to allow the ME communicate with display but we don't need turn off for unload actually.

Best regards,
Sean

-----Original Message-----
From: Chris Wilson <[email protected]>
Sent: Thursday, December 10, 2020 12:45 AM
To: Huang, Sean Z <[email protected]>; [email protected]
Subject: Re: [Intel-gfx] [RFC-v4 02/21] drm/i915/pxp: set KCR reg init during the boot time

Quoting Huang, Sean Z (2020-12-10 07:24:16)

Quoted 28 lines

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.

---
 drivers/gpu/drm/i915/pxp/intel_pxp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/i915/pxp/intel_pxp.c +7 -0
index ba43b2c923c7..c4815950567d 100644
@@ -6,6 +6,12 @@
 #include "intel_pxp.h"
 #include "intel_pxp_context.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 intel_pxp_init(struct intel_pxp *pxp)  {
        struct intel_gt *gt = container_of(pxp, struct intel_gt, pxp); 

drivers/gpu/drm/i915/pxp/intel_pxp.c int intel_pxp_init(struct intel_pxp *pxp) · line 26

Quoted 5 lines
drivers/gpu/drm/i915/pxp/intel_pxp.c +2 -0
@@ -16,6 +22,8 @@ int intel_pxp_init(struct intel_pxp *pxp)
 
        intel_pxp_ctx_init(&pxp->ctx);
 
+       intel_uncore_write(gt->uncore, KCR_INIT, 
+ KCR_INIT_ALLOW_DISPLAY_ME_WRITES);

So this looks dangerous to leave enabled after driver unload? -Chris
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw

RFC v4 3/21 drm/i915/pxp: Implement funcs to create the TEE channel

In reply to Huang, Sean Z

Implement the funcs to create the TEE channel, so kernel can send the TEE commands directly to TEE for creating the arbitrary (defualt) session.

---
 drivers/gpu/drm/i915/Makefile            |   3 +-
 drivers/gpu/drm/i915/i915_drv.c          |   1 +
 drivers/gpu/drm/i915/i915_drv.h          |   6 ++
 drivers/gpu/drm/i915/pxp/intel_pxp.c     |   5 +
 drivers/gpu/drm/i915/pxp/intel_pxp_tee.c | 132 +++++++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_tee.h |  14 +++
 include/drm/i915_component.h             |   1 +
 include/drm/i915_pxp_tee_interface.h     |  45 ++++++++
 8 files changed, 206 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_tee.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_tee.h
 create mode 100644 include/drm/i915_pxp_tee_interface.h
drivers/gpu/drm/i915/Makefile +2 -1
index 99efac469cc2..c703dbd91158 100644
@@ -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_tee.o
 
 # Post-mortem debug and GPU hang state capture
 i915-$(CONFIG_DRM_I915_CAPTURE_ERROR) += i915_gpu_error.o
drivers/gpu/drm/i915/i915_drv.c +1 -0
index 5708e11d917b..9299a456adb0 100644
@@ -322,6 +322,7 @@ static int i915_driver_early_probe(struct drm_i915_private *dev_priv)
 	mutex_init(&dev_priv->wm.wm_mutex);
 	mutex_init(&dev_priv->pps_mutex);
 	mutex_init(&dev_priv->hdcp_comp_mutex);
+	mutex_init(&dev_priv->pxp_tee_comp_mutex);
 
 	i915_memcpy_init_early(dev_priv);
 	intel_runtime_pm_init_early(&dev_priv->runtime_pm);
drivers/gpu/drm/i915/i915_drv.h +6 -0
index fc1090c6889c..66f91d8a575b 100644
@@ -1216,6 +1216,12 @@ struct drm_i915_private {
 	/* Mutex to protect the above hdcp component related values. */
 	struct mutex hdcp_comp_mutex;
 
+	struct i915_pxp_comp_master *pxp_tee_master;
+	bool pxp_tee_comp_added;
+
+	/* Mutex to protect the above pxp_tee component related values. */
+	struct mutex pxp_tee_comp_mutex;
+
 	I915_SELFTEST_DECLARE(struct i915_selftest_stash selftest;)
 
 	/*
drivers/gpu/drm/i915/pxp/intel_pxp.c +5 -0
index c4815950567d..4104dd89ca7f 100644
@@ -5,6 +5,7 @@
 #include "i915_drv.h"
 #include "intel_pxp.h"
 #include "intel_pxp_context.h"
+#include "intel_pxp_tee.h"
 
 /* KCR register definitions */
 #define KCR_INIT            _MMIO(0x320f0)
@@ -24,6 +25,8 @@ int intel_pxp_init(struct intel_pxp *pxp)
 
 	intel_uncore_write(gt->uncore, KCR_INIT, KCR_INIT_ALLOW_DISPLAY_ME_WRITES);
 
+	intel_pxp_tee_component_init(pxp);
+
 	drm_info(&gt->i915->drm, "Protected Xe Path (PXP) protected content support initialized\n");
 
 	return 0;
@@ -31,5 +34,7 @@ int intel_pxp_init(struct intel_pxp *pxp)
 
 void intel_pxp_uninit(struct intel_pxp *pxp)
 {
+	intel_pxp_tee_component_fini(pxp);
+
 	intel_pxp_ctx_fini(&pxp->ctx);
 }
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c new file +132 -0

132 lines not on this page · raw message

drivers/gpu/drm/i915/pxp/intel_pxp_tee.h new file +14 -0
new file mode 100644
index 000000000000..4b5e3edb1d9b
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#ifndef __INTEL_PXP_TEE_H__
+#define __INTEL_PXP_TEE_H__
+
+#include "intel_pxp.h"
+
+void intel_pxp_tee_component_init(struct intel_pxp *pxp);
+void intel_pxp_tee_component_fini(struct intel_pxp *pxp);
+
+#endif /* __INTEL_PXP_TEE_H__ */
include/drm/i915_component.h +1 -0
index 55c3b123581b..c1e2a43d2d1e 100644
@@ -29,6 +29,7 @@
 enum i915_component_type {
 	I915_COMPONENT_AUDIO = 1,
 	I915_COMPONENT_HDCP,
+	I915_COMPONENT_PXP
 };
 
 /* MAX_PORT is the number of port
include/drm/i915_pxp_tee_interface.h new file +45 -0

45 lines not on this page · raw message

Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw

Re: [Intel-gfx] [RFC-v4 03/21] drm/i915/pxp: Implement funcs to create the TEE channel

Quoting Huang, Sean Z (2020-12-10 07:24:17)

Quoted 104 lines

Implement the funcs to create the TEE channel, so kernel can send the TEE commands directly to TEE for creating the arbitrary (defualt) session.

---
 drivers/gpu/drm/i915/Makefile            |   3 +-
 drivers/gpu/drm/i915/i915_drv.c          |   1 +
 drivers/gpu/drm/i915/i915_drv.h          |   6 ++
 drivers/gpu/drm/i915/pxp/intel_pxp.c     |   5 +
 drivers/gpu/drm/i915/pxp/intel_pxp_tee.c | 132 +++++++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_tee.h |  14 +++
 include/drm/i915_component.h             |   1 +
 include/drm/i915_pxp_tee_interface.h     |  45 ++++++++
 8 files changed, 206 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_tee.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_tee.h
 create mode 100644 include/drm/i915_pxp_tee_interface.h
drivers/gpu/drm/i915/Makefile +2 -1
index 99efac469cc2..c703dbd91158 100644
@@ -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_tee.o
 
 # Post-mortem debug and GPU hang state capture
 i915-$(CONFIG_DRM_I915_CAPTURE_ERROR) += i915_gpu_error.o
drivers/gpu/drm/i915/i915_drv.c +1 -0
index 5708e11d917b..9299a456adb0 100644
@@ -322,6 +322,7 @@ static int i915_driver_early_probe(struct drm_i915_private *dev_priv)
        mutex_init(&dev_priv->wm.wm_mutex);
        mutex_init(&dev_priv->pps_mutex);
        mutex_init(&dev_priv->hdcp_comp_mutex);
+       mutex_init(&dev_priv->pxp_tee_comp_mutex);
 
        i915_memcpy_init_early(dev_priv);
        intel_runtime_pm_init_early(&dev_priv->runtime_pm);
drivers/gpu/drm/i915/i915_drv.h +6 -0
index fc1090c6889c..66f91d8a575b 100644
@@ -1216,6 +1216,12 @@ struct drm_i915_private {
        /* Mutex to protect the above hdcp component related values. */
        struct mutex hdcp_comp_mutex;
 
+       struct i915_pxp_comp_master *pxp_tee_master;
+       bool pxp_tee_comp_added;
+
+       /* Mutex to protect the above pxp_tee component related values. */
+       struct mutex pxp_tee_comp_mutex;
+
        I915_SELFTEST_DECLARE(struct i915_selftest_stash selftest;)
 
        /*
drivers/gpu/drm/i915/pxp/intel_pxp.c +5 -0
index c4815950567d..4104dd89ca7f 100644
@@ -5,6 +5,7 @@
 #include "i915_drv.h"
 #include "intel_pxp.h"
 #include "intel_pxp_context.h"
+#include "intel_pxp_tee.h"
 
 /* KCR register definitions */
 #define KCR_INIT            _MMIO(0x320f0)
@@ -24,6 +25,8 @@ int intel_pxp_init(struct intel_pxp *pxp)
 
        intel_uncore_write(gt->uncore, KCR_INIT, KCR_INIT_ALLOW_DISPLAY_ME_WRITES);
 
+       intel_pxp_tee_component_init(pxp);
+
        drm_info(&gt->i915->drm, "Protected Xe Path (PXP) protected content support initialized\n");
 
        return 0;
@@ -31,5 +34,7 @@ int intel_pxp_init(struct intel_pxp *pxp)
 
 void intel_pxp_uninit(struct intel_pxp *pxp)
 {
+       intel_pxp_tee_component_fini(pxp);
+
        intel_pxp_ctx_fini(&pxp->ctx);
 }
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c new file +7 -0
new file mode 100644
index 000000000000..ca6b61099aee
@@ -0,0 +1,132 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright(c) 2020 Intel Corporation.
+ */
+
+#include <linux/component.h>
+#include "drm/i915_pxp_tee_interface.h"

drivers/gpu/drm/i915/pxp/intel_pxp_tee.c line 17

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c new file +10 -0
+#include "drm/i915_component.h"
+#include  "i915_drv.h"
+#include "intel_pxp.h"
+#include "intel_pxp_context.h"
+#include "intel_pxp_tee.h"
+
+static int intel_pxp_tee_io_message(struct intel_pxp *pxp,
+                                   void *msg_in, u32 msg_in_size,
+                                   void *msg_out, u32 *msg_out_size_ptr,
+                                   u32 msg_out_buf_size)

Unused. Breaks compilation.

Quoted 52 lines
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c new file +52 -0
+{
+       int ret;
+       struct intel_gt *gt = container_of(pxp, typeof(*gt), pxp);
+       struct drm_i915_private *i915 = gt->i915;
+       struct i915_pxp_comp_master *pxp_tee_master = i915->pxp_tee_master;
+
+       if (!pxp_tee_master || !msg_in || !msg_out || !msg_out_size_ptr)
+               return -EINVAL;
+
+       lockdep_assert_held(&i915->pxp_tee_comp_mutex);
+
+       if (drm_debug_enabled(DRM_UT_DRIVER))
+               print_hex_dump(KERN_DEBUG, "TEE input message binaries:",
+                              DUMP_PREFIX_OFFSET, 4, 4, msg_in, msg_in_size, true);
+
+       ret = pxp_tee_master->ops->send(pxp_tee_master->tee_dev, msg_in, msg_in_size);
+       if (ret) {
+               drm_err(&i915->drm, "Failed to send TEE message\n");
+               return -EFAULT;
+       }
+
+       ret = pxp_tee_master->ops->receive(pxp_tee_master->tee_dev, msg_out, msg_out_buf_size);
+       if (ret < 0) {
+               drm_err(&i915->drm, "Failed to receive TEE message\n");
+               return -EFAULT;
+       }
+
+       if (ret > msg_out_buf_size) {
+               drm_err(&i915->drm, "Failed to receive TEE message due to unexpected output size\n");
+               return -EFAULT;
+       }
+
+       *msg_out_size_ptr = ret;
+       ret = 0;
+
+       if (drm_debug_enabled(DRM_UT_DRIVER))
+               print_hex_dump(KERN_DEBUG, "TEE output message binaries:",
+                              DUMP_PREFIX_OFFSET, 4, 4, msg_out, *msg_out_size_ptr, true);
+
+       return ret;
+}
+
+/**
+ * i915_pxp_tee_component_bind - bind funciton to pass the function pointers to pxp_tee
+ * @i915_kdev: pointer to i915 kernel device
+ * @tee_kdev: pointer to tee kernel device
+ * @data: pointer to pxp_tee_master containing the function pointers
+ *
+ * This bind function is called during the system boot or resume from system sleep.
+ *
+ * Return: return 0 if successful.
+ */

drivers/gpu/drm/i915/pxp/intel_pxp_tee.c line 79

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c new file +10 -0
+static int i915_pxp_tee_component_bind(struct device *i915_kdev,
+                                      struct device *tee_kdev, void *data)
+{
+       struct drm_i915_private *i915 = kdev_to_i915(i915_kdev);
+
+       if (!i915 || !tee_kdev || !data)
+               return -EPERM;
+
+       mutex_lock(&i915->pxp_tee_comp_mutex);
+       i915->pxp_tee_master = (struct i915_pxp_comp_master *)data;

Random cast.

drivers/gpu/drm/i915/pxp/intel_pxp_tee.c line 81

Quoted 2 lines
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c new file +2 -0
+       i915->pxp_tee_master->tee_dev = tee_kdev;
+       mutex_unlock(&i915->pxp_tee_comp_mutex);

Mutex usage throughout the series is still very ill considered. In this case, what are you protecting? Does it need protecting? If it does, where are the validation checks?

Quoted 28 lines
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c new file +28 -0
+
+       return 0;
+}
+
+static void i915_pxp_tee_component_unbind(struct device *i915_kdev,
+                                         struct device *tee_kdev, void *data)
+{
+       struct drm_i915_private *i915 = kdev_to_i915(i915_kdev);
+
+       if (!i915 || !tee_kdev || !data)
+               return;
+
+       mutex_lock(&i915->pxp_tee_comp_mutex);
+       i915->pxp_tee_master = NULL;
+       mutex_unlock(&i915->pxp_tee_comp_mutex);
+}
+
+static const struct component_ops i915_pxp_tee_component_ops = {
+       .bind   = i915_pxp_tee_component_bind,
+       .unbind = i915_pxp_tee_component_unbind,
+};
+
+void intel_pxp_tee_component_init(struct intel_pxp *pxp)
+{
+       int ret;
+       struct intel_gt *gt = container_of(pxp, typeof(*gt), pxp);
+       struct drm_i915_private *i915 = gt->i915;
+

drivers/gpu/drm/i915/pxp/intel_pxp_tee.c line 119

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c new file +10 -0
+       ret = component_add_typed(i915->drm.dev, &i915_pxp_tee_component_ops,
+                                 I915_COMPONENT_PXP);
+       if (ret < 0) {
+               drm_err(&i915->drm, "Failed at component add(%d)\n", ret);
+               return;
+       }
+
+       mutex_lock(&i915->pxp_tee_comp_mutex);
+       i915->pxp_tee_comp_added = true;
+       mutex_unlock(&i915->pxp_tee_comp_mutex);

Seriously, please review all your mutex usage. Write down what you think it protects. And then think again.

drivers/gpu/drm/i915/pxp/intel_pxp_tee.c line 129

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c new file +10 -0
+}
+
+void intel_pxp_tee_component_fini(struct intel_pxp *pxp)
+{
+       struct intel_gt *gt = container_of(pxp, typeof(*gt), pxp);
+       struct drm_i915_private *i915 = gt->i915;
+
+       mutex_lock(&i915->pxp_tee_comp_mutex);
+       i915->pxp_tee_comp_added = false;
+       mutex_unlock(&i915->pxp_tee_comp_mutex);

Well that was a waste of time.

Quoted 59 lines
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c new file +3 -0
+
+       component_del(i915->drm.dev, &i915_pxp_tee_component_ops);
+}
drivers/gpu/drm/i915/pxp/intel_pxp_tee.h new file +14 -0
new file mode 100644
index 000000000000..4b5e3edb1d9b
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#ifndef __INTEL_PXP_TEE_H__
+#define __INTEL_PXP_TEE_H__
+
+#include "intel_pxp.h"
+
+void intel_pxp_tee_component_init(struct intel_pxp *pxp);
+void intel_pxp_tee_component_fini(struct intel_pxp *pxp);
+
+#endif /* __INTEL_PXP_TEE_H__ */
include/drm/i915_component.h +1 -0
index 55c3b123581b..c1e2a43d2d1e 100644
@@ -29,6 +29,7 @@
 enum i915_component_type {
        I915_COMPONENT_AUDIO = 1,
        I915_COMPONENT_HDCP,
+       I915_COMPONENT_PXP
 };
 
 /* MAX_PORT is the number of port
include/drm/i915_pxp_tee_interface.h new file +18 -0
new file mode 100644
index 000000000000..3999e255e145
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2020 Intel Corporation
+ *
+ * Authors:
+ * Vitaly Lubart <[email protected]>
+ */
+
+#ifndef _I915_PXP_TEE_INTERFACE_H_
+#define _I915_PXP_TEE_INTERFACE_H_
+
+#include <linux/mutex.h>
+#include <linux/device.h>
+
+/**
+ * struct i915_pxp_component_ops - ops for PXP services.
+ * @owner: Module providing the ops
+ * @send: sends data to PXP

include/drm/i915_pxp_tee_interface.h line 28

Quoted 10 lines
include/drm/i915_pxp_tee_interface.h new file +10 -0
+ * @receive: receives data from PXP
+ */
+struct i915_pxp_component_ops {
+       /**
+        * @owner: owner of the module provding the ops
+        */
+       struct module *owner;
+
+       int (*send)(struct device *dev, const void *message, size_t size);
+       int (*receive)(struct device *dev, void *buffer, size_t size);

send & recv

Be consistent with your nouns.

Quoted 24 lines
include/drm/i915_pxp_tee_interface.h new file +17 -0
+};
+
+/**
+ * struct i915_pxp_component_master - Used for communication between i915
+ * and TEE drivers for the PXP services
+ * @tee_dev: device that provide the PXP service from TEE Bus.
+ * @pxp_ops: Ops implemented by TEE driver, used by i915 driver.
+ */
+struct i915_pxp_comp_master {
+       struct device *tee_dev;
+       const struct i915_pxp_component_ops *ops;
+
+       /* To protect the above members. */
+       struct mutex mutex;
+};
+
+#endif /* _I915_TEE_PXP_INTERFACE_H_ */
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#10 lore raw

RFC v4 4/21 drm/i915/pxp: Create the arbitrary session after boot

In reply to Huang, Sean Z

Create the arbitrary session, with the fixed session id 0xf, after system boot, for the case that application allocates the protected buffer without establishing any protection session. Because the hardware requires at least one alive session for protected buffer creation. This arbitrary session needs to be re-created after teardown or power event because hardware encryption key won't be valid after such cases.

---
 drivers/gpu/drm/i915/Makefile                |   1 +
 drivers/gpu/drm/i915/pxp/intel_pxp.c         |   1 +
 drivers/gpu/drm/i915/pxp/intel_pxp.h         |  16 ++
 drivers/gpu/drm/i915/pxp/intel_pxp_arb.c     | 152 +++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_arb.h     |  36 +++++
 drivers/gpu/drm/i915/pxp/intel_pxp_context.h |   5 +
 drivers/gpu/drm/i915/pxp/intel_pxp_tee.c     |  38 +++++
 drivers/gpu/drm/i915/pxp/intel_pxp_tee.h     |   6 +
 8 files changed, 255 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_arb.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_arb.h
drivers/gpu/drm/i915/Makefile +1 -0
index c703dbd91158..0710cc522f38 100644
@@ -257,6 +257,7 @@ i915-y += i915_perf.o
 # Protected execution platform (PXP) support
 i915-$(CONFIG_DRM_I915_PXP) += \
 	pxp/intel_pxp.o \
+	pxp/intel_pxp_arb.o \
 	pxp/intel_pxp_context.o \
 	pxp/intel_pxp_tee.o
 
drivers/gpu/drm/i915/pxp/intel_pxp.c +1 -0
index 4104dd89ca7f..67bdaeb79b40 100644
@@ -6,6 +6,7 @@
 #include "intel_pxp.h"
 #include "intel_pxp_context.h"
 #include "intel_pxp_tee.h"
+#include "intel_pxp_arb.h"
 
 /* KCR register definitions */
 #define KCR_INIT            _MMIO(0x320f0)
drivers/gpu/drm/i915/pxp/intel_pxp.h +16 -0
index 7c3d49a6a3ab..1841a9aa972d 100644
@@ -8,6 +8,22 @@
 
 #include "intel_pxp_context.h"
 
+enum pxp_session_types {
+	SESSION_TYPE_TYPE0 = 0,
+	SESSION_TYPE_TYPE1 = 1,
+
+	SESSION_TYPE_MAX
+};
+
+enum pxp_protection_modes {
+	PROTECTION_MODE_NONE = 0,
+	PROTECTION_MODE_LM   = 2,
+	PROTECTION_MODE_HM   = 3,
+	PROTECTION_MODE_SM   = 6,
+
+	PROTECTION_MODE_ALL
+};
+
 struct intel_pxp {
 	struct pxp_context ctx;
 };
drivers/gpu/drm/i915/pxp/intel_pxp_arb.c new file +152 -0

152 lines not on this page · raw message

drivers/gpu/drm/i915/pxp/intel_pxp_arb.h new file +36 -0
new file mode 100644
index 000000000000..61bad3ada20f
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#ifndef __INTEL_PXP_ARB_H__
+#define __INTEL_PXP_ARB_H__
+
+#include "intel_pxp.h"
+
+/**
+ * struct pxp_protected_session - structure to track all active sessions.
+ */
+struct pxp_protected_session {
+	/** @index: Numeric identifier for this protected session */
+	int index;
+	/** @type: Type of session */
+	int type;
+	/** @protection_mode: mode of protection requested */
+	int protection_mode;
+	/** @context_id: context identifier of the protected session requestor */
+	int context_id;
+
+	/**
+	 * @is_in_play: indicates whether the session has been established
+	 *              in the HW root of trust if this flag is false, it
+	 *              indicates an application has reserved this session,
+	 *              but has not * established the session in the
+	 *              hardware yet.
+	 */
+	bool is_in_play;
+};
+
+int intel_pxp_arb_create_session(struct intel_pxp *pxp);
+
+#endif /* __INTEL_PXP_ARB_H__ */
drivers/gpu/drm/i915/pxp/intel_pxp_context.h +5 -0
index 953a2e700931..e37125ed7434 100644
@@ -13,7 +13,12 @@ struct pxp_context {
 	/** @mutex: mutex to protect the pxp context */
 	struct mutex mutex;
 
+	void *arb_session;
+	u32 arb_session_pxp_tag;
+
 	int id;
+
+	bool flag_display_hm_surface_keys;
 };
 
 void intel_pxp_ctx_init(struct pxp_context *ctx);
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c +38 -0
index ca6b61099aee..816a6d5a54e4 100644
@@ -10,6 +10,7 @@
 #include "intel_pxp.h"
 #include "intel_pxp_context.h"
 #include "intel_pxp_tee.h"
+#include "intel_pxp_arb.h"
 
 static int intel_pxp_tee_io_message(struct intel_pxp *pxp,
 				    void *msg_in, u32 msg_in_size,
@@ -70,7 +71,9 @@ static int intel_pxp_tee_io_message(struct intel_pxp *pxp,
 static int i915_pxp_tee_component_bind(struct device *i915_kdev,
 				       struct device *tee_kdev, void *data)
 {
+	int ret;
 	struct drm_i915_private *i915 = kdev_to_i915(i915_kdev);
+	struct intel_pxp *pxp = &i915->gt.pxp;
 
 	if (!i915 || !tee_kdev || !data)
 		return -EPERM;
@@ -80,6 +83,16 @@ static int i915_pxp_tee_component_bind(struct device *i915_kdev,
 	i915->pxp_tee_master->tee_dev = tee_kdev;
 	mutex_unlock(&i915->pxp_tee_comp_mutex);
 
+	mutex_lock(&pxp->ctx.mutex);
+	/* Create arb session only if tee is ready, during system boot or sleep/resume */
+	ret = intel_pxp_arb_create_session(pxp);
+	mutex_unlock(&pxp->ctx.mutex);
+
+	if (ret) {
+		drm_err(&i915->drm, "Failed to create arb session ret=[%d]\n", ret);
+		return ret;
+	}
+
 	return 0;
 }
 
@@ -130,3 +143,28 @@ void intel_pxp_tee_component_fini(struct intel_pxp *pxp)
 
 	component_del(i915->drm.dev, &i915_pxp_tee_component_ops);
 }
+
+int intel_pxp_tee_cmd_create_arb_session(struct intel_pxp *pxp)
+{
+	int ret;
+	u32 msg_out_size_received = 0;
+	u32 msg_in[PXP_TEE_ARB_CMD_DW_LEN] = PXP_TEE_ARB_CMD_BIN;
+	u32 msg_out[PXP_TEE_ARB_CMD_DW_LEN] = {0};
+	struct intel_gt *gt = container_of(pxp, typeof(*gt), pxp);
+	struct drm_i915_private *i915 = gt->i915;
+
+	mutex_lock(&i915->pxp_tee_comp_mutex);
+
+	ret = intel_pxp_tee_io_message(pxp,
+				       &msg_in,
+				       sizeof(msg_in),
+				       &msg_out, &msg_out_size_received,
+				       sizeof(msg_out));
+
+	mutex_unlock(&i915->pxp_tee_comp_mutex);
+
+	if (ret)
+		drm_err(&i915->drm, "Failed to send/receive tee message\n");
+
+	return ret;
+}
drivers/gpu/drm/i915/pxp/intel_pxp_tee.h +6 -0
index 4b5e3edb1d9b..757a54208a4d 100644
@@ -11,4 +11,10 @@
 void intel_pxp_tee_component_init(struct intel_pxp *pxp);
 void intel_pxp_tee_component_fini(struct intel_pxp *pxp);
 
+int intel_pxp_tee_cmd_create_arb_session(struct intel_pxp *pxp);
+
+/* TEE command to create the arbitrary session */
+#define PXP_TEE_ARB_CMD_BIN {0x00040000, 0x0000001e, 0x00000000, 0x00000008, 0x00000002, 0x0000000f}
+#define PXP_TEE_ARB_CMD_DW_LEN (6)
+
 #endif /* __INTEL_PXP_TEE_H__ */
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw

Re: [Intel-gfx] [RFC-v4 04/21] drm/i915/pxp: Create the arbitrary session after boot

Quoting Huang, Sean Z (2020-12-10 07:24:18)

Quoted 96 lines

Create the arbitrary session, with the fixed session id 0xf, after system boot, for the case that application allocates the protected buffer without establishing any protection session. Because the hardware requires at least one alive session for protected buffer creation. This arbitrary session needs to be re-created after teardown or power event because hardware encryption key won't be valid after such cases.

---
 drivers/gpu/drm/i915/Makefile                |   1 +
 drivers/gpu/drm/i915/pxp/intel_pxp.c         |   1 +
 drivers/gpu/drm/i915/pxp/intel_pxp.h         |  16 ++
 drivers/gpu/drm/i915/pxp/intel_pxp_arb.c     | 152 +++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_arb.h     |  36 +++++
 drivers/gpu/drm/i915/pxp/intel_pxp_context.h |   5 +
 drivers/gpu/drm/i915/pxp/intel_pxp_tee.c     |  38 +++++
 drivers/gpu/drm/i915/pxp/intel_pxp_tee.h     |   6 +
 8 files changed, 255 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_arb.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_arb.h
drivers/gpu/drm/i915/Makefile +1 -0
index c703dbd91158..0710cc522f38 100644
@@ -257,6 +257,7 @@ i915-y += i915_perf.o
 # Protected execution platform (PXP) support
 i915-$(CONFIG_DRM_I915_PXP) += \
        pxp/intel_pxp.o \
+       pxp/intel_pxp_arb.o \
        pxp/intel_pxp_context.o \
        pxp/intel_pxp_tee.o
 
drivers/gpu/drm/i915/pxp/intel_pxp.c +1 -0
index 4104dd89ca7f..67bdaeb79b40 100644
@@ -6,6 +6,7 @@
 #include "intel_pxp.h"
 #include "intel_pxp_context.h"
 #include "intel_pxp_tee.h"
+#include "intel_pxp_arb.h"
 
 /* KCR register definitions */
 #define KCR_INIT            _MMIO(0x320f0)
drivers/gpu/drm/i915/pxp/intel_pxp.h +16 -0
index 7c3d49a6a3ab..1841a9aa972d 100644
@@ -8,6 +8,22 @@
 
 #include "intel_pxp_context.h"
 
+enum pxp_session_types {
+       SESSION_TYPE_TYPE0 = 0,
+       SESSION_TYPE_TYPE1 = 1,
+
+       SESSION_TYPE_MAX
+};
+
+enum pxp_protection_modes {
+       PROTECTION_MODE_NONE = 0,
+       PROTECTION_MODE_LM   = 2,
+       PROTECTION_MODE_HM   = 3,
+       PROTECTION_MODE_SM   = 6,
+
+       PROTECTION_MODE_ALL
+};
+
 struct intel_pxp {
        struct pxp_context ctx;
 };
drivers/gpu/drm/i915/pxp/intel_pxp_arb.c new file +17 -0
new file mode 100644
index 000000000000..c1ad45b83478
@@ -0,0 +1,152 @@
+// 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_arb.h"
+#include "intel_pxp.h"
+#include "intel_pxp_context.h"
+#include "intel_pxp_tee.h"
+
+#define GEN12_KCR_SIP _MMIO(0x32260) /* KCR type0 session in play 0-31 */
+
+/* Arbitrary session */
+#define ARB_SESSION_INDEX 0xf

drivers/gpu/drm/i915/pxp/intel_pxp_arb.c line 27

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp_arb.c new file +10 -0
+#define ARB_SESSION_TYPE SESSION_TYPE_TYPE0
+#define ARB_PROTECTION_MODE PROTECTION_MODE_HM
+
+static bool is_hw_arb_session_in_play(struct intel_pxp *pxp)
+{
+       u32 regval_sip = 0;
+       intel_wakeref_t wakeref;
+       struct intel_gt *gt = container_of(pxp, struct intel_gt, pxp);
+
+       with_intel_runtime_pm(&gt->i915->runtime_pm, wakeref) {

with_intel_runtime_pm(uncore->rpm, wakeref)

Quoted 12 lines
drivers/gpu/drm/i915/pxp/intel_pxp_arb.c new file +12 -0
+               regval_sip = intel_uncore_read(gt->uncore, GEN12_KCR_SIP);
+       }
+
+       return regval_sip & BIT(ARB_SESSION_INDEX);
+}
+
+/* wait hw session_in_play reg to match the current sw state */
+static int wait_arb_hw_sw_state(struct intel_pxp *pxp)
+{
+       const int max_retry = 10;
+       const int ms_delay = 10;
+       int retry = 0;

drivers/gpu/drm/i915/pxp/intel_pxp_arb.c line 49

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp_arb.c new file +10 -0
+       int ret;
+       struct pxp_protected_session *arb = pxp->ctx.arb_session;
+
+       ret = -EINVAL;
+       for (retry = 0; retry < max_retry; retry++) {
+               if (is_hw_arb_session_in_play(pxp) ==
+                   arb->is_in_play) {
+                       ret = 0;
+                       break;
+               }

return intel_wait_for_register(uncore, GEN12_KCR_SIP,

			       REG_BIT(ARB_SESSION_INDEX),
			       arb->is_in_play ? REG_BIT(ARB_SESSION_INDEX) : 0,
			       100);

Although that does push the burden of holding the wakeref to the caller.

Quoted 34 lines
drivers/gpu/drm/i915/pxp/intel_pxp_arb.c new file +34 -0
+
+               msleep(ms_delay);
+       }
+
+       return ret;
+}
+
+/**
+ * create_session_entry - Create a new session entry with provided info.
+ * @pxp: pointer to pxp struct.
+ *
+ * Return: the pointer to the created session.
+ */
+static struct pxp_protected_session *create_session_entry(struct intel_pxp *pxp)
+{
+       struct pxp_protected_session *session;
+
+       session = kzalloc(sizeof(*session), GFP_KERNEL);
+       if (!session)
+               return NULL;
+
+       session->context_id = pxp->ctx.id;
+       session->type = ARB_SESSION_TYPE;
+       session->protection_mode = ARB_PROTECTION_MODE;
+       session->index = ARB_SESSION_INDEX;
+       session->is_in_play = false;
+
+       return session;
+}
+
+int intel_pxp_arb_reserve_session(struct intel_pxp *pxp)
+{
+       int ret;
+       struct pxp_protected_session *session = NULL;

drivers/gpu/drm/i915/pxp/intel_pxp_arb.c line 93

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp_arb.c new file +10 -0
+
+       lockdep_assert_held(&pxp->ctx.mutex);
+
+       ret = wait_arb_hw_sw_state(pxp);
+       if (ret)
+               return ret;
+
+       session = create_session_entry(pxp);
+       if (!session)
+               return -ENOMEM;

This function is incomplete.

Quoted 162 lines
drivers/gpu/drm/i915/pxp/intel_pxp_arb.c new file +59 -0
+
+       return ret;
+}
+
+/**
+ * intel_pxp_arb_mark_session_in_play - To put an reserved protected session to "in_play" state
+ * @pxp: pointer to pxp struct.
+ *
+ * Return: status. 0 means update is successful.
+ */
+static int intel_pxp_arb_mark_session_in_play(struct intel_pxp *pxp)
+{
+       struct pxp_protected_session *arb = pxp->ctx.arb_session;
+
+       lockdep_assert_held(&pxp->ctx.mutex);
+
+       if (arb->is_in_play)
+               return -EINVAL;
+
+       arb->is_in_play = true;
+       return 0;
+}
+
+int intel_pxp_arb_create_session(struct intel_pxp *pxp)
+{
+       int ret;
+       struct intel_gt *gt = container_of(pxp, typeof(*gt), pxp);
+
+       lockdep_assert_held(&pxp->ctx.mutex);
+
+       if (pxp->ctx.flag_display_hm_surface_keys) {
+               drm_err(&gt->i915->drm, "%s: arb session is alive so skipping the creation\n",
+                       __func__);
+               return 0;
+       }
+
+       ret = intel_pxp_arb_reserve_session(pxp);
+       if (ret) {
+               drm_err(&gt->i915->drm, "Failed to reserve arb session\n");
+               goto end;
+       }
+
+       ret = intel_pxp_tee_cmd_create_arb_session(pxp);
+       if (ret) {
+               drm_err(&gt->i915->drm, "Failed to send tee cmd for arb session creation\n");
+               goto end;
+       }
+
+       ret = intel_pxp_arb_mark_session_in_play(pxp);
+       if (ret) {
+               drm_err(&gt->i915->drm, "Failed to mark arb session status in play\n");
+               goto end;
+       }
+
+       pxp->ctx.flag_display_hm_surface_keys = true;
+
+end:
+       return ret;
+}
drivers/gpu/drm/i915/pxp/intel_pxp_arb.h new file +36 -0
new file mode 100644
index 000000000000..61bad3ada20f
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#ifndef __INTEL_PXP_ARB_H__
+#define __INTEL_PXP_ARB_H__
+
+#include "intel_pxp.h"
+
+/**
+ * struct pxp_protected_session - structure to track all active sessions.
+ */
+struct pxp_protected_session {
+       /** @index: Numeric identifier for this protected session */
+       int index;
+       /** @type: Type of session */
+       int type;
+       /** @protection_mode: mode of protection requested */
+       int protection_mode;
+       /** @context_id: context identifier of the protected session requestor */
+       int context_id;
+
+       /**
+        * @is_in_play: indicates whether the session has been established
+        *              in the HW root of trust if this flag is false, it
+        *              indicates an application has reserved this session,
+        *              but has not * established the session in the
+        *              hardware yet.
+        */
+       bool is_in_play;
+};
+
+int intel_pxp_arb_create_session(struct intel_pxp *pxp);
+
+#endif /* __INTEL_PXP_ARB_H__ */
drivers/gpu/drm/i915/pxp/intel_pxp_context.h +5 -0
index 953a2e700931..e37125ed7434 100644
@@ -13,7 +13,12 @@ struct pxp_context {
        /** @mutex: mutex to protect the pxp context */
        struct mutex mutex;
 
+       void *arb_session;
+       u32 arb_session_pxp_tag;
+
        int id;
+
+       bool flag_display_hm_surface_keys;
 };
 
 void intel_pxp_ctx_init(struct pxp_context *ctx);
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c +14 -0
index ca6b61099aee..816a6d5a54e4 100644
@@ -10,6 +10,7 @@
 #include "intel_pxp.h"
 #include "intel_pxp_context.h"
 #include "intel_pxp_tee.h"
+#include "intel_pxp_arb.h"
 
 static int intel_pxp_tee_io_message(struct intel_pxp *pxp,
                                    void *msg_in, u32 msg_in_size,
@@ -70,7 +71,9 @@ static int intel_pxp_tee_io_message(struct intel_pxp *pxp,
 static int i915_pxp_tee_component_bind(struct device *i915_kdev,
                                       struct device *tee_kdev, void *data)
 {
+       int ret;
        struct drm_i915_private *i915 = kdev_to_i915(i915_kdev);
+       struct intel_pxp *pxp = &i915->gt.pxp;
 
        if (!i915 || !tee_kdev || !data)
                return -EPERM;
@@ -80,6 +83,16 @@ static int i915_pxp_tee_component_bind(struct device *i915_kdev,
        i915->pxp_tee_master->tee_dev = tee_kdev;
        mutex_unlock(&i915->pxp_tee_comp_mutex);
 
+       mutex_lock(&pxp->ctx.mutex);
+       /* Create arb session only if tee is ready, during system boot or sleep/resume */
+       ret = intel_pxp_arb_create_session(pxp);
+       mutex_unlock(&pxp->ctx.mutex);
+
+       if (ret) {
+               drm_err(&i915->drm, "Failed to create arb session ret=[%d]\n", ret);
+               return ret;
+       }
+
        return 0;
 }
 
@@ -130,3 +143,28 @@ void intel_pxp_tee_component_fini(struct intel_pxp *pxp)
 
        component_del(i915->drm.dev, &i915_pxp_tee_component_ops);
 }
+

drivers/gpu/drm/i915/pxp/intel_pxp_tee.c void intel_pxp_tee_component_fini(struct intel_pxp *pxp) · line 156

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c +10 -0
+int intel_pxp_tee_cmd_create_arb_session(struct intel_pxp *pxp)
+{
+       int ret;
+       u32 msg_out_size_received = 0;
+       u32 msg_in[PXP_TEE_ARB_CMD_DW_LEN] = PXP_TEE_ARB_CMD_BIN;
+       u32 msg_out[PXP_TEE_ARB_CMD_DW_LEN] = {0};
+       struct intel_gt *gt = container_of(pxp, typeof(*gt), pxp);
+       struct drm_i915_private *i915 = gt->i915;
+
+       mutex_lock(&i915->pxp_tee_comp_mutex);

Consider moving this into the io handler, with a targeted mutex.

drivers/gpu/drm/i915/pxp/intel_pxp_tee.c void intel_pxp_tee_component_fini(struct intel_pxp *pxp) · line 167

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c +10 -0
+       ret = intel_pxp_tee_io_message(pxp,
+                                      &msg_in,
+                                      sizeof(msg_in),
+                                      &msg_out, &msg_out_size_received,
+                                      sizeof(msg_out));
+
+       mutex_unlock(&i915->pxp_tee_comp_mutex);
+
+       if (ret)
+               drm_err(&i915->drm, "Failed to send/receive tee message\n");

Fluff. Errors at the intermediate layers that provide no information we don't already have are worse than useless.

Quoted 8 lines
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c +3 -0
+
+       return ret;
+}
drivers/gpu/drm/i915/pxp/intel_pxp_tee.h +0 -0
index 4b5e3edb1d9b..757a54208a4d 100644

drivers/gpu/drm/i915/pxp/intel_pxp_tee.h line 18

Quoted 8 lines
drivers/gpu/drm/i915/pxp/intel_pxp_tee.h +5 -0
@@ -11,4 +11,10 @@
 void intel_pxp_tee_component_init(struct intel_pxp *pxp);
 void intel_pxp_tee_component_fini(struct intel_pxp *pxp);
 
+int intel_pxp_tee_cmd_create_arb_session(struct intel_pxp *pxp);
+
+/* TEE command to create the arbitrary session */
+#define PXP_TEE_ARB_CMD_BIN {0x00040000, 0x0000001e, 0x00000000, 0x00000008, 0x00000002, 0x0000000f}
+#define PXP_TEE_ARB_CMD_DW_LEN (6)

Do you really expect users of the intel_pxp interface to use these internal defines?

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp_tee.h +1 -0
+
 #endif /* __INTEL_PXP_TEE_H__ */
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#12 lore raw

RFC v4 5/21 drm/i915/pxp: Func to send hardware session termination

In reply to Huang, Sean Z

Implement the functions to allow PXP to send a GPU command, in order to terminate the hardware session, so hardware can recycle this session slot for the next usage.

---
 drivers/gpu/drm/i915/Makefile            |   1 +
 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c | 156 +++++++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.h |  18 +++
 3 files changed, 175 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.h
drivers/gpu/drm/i915/Makefile +1 -0
index 0710cc522f38..2da904cda49f 100644
@@ -258,6 +258,7 @@ i915-y += i915_perf.o
 i915-$(CONFIG_DRM_I915_PXP) += \
 	pxp/intel_pxp.o \
 	pxp/intel_pxp_arb.o \
+	pxp/intel_pxp_cmd.o \
 	pxp/intel_pxp_context.o \
 	pxp/intel_pxp_tee.o
 
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +156 -0

156 lines not on this page · raw message

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.h new file +18 -0
new file mode 100644
index 000000000000..d04463962421
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#ifndef __INTEL_PXP_CMD_H__
+#define __INTEL_PXP_CMD_H__
+
+#include "gt/intel_gt_buffer_pool.h"
+#include "intel_pxp.h"
+
+struct i915_vma *intel_pxp_cmd_get_batch(struct intel_pxp *pxp,
+					 struct intel_context *ce,
+					 struct intel_gt_buffer_pool_node *pool,
+					 u32 *cmd_buf, int cmd_size_in_dw);
+
+int intel_pxp_cmd_submit(struct intel_pxp *pxp, u32 *cmd, int cmd_size_in_dw);
+#endif /* __INTEL_PXP_SM_H__ */
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#13 lore raw

Re: [Intel-gfx] [RFC-v4 05/21] drm/i915/pxp: Func to send hardware session termination

Quoting Huang, Sean Z (2020-12-10 07:24:19)

Quoted 42 lines

Implement the functions to allow PXP to send a GPU command, in order to terminate the hardware session, so hardware can recycle this session slot for the next usage.

---
 drivers/gpu/drm/i915/Makefile            |   1 +
 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c | 156 +++++++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.h |  18 +++
 3 files changed, 175 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.h
drivers/gpu/drm/i915/Makefile +1 -0
index 0710cc522f38..2da904cda49f 100644
@@ -258,6 +258,7 @@ i915-y += i915_perf.o
 i915-$(CONFIG_DRM_I915_PXP) += \
        pxp/intel_pxp.o \
        pxp/intel_pxp_arb.o \
+       pxp/intel_pxp_cmd.o \
        pxp/intel_pxp_context.o \
        pxp/intel_pxp_tee.o
 
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +11 -0
new file mode 100644
index 000000000000..e531ea9f3cdc
@@ -0,0 +1,156 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#include "intel_pxp_cmd.h"
+#include "i915_drv.h"
+#include "gt/intel_context.h"
+#include "gt/intel_engine_pm.h"
+
+struct i915_vma *intel_pxp_cmd_get_batch(struct intel_pxp *pxp,

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 21

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +10 -0
+                                        struct intel_context *ce,
+                                        struct intel_gt_buffer_pool_node *pool,
+                                        u32 *cmd_buf, int cmd_size_in_dw)
+{
+       struct i915_vma *batch = ERR_PTR(-EINVAL);
+       struct intel_gt *gt = container_of(pxp, struct intel_gt, pxp);
+       u32 *cmd;
+
+       if (!ce || !ce->engine || !cmd_buf)
+               return ERR_PTR(-EINVAL);

Really?

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 23

Quoted 1 line
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +1 -0
+       if (cmd_size_in_dw * 4 > PAGE_SIZE) {

Pardon?

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 35

Quoted 12 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +12 -0
+               drm_err(&gt->i915->drm, "Failed to %s, invalid cmd_size_id_dw=[%d]\n",
+                       __func__, cmd_size_in_dw);
+               return ERR_PTR(-EINVAL);
+       }
+
+       cmd = i915_gem_object_pin_map(pool->obj, I915_MAP_FORCE_WC);
+       if (IS_ERR(cmd)) {
+               drm_err(&gt->i915->drm, "Failed to i915_gem_object_pin_map()\n");
+               return ERR_PTR(-EINVAL);
+       }
+
+       memcpy(cmd, cmd_buf, cmd_size_in_dw * 4);

Why did you bother creating a temporary?
[memcpy32]

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 39

Quoted 3 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +3 -0
+       if (drm_debug_enabled(DRM_UT_DRIVER)) {
+               print_hex_dump(KERN_DEBUG, "cmd binaries:",
+                              DUMP_PREFIX_OFFSET, 4, 4, cmd, cmd_size_in_dw * 4, true);

More sillyness again.

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 39

Quoted 2 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +2 -0
+       }
+

Flush the map after a write

Quoted 11 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +11 -0
+       i915_gem_object_unpin_map(pool->obj);
+
+       batch = i915_vma_instance(pool->obj, ce->vm, NULL);
+       if (IS_ERR(batch)) {
+               drm_err(&gt->i915->drm, "Failed to i915_vma_instance()\n");
+               return batch;
+       }
+
+       return batch;
+}
+

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 62

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +10 -0
+int intel_pxp_cmd_submit(struct intel_pxp *pxp, u32 *cmd, int cmd_size_in_dw)
+{
+       int err = -EINVAL;
+       struct i915_vma *batch;
+       struct i915_request *rq;
+       struct intel_context *ce = NULL;
+       bool is_engine_pm_get = false;
+       bool is_batch_vma_pin = false;
+       bool is_skip_req_on_err = false;
+       bool is_engine_get_pool = false;

Please implement onion unwind correctly.

And a general plea to be consistent with the rest of the code in laying out locals.

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 67

Quoted 5 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +5 -0
+       struct intel_gt_buffer_pool_node *pool = NULL;
+       struct intel_gt *gt = container_of(pxp, struct intel_gt, pxp);
+
+       if (!HAS_ENGINE(gt, VCS0) ||
+           !gt->engine[VCS0]->kernel_context) {

What are you doing here if you don't have a VCS? Surely you should not have even bothered to bind PXP in that case?

Don't assume the first available VCS engine has the HW instance id of 0.

The kernel_context exists if the engine exists.

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 72

Quoted 5 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +5 -0
+               err = -EINVAL;
+               goto end;
+       }
+
+       if (!cmd || (cmd_size_in_dw * 4) > PAGE_SIZE) {

Fix your debug code.

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 77

Quoted 5 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +5 -0
+               drm_err(&gt->i915->drm, "Failed to %s bad params\n", __func__);
+               return -EINVAL;
+       }
+
+       ce = gt->engine[VCS0]->kernel_context;

DO NOT USE THE KERNEL CONTEXT. Unless you really know what you are doing and can guarantee that under no circumstances does it break.

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 82

Quoted 4 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +4 -0
+       intel_engine_pm_get(ce->engine);
+       is_engine_pm_get = true;
+
+       pool = intel_gt_get_buffer_pool(gt, PAGE_SIZE);

If only you knew what the desired size actually was.

Quoted 42 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +42 -0
+       if (IS_ERR(pool)) {
+               drm_err(&gt->i915->drm, "Failed to intel_engine_get_pool()\n");
+               goto end;
+       }
+       is_engine_get_pool = true;
+
+       batch = intel_pxp_cmd_get_batch(pxp, ce, pool, cmd, cmd_size_in_dw);
+       if (IS_ERR(batch)) {
+               drm_err(&gt->i915->drm, "Failed to intel_pxp_cmd_get_batch()\n");
+               goto end;
+       }
+
+       err = i915_vma_pin(batch, 0, 0, PIN_USER);
+       if (err) {
+               drm_err(&gt->i915->drm, "Failed to i915_vma_pin()\n");
+               goto end;
+       }
+       is_batch_vma_pin = true;
+
+       rq = intel_context_create_request(ce);
+       if (IS_ERR(rq)) {
+               drm_err(&gt->i915->drm, "Failed to intel_context_create_request()\n");
+               goto end;
+       }
+       is_skip_req_on_err = true;
+
+       err = intel_gt_buffer_pool_mark_active(pool, rq);
+       if (err) {
+               drm_err(&gt->i915->drm, "Failed to intel_engine_pool_mark_active()\n");
+               goto end;
+       }
+
+       i915_vma_lock(batch);
+       err = i915_request_await_object(rq, batch->obj, false);
+       if (!err)
+               err = i915_vma_move_to_active(batch, rq, 0);
+       i915_vma_unlock(batch);
+       if (err) {
+               drm_err(&gt->i915->drm, "Failed to i915_request_await_object()\n");
+               goto end;
+       }
+

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 134

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +10 -0
+       if (ce->engine->emit_init_breadcrumb) {
+               err = ce->engine->emit_init_breadcrumb(rq);
+               if (err) {
+                       drm_err(&gt->i915->drm, "Failed to emit_init_breadcrumb()\n");
+                       goto end;
+               }
+       }
+
+       err = ce->engine->emit_bb_start(rq, batch->node.start,
+               batch->node.size, 0);

If this is not privileged, why is it done in the kernel? What prevents everyone else from issuing the very same commands to give themselves control?

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 142

Quoted 8 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +8 -0
+       if (err) {
+               drm_err(&gt->i915->drm, "Failed to emit_bb_start()\n");
+               goto end;
+       }
+
+       i915_request_add(rq);
+
+end:

Consistency would be to use out:

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 144

Quoted 2 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +2 -0
+       if (unlikely(err) && is_skip_req_on_err)
+               i915_request_set_error_once(rq, err);

Why?

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 153

Quoted 8 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +8 -0
+       if (is_batch_vma_pin)
+               i915_vma_unpin(batch);
+
+       if (is_engine_get_pool)
+               intel_gt_buffer_pool_put(pool);
+
+       if (is_engine_pm_get)
+               intel_engine_pm_put(ce->engine);

Style wise, highly inconsistent. Just use labels, spare the locals.

Quoted 34 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +2 -0
+       return err;
+}
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.h new file +18 -0
new file mode 100644
index 000000000000..d04463962421
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#ifndef __INTEL_PXP_CMD_H__
+#define __INTEL_PXP_CMD_H__
+
+#include "gt/intel_gt_buffer_pool.h"
+#include "intel_pxp.h"
+
+struct i915_vma *intel_pxp_cmd_get_batch(struct intel_pxp *pxp,
+                                        struct intel_context *ce,
+                                        struct intel_gt_buffer_pool_node *pool,
+                                        u32 *cmd_buf, int cmd_size_in_dw);
+
+int intel_pxp_cmd_submit(struct intel_pxp *pxp, u32 *cmd, int cmd_size_in_dw);
+#endif /* __INTEL_PXP_SM_H__ */
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#14 lore raw

Re: [Intel-gfx] [RFC-v4 05/21] drm/i915/pxp: Func to send hardware session termination

+Rodrigo,

Hi Chris,

Thanks for your feedback. Replied inline below, and have made several modifications according to your feedback. May I know if you still have concern regarding the latest rev23? https://patchwork.freedesktop.org/series/84620/#rev23

Regarding the concern about 915->pxp_tee_comp_mutex in https://patchwork.freedesktop.org/patch/406639/?series=84620&rev=4
The pxp_tee_comp_mutex is to protect pxp_tee_comp_added to prevent the race condition that intel_pxp_tee_component_init() and intel_pxp_tee_component_fini() are called at the same time.

We can see the similar usage case for HDCP, but please educate me if there is something I miss.
https://elixir.bootlin.com/linux/v5.11-rc3/source/drivers/gpu/drm/i915/display/intel_hdcp.c#L2025
https://elixir.bootlin.com/linux/v5.11-rc3/source/drivers/gpu/drm/i915/display/intel_hdcp.c#L2232

Best regards,
Sean

-----Original Message-----
From: Chris Wilson <[email protected]>
Sent: Thursday, December 10, 2020 1:19 AM
To: Huang, Sean Z <[email protected]>; [email protected]
Subject: Re: [Intel-gfx] [RFC-v4 05/21] drm/i915/pxp: Func to send hardware session termination

Quoting Huang, Sean Z (2020-12-10 07:24:19)

Quoted 45 lines

Implement the functions to allow PXP to send a GPU command, in order to terminate the hardware session, so hardware can recycle this session slot for the next usage.

---
 drivers/gpu/drm/i915/Makefile            |   1 +
 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c | 156 
+++++++++++++++++++++++  drivers/gpu/drm/i915/pxp/intel_pxp_cmd.h |  
18 +++
 3 files changed, 175 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.h
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/Makefile index 0710cc522f38..2da904cda49f 100644

drivers/gpu/drm/i915/Makefile +1 -0
@@ -258,6 +258,7 @@ i915-y += i915_perf.o
 i915-$(CONFIG_DRM_I915_PXP) += \
        pxp/intel_pxp.o \
        pxp/intel_pxp_arb.o \
+       pxp/intel_pxp_cmd.o \
        pxp/intel_pxp_context.o \
        pxp/intel_pxp_tee.o
 
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +11 -0
new file mode 100644
index 000000000000..e531ea9f3cdc
@@ -0,0 +1,156 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#include "intel_pxp_cmd.h"
+#include "i915_drv.h"
+#include "gt/intel_context.h"
+#include "gt/intel_engine_pm.h"
+
+struct i915_vma *intel_pxp_cmd_get_batch(struct intel_pxp *pxp,

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 21

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +10 -0
+                                        struct intel_context *ce,
+                                        struct intel_gt_buffer_pool_node *pool,
+                                        u32 *cmd_buf, int 
+cmd_size_in_dw) {
+       struct i915_vma *batch = ERR_PTR(-EINVAL);
+       struct intel_gt *gt = container_of(pxp, struct intel_gt, pxp);
+       u32 *cmd;
+
+       if (!ce || !ce->engine || !cmd_buf)
+               return ERR_PTR(-EINVAL);

Really?

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 23

Quoted 1 line
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +1 -0
+       if (cmd_size_in_dw * 4 > PAGE_SIZE) {

Pardon?
//sean: remove the check

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 35

Quoted 12 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +12 -0
+               drm_err(&gt->i915->drm, "Failed to %s, invalid cmd_size_id_dw=[%d]\n",
+                       __func__, cmd_size_in_dw);
+               return ERR_PTR(-EINVAL);
+       }
+
+       cmd = i915_gem_object_pin_map(pool->obj, I915_MAP_FORCE_WC);
+       if (IS_ERR(cmd)) {
+               drm_err(&gt->i915->drm, "Failed to i915_gem_object_pin_map()\n");
+               return ERR_PTR(-EINVAL);
+       }
+
+       memcpy(cmd, cmd_buf, cmd_size_in_dw * 4);

Why did you bother creating a temporary?
[memcpy32]
//sean: because when this function was called, the PXP caller has completed the GPU command programming in cmd_buf so here is to copy the cmd_buf to cmd which is mapped to graphics address.

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c

Quoted 4 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +4 -0
+       if (drm_debug_enabled(DRM_UT_DRIVER)) {
+               print_hex_dump(KERN_DEBUG, "cmd binaries:",
+                              DUMP_PREFIX_OFFSET, 4, 4, cmd, 
+ cmd_size_in_dw * 4, true);

More sillyness again.

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 40

Quoted 2 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +2 -0
+       }
+

Flush the map after a write
// sean, yes apply the change accordingly in rev23

Quoted 11 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +11 -0
+       i915_gem_object_unpin_map(pool->obj);
+
+       batch = i915_vma_instance(pool->obj, ce->vm, NULL);
+       if (IS_ERR(batch)) {
+               drm_err(&gt->i915->drm, "Failed to i915_vma_instance()\n");
+               return batch;
+       }
+
+       return batch;
+}
+

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 62

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +10 -0
+int intel_pxp_cmd_submit(struct intel_pxp *pxp, u32 *cmd, int 
+cmd_size_in_dw) {
+       int err = -EINVAL;
+       struct i915_vma *batch;
+       struct i915_request *rq;
+       struct intel_context *ce = NULL;
+       bool is_engine_pm_get = false;
+       bool is_batch_vma_pin = false;
+       bool is_skip_req_on_err = false;
+       bool is_engine_get_pool = false;

//sean: I have remove those bool and use label at rev23, thanks. Please implement onion unwind correctly.

And a general plea to be consistent with the rest of the code in laying out locals.

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 67

Quoted 5 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +5 -0
+       struct intel_gt_buffer_pool_node *pool = NULL;
+       struct intel_gt *gt = container_of(pxp, struct intel_gt, pxp);
+
+       if (!HAS_ENGINE(gt, VCS0) ||
+           !gt->engine[VCS0]->kernel_context) {

What are you doing here if you don't have a VCS? Surely you should not have even bothered to bind PXP in that case?

Don't assume the first available VCS engine has the HW instance id of 0.

The kernel_context exists if the engine exists.

// sean: Yes at rev23 I no long assume VCS0 exists.

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 72

Quoted 5 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +5 -0
+               err = -EINVAL;
+               goto end;
+       }
+
+       if (!cmd || (cmd_size_in_dw * 4) > PAGE_SIZE) {

Fix your debug code.
//sean: okay, I removed the log print.

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 77

Quoted 5 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +5 -0
+               drm_err(&gt->i915->drm, "Failed to %s bad params\n", __func__);
+               return -EINVAL;
+       }
+
+       ce = gt->engine[VCS0]->kernel_context;

DO NOT USE THE KERNEL CONTEXT. Unless you really know what you are doing and can guarantee that under no circumstances does it break. // I need access the context for submit the GPU command to VCS.

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 82

Quoted 4 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +4 -0
+       intel_engine_pm_get(ce->engine);
+       is_engine_pm_get = true;
+
+       pool = intel_gt_get_buffer_pool(gt, PAGE_SIZE);

If only you knew what the desired size actually was.

Quoted 42 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +42 -0
+       if (IS_ERR(pool)) {
+               drm_err(&gt->i915->drm, "Failed to intel_engine_get_pool()\n");
+               goto end;
+       }
+       is_engine_get_pool = true;
+
+       batch = intel_pxp_cmd_get_batch(pxp, ce, pool, cmd, cmd_size_in_dw);
+       if (IS_ERR(batch)) {
+               drm_err(&gt->i915->drm, "Failed to intel_pxp_cmd_get_batch()\n");
+               goto end;
+       }
+
+       err = i915_vma_pin(batch, 0, 0, PIN_USER);
+       if (err) {
+               drm_err(&gt->i915->drm, "Failed to i915_vma_pin()\n");
+               goto end;
+       }
+       is_batch_vma_pin = true;
+
+       rq = intel_context_create_request(ce);
+       if (IS_ERR(rq)) {
+               drm_err(&gt->i915->drm, "Failed to intel_context_create_request()\n");
+               goto end;
+       }
+       is_skip_req_on_err = true;
+
+       err = intel_gt_buffer_pool_mark_active(pool, rq);
+       if (err) {
+               drm_err(&gt->i915->drm, "Failed to intel_engine_pool_mark_active()\n");
+               goto end;
+       }
+
+       i915_vma_lock(batch);
+       err = i915_request_await_object(rq, batch->obj, false);
+       if (!err)
+               err = i915_vma_move_to_active(batch, rq, 0);
+       i915_vma_unlock(batch);
+       if (err) {
+               drm_err(&gt->i915->drm, "Failed to i915_request_await_object()\n");
+               goto end;
+       }
+

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 134

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +10 -0
+       if (ce->engine->emit_init_breadcrumb) {
+               err = ce->engine->emit_init_breadcrumb(rq);
+               if (err) {
+                       drm_err(&gt->i915->drm, "Failed to emit_init_breadcrumb()\n");
+                       goto end;
+               }
+       }
+
+       err = ce->engine->emit_bb_start(rq, batch->node.start,
+               batch->node.size, 0);

If this is not privileged, why is it done in the kernel? What prevents everyone else from issuing the very same commands to give themselves control?
// According to our design, the PXP default session is owned by kernel space so it's the reason we need to submit this command, to terminate the PXP default session, from kernel instead of user space.

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 142

Quoted 8 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +8 -0
+       if (err) {
+               drm_err(&gt->i915->drm, "Failed to emit_bb_start()\n");
+               goto end;
+       }
+
+       i915_request_add(rq);
+
+end:

Consistency would be to use out:

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 144

Quoted 2 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +2 -0
+       if (unlikely(err) && is_skip_req_on_err)
+               i915_request_set_error_once(rq, err);

Why?
// sean: I think you're correct, I should just return the err not just for once.

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c line 153

Quoted 8 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +8 -0
+       if (is_batch_vma_pin)
+               i915_vma_unpin(batch);
+
+       if (is_engine_get_pool)
+               intel_gt_buffer_pool_put(pool);
+
+       if (is_engine_pm_get)
+               intel_engine_pm_put(ce->engine);

Style wise, highly inconsistent. Just use labels, spare the locals. // sean: Changed accordingly, now we use label at rev23.

Quoted 31 lines
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c new file +2 -0
+       return err;
+}
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.h new file +19 -1
new file mode 100644
index 000000000000..d04463962421
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#ifndef __INTEL_PXP_CMD_H__
+#define __INTEL_PXP_CMD_H__
+
+#include "gt/intel_gt_buffer_pool.h"
+#include "intel_pxp.h"
+
+struct i915_vma *intel_pxp_cmd_get_batch(struct intel_pxp *pxp,
+                                        struct intel_context *ce,
+                                        struct intel_gt_buffer_pool_node *pool,
+                                        u32 *cmd_buf, int 
+cmd_size_in_dw);
+
+int intel_pxp_cmd_submit(struct intel_pxp *pxp, u32 *cmd, int 
+cmd_size_in_dw); #endif /* __INTEL_PXP_SM_H__ */
--

2.17.1

Quoted 5 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#15 lore raw

RFC v4 6/21 drm/i915/pxp: Enable PXP irq worker and callback stub

In reply to Huang, Sean Z

Create the irq worker that serves as callback handler, those callback stubs should be called while the hardware key teardown occurs.

---
 drivers/gpu/drm/i915/gt/intel_gt_irq.c       |   4 +
 drivers/gpu/drm/i915/i915_reg.h              |   3 +-
 drivers/gpu/drm/i915/pxp/intel_pxp.c         | 101 +++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp.h         |  27 +++++
 drivers/gpu/drm/i915/pxp/intel_pxp_context.c |   2 +
 drivers/gpu/drm/i915/pxp/intel_pxp_context.h |   1 +
 6 files changed, 137 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_gt_irq.c +4 -0
index 257063a57101..fbe9ef88b905 100644
@@ -13,6 +13,7 @@
 #include "intel_gt_irq.h"
 #include "intel_uncore.h"
 #include "intel_rps.h"
+#include "pxp/intel_pxp.h"
 
 static void guc_irq_handler(struct intel_guc *guc, u16 iir)
 {
@@ -106,6 +107,9 @@ gen11_other_irq_handler(struct intel_gt *gt, const u8 instance,
 	if (instance == OTHER_GTPM_INSTANCE)
 		return gen11_rps_irq_handler(&gt->rps, iir);
 
+	if (instance == OTHER_KCR_INSTANCE)
+		return intel_pxp_irq_handler(&gt->pxp, iir);
+
 	WARN_ONCE(1, "unhandled other interrupt instance=0x%x, iir=0x%x\n",
 		  instance, iir);
 }
drivers/gpu/drm/i915/i915_reg.h +2 -1
index 0023c023f472..1e8dfe435ca8 100644
@@ -7944,6 +7944,7 @@ enum {
 /* irq instances for OTHER_CLASS */
 #define OTHER_GUC_INSTANCE	0
 #define OTHER_GTPM_INSTANCE	1
+#define OTHER_KCR_INSTANCE	4
 
 #define GEN11_INTR_IDENTITY_REG(x)	_MMIO(0x190060 + ((x) * 4))
 
@@ -7966,7 +7967,7 @@ enum {
 #define GEN11_VECS0_VECS1_INTR_MASK	_MMIO(0x1900d0)
 #define GEN11_GUC_SG_INTR_MASK		_MMIO(0x1900e8)
 #define GEN11_GPM_WGBOXPERF_INTR_MASK	_MMIO(0x1900ec)
-#define GEN11_CRYPTO_RSVD_INTR_MASK	_MMIO(0x1900f0)
+#define GEN11_CRYPTO_INTR_MASK		_MMIO(0x1900f0) /* crypto mask is in bit31-16 (Engine1 Interrupt Mask) */
 #define GEN11_GUNIT_CSME_INTR_MASK	_MMIO(0x1900f4)
 
 #define   ENGINE1_MASK			REG_GENMASK(31, 16)
drivers/gpu/drm/i915/pxp/intel_pxp.c +101 -0

116 lines not on this page · raw message

drivers/gpu/drm/i915/pxp/intel_pxp.h +27 -0
index 1841a9aa972d..ddcc3faa4ea3 100644
@@ -6,8 +6,13 @@
 #ifndef __INTEL_PXP_H__
 #define __INTEL_PXP_H__
 
+#include <linux/workqueue.h>
 #include "intel_pxp_context.h"
 
+#define PXP_IRQ_VECTOR_DISPLAY_PXP_STATE_TERMINATED BIT(1)
+#define PXP_IRQ_VECTOR_DISPLAY_APP_TERM_PER_FW_REQ BIT(2)
+#define PXP_IRQ_VECTOR_PXP_DISP_STATE_RESET_COMPLETE BIT(3)
+
 enum pxp_session_types {
 	SESSION_TYPE_TYPE0 = 0,
 	SESSION_TYPE_TYPE1 = 1,
@@ -25,13 +30,35 @@ enum pxp_protection_modes {
 };
 
 struct intel_pxp {
+	struct work_struct irq_work;
+	u32 handled_irr;
+	u32 current_events;
+
 	struct pxp_context ctx;
 };
 
 #ifdef CONFIG_DRM_I915_PXP
+void intel_pxp_irq_handler(struct intel_pxp *pxp, u16 iir);
+int i915_pxp_teardown_required_callback(struct intel_pxp *pxp);
+int i915_pxp_global_terminate_complete_callback(struct intel_pxp *pxp);
+
 int intel_pxp_init(struct intel_pxp *pxp);
 void intel_pxp_uninit(struct intel_pxp *pxp);
 #else
+static inline void intel_pxp_irq_handler(struct intel_pxp *pxp, u16 iir)
+{
+}
+
+static inline int i915_pxp_teardown_required_callback(struct intel_pxp *pxp)
+{
+	return 0;
+}
+
+static inline int i915_pxp_global_terminate_complete_callback(struct intel_pxp *pxp)
+{
+	return 0;
+}
+
 static inline int intel_pxp_init(struct intel_pxp *pxp)
 {
 	return 0;
drivers/gpu/drm/i915/pxp/intel_pxp_context.c +2 -0
index 5ffaf55dc7df..d00f4e0b88ba 100644
@@ -14,6 +14,8 @@ void intel_pxp_ctx_init(struct pxp_context *ctx)
 {
 	get_random_bytes(&ctx->id, sizeof(ctx->id));
 
+	ctx->global_state_attacked = false;
+
 	mutex_init(&ctx->mutex);
 }
 
drivers/gpu/drm/i915/pxp/intel_pxp_context.h +1 -0
index e37125ed7434..62a2504b33bf 100644
@@ -18,6 +18,7 @@ struct pxp_context {
 
 	int id;
 
+	bool global_state_attacked;
 	bool flag_display_hm_surface_keys;
 };
 
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#16 lore raw

RFC v4 7/21 drm/i915/pxp: Destroy arb session upon teardown

In reply to Huang, Sean Z

Teardown is triggered when the display topology changes and no long meets the secure playback requirement, and hardware trashes all the encryption keys for display. So as a result, PXP should handle such case and terminate the type0 sessions, which including arb session

---
 drivers/gpu/drm/i915/pxp/intel_pxp.c     |   3 +
 drivers/gpu/drm/i915/pxp/intel_pxp_arb.c |  76 +++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_arb.h |   1 +
 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c | 129 ++++++++++++++++++++++-
 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.h |  12 ++-
 5 files changed, 211 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/pxp/intel_pxp.c +3 -0
index 9bcb170b34f1..48e926363696 100644
@@ -28,6 +28,9 @@ static int intel_pxp_teardown_required_callback(struct intel_pxp *pxp)
 	mutex_lock(&pxp->ctx.mutex);
 
 	pxp->ctx.global_state_attacked = true;
+	pxp->ctx.flag_display_hm_surface_keys = false;
+
+	ret = intel_pxp_arb_terminate_session(pxp);
 
 	mutex_unlock(&pxp->ctx.mutex);
 
drivers/gpu/drm/i915/pxp/intel_pxp_arb.c +76 -0

85 lines not on this page · raw message

drivers/gpu/drm/i915/pxp/intel_pxp_arb.h +1 -0
index 61bad3ada20f..f9b129b8d2a1 100644
@@ -32,5 +32,6 @@ struct pxp_protected_session {
 };
 
 int intel_pxp_arb_create_session(struct intel_pxp *pxp);
+int intel_pxp_arb_terminate_session(struct intel_pxp *pxp);
 
 #endif /* __INTEL_PXP_ARB_H__ */
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c +124 -5

144 lines not on this page · raw message

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.h +7 -5
index d04463962421..087f260034c4 100644
@@ -9,10 +9,12 @@
 #include "gt/intel_gt_buffer_pool.h"
 #include "intel_pxp.h"
 
-struct i915_vma *intel_pxp_cmd_get_batch(struct intel_pxp *pxp,
-					 struct intel_context *ce,
-					 struct intel_gt_buffer_pool_node *pool,
-					 u32 *cmd_buf, int cmd_size_in_dw);
+int intel_pxp_cmd_submit(struct intel_pxp *pxp, u32 *cmd,
+			 int cmd_size_in_dw);
+int intel_pxp_cmd_add_prolog(struct intel_pxp *pxp, u32 *cmd,
+			     int session_type,
+			     int session_index);
+int intel_pxp_cmd_add_epilog(u32 *cmd);
+int intel_pxp_cmd_add_inline_termination(u32 *cmd);
 
-int intel_pxp_cmd_submit(struct intel_pxp *pxp, u32 *cmd, int cmd_size_in_dw);
 #endif /* __INTEL_PXP_SM_H__ */
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#17 lore raw

RFC v4 8/21 drm/i915/pxp: Enable PXP power management

In reply to Huang, Sean Z

During the power event S3+ sleep/resume, hardware will lose all the encryption keys for every hardware session, even though the software session state was marked as alive after resume. So to handle such case, PXP should terminate all the hardware sessions and cleanup all the software states after the power cycle.

---
 drivers/gpu/drm/i915/Makefile                |  1 +
 drivers/gpu/drm/i915/gt/intel_gt_pm.c        |  4 ++
 drivers/gpu/drm/i915/i915_drv.c              |  4 ++
 drivers/gpu/drm/i915/pxp/intel_pxp_context.h |  1 +
 drivers/gpu/drm/i915/pxp/intel_pxp_pm.c      | 65 ++++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_pm.h      | 31 ++++++++++
 6 files changed, 106 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_pm.c
 create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_pm.h
drivers/gpu/drm/i915/Makefile +1 -0
index 2da904cda49f..2545b59fa4f2 100644
@@ -260,6 +260,7 @@ i915-$(CONFIG_DRM_I915_PXP) += \
 	pxp/intel_pxp_arb.o \
 	pxp/intel_pxp_cmd.o \
 	pxp/intel_pxp_context.o \
+	pxp/intel_pxp_pm.o \
 	pxp/intel_pxp_tee.o
 
 # Post-mortem debug and GPU hang state capture
drivers/gpu/drm/i915/gt/intel_gt_pm.c +4 -0
index 274aa0dd7050..09a64d0feafe 100644
@@ -20,6 +20,7 @@
 #include "intel_rc6.h"
 #include "intel_rps.h"
 #include "intel_wakeref.h"
+#include "pxp/intel_pxp_pm.h"
 
 static void user_forcewake(struct intel_gt *gt, bool suspend)
 {
@@ -241,6 +242,8 @@ int intel_gt_resume(struct intel_gt *gt)
 
 	intel_uc_resume(&gt->uc);
 
+	intel_pxp_pm_resume(&gt->pxp);
+
 	user_forcewake(gt, false);
 
 out_fw:
@@ -275,6 +278,7 @@ void intel_gt_suspend_prepare(struct intel_gt *gt)
 	user_forcewake(gt, true);
 	wait_for_suspend(gt);
 
+	intel_pxp_pm_prepare_suspend(&gt->pxp);
 	intel_uc_suspend(&gt->uc);
 }
 
drivers/gpu/drm/i915/i915_drv.c +4 -0
index 9299a456adb0..af06c85e6ba7 100644
@@ -68,6 +68,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"
@@ -1344,6 +1346,8 @@ static int i915_drm_resume_early(struct drm_device *dev)
 
 	intel_power_domains_resume(dev_priv);
 
+	intel_pxp_pm_resume_early(&dev_priv->gt.pxp);
+
 	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	return ret;
drivers/gpu/drm/i915/pxp/intel_pxp_context.h +1 -0
index 62a2504b33bf..f03cba187c75 100644
@@ -19,6 +19,7 @@ struct pxp_context {
 	int id;
 
 	bool global_state_attacked;
+	bool global_state_in_suspend;
 	bool flag_display_hm_surface_keys;
 };
 
drivers/gpu/drm/i915/pxp/intel_pxp_pm.c new file +65 -0

65 lines not on this page · raw message

drivers/gpu/drm/i915/pxp/intel_pxp_pm.h new file +31 -0
new file mode 100644
index 000000000000..135bfb59aaf7
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright(c) 2020, Intel Corporation. All rights reserved.
+ */
+
+#ifndef __INTEL_PXP_PM_H__
+#define __INTEL_PXP_PM_H__
+
+#include "i915_drv.h"
+
+#ifdef CONFIG_DRM_I915_PXP
+void intel_pxp_pm_prepare_suspend(struct intel_pxp *pxp);
+
+void intel_pxp_pm_resume_early(struct intel_pxp *pxp);
+int intel_pxp_pm_resume(struct intel_pxp *pxp);
+#else
+static inline void intel_pxp_pm_prepare_suspend(struct intel_pxp *pxp)
+{
+}
+
+static inline void intel_pxp_pm_resume_early(struct intel_pxp *pxp)
+{
+}
+
+static inline int intel_pxp_pm_resume(struct intel_pxp *pxp)
+{
+	return 0;
+}
+#endif
+
+#endif /* __INTEL_PXP_PM_H__ */
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#18 lore raw

RFC v4 9/21 drm/i915/pxp: Expose session state for display protection flip

In reply to Huang, Sean Z

Implement the intel_pxp_gem_object_status() to allow i915 display querying the current PXP session state. In the design, display should not perform protection flip on the protected buffers if there is no PXP session alive.

---
 drivers/gpu/drm/i915/pxp/intel_pxp.c | 9 +++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp.h | 8 ++++++++
 2 files changed, 17 insertions(+)
drivers/gpu/drm/i915/pxp/intel_pxp.c +9 -0
index 48e926363696..ce3760206b76 100644
@@ -143,3 +143,12 @@ void intel_pxp_irq_handler(struct intel_pxp *pxp, u16 iir)
 	pxp->current_events |= events;
 	schedule_work(&pxp->irq_work);
 }
+
+bool intel_pxp_gem_object_status(struct drm_i915_private *i915)
+{
+	if (i915->gt.pxp.ctx.id != 0 &&
+	    i915->gt.pxp.ctx.flag_display_hm_surface_keys)
+		return true;
+	else
+		return false;
+}
drivers/gpu/drm/i915/pxp/intel_pxp.h +8 -0
index ddcc3faa4ea3..027c0eb84a52 100644
@@ -37,6 +37,8 @@ struct intel_pxp {
 	struct pxp_context ctx;
 };
 
+struct drm_i915_private;
+
 #ifdef CONFIG_DRM_I915_PXP
 void intel_pxp_irq_handler(struct intel_pxp *pxp, u16 iir);
 int i915_pxp_teardown_required_callback(struct intel_pxp *pxp);
@@ -44,6 +46,7 @@ int i915_pxp_global_terminate_complete_callback(struct intel_pxp *pxp);
 
 int intel_pxp_init(struct intel_pxp *pxp);
 void intel_pxp_uninit(struct intel_pxp *pxp);
+bool intel_pxp_gem_object_status(struct drm_i915_private *i915);
 #else
 static inline void intel_pxp_irq_handler(struct intel_pxp *pxp, u16 iir)
 {
@@ -67,6 +70,11 @@ static inline int intel_pxp_init(struct intel_pxp *pxp)
 static inline void intel_pxp_uninit(struct intel_pxp *pxp)
 {
 }
+
+static inline bool intel_pxp_gem_object_status(struct drm_i915_private *i915)
+{
+	return false;
+}
 #endif
 
 #endif /* __INTEL_PXP_PM_H__ */
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#19 lore raw

RFC v4 10/21 mei: pxp: export pavp client to me client bus

In reply to Huang, Sean Z

From: Vitaly Lubart <[email protected]>

Export PAVP client to work with i915_cp driver,
for binding it uses kernel component framework.

---
 drivers/misc/mei/Kconfig       |   2 +
 drivers/misc/mei/Makefile      |   1 +
 drivers/misc/mei/pxp/Kconfig   |  13 ++
 drivers/misc/mei/pxp/Makefile  |   7 +
 drivers/misc/mei/pxp/mei_pxp.c | 230 +++++++++++++++++++++++++++++++++
 drivers/misc/mei/pxp/mei_pxp.h |  18 +++
 6 files changed, 271 insertions(+)
 create mode 100644 drivers/misc/mei/pxp/Kconfig
 create mode 100644 drivers/misc/mei/pxp/Makefile
 create mode 100644 drivers/misc/mei/pxp/mei_pxp.c
 create mode 100644 drivers/misc/mei/pxp/mei_pxp.h
drivers/misc/mei/Kconfig +2 -0
index f5fd5b786607..0e0bcd0da852 100644
@@ -47,3 +47,5 @@ config INTEL_MEI_TXE
 	  Intel Bay Trail
 
 source "drivers/misc/mei/hdcp/Kconfig"
+source "drivers/misc/mei/pxp/Kconfig"
+
drivers/misc/mei/Makefile +1 -0
index f1c76f7ee804..d8e5165917f2 100644
@@ -26,3 +26,4 @@ mei-$(CONFIG_EVENT_TRACING) += mei-trace.o
 CFLAGS_mei-trace.o = -I$(src)
 
 obj-$(CONFIG_INTEL_MEI_HDCP) += hdcp/
+obj-$(CONFIG_INTEL_MEI_PXP) += pxp/
drivers/misc/mei/pxp/Kconfig new file +13 -0
new file mode 100644
index 000000000000..4029b96afc04
@@ -0,0 +1,13 @@
+
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020, Intel Corporation. All rights reserved.
+#
+config INTEL_MEI_PXP
+	tristate "Intel PXP services of ME Interface"
+	select INTEL_MEI_ME
+	depends on DRM_I915
+	help
+	  MEI Support for PXP Services on Intel platforms.
+
+	  Enables the ME FW services required for PXP support through
+	  I915 display driver of Intel.
drivers/misc/mei/pxp/Makefile new file +7 -0
new file mode 100644
index 000000000000..0329950d5794
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (c) 2020, Intel Corporation. All rights reserved.
+#
+# Makefile - PXP client driver for Intel MEI Bus Driver.
+
+obj-$(CONFIG_INTEL_MEI_PXP) += mei_pxp.o
drivers/misc/mei/pxp/mei_pxp.c new file +230 -0

230 lines not on this page · raw message

drivers/misc/mei/pxp/mei_pxp.h new file +18 -0
new file mode 100644
index 000000000000..e7b15373fefd
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright © 2020 Intel Corporation
+ *
+ * Authors:
+ * Vitaly Lubart <[email protected]>
+ */
+
+#ifndef __MEI_PXP_H__
+#define __MEI_PXP_H__
+
+/* me_pxp_status: Enumeration of all PXP Status Codes */
+enum me_pxp_status {
+	ME_PXP_STATUS_SUCCESS			= 0x0000,
+
+};
+
+#endif /* __MEI_PXP_H__ */
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#20 lore raw

RFC v4 11/21 drm/i915/uapi: introduce drm_i915_gem_create_ext

In reply to Huang, Sean Z

From: Bommu Krishnaiah <[email protected]>

Same old gem_create but with now with extensions support. This is needed to support various upcoming usecases. For now we use the extensions mechanism to support PAVP.

Cc Joonas Lahtinen [email protected]
Cc Matthew Auld [email protected]
Cc Telukuntla Sreedhar <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.c |  2 +-
 drivers/gpu/drm/i915/i915_gem.c | 42 ++++++++++++++++++++++++++++-
 include/uapi/drm/i915_drm.h     | 47 +++++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +1 -1
index af06c85e6ba7..3dbda949bf71 100644
@@ -1733,7 +1733,7 @@ static const struct drm_ioctl_desc i915_ioctls[] = {
 	DRM_IOCTL_DEF_DRV(I915_GEM_THROTTLE, i915_gem_throttle_ioctl, DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(I915_GEM_ENTERVT, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 	DRM_IOCTL_DEF_DRV(I915_GEM_LEAVEVT, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-	DRM_IOCTL_DEF_DRV(I915_GEM_CREATE, i915_gem_create_ioctl, DRM_RENDER_ALLOW),
+	DRM_IOCTL_DEF_DRV(I915_GEM_CREATE_EXT, i915_gem_create_ioctl, DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(I915_GEM_PREAD, i915_gem_pread_ioctl, DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(I915_GEM_PWRITE, i915_gem_pwrite_ioctl, DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(I915_GEM_MMAP, i915_gem_mmap_ioctl, DRM_RENDER_ALLOW),
drivers/gpu/drm/i915/i915_gem.c +41 -1

63 lines not on this page · raw message

include/uapi/drm/i915_drm.h +47 -0

65 lines not on this page · raw message

Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#21 lore raw

RFC v4 12/21 drm/i915/pxp: User interface for Protected buffer

In reply to Huang, Sean Z

From: Bommu Krishnaiah <[email protected]>

This api allow user mode to create Protected buffer and context creation.

Cc Telukuntla Sreedhar <[email protected]>
Cc Kondapally Kalyan <[email protected]>
Cc Gupta Anshuman <[email protected]>
Cc Huang Sean Z <[email protected]>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c   | 15 ++++++++++--
 drivers/gpu/drm/i915/gem/i915_gem_context.h   | 10 ++++++++
 .../gpu/drm/i915/gem/i915_gem_context_types.h |  2 +-
 .../gpu/drm/i915/gem/i915_gem_object_types.h  |  5 ++++
 drivers/gpu/drm/i915/i915_gem.c               | 23 +++++++++++++++----
 include/uapi/drm/i915_drm.h                   | 19 +++++++++++++++
 6 files changed, 67 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +13 -2
index a6299da64de4..dd5d24a13cb9 100644
@@ -2060,12 +2060,23 @@ static int ctx_setparam(struct drm_i915_file_private *fpriv,
 	case I915_CONTEXT_PARAM_RECOVERABLE:
 		if (args->size)
 			ret = -EINVAL;
-		else if (args->value)
-			i915_gem_context_set_recoverable(ctx);
+		else if (args->value) {
+			if (!i915_gem_context_is_protected(ctx))
+				i915_gem_context_set_recoverable(ctx);
+			else
+				ret = -EPERM;
+			}
 		else
 			i915_gem_context_clear_recoverable(ctx);
 		break;
 
+	case I915_CONTEXT_PARAM_PROTECTED_CONTENT:
+		if (args->size)
+			ret = -EINVAL;
+		else if (args->value)
+			i915_gem_context_set_protected(ctx);
+		break;
+
 	case I915_CONTEXT_PARAM_PRIORITY:
 		ret = set_priority(ctx, args);
 		break;
drivers/gpu/drm/i915/gem/i915_gem_context.h +10 -0
index a133f92bbedb..5897e7ca11a8 100644
@@ -70,6 +70,16 @@ static inline void i915_gem_context_set_recoverable(struct i915_gem_context *ctx
 	set_bit(UCONTEXT_RECOVERABLE, &ctx->user_flags);
 }
 
+static inline void i915_gem_context_set_protected(struct i915_gem_context *ctx)
+{
+	set_bit(UCONTEXT_PROTECTED, &ctx->user_flags);
+}
+
+static inline bool i915_gem_context_is_protected(struct i915_gem_context *ctx)
+{
+	return test_bit(UCONTEXT_PROTECTED, &ctx->user_flags);
+}
+
 static inline void i915_gem_context_clear_recoverable(struct i915_gem_context *ctx)
 {
 	clear_bit(UCONTEXT_RECOVERABLE, &ctx->user_flags);
drivers/gpu/drm/i915/gem/i915_gem_context_types.h +1 -1
index ae14ca24a11f..81ae94c2be86 100644
@@ -135,7 +135,7 @@ struct i915_gem_context {
 #define UCONTEXT_BANNABLE		2
 #define UCONTEXT_RECOVERABLE		3
 #define UCONTEXT_PERSISTENCE		4
-
+#define UCONTEXT_PROTECTED		5
 	/**
 	 * @flags: small set of booleans
 	 */
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +5 -0
index e2d9b7e1e152..90ac955463f4 100644
@@ -161,6 +161,11 @@ struct drm_i915_gem_object {
 	} mmo;
 
 	I915_SELFTEST_DECLARE(struct list_head st_link);
+	/**
+	 * @user_flags: small set of booleans set by the user
+	 */
+	unsigned long user_flags;
+#define I915_BO_PROTECTED     BIT(0)
 
 	unsigned long flags;
 #define I915_BO_ALLOC_CONTIGUOUS BIT(0)
drivers/gpu/drm/i915/i915_gem.c +19 -4
index 41698a823737..6a791fd24eaa 100644
@@ -184,7 +184,8 @@ static int
 i915_gem_create(struct drm_file *file,
 		struct intel_memory_region *mr,
 		u64 *size_p,
-		u32 *handle_p)
+		u32 *handle_p,
+		u64 user_flags)
 {
 	struct drm_i915_gem_object *obj;
 	u32 handle;
@@ -204,6 +205,8 @@ i915_gem_create(struct drm_file *file,
 	if (IS_ERR(obj))
 		return PTR_ERR(obj);
 
+	obj->user_flags = user_flags;
+
 	ret = drm_gem_handle_create(file, &obj->base, &handle);
 	/* drop reference from allocate - handle holds it now */
 	i915_gem_object_put(obj);
@@ -258,11 +261,12 @@ i915_gem_dumb_create(struct drm_file *file,
 	return i915_gem_create(file,
 			       intel_memory_region_by_type(to_i915(dev),
 							   mem_type),
-			       &args->size, &args->handle);
+			       &args->size, &args->handle, 0);
 }
 
 struct create_ext {
-        struct drm_i915_private *i915;
+	struct drm_i915_private *i915;
+	unsigned long user_flags;
 };
 
 static int __create_setparam(struct drm_i915_gem_object_param *args,
@@ -273,6 +277,17 @@ static int __create_setparam(struct drm_i915_gem_object_param *args,
 		return -EINVAL;
 	}
 
+	switch (lower_32_bits(args->param)) {
+	case I915_PARAM_PROTECTED_CONTENT:
+		if (args->size) {
+			return -EINVAL;
+		} else if (args->data) {
+			ext_data->user_flags = args->data;
+			return 0;
+		}
+	break;
+	}
+
 	return -EINVAL;
 }
 
@@ -318,7 +333,7 @@ i915_gem_create_ioctl(struct drm_device *dev, void *data,
 	return i915_gem_create(file,
 			       intel_memory_region_by_type(i915,
 							   INTEL_MEMORY_SYSTEM),
-			       &args->size, &args->handle);
+			       &args->size, &args->handle, ext_data.user_flags);
 }
 
 static int
include/uapi/drm/i915_drm.h +19 -0
index e918ccc81c74..d6085a328b2c 100644
@@ -1715,6 +1715,15 @@ struct drm_i915_gem_context_param {
  * Default is 16 KiB.
  */
 #define I915_CONTEXT_PARAM_RINGSIZE	0xc
+
+/*
+ * I915_CONTEXT_PARAM_PROTECTED_CONTENT:
+ *
+ * If set to true (1) PAVP content protection is enabled.
+ * When enabled, the context is marked unrecoverable and may
+ * become invalid due to PAVP teardown event or other error.
+ */
+#define I915_CONTEXT_PARAM_PROTECTED_CONTENT    0xd
 /* Must be kept compact -- no holes and well documented */
 
 	__u64 value;
@@ -1734,6 +1743,16 @@ struct drm_i915_gem_object_param {
  */
 #define I915_OBJECT_PARAM  (1ull<<32)
 
+/*
+ * I915_PARAM_PROTECTED_CONTENT:
+ *
+ * If set to true (1) buffer contents is expected to be protected by
+ * PAVP encryption and requires decryption for scan out and processing.
+ * Protected buffers can only be used in PAVP protected contexts.
+ * A protected buffer may become invalid as a result of PAVP teardown.
+ */
+#define I915_PARAM_PROTECTED_CONTENT  0x1
+
 	__u64 param;
 
 	/* Data value or pointer */
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#22 lore raw

RFC v4 13/21 drm/i915/pxp: Add plane decryption support

In reply to Huang, Sean Z

From: Anshuman Gupta <[email protected]>

Add support to enable/disable PLANE_SURF Decryption Request bit. It requires only to enable plane decryption support when following condition met.
1. PAVP session is enabled.
2. Buffer object is protected.

v2:
- Rebased to libva_cp-drm-tip_tgl_cp tree.
- Used gen fb obj user_flags instead gem_object_metadata. [Krishna]

Cc Bommu Krishnaiah <[email protected]>
Cc Huang, Sean Z <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_sprite.c | 21 ++++++++++++++++++---
 drivers/gpu/drm/i915/i915_reg.h             |  1 +
 2 files changed, 19 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_sprite.c +18 -3
index b7e208816074..273bdc031e8d 100644
@@ -39,6 +39,8 @@
 #include <drm/drm_plane_helper.h>
 #include <drm/drm_rect.h>
 
+#include "pxp/intel_pxp.h"
+
 #include "i915_drv.h"
 #include "i915_trace.h"
 #include "i915_vgpu.h"
@@ -767,6 +769,11 @@ icl_program_input_csc(struct intel_plane *plane,
 			  PLANE_INPUT_CSC_POSTOFF(pipe, plane_id, 2), 0x0);
 }
 
+static bool intel_fb_obj_protected(const struct drm_i915_gem_object *obj)
+{
+	return obj->user_flags & I915_BO_PROTECTED ? true : false;
+}
+
 static void
 skl_plane_async_flip(struct intel_plane *plane,
 		     const struct intel_crtc_state *crtc_state,
@@ -803,6 +810,7 @@ skl_program_plane(struct intel_plane *plane,
 	u32 surf_addr = plane_state->color_plane[color_plane].offset;
 	u32 stride = skl_plane_stride(plane_state, color_plane);
 	const struct drm_framebuffer *fb = plane_state->hw.fb;
+	const struct drm_i915_gem_object *obj = intel_fb_obj(fb);
 	int aux_plane = intel_main_to_aux_plane(fb, color_plane);
 	int crtc_x = plane_state->uapi.dst.x1;
 	int crtc_y = plane_state->uapi.dst.y1;
@@ -813,7 +821,7 @@ skl_program_plane(struct intel_plane *plane,
 	u8 alpha = plane_state->hw.alpha >> 8;
 	u32 plane_color_ctl = 0, aux_dist = 0;
 	unsigned long irqflags;
-	u32 keymsk, keymax;
+	u32 keymsk, keymax, plane_surf;
 	u32 plane_ctl = plane_state->ctl;
 
 	plane_ctl |= skl_plane_ctl_crtc(crtc_state);
@@ -889,8 +897,15 @@ skl_program_plane(struct intel_plane *plane,
 	 * the control register just before the surface register.
 	 */
 	intel_de_write_fw(dev_priv, PLANE_CTL(pipe, plane_id), plane_ctl);
-	intel_de_write_fw(dev_priv, PLANE_SURF(pipe, plane_id),
-			  intel_plane_ggtt_offset(plane_state) + surf_addr);
+	plane_surf = intel_plane_ggtt_offset(plane_state) + surf_addr;
+
+	if (intel_pxp_gem_object_status(dev_priv) &&
+	    intel_fb_obj_protected(obj))
+		plane_surf |= PLANE_SURF_DECRYPTION_ENABLED;
+	else
+		plane_surf &= ~PLANE_SURF_DECRYPTION_ENABLED;
+
+	intel_de_write_fw(dev_priv, PLANE_SURF(pipe, plane_id), plane_surf);
 
 	if (plane_state->scaler_id >= 0)
 		skl_program_scaler(plane, crtc_state, plane_state);
drivers/gpu/drm/i915/i915_reg.h +1 -0
index 1e8dfe435ca8..0ea7e2a402ae 100644
@@ -7209,6 +7209,7 @@ enum {
 #define _PLANE_SURF_3(pipe)	_PIPE(pipe, _PLANE_SURF_3_A, _PLANE_SURF_3_B)
 #define PLANE_SURF(pipe, plane)	\
 	_MMIO_PLANE(plane, _PLANE_SURF_1(pipe), _PLANE_SURF_2(pipe))
+#define   PLANE_SURF_DECRYPTION_ENABLED		REG_BIT(2)
 
 #define _PLANE_OFFSET_1_B			0x711a4
 #define _PLANE_OFFSET_2_B			0x712a4
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#23 lore raw

RFC v4 14/21 drm/i915/pxp: Implement ioctl action to reserve session slots

In reply to Huang, Sean Z

With this ioctl action, userspace driver can reserve one or multiple session slot/id assigned by kernel PXP, as the first step of PXP session establishment flow. The session info is stored in the session list structure.

---
 drivers/gpu/drm/i915/Makefile                |   1 +
 drivers/gpu/drm/i915/pxp/intel_pxp.c         |  91 +++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp.h         |  22 +++
 drivers/gpu/drm/i915/pxp/intel_pxp_arb.c     |   2 -
 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c     |   3 -
 drivers/gpu/drm/i915/pxp/intel_pxp_context.c |   3 +
 drivers/gpu/drm/i915/pxp/intel_pxp_context.h |   3 +
 drivers/gpu/drm/i915/pxp/intel_pxp_sm.c      | 194 +++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_sm.h      |  44 +++++
 9 files changed, 358 insertions(+), 5 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
drivers/gpu/drm/i915/Makefile +1 -0
index 2545b59fa4f2..c96c5ed48e51 100644
@@ -261,6 +261,7 @@ i915-$(CONFIG_DRM_I915_PXP) += \
 	pxp/intel_pxp_cmd.o \
 	pxp/intel_pxp_context.o \
 	pxp/intel_pxp_pm.o \
+	pxp/intel_pxp_sm.o \
 	pxp/intel_pxp_tee.o
 
 # Post-mortem debug and GPU hang state capture
drivers/gpu/drm/i915/pxp/intel_pxp.c +91 -0

106 lines not on this page · raw message

drivers/gpu/drm/i915/pxp/intel_pxp.h +22 -0
index 027c0eb84a52..461b9321441f 100644
@@ -7,12 +7,21 @@
 #define __INTEL_PXP_H__
 
 #include <linux/workqueue.h>
+#include <drm/drm_file.h>
 #include "intel_pxp_context.h"
 
 #define PXP_IRQ_VECTOR_DISPLAY_PXP_STATE_TERMINATED BIT(1)
 #define PXP_IRQ_VECTOR_DISPLAY_APP_TERM_PER_FW_REQ BIT(2)
 #define PXP_IRQ_VECTOR_PXP_DISP_STATE_RESET_COMPLETE BIT(3)
 
+#define GEN12_KCR_SIP _MMIO(0x32260) /* KCR type0 session in play 0-31 */
+
+#define PXP_MAX_TYPE0_SESSIONS 16
+#define PXP_MAX_TYPE1_SESSIONS 6
+
+/* we need to reserve one type0 slot for arbitrary session */
+#define PXP_MAX_NORMAL_TYPE0_SESSIONS (PXP_MAX_TYPE0_SESSIONS - 1)
+
 enum pxp_session_types {
 	SESSION_TYPE_TYPE0 = 0,
 	SESSION_TYPE_TYPE1 = 1,
@@ -29,6 +38,13 @@ enum pxp_protection_modes {
 	PROTECTION_MODE_ALL
 };
 
+enum pxp_sm_status {
+	PXP_SM_STATUS_SUCCESS,
+	PXP_SM_STATUS_RETRY_REQUIRED,
+	PXP_SM_STATUS_SESSION_NOT_AVAILABLE,
+	PXP_SM_STATUS_ERROR_UNKNOWN
+};
+
 struct intel_pxp {
 	struct work_struct irq_work;
 	u32 handled_irr;
@@ -47,6 +63,7 @@ int i915_pxp_global_terminate_complete_callback(struct intel_pxp *pxp);
 int intel_pxp_init(struct intel_pxp *pxp);
 void intel_pxp_uninit(struct intel_pxp *pxp);
 bool intel_pxp_gem_object_status(struct drm_i915_private *i915);
+int i915_pxp_ops_ioctl(struct drm_device *dev, void *data, struct drm_file *drmfile);
 #else
 static inline void intel_pxp_irq_handler(struct intel_pxp *pxp, u16 iir)
 {
@@ -75,6 +92,11 @@ static inline bool intel_pxp_gem_object_status(struct drm_i915_private *i915)
 {
 	return false;
 }
+
+static inline int i915_pxp_ops_ioctl(struct drm_device *dev, void *data, struct drm_file *drmfile)
+{
+	return 0;
+}
 #endif
 
 #endif /* __INTEL_PXP_PM_H__ */
drivers/gpu/drm/i915/pxp/intel_pxp_arb.c +0 -2
index 09148ca9035c..286bb5b16632 100644
@@ -12,8 +12,6 @@
 #include "intel_pxp_tee.h"
 #include "intel_pxp_cmd.h"
 
-#define GEN12_KCR_SIP _MMIO(0x32260) /* KCR type0 session in play 0-31 */
-
 /* Arbitrary session */
 #define ARB_SESSION_INDEX 0xf
 #define ARB_SESSION_TYPE SESSION_TYPE_TYPE0
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c +0 -3
index 079024d5f063..17ff6bd61d20 100644
@@ -24,9 +24,6 @@
 /* CRYPTO_KEY_EXCHANGE */
 #define CRYPTO_KEY_EXCHANGE ((0x3 << 29) | (0x01609 << 16))
 
-#define PXP_MAX_TYPE0_SESSIONS 16
-#define PXP_MAX_TYPE1_SESSIONS 6
-
 static struct i915_vma *intel_pxp_cmd_get_batch(struct intel_pxp *pxp,
 						struct intel_context *ce,
 						struct intel_gt_buffer_pool_node *pool,
drivers/gpu/drm/i915/pxp/intel_pxp_context.c +3 -0
index d00f4e0b88ba..f690c1470bd5 100644
@@ -17,6 +17,9 @@ void intel_pxp_ctx_init(struct pxp_context *ctx)
 	ctx->global_state_attacked = false;
 
 	mutex_init(&ctx->mutex);
+
+	INIT_LIST_HEAD(&ctx->type0_sessions);
+	INIT_LIST_HEAD(&ctx->type1_sessions);
 }
 
 /**
drivers/gpu/drm/i915/pxp/intel_pxp_context.h +3 -0
index f03cba187c75..e8adafa58a0e 100644
@@ -16,6 +16,9 @@ struct pxp_context {
 	void *arb_session;
 	u32 arb_session_pxp_tag;
 
+	struct list_head type0_sessions;
+	struct list_head type1_sessions;
+
 	int id;
 
 	bool global_state_attacked;
drivers/gpu/drm/i915/pxp/intel_pxp_sm.c new file +194 -0

194 lines not on this page · raw message

drivers/gpu/drm/i915/pxp/intel_pxp_sm.h new file +44 -0

44 lines not on this page · raw message

Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#24 lore raw

RFC v4 15/21 drm/i915/pxp: Implement ioctl action to set session in play

In reply to Huang, Sean Z

With this ioctl action, userspace driver can set the session in state "session in play", after dirver reserved the session slot/id from kernel PXP, and sent the TEE commands to activate the corresponding hardware session. Session state "session in play" means this session is ready for secure playback.

---
 drivers/gpu/drm/i915/pxp/intel_pxp.c    | 11 +++++-
 drivers/gpu/drm/i915/pxp/intel_pxp_sm.c | 51 +++++++++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_sm.h |  2 +
 3 files changed, 63 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/pxp/intel_pxp.c +10 -1
index e294134fef78..e000a78b782e 100644
@@ -16,7 +16,13 @@
 #define KCR_INIT_ALLOW_DISPLAY_ME_WRITES (BIT(14) | (BIT(14) << KCR_INIT_MASK_SHIFT))
 
 #define PXP_ACTION_SET_SESSION_STATUS 1
-#define PXP_REQ_SESSION_ID_INIT 0
+
+enum pxp_session_req {
+	/* Request KMD to allocate session id and move it to IN INIT */
+	PXP_REQ_SESSION_ID_INIT = 0x0,
+	/* Inform KMD that UMD has completed the initialization */
+	PXP_REQ_SESSION_IN_PLAY,
+};
 
 /*
  * struct pxp_set_session_status_params - Params to reserved, set or destroy
@@ -228,6 +234,9 @@ int i915_pxp_ops_ioctl(struct drm_device *dev, void *data, struct drm_file *drmf
 				pxp_info.sm_status = ret;
 				ret = 0;
 			}
+		} else if (params->req_session_state == PXP_REQ_SESSION_IN_PLAY) {
+			ret = intel_pxp_sm_ioctl_mark_session_in_play(pxp, params->session_type,
+								      params->pxp_tag);
 		} else {
 			ret = -EINVAL;
 		}
drivers/gpu/drm/i915/pxp/intel_pxp_sm.c +51 -0

66 lines not on this page · raw message

drivers/gpu/drm/i915/pxp/intel_pxp_sm.h +2 -0
index 1d7916867ce6..eae8acd56510 100644
@@ -41,4 +41,6 @@ struct intel_pxp_sm_session {
 int intel_pxp_sm_ioctl_reserve_session(struct intel_pxp *pxp, struct drm_file *drmfile,
 				       int session_type, int protection_mode,
 				       u32 *pxp_tag);
+int intel_pxp_sm_ioctl_mark_session_in_play(struct intel_pxp *pxp, int session_type,
+					    u32 session_id);
 #endif /* __INTEL_PXP_SM_H__ */
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#25 lore raw

RFC v4 16/21 drm/i915/pxp: Implement ioctl action to terminate the session

In reply to Huang, Sean Z

Implement the PXP ioctl action to allow userspace driver to terminate the hardware session and cleanup its software session state. PXP sends the session termination command to GPU once receves this ioctl action.

---
 drivers/gpu/drm/i915/pxp/intel_pxp.c     |  10 +++
 drivers/gpu/drm/i915/pxp/intel_pxp.h     |   6 ++
 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c |  56 ++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_cmd.h |   2 +
 drivers/gpu/drm/i915/pxp/intel_pxp_pm.c  |   7 ++
 drivers/gpu/drm/i915/pxp/intel_pxp_sm.c  | 109 ++++++++++++++++++++---
 drivers/gpu/drm/i915/pxp/intel_pxp_sm.h  |   6 ++
 7 files changed, 186 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/pxp/intel_pxp.c +10 -0
index e000a78b782e..c35011b84f5a 100644
@@ -8,6 +8,7 @@
 #include "intel_pxp_tee.h"
 #include "intel_pxp_arb.h"
 #include "intel_pxp_sm.h"
+#include "intel_pxp_cmd.h"
 
 /* KCR register definitions */
 #define KCR_INIT            _MMIO(0x320f0)
@@ -22,6 +23,8 @@ enum pxp_session_req {
 	PXP_REQ_SESSION_ID_INIT = 0x0,
 	/* Inform KMD that UMD has completed the initialization */
 	PXP_REQ_SESSION_IN_PLAY,
+	/* Request KMD to terminate the session */
+	PXP_REQ_SESSION_TERMINATE
 };
 
 /*
@@ -68,7 +71,11 @@ static int intel_pxp_teardown_required_callback(struct intel_pxp *pxp)
 	pxp->ctx.flag_display_hm_surface_keys = false;
 
 	ret = intel_pxp_arb_terminate_session(pxp);
+	if (ret)
+		goto end;
 
+	ret = intel_pxp_sm_terminate_all_sessions(pxp, SESSION_TYPE_TYPE0);
+end:
 	mutex_unlock(&pxp->ctx.mutex);
 
 	return ret;
@@ -237,6 +244,9 @@ int i915_pxp_ops_ioctl(struct drm_device *dev, void *data, struct drm_file *drmf
 		} else if (params->req_session_state == PXP_REQ_SESSION_IN_PLAY) {
 			ret = intel_pxp_sm_ioctl_mark_session_in_play(pxp, params->session_type,
 								      params->pxp_tag);
+		} else if (params->req_session_state == PXP_REQ_SESSION_TERMINATE) {
+			ret = intel_pxp_sm_ioctl_terminate_session(pxp, params->session_type,
+								   params->pxp_tag);
 		} else {
 			ret = -EINVAL;
 		}
drivers/gpu/drm/i915/pxp/intel_pxp.h +6 -0
index 461b9321441f..e68c035d8448 100644
@@ -53,6 +53,12 @@ struct intel_pxp {
 	struct pxp_context ctx;
 };
 
+static inline int pxp_session_max(int session_type)
+{
+	return (session_type == SESSION_TYPE_TYPE0) ?
+		PXP_MAX_NORMAL_TYPE0_SESSIONS : PXP_MAX_TYPE1_SESSIONS;
+}
+
 struct drm_i915_private;
 
 #ifdef CONFIG_DRM_I915_PXP
drivers/gpu/drm/i915/pxp/intel_pxp_cmd.c +56 -0

65 lines not on this page · raw message

drivers/gpu/drm/i915/pxp/intel_pxp_cmd.h +2 -0
index 087f260034c4..ba008aa5df4e 100644
@@ -16,5 +16,7 @@ int intel_pxp_cmd_add_prolog(struct intel_pxp *pxp, u32 *cmd,
 			     int session_index);
 int intel_pxp_cmd_add_epilog(u32 *cmd);
 int intel_pxp_cmd_add_inline_termination(u32 *cmd);
+int intel_pxp_cmd_terminate_all_hw_session(struct intel_pxp *pxp,
+					   int session_type);
 
 #endif /* __INTEL_PXP_SM_H__ */
drivers/gpu/drm/i915/pxp/intel_pxp_pm.c +7 -0
index 0da2ecbf3b4d..73ec5e47b485 100644
@@ -6,6 +6,7 @@
 #include "intel_pxp_context.h"
 #include "intel_pxp_arb.h"
 #include "intel_pxp_pm.h"
+#include "intel_pxp_sm.h"
 
 void intel_pxp_pm_prepare_suspend(struct intel_pxp *pxp)
 {
@@ -55,6 +56,12 @@ int intel_pxp_pm_resume(struct intel_pxp *pxp)
 			goto end;
 		}
 
+		ret = intel_pxp_sm_terminate_all_sessions(pxp, SESSION_TYPE_TYPE0);
+		if (ret) {
+			drm_err(&gt->i915->drm, "Failed to terminate the sessions\n");
+			goto end;
+		}
+
 		pxp->ctx.global_state_in_suspend = false;
 	}
 
drivers/gpu/drm/i915/pxp/intel_pxp_sm.c +99 -10

148 lines not on this page · raw message

drivers/gpu/drm/i915/pxp/intel_pxp_sm.h +6 -0
index eae8acd56510..d9cf1c6e9ddf 100644
@@ -43,4 +43,10 @@ int intel_pxp_sm_ioctl_reserve_session(struct intel_pxp *pxp, struct drm_file *d
 				       u32 *pxp_tag);
 int intel_pxp_sm_ioctl_mark_session_in_play(struct intel_pxp *pxp, int session_type,
 					    u32 session_id);
+int intel_pxp_sm_ioctl_terminate_session(struct intel_pxp *pxp, int session_type,
+					 int session_id);
+
+bool intel_pxp_sm_is_hw_session_in_play(struct intel_pxp *pxp,
+					int session_type, int session_index);
+int intel_pxp_sm_terminate_all_sessions(struct intel_pxp *pxp, int session_type);
 #endif /* __INTEL_PXP_SM_H__ */
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#26 lore raw

RFC v4 17/21 drm/i915/pxp: Implement ioctl action to send TEE commands

In reply to Huang, Sean Z

Implement the ioctl action to allow userspace driver sends TEE commands via PXP ioctl, instead of TEE iotcl. So we can centralize those protection operations at PXP.

---
 drivers/gpu/drm/i915/pxp/intel_pxp.c     | 48 +++++++++++++++++---
 drivers/gpu/drm/i915/pxp/intel_pxp_tee.c | 57 ++++++++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_tee.h |  5 +++
 3 files changed, 105 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/pxp/intel_pxp.c +43 -5
index c35011b84f5a..2445af5f763c 100644
@@ -16,7 +16,10 @@
 /* Setting KCR Init bit is required after system boot */
 #define KCR_INIT_ALLOW_DISPLAY_ME_WRITES (BIT(14) | (BIT(14) << KCR_INIT_MASK_SHIFT))
 
-#define PXP_ACTION_SET_SESSION_STATUS 1
+enum pxp_ioctl_action {
+	PXP_ACTION_SET_SESSION_STATUS = 1,
+	PXP_ACTION_TEE_IO_MESSAGE = 4,
+};
 
 enum pxp_session_req {
 	/* Request KMD to allocate session id and move it to IN INIT */
@@ -38,13 +41,28 @@ struct pxp_set_session_status_params {
 	u32 req_session_state; /* in, new session state */
 };
 
+/*
+ * struct pxp_tee_io_message_params - Params to send/receive message to/from TEE.
+ */
+struct pxp_tee_io_message_params {
+	u8 __user *msg_in; /* in - message input */
+	u32 msg_in_size; /* in - message input size */
+	u8 __user *msg_out; /* in - message output buffer */
+	u32 msg_out_size; /* out- message output size from TEE */
+	u32 msg_out_buf_size; /* in - message output buffer size */
+};
+
 /* struct pxp_info - Params for PXP operation. */
 struct pxp_info {
 	u32 action; /* in - specified action of this operation */
 	u32 sm_status; /* out - status output for this operation */
 
-	/* in - action params to set the PXP session state */
-	struct pxp_set_session_status_params set_session_status;
+	union {
+		/* in - action params to set the PXP session state */
+		struct pxp_set_session_status_params set_session_status;
+		/* in - action params to send TEE commands */
+		struct pxp_tee_io_message_params tee_io_message;
+	};
 } __attribute__((packed));
 
 struct drm_i915_pxp_ops {
@@ -228,7 +246,9 @@ int i915_pxp_ops_ioctl(struct drm_device *dev, void *data, struct drm_file *drmf
 		goto end;
 	}
 
-	if (pxp_info.action == PXP_ACTION_SET_SESSION_STATUS) {
+	switch (pxp_info.action) {
+	case PXP_ACTION_SET_SESSION_STATUS:
+	{
 		struct pxp_set_session_status_params *params = &pxp_info.set_session_status;
 
 		if (params->req_session_state == PXP_REQ_SESSION_ID_INIT) {
@@ -250,8 +270,26 @@ int i915_pxp_ops_ioctl(struct drm_device *dev, void *data, struct drm_file *drmf
 		} else {
 			ret = -EINVAL;
 		}
-	} else {
+		break;
+	}
+	case PXP_ACTION_TEE_IO_MESSAGE:
+	{
+		struct pxp_tee_io_message_params *params = &pxp_info.tee_io_message;
+
+		ret = intel_pxp_tee_ioctl_io_message(pxp,
+						     params->msg_in, params->msg_in_size,
+						     params->msg_out, &params->msg_out_size,
+						     params->msg_out_buf_size);
+		if (ret) {
+			drm_err(&i915->drm, "Failed to send TEE IO message\n");
+			ret = -EFAULT;
+		}
+		break;
+	}
+	default:
+		drm_err(&i915->drm, "Failed to %s due to bad params\n", __func__);
 		ret = -EINVAL;
+		break;
 	}
 
 end:
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c +57 -0

60 lines not on this page · raw message

drivers/gpu/drm/i915/pxp/intel_pxp_tee.h +5 -0
index 757a54208a4d..d3129786758f 100644
@@ -13,6 +13,11 @@ void intel_pxp_tee_component_fini(struct intel_pxp *pxp);
 
 int intel_pxp_tee_cmd_create_arb_session(struct intel_pxp *pxp);
 
+int intel_pxp_tee_ioctl_io_message(struct intel_pxp *pxp,
+				   void __user *msg_in_user_ptr, u32 msg_in_size,
+				   void __user *msg_out_user_ptr, u32 *msg_out_size_ptr,
+				   u32 msg_out_buf_size);
+
 /* TEE command to create the arbitrary session */
 #define PXP_TEE_ARB_CMD_BIN {0x00040000, 0x0000001e, 0x00000000, 0x00000008, 0x00000002, 0x0000000f}
 #define PXP_TEE_ARB_CMD_DW_LEN (6)
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#27 lore raw

RFC v4 18/21 drm/i915/pxp: Enable ioctl action to query PXP tag

In reply to Huang, Sean Z

Enable the PXP ioctl action to allow userspace driver to query the PXP tag, which is a 32-bit bitwise value indicating the current session info, including protection type, session id, and whether the session is enabled.

---
 drivers/gpu/drm/i915/pxp/intel_pxp.c         |  20 +++
 drivers/gpu/drm/i915/pxp/intel_pxp.h         |   6 -
 drivers/gpu/drm/i915/pxp/intel_pxp_context.h |   9 ++
 drivers/gpu/drm/i915/pxp/intel_pxp_sm.c      | 130 ++++++++++++++++++-
 drivers/gpu/drm/i915/pxp/intel_pxp_sm.h      |   2 +
 5 files changed, 160 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/pxp/intel_pxp.c +20 -0
index 2445af5f763c..46ad2ab229c1 100644
@@ -17,6 +17,7 @@
 #define KCR_INIT_ALLOW_DISPLAY_ME_WRITES (BIT(14) | (BIT(14) << KCR_INIT_MASK_SHIFT))
 
 enum pxp_ioctl_action {
+	PXP_ACTION_QUERY_PXP_TAG = 0,
 	PXP_ACTION_SET_SESSION_STATUS = 1,
 	PXP_ACTION_TEE_IO_MESSAGE = 4,
 };
@@ -30,6 +31,15 @@ enum pxp_session_req {
 	PXP_REQ_SESSION_TERMINATE
 };
 
+/*
+ * struct pxp_sm_query_pxp_tag - Params to query the PXP tag of specified
+ * session id and whether the session is alive from PXP state machine.
+ */
+struct pxp_sm_query_pxp_tag {
+	u32 session_is_alive;
+	u32 pxp_tag; /* in  - Session ID, out pxp tag */
+};
+
 /*
  * struct pxp_set_session_status_params - Params to reserved, set or destroy
  * the session from the PXP state machine.
@@ -58,6 +68,8 @@ struct pxp_info {
 	u32 sm_status; /* out - status output for this operation */
 
 	union {
+		/* in - action params to query PXP tag */
+		struct pxp_sm_query_pxp_tag query_pxp_tag;
 		/* in - action params to set the PXP session state */
 		struct pxp_set_session_status_params set_session_status;
 		/* in - action params to send TEE commands */
@@ -272,6 +284,14 @@ int i915_pxp_ops_ioctl(struct drm_device *dev, void *data, struct drm_file *drmf
 		}
 		break;
 	}
+	case PXP_ACTION_QUERY_PXP_TAG:
+	{
+		struct pxp_sm_query_pxp_tag *params = &pxp_info.query_pxp_tag;
+
+		ret = intel_pxp_sm_ioctl_query_pxp_tag(pxp, &params->session_is_alive,
+						       &params->pxp_tag);
+		break;
+	}
 	case PXP_ACTION_TEE_IO_MESSAGE:
 	{
 		struct pxp_tee_io_message_params *params = &pxp_info.tee_io_message;
drivers/gpu/drm/i915/pxp/intel_pxp.h +0 -6
index e68c035d8448..133e3df9b1f6 100644
@@ -16,12 +16,6 @@
 
 #define GEN12_KCR_SIP _MMIO(0x32260) /* KCR type0 session in play 0-31 */
 
-#define PXP_MAX_TYPE0_SESSIONS 16
-#define PXP_MAX_TYPE1_SESSIONS 6
-
-/* we need to reserve one type0 slot for arbitrary session */
-#define PXP_MAX_NORMAL_TYPE0_SESSIONS (PXP_MAX_TYPE0_SESSIONS - 1)
-
 enum pxp_session_types {
 	SESSION_TYPE_TYPE0 = 0,
 	SESSION_TYPE_TYPE1 = 1,
drivers/gpu/drm/i915/pxp/intel_pxp_context.h +9 -0
index e8adafa58a0e..4338d893088c 100644
@@ -8,6 +8,12 @@
 
 #include <linux/mutex.h>
 
+#define PXP_MAX_TYPE0_SESSIONS 16
+#define PXP_MAX_TYPE1_SESSIONS 6
+
+/* we need to reserve one type0 slot for arbitrary session */
+#define PXP_MAX_NORMAL_TYPE0_SESSIONS (PXP_MAX_TYPE0_SESSIONS - 1)
+
 /* struct pxp_context - Represents combined view of driver and logical HW states. */
 struct pxp_context {
 	/** @mutex: mutex to protect the pxp context */
@@ -19,6 +25,9 @@ struct pxp_context {
 	struct list_head type0_sessions;
 	struct list_head type1_sessions;
 
+	u32 type0_pxp_tag[PXP_MAX_NORMAL_TYPE0_SESSIONS];
+	u32 type1_pxp_tag[PXP_MAX_TYPE1_SESSIONS];
+
 	int id;
 
 	bool global_state_attacked;
drivers/gpu/drm/i915/pxp/intel_pxp_sm.c +129 -1

163 lines not on this page · raw message

drivers/gpu/drm/i915/pxp/intel_pxp_sm.h +2 -0
index d9cf1c6e9ddf..003499aa9385 100644
@@ -45,6 +45,8 @@ int intel_pxp_sm_ioctl_mark_session_in_play(struct intel_pxp *pxp, int session_t
 					    u32 session_id);
 int intel_pxp_sm_ioctl_terminate_session(struct intel_pxp *pxp, int session_type,
 					 int session_id);
+int intel_pxp_sm_ioctl_query_pxp_tag(struct intel_pxp *pxp,
+				     u32 *session_is_alive, u32 *pxp_tag);
 
 bool intel_pxp_sm_is_hw_session_in_play(struct intel_pxp *pxp,
 					int session_type, int session_index);
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#28 lore raw

RFC v4 19/21 drm/i915/pxp: Termiante the session upon app crash

In reply to Huang, Sean Z

PXP should terminate the hardware session and cleanup the software state gracefully when the application has established the protection session, but doesn't close the session correctly due to some cases like application crash.

---
 drivers/gpu/drm/i915/i915_drv.c         |  3 +++
 drivers/gpu/drm/i915/pxp/intel_pxp.c    | 15 +++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp.h    |  5 +++++
 drivers/gpu/drm/i915/pxp/intel_pxp_sm.c | 25 +++++++++++++++++++++++++
 drivers/gpu/drm/i915/pxp/intel_pxp_sm.h |  1 +
 5 files changed, 49 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +3 -0
index 3dbda949bf71..e74201e81369 100644
@@ -69,6 +69,7 @@
 #include "gt/intel_rc6.h"
 
 #include "pxp/intel_pxp_pm.h"
+#include "pxp/intel_pxp.h"
 
 #include "i915_debugfs.h"
 #include "i915_drv.h"
@@ -1026,6 +1027,8 @@ static void i915_driver_postclose(struct drm_device *dev, struct drm_file *file)
 
 	/* Catch up with all the deferred frees from "this" client */
 	i915_gem_flush_free_objects(to_i915(dev));
+
+	intel_pxp_close(&(to_i915(dev)->gt.pxp), file);
 }
 
 static void intel_suspend_encoders(struct drm_i915_private *dev_priv)
drivers/gpu/drm/i915/pxp/intel_pxp.c +15 -0
index 46ad2ab229c1..789990b3a5e3 100644
@@ -320,3 +320,18 @@ int i915_pxp_ops_ioctl(struct drm_device *dev, void *data, struct drm_file *drmf
 			ret = -EFAULT;
 	return ret;
 }
+
+void intel_pxp_close(struct intel_pxp *pxp, struct drm_file *drmfile)
+{
+	int ret;
+	struct intel_gt *gt = container_of(pxp, typeof(*gt), pxp);
+
+	if (!drmfile)
+		return;
+
+	mutex_lock(&pxp->ctx.mutex);
+	ret = intel_pxp_sm_close(pxp, drmfile);
+	if (ret)
+		drm_err(&gt->i915->drm, "Failed to %s, ret=[%d]\n", __func__, ret);
+	mutex_unlock(&pxp->ctx.mutex);
+}
drivers/gpu/drm/i915/pxp/intel_pxp.h +5 -0
index 133e3df9b1f6..ffb460327315 100644
@@ -64,6 +64,7 @@ int intel_pxp_init(struct intel_pxp *pxp);
 void intel_pxp_uninit(struct intel_pxp *pxp);
 bool intel_pxp_gem_object_status(struct drm_i915_private *i915);
 int i915_pxp_ops_ioctl(struct drm_device *dev, void *data, struct drm_file *drmfile);
+void intel_pxp_close(struct intel_pxp *pxp, struct drm_file *drmfile);
 #else
 static inline void intel_pxp_irq_handler(struct intel_pxp *pxp, u16 iir)
 {
@@ -97,6 +98,10 @@ static inline int i915_pxp_ops_ioctl(struct drm_device *dev, void *data, struct
 {
 	return 0;
 }
+
+static inline void intel_pxp_close(struct intel_pxp *pxp, struct drm_file *drmfile)
+{
+}
 #endif
 
 #endif /* __INTEL_PXP_PM_H__ */
drivers/gpu/drm/i915/pxp/intel_pxp_sm.c +25 -0
index fd1dc1269c4e..fcf11c61bffb 100644
@@ -460,3 +460,28 @@ int intel_pxp_sm_ioctl_query_pxp_tag(struct intel_pxp *pxp,
 
 	return 0;
 }
+
+int intel_pxp_sm_close(struct intel_pxp *pxp, struct drm_file *drmfile)
+{
+	int ret;
+	struct intel_pxp_sm_session *curr;
+
+	list_for_each_entry(curr, session_list(pxp, SESSION_TYPE_TYPE0), list) {
+		if (curr->drmfile && curr->drmfile == drmfile &&
+		    curr->pid == pid_nr(drmfile->pid)) {
+			ret = pxp_terminate_hw_session(pxp, curr->type,
+						       curr->index);
+			if (ret)
+				return ret;
+
+			ret = pxp_set_pxp_tag(pxp, curr->type, curr->index,
+					      PROTECTION_MODE_NONE);
+			if (ret)
+				return ret;
+
+			list_del(&curr->list);
+			kfree(curr);
+		}
+	}
+	return 0;
+}
drivers/gpu/drm/i915/pxp/intel_pxp_sm.h +1 -0
index 003499aa9385..59a4dee01880 100644
@@ -51,4 +51,5 @@ int intel_pxp_sm_ioctl_query_pxp_tag(struct intel_pxp *pxp,
 bool intel_pxp_sm_is_hw_session_in_play(struct intel_pxp *pxp,
 					int session_type, int session_index);
 int intel_pxp_sm_terminate_all_sessions(struct intel_pxp *pxp, int session_type);
+int intel_pxp_sm_close(struct intel_pxp *pxp, struct drm_file *drmfile);
 #endif /* __INTEL_PXP_SM_H__ */
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#29 lore raw

RFC v4 20/21 drm/i915/pxp: Add PXP-related registers into allowlist

In reply to Huang, Sean Z

Add several PXP-related reg into allowlist to allow user space driver to read the those register values.

---
 drivers/gpu/drm/i915/i915_reg.h     |  6 ++++
 drivers/gpu/drm/i915/intel_uncore.c | 50 ++++++++++++++++++++---------
 2 files changed, 41 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +6 -0
index 0ea7e2a402ae..bcb7eb7a0e3c 100644
@@ -12425,4 +12425,10 @@ enum skl_power_gate {
 #define TGL_ROOT_DEVICE_SKU_ULX		0x2
 #define TGL_ROOT_DEVICE_SKU_ULT		0x4
 
+/* Registers for allowlist check */
+#define PXP_REG_01_LOWERBOUND		_MMIO(0x32260)
+#define PXP_REG_01_UPPERBOUND		_MMIO(0x32268)
+#define PXP_REG_02_LOWERBOUND		_MMIO(0x32670)
+#define PXP_REG_02_UPPERBOUND		_MMIO(0x32678)
+
 #endif /* _I915_REG_H_ */
drivers/gpu/drm/i915/intel_uncore.c +35 -15

92 lines not on this page · raw message

Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#30 lore raw

RFC v4 21/21 drm/i915/pxp: Enable the PXP ioctl for protected session

In reply to Huang, Sean Z

In the previous commits, we have implemented the PXP ioctl functions. Now we enable those handlers and expose them as PXP ioctl, so allow the userspace driver can establish, set, or destory the protected session via this ioctl.

---
 drivers/gpu/drm/i915/i915_drv.c      |  1 +
 drivers/gpu/drm/i915/pxp/intel_pxp.c | 53 --------------------
 include/uapi/drm/i915_drm.h          | 72 ++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+), 53 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +1 -0
index e74201e81369..201550ffb353 100644
@@ -1766,6 +1766,7 @@ static const struct drm_ioctl_desc i915_ioctls[] = {
 	DRM_IOCTL_DEF_DRV(I915_QUERY, i915_query_ioctl, DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(I915_GEM_VM_CREATE, i915_gem_vm_create_ioctl, DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(I915_GEM_VM_DESTROY, i915_gem_vm_destroy_ioctl, DRM_RENDER_ALLOW),
+	DRM_IOCTL_DEF_DRV(I915_PXP_OPS, i915_pxp_ops_ioctl, DRM_RENDER_ALLOW),
 };
 
 static const struct drm_driver driver = {
drivers/gpu/drm/i915/pxp/intel_pxp.c +0 -53

59 lines not on this page · raw message

include/uapi/drm/i915_drm.h +72 -0

90 lines not on this page · raw message

Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#31 lore raw

[Intel-gfx] ✗ Fi.CI.BUILD: failure for Introduce Intel PXP component - Mesa single session (rev4)

In reply to Huang, Sean Z
== Series Details ==

== Series Details ==

Series: Introduce Intel PXP component - Mesa single session (rev4)
URL : https://patchwork.freedesktop.org/series/84620/
State : failure

== Summary ==

CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool
CHK include/generated/compile.h
HDRTEST drivers/gpu/drm/i915/pxp/intel_pxp_sm.h
In file included from <command-line>:
./drivers/gpu/drm/i915/pxp/intel_pxp_sm.h:17:19: error: field ‘list’ has incomplete type

  struct list_head list;
                   ^~~~

./drivers/gpu/drm/i915/pxp/intel_pxp_sm.h:38:2: error: unknown type name ‘bool’
bool is_in_play;
^~~~
./drivers/gpu/drm/i915/pxp/intel_pxp_sm.h:43:12: error: unknown type name ‘u32’

            u32 *pxp_tag);
            ^~~
./drivers/gpu/drm/i915/pxp/intel_pxp_sm.h:45:10: error: unknown type name ‘u32’
          u32 session_id);
          ^~~
./drivers/gpu/drm/i915/pxp/intel_pxp_sm.h:49:10: error: unknown type name ‘u32’
          u32 *session_is_alive, u32 *pxp_tag);
          ^~~
./drivers/gpu/drm/i915/pxp/intel_pxp_sm.h:49:33: error: unknown type name ‘u32’
          u32 *session_is_alive, u32 *pxp_tag);
                                 ^~~

./drivers/gpu/drm/i915/pxp/intel_pxp_sm.h:51:1: error: unknown type name ‘bool’; did you mean ‘_Bool’?
bool intel_pxp_sm_is_hw_session_in_play(struct intel_pxp *pxp,
^~~~
_Bool
drivers/gpu/drm/i915/Makefile:315: recipe for target 'drivers/gpu/drm/i915/pxp/intel_pxp_sm.hdrtest' failed make[4]: *** [drivers/gpu/drm/i915/pxp/intel_pxp_sm.hdrtest] Error 1 scripts/Makefile.build:496: recipe for target 'drivers/gpu/drm/i915' failed
make[3]: *** [drivers/gpu/drm/i915] Error 2
scripts/Makefile.build:496: recipe for target 'drivers/gpu/drm' failed
make[2]: *** [drivers/gpu/drm] Error 2
scripts/Makefile.build:496: recipe for target 'drivers/gpu' failed
make[1]: *** [drivers/gpu] Error 2
Makefile:1805: recipe for target 'drivers' failed
make: *** [drivers] Error 2

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx