drm/i915/pxp: load the pxp module when we have a gsc-loaded huc

The mei_pxp module is required to send the command to load authenticate
the HuC to the GSC even if pxp is not in use for protected content
management.
Signed-off-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Alan Previn <alan.previn.teres.alexis@intel.com>
Reviewed-by: default avatarAlan Previn <alan.previn.teres.alexis@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220928004145.745803-8-daniele.ceraolospurio@intel.com
parent bd58904a
......@@ -309,15 +309,17 @@ i915-y += \
i915-y += i915_perf.o
# Protected execution platform (PXP) support
i915-$(CONFIG_DRM_I915_PXP) += \
# Protected execution platform (PXP) support. Base support is required for HuC
i915-y += \
pxp/intel_pxp.o \
pxp/intel_pxp_tee.o
i915-$(CONFIG_DRM_I915_PXP) += \
pxp/intel_pxp_cmd.o \
pxp/intel_pxp_debugfs.o \
pxp/intel_pxp_irq.o \
pxp/intel_pxp_pm.o \
pxp/intel_pxp_session.o \
pxp/intel_pxp_tee.o
pxp/intel_pxp_session.o
# Post-mortem debug and GPU hang state capture
i915-$(CONFIG_DRM_I915_CAPTURE_ERROR) += i915_gpu_error.o
......
......@@ -103,19 +103,15 @@ static int create_vcs_context(struct intel_pxp *pxp)
static void destroy_vcs_context(struct intel_pxp *pxp)
{
intel_engine_destroy_pinned_context(fetch_and_zero(&pxp->ce));
if (pxp->ce)
intel_engine_destroy_pinned_context(fetch_and_zero(&pxp->ce));
}
void intel_pxp_init(struct intel_pxp *pxp)
static void pxp_init_full(struct intel_pxp *pxp)
{
struct intel_gt *gt = pxp_to_gt(pxp);
int ret;
if (!HAS_PXP(gt->i915))
return;
mutex_init(&pxp->tee_mutex);
/*
* we'll use the completion to check if there is a termination pending,
* so we start it as completed and we reinit it when a termination
......@@ -124,8 +120,7 @@ void intel_pxp_init(struct intel_pxp *pxp)
init_completion(&pxp->termination);
complete_all(&pxp->termination);
mutex_init(&pxp->arb_mutex);
INIT_WORK(&pxp->session_work, intel_pxp_session_work);
intel_pxp_session_management_init(pxp);
ret = create_vcs_context(pxp);
if (ret)
......@@ -143,11 +138,26 @@ void intel_pxp_init(struct intel_pxp *pxp)
destroy_vcs_context(pxp);
}
void intel_pxp_fini(struct intel_pxp *pxp)
void intel_pxp_init(struct intel_pxp *pxp)
{
if (!intel_pxp_is_enabled(pxp))
struct intel_gt *gt = pxp_to_gt(pxp);
/* we rely on the mei PXP module */
if (!IS_ENABLED(CONFIG_INTEL_MEI_PXP))
return;
/*
* If HuC is loaded by GSC but PXP is disabled, we can skip the init of
* the full PXP session/object management and just init the tee channel.
*/
if (HAS_PXP(gt->i915))
pxp_init_full(pxp);
else if (intel_huc_is_loaded_by_gsc(&gt->uc.huc) && intel_uc_uses_huc(&gt->uc))
intel_pxp_tee_component_init(pxp);
}
void intel_pxp_fini(struct intel_pxp *pxp)
{
pxp->arb_is_valid = false;
intel_pxp_tee_component_fini(pxp);
......
......@@ -12,7 +12,6 @@
struct intel_pxp;
struct drm_i915_gem_object;
#ifdef CONFIG_DRM_I915_PXP
struct intel_gt *pxp_to_gt(const struct intel_pxp *pxp);
bool intel_pxp_is_enabled(const struct intel_pxp *pxp);
bool intel_pxp_is_active(const struct intel_pxp *pxp);
......@@ -32,36 +31,5 @@ int intel_pxp_key_check(struct intel_pxp *pxp,
bool assign);
void intel_pxp_invalidate(struct intel_pxp *pxp);
#else
static inline void intel_pxp_init(struct intel_pxp *pxp)
{
}
static inline void intel_pxp_fini(struct intel_pxp *pxp)
{
}
static inline int intel_pxp_start(struct intel_pxp *pxp)
{
return -ENODEV;
}
static inline bool intel_pxp_is_enabled(const struct intel_pxp *pxp)
{
return false;
}
static inline bool intel_pxp_is_active(const struct intel_pxp *pxp)
{
return false;
}
static inline int intel_pxp_key_check(struct intel_pxp *pxp,
struct drm_i915_gem_object *obj,
bool assign)
{
return -ENODEV;
}
#endif
#endif /* __INTEL_PXP_H__ */
......@@ -27,6 +27,14 @@ void intel_pxp_irq_handler(struct intel_pxp *pxp, u16 iir);
static inline void intel_pxp_irq_handler(struct intel_pxp *pxp, u16 iir)
{
}
static inline void intel_pxp_irq_enable(struct intel_pxp *pxp)
{
}
static inline void intel_pxp_irq_disable(struct intel_pxp *pxp)
{
}
#endif
#endif /* __INTEL_PXP_IRQ_H__ */
......@@ -137,7 +137,7 @@ static void pxp_terminate_complete(struct intel_pxp *pxp)
complete_all(&pxp->termination);
}
void intel_pxp_session_work(struct work_struct *work)
static void pxp_session_work(struct work_struct *work)
{
struct intel_pxp *pxp = container_of(work, typeof(*pxp), session_work);
struct intel_gt *gt = pxp_to_gt(pxp);
......@@ -172,3 +172,9 @@ void intel_pxp_session_work(struct work_struct *work)
intel_runtime_pm_put(gt->uncore->rpm, wakeref);
}
void intel_pxp_session_management_init(struct intel_pxp *pxp)
{
mutex_init(&pxp->arb_mutex);
INIT_WORK(&pxp->session_work, pxp_session_work);
}
......@@ -8,8 +8,13 @@
#include <linux/types.h>
struct work_struct;
void intel_pxp_session_work(struct work_struct *work);
struct intel_pxp;
#ifdef CONFIG_DRM_I915_PXP
void intel_pxp_session_management_init(struct intel_pxp *pxp);
#else
static inline void intel_pxp_session_management_init(struct intel_pxp *pxp)
{
}
#endif
#endif /* __INTEL_PXP_SESSION_H__ */
......@@ -97,7 +97,8 @@ static int i915_pxp_tee_component_bind(struct device *i915_kdev,
return 0;
/* the component is required to fully start the PXP HW */
intel_pxp_init_hw(pxp);
if (intel_pxp_is_enabled(pxp))
intel_pxp_init_hw(pxp);
intel_runtime_pm_put(&i915->runtime_pm, wakeref);
......@@ -111,8 +112,9 @@ static void i915_pxp_tee_component_unbind(struct device *i915_kdev,
struct intel_pxp *pxp = i915_dev_to_pxp(i915_kdev);
intel_wakeref_t wakeref;
with_intel_runtime_pm_if_in_use(&i915->runtime_pm, wakeref)
intel_pxp_fini_hw(pxp);
if (intel_pxp_is_enabled(pxp))
with_intel_runtime_pm_if_in_use(&i915->runtime_pm, wakeref)
intel_pxp_fini_hw(pxp);
mutex_lock(&pxp->tee_mutex);
pxp->pxp_component = NULL;
......@@ -130,6 +132,8 @@ int intel_pxp_tee_component_init(struct intel_pxp *pxp)
struct intel_gt *gt = pxp_to_gt(pxp);
struct drm_i915_private *i915 = gt->i915;
mutex_init(&pxp->tee_mutex);
ret = component_add_typed(i915->drm.dev, &i915_pxp_tee_component_ops,
I915_COMPONENT_PXP);
if (ret < 0) {
......
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