Commit 0436ac1b authored by Huang, Sean Z's avatar Huang, Sean Z Committed by Rodrigo Vivi

drm/i915/pxp: Implement funcs to create the TEE channel

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

v2: fix locking, don't pollute dev_priv (Chris)

v3: wait for mei PXP component to be bound.

v4: drop the wait, as the component might be bound after i915 load
completes. We'll instead check when sending a tee message.

v5: fix an issue with mei_pxp module removal

v6: don't use fetch_and_zero in fini (Rodrigo)
Signed-off-by: default avatarHuang, Sean Z <sean.z.huang@intel.com>
Signed-off-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210924191452.1539378-6-alan.previn.teres.alexis@intel.com
parent 3ad2dd9c
...@@ -280,7 +280,8 @@ i915-y += i915_perf.o ...@@ -280,7 +280,8 @@ i915-y += i915_perf.o
# Protected execution platform (PXP) support # Protected execution platform (PXP) support
i915-$(CONFIG_DRM_I915_PXP) += \ i915-$(CONFIG_DRM_I915_PXP) += \
pxp/intel_pxp.o pxp/intel_pxp.o \
pxp/intel_pxp_tee.o
# Post-mortem debug and GPU hang state capture # Post-mortem debug and GPU hang state capture
i915-$(CONFIG_DRM_I915_CAPTURE_ERROR) += i915_gpu_error.o i915-$(CONFIG_DRM_I915_CAPTURE_ERROR) += i915_gpu_error.o
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* Copyright(c) 2020 Intel Corporation. * Copyright(c) 2020 Intel Corporation.
*/ */
#include "intel_pxp.h" #include "intel_pxp.h"
#include "intel_pxp_tee.h"
#include "gt/intel_context.h" #include "gt/intel_context.h"
#include "i915_drv.h" #include "i915_drv.h"
...@@ -58,7 +59,16 @@ void intel_pxp_init(struct intel_pxp *pxp) ...@@ -58,7 +59,16 @@ void intel_pxp_init(struct intel_pxp *pxp)
if (ret) if (ret)
return; return;
ret = intel_pxp_tee_component_init(pxp);
if (ret)
goto out_context;
drm_info(&gt->i915->drm, "Protected Xe Path (PXP) protected content support initialized\n"); drm_info(&gt->i915->drm, "Protected Xe Path (PXP) protected content support initialized\n");
return;
out_context:
destroy_vcs_context(pxp);
} }
void intel_pxp_fini(struct intel_pxp *pxp) void intel_pxp_fini(struct intel_pxp *pxp)
...@@ -66,5 +76,8 @@ void intel_pxp_fini(struct intel_pxp *pxp) ...@@ -66,5 +76,8 @@ void intel_pxp_fini(struct intel_pxp *pxp)
if (!intel_pxp_is_enabled(pxp)) if (!intel_pxp_is_enabled(pxp))
return; return;
intel_pxp_tee_component_fini(pxp);
destroy_vcs_context(pxp); destroy_vcs_context(pxp);
} }
// SPDX-License-Identifier: MIT
/*
* Copyright(c) 2020 Intel Corporation.
*/
#include <linux/component.h>
#include "drm/i915_pxp_tee_interface.h"
#include "drm/i915_component.h"
#include "i915_drv.h"
#include "intel_pxp.h"
#include "intel_pxp_tee.h"
static inline struct intel_pxp *i915_dev_to_pxp(struct device *i915_kdev)
{
return &kdev_to_i915(i915_kdev)->gt.pxp;
}
/**
* i915_pxp_tee_component_bind - bind function 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.
*/
static int i915_pxp_tee_component_bind(struct device *i915_kdev,
struct device *tee_kdev, void *data)
{
struct intel_pxp *pxp = i915_dev_to_pxp(i915_kdev);
pxp->pxp_component = data;
pxp->pxp_component->tee_dev = tee_kdev;
return 0;
}
static void i915_pxp_tee_component_unbind(struct device *i915_kdev,
struct device *tee_kdev, void *data)
{
struct intel_pxp *pxp = i915_dev_to_pxp(i915_kdev);
pxp->pxp_component = NULL;
}
static const struct component_ops i915_pxp_tee_component_ops = {
.bind = i915_pxp_tee_component_bind,
.unbind = i915_pxp_tee_component_unbind,
};
int intel_pxp_tee_component_init(struct intel_pxp *pxp)
{
int ret;
struct intel_gt *gt = pxp_to_gt(pxp);
struct drm_i915_private *i915 = gt->i915;
ret = component_add_typed(i915->drm.dev, &i915_pxp_tee_component_ops,
I915_COMPONENT_PXP);
if (ret < 0) {
drm_err(&i915->drm, "Failed to add PXP component (%d)\n", ret);
return ret;
}
pxp->pxp_component_added = true;
return 0;
}
void intel_pxp_tee_component_fini(struct intel_pxp *pxp)
{
struct drm_i915_private *i915 = pxp_to_gt(pxp)->i915;
if (!pxp->pxp_component_added)
return;
component_del(i915->drm.dev, &i915_pxp_tee_component_ops);
pxp->pxp_component_added = false;
}
/* 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"
int intel_pxp_tee_component_init(struct intel_pxp *pxp);
void intel_pxp_tee_component_fini(struct intel_pxp *pxp);
#endif /* __INTEL_PXP_TEE_H__ */
...@@ -9,8 +9,12 @@ ...@@ -9,8 +9,12 @@
#include <linux/types.h> #include <linux/types.h>
struct intel_context; struct intel_context;
struct i915_pxp_component;
struct intel_pxp { struct intel_pxp {
struct i915_pxp_component *pxp_component;
bool pxp_component_added;
struct intel_context *ce; struct intel_context *ce;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment