Lines Matching full:pxp
23 * DOC: PXP
25 * PXP (Protected Xe Path) is a feature available in Gen12 and newer platforms.
29 * Objects can opt-in to PXP encryption at creation time via the
35 * Protected objects are tied to a pxp session; currently we only support one
45 * Some of the PXP setup operations are performed by the Management Engine,
50 bool intel_pxp_is_supported(const struct intel_pxp *pxp) in intel_pxp_is_supported() argument
52 return IS_ENABLED(CONFIG_DRM_I915_PXP) && pxp; in intel_pxp_is_supported()
55 bool intel_pxp_is_enabled(const struct intel_pxp *pxp) in intel_pxp_is_enabled() argument
57 return IS_ENABLED(CONFIG_DRM_I915_PXP) && pxp && pxp->ce; in intel_pxp_is_enabled()
60 bool intel_pxp_is_active(const struct intel_pxp *pxp) in intel_pxp_is_active() argument
62 return IS_ENABLED(CONFIG_DRM_I915_PXP) && pxp && pxp->arb_is_valid; in intel_pxp_is_active()
65 static void kcr_pxp_set_status(const struct intel_pxp *pxp, bool enable) in kcr_pxp_set_status() argument
70 intel_uncore_write(pxp->ctrl_gt->uncore, KCR_INIT(pxp->kcr_base), val); in kcr_pxp_set_status()
73 static void kcr_pxp_enable(const struct intel_pxp *pxp) in kcr_pxp_enable() argument
75 kcr_pxp_set_status(pxp, true); in kcr_pxp_enable()
78 static void kcr_pxp_disable(const struct intel_pxp *pxp) in kcr_pxp_disable() argument
80 kcr_pxp_set_status(pxp, false); in kcr_pxp_disable()
83 static int create_vcs_context(struct intel_pxp *pxp) in create_vcs_context() argument
86 struct intel_gt *gt = pxp->ctrl_gt; in create_vcs_context()
104 drm_err(>->i915->drm, "failed to create VCS ctx for PXP\n"); in create_vcs_context()
108 pxp->ce = ce; in create_vcs_context()
113 static void destroy_vcs_context(struct intel_pxp *pxp) in destroy_vcs_context() argument
115 if (pxp->ce) in destroy_vcs_context()
116 intel_engine_destroy_pinned_context(fetch_and_zero(&pxp->ce)); in destroy_vcs_context()
119 static void pxp_init_full(struct intel_pxp *pxp) in pxp_init_full() argument
121 struct intel_gt *gt = pxp->ctrl_gt; in pxp_init_full()
129 init_completion(&pxp->termination); in pxp_init_full()
130 complete_all(&pxp->termination); in pxp_init_full()
132 if (pxp->ctrl_gt->type == GT_MEDIA) in pxp_init_full()
133 pxp->kcr_base = MTL_KCR_BASE; in pxp_init_full()
135 pxp->kcr_base = GEN12_KCR_BASE; in pxp_init_full()
137 intel_pxp_session_management_init(pxp); in pxp_init_full()
139 ret = create_vcs_context(pxp); in pxp_init_full()
143 if (HAS_ENGINE(pxp->ctrl_gt, GSC0)) in pxp_init_full()
144 ret = intel_pxp_gsccs_init(pxp); in pxp_init_full()
146 ret = intel_pxp_tee_component_init(pxp); in pxp_init_full()
150 drm_info(>->i915->drm, "Protected Xe Path (PXP) protected content support initialized\n"); in pxp_init_full()
155 destroy_vcs_context(pxp); in pxp_init_full()
161 * NOTE: Only certain platforms require PXP-tee-backend dependencies in find_gt_for_required_teelink()
177 * For MTL onwards, PXP-controller-GT needs to have a valid GSC engine in find_gt_for_required_protected_content()
188 * Else we rely on mei-pxp module but only on legacy platforms in find_gt_for_required_protected_content()
207 * we still need it if PXP's backend tee transport is needed. in intel_pxp_init()
219 * At this point, we will either enable full featured PXP capabilities in intel_pxp_init()
223 i915->pxp = kzalloc(sizeof(*i915->pxp), GFP_KERNEL); in intel_pxp_init()
224 if (!i915->pxp) in intel_pxp_init()
228 i915->pxp->ctrl_gt = gt; in intel_pxp_init()
229 mutex_init(&i915->pxp->tee_mutex); in intel_pxp_init()
232 * If full PXP feature is not available but HuC is loaded by GSC on pre-MTL in intel_pxp_init()
233 * such as DG2, we can skip the init of the full PXP session/object management in intel_pxp_init()
237 pxp_init_full(i915->pxp); in intel_pxp_init()
239 intel_pxp_tee_component_init(i915->pxp); in intel_pxp_init()
246 if (!i915->pxp) in intel_pxp_fini()
249 i915->pxp->arb_is_valid = false; in intel_pxp_fini()
251 if (HAS_ENGINE(i915->pxp->ctrl_gt, GSC0)) in intel_pxp_fini()
252 intel_pxp_gsccs_fini(i915->pxp); in intel_pxp_fini()
254 intel_pxp_tee_component_fini(i915->pxp); in intel_pxp_fini()
256 destroy_vcs_context(i915->pxp); in intel_pxp_fini()
258 kfree(i915->pxp); in intel_pxp_fini()
259 i915->pxp = NULL; in intel_pxp_fini()
262 void intel_pxp_mark_termination_in_progress(struct intel_pxp *pxp) in intel_pxp_mark_termination_in_progress() argument
264 pxp->arb_is_valid = false; in intel_pxp_mark_termination_in_progress()
265 reinit_completion(&pxp->termination); in intel_pxp_mark_termination_in_progress()
268 static void pxp_queue_termination(struct intel_pxp *pxp) in pxp_queue_termination() argument
270 struct intel_gt *gt = pxp->ctrl_gt; in pxp_queue_termination()
277 intel_pxp_mark_termination_in_progress(pxp); in pxp_queue_termination()
278 pxp->session_events |= PXP_TERMINATION_REQUEST; in pxp_queue_termination()
279 queue_work(system_unbound_wq, &pxp->session_work); in pxp_queue_termination()
283 static bool pxp_component_bound(struct intel_pxp *pxp) in pxp_component_bound() argument
287 mutex_lock(&pxp->tee_mutex); in pxp_component_bound()
288 if (pxp->pxp_component) in pxp_component_bound()
290 mutex_unlock(&pxp->tee_mutex); in pxp_component_bound()
295 int intel_pxp_get_backend_timeout_ms(struct intel_pxp *pxp) in intel_pxp_get_backend_timeout_ms() argument
297 if (HAS_ENGINE(pxp->ctrl_gt, GSC0)) in intel_pxp_get_backend_timeout_ms()
303 static int __pxp_global_teardown_final(struct intel_pxp *pxp) in __pxp_global_teardown_final() argument
307 if (!pxp->arb_is_valid) in __pxp_global_teardown_final()
310 drm_dbg(&pxp->ctrl_gt->i915->drm, "PXP: teardown for suspend/fini"); in __pxp_global_teardown_final()
315 intel_pxp_mark_termination_in_progress(pxp); in __pxp_global_teardown_final()
316 intel_pxp_terminate(pxp, false); in __pxp_global_teardown_final()
318 timeout = intel_pxp_get_backend_timeout_ms(pxp); in __pxp_global_teardown_final()
320 if (!wait_for_completion_timeout(&pxp->termination, msecs_to_jiffies(timeout))) in __pxp_global_teardown_final()
326 static int __pxp_global_teardown_restart(struct intel_pxp *pxp) in __pxp_global_teardown_restart() argument
330 if (pxp->arb_is_valid) in __pxp_global_teardown_restart()
333 drm_dbg(&pxp->ctrl_gt->i915->drm, "PXP: teardown for restart"); in __pxp_global_teardown_restart()
338 pxp_queue_termination(pxp); in __pxp_global_teardown_restart()
340 timeout = intel_pxp_get_backend_timeout_ms(pxp); in __pxp_global_teardown_restart()
342 if (!wait_for_completion_timeout(&pxp->termination, msecs_to_jiffies(timeout))) { in __pxp_global_teardown_restart()
343 drm_dbg(&pxp->ctrl_gt->i915->drm, "PXP: restart backend timed out (%d ms)", in __pxp_global_teardown_restart()
351 void intel_pxp_end(struct intel_pxp *pxp) in intel_pxp_end() argument
353 struct drm_i915_private *i915 = pxp->ctrl_gt->i915; in intel_pxp_end()
356 if (!intel_pxp_is_enabled(pxp)) in intel_pxp_end()
361 mutex_lock(&pxp->arb_mutex); in intel_pxp_end()
363 if (__pxp_global_teardown_final(pxp)) in intel_pxp_end()
364 drm_dbg(&i915->drm, "PXP end timed out\n"); in intel_pxp_end()
366 mutex_unlock(&pxp->arb_mutex); in intel_pxp_end()
368 intel_pxp_fini_hw(pxp); in intel_pxp_end()
372 static bool pxp_required_fw_failed(struct intel_pxp *pxp) in pxp_required_fw_failed() argument
374 if (__intel_uc_fw_status(&pxp->ctrl_gt->uc.huc.fw) == INTEL_UC_FIRMWARE_LOAD_FAIL) in pxp_required_fw_failed()
376 if (HAS_ENGINE(pxp->ctrl_gt, GSC0) && in pxp_required_fw_failed()
377 __intel_uc_fw_status(&pxp->ctrl_gt->uc.gsc.fw) == INTEL_UC_FIRMWARE_LOAD_FAIL) in pxp_required_fw_failed()
383 static bool pxp_fw_dependencies_completed(struct intel_pxp *pxp) in pxp_fw_dependencies_completed() argument
385 if (HAS_ENGINE(pxp->ctrl_gt, GSC0)) in pxp_fw_dependencies_completed()
386 return intel_pxp_gsccs_is_ready_for_sessions(pxp); in pxp_fw_dependencies_completed()
388 return pxp_component_bound(pxp); in pxp_fw_dependencies_completed()
396 int intel_pxp_get_readiness_status(struct intel_pxp *pxp, int timeout_ms) in intel_pxp_get_readiness_status() argument
398 if (!intel_pxp_is_enabled(pxp)) in intel_pxp_get_readiness_status()
401 if (pxp_required_fw_failed(pxp)) in intel_pxp_get_readiness_status()
404 if (pxp->platform_cfg_is_bad) in intel_pxp_get_readiness_status()
408 if (wait_for(pxp_fw_dependencies_completed(pxp), timeout_ms)) in intel_pxp_get_readiness_status()
410 } else if (!pxp_fw_dependencies_completed(pxp)) { in intel_pxp_get_readiness_status()
422 int intel_pxp_start(struct intel_pxp *pxp) in intel_pxp_start() argument
426 ret = intel_pxp_get_readiness_status(pxp, PXP_READINESS_TIMEOUT); in intel_pxp_start()
428 drm_dbg(&pxp->ctrl_gt->i915->drm, "PXP: tried but not-avail (%d)", ret); in intel_pxp_start()
434 mutex_lock(&pxp->arb_mutex); in intel_pxp_start()
436 ret = __pxp_global_teardown_restart(pxp); in intel_pxp_start()
443 if (!pxp->arb_is_valid) in intel_pxp_start()
447 mutex_unlock(&pxp->arb_mutex); in intel_pxp_start()
451 void intel_pxp_init_hw(struct intel_pxp *pxp) in intel_pxp_init_hw() argument
453 kcr_pxp_enable(pxp); in intel_pxp_init_hw()
454 intel_pxp_irq_enable(pxp); in intel_pxp_init_hw()
457 void intel_pxp_fini_hw(struct intel_pxp *pxp) in intel_pxp_fini_hw() argument
459 kcr_pxp_disable(pxp); in intel_pxp_fini_hw()
460 intel_pxp_irq_disable(pxp); in intel_pxp_fini_hw()
463 int intel_pxp_key_check(struct intel_pxp *pxp, in intel_pxp_key_check() argument
467 if (!intel_pxp_is_active(pxp)) in intel_pxp_key_check()
473 GEM_BUG_ON(!pxp->key_instance); in intel_pxp_key_check()
482 obj->pxp_key_instance = pxp->key_instance; in intel_pxp_key_check()
484 if (obj->pxp_key_instance != pxp->key_instance) in intel_pxp_key_check()
490 void intel_pxp_invalidate(struct intel_pxp *pxp) in intel_pxp_invalidate() argument
492 struct drm_i915_private *i915 = pxp->ctrl_gt->i915; in intel_pxp_invalidate()