Lines Matching +full:termination +full:- +full:current
1 // SPDX-License-Identifier: MIT
29 * Objects can opt-in to PXP encryption at creation time via the
57 return IS_ENABLED(CONFIG_DRM_I915_PXP) && pxp && pxp->ce; in intel_pxp_is_enabled()
62 return IS_ENABLED(CONFIG_DRM_I915_PXP) && pxp && pxp->arb_is_valid; in intel_pxp_is_active()
70 intel_uncore_write(pxp->ctrl_gt->uncore, KCR_INIT(pxp->kcr_base), val); in kcr_pxp_set_status()
86 struct intel_gt *gt = pxp->ctrl_gt; in create_vcs_context()
96 engine = gt->engine_class[VIDEO_DECODE_CLASS][i]; in create_vcs_context()
98 GEM_BUG_ON(!engine || engine->class != VIDEO_DECODE_CLASS); in create_vcs_context()
100 ce = intel_engine_create_pinned_context(engine, engine->gt->vm, SZ_4K, 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()
115 if (pxp->ce) in destroy_vcs_context()
116 intel_engine_destroy_pinned_context(fetch_and_zero(&pxp->ce)); in destroy_vcs_context()
121 struct intel_gt *gt = pxp->ctrl_gt; in pxp_init_full()
125 * we'll use the completion to check if there is a termination pending, in pxp_init_full()
126 * so we start it as completed and we reinit it when a termination 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()
143 if (HAS_ENGINE(pxp->ctrl_gt, GSC0)) in pxp_init_full()
150 drm_info(>->i915->drm, "Protected Xe Path (PXP) protected content support initialized\n"); in pxp_init_full()
161 * NOTE: Only certain platforms require PXP-tee-backend dependencies in find_gt_for_required_teelink()
165 intel_huc_is_loaded_by_gsc(&to_gt(i915)->uc.huc) && intel_uc_uses_huc(&to_gt(i915)->uc)) in find_gt_for_required_teelink()
173 if (!IS_ENABLED(CONFIG_DRM_I915_PXP) || !INTEL_INFO(i915)->has_pxp) in find_gt_for_required_protected_content()
177 * For MTL onwards, PXP-controller-GT needs to have a valid GSC engine in find_gt_for_required_protected_content()
178 * on the media GT. NOTE: if we have a media-tile with a GSC-engine, in find_gt_for_required_protected_content()
182 if (i915->media_gt && HAS_ENGINE(i915->media_gt, GSC0) && in find_gt_for_required_protected_content()
183 intel_uc_fw_is_loadable(&i915->media_gt->uc.gsc.fw) && in find_gt_for_required_protected_content()
184 intel_uc_fw_is_loadable(&i915->media_gt->uc.huc.fw)) in find_gt_for_required_protected_content()
185 return i915->media_gt; 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()
191 if (IS_ENABLED(CONFIG_INTEL_MEI_PXP) && !i915->media_gt && VDBOX_MASK(to_gt(i915))) in find_gt_for_required_protected_content()
203 return -ENOTCONN; in intel_pxp_init()
216 return -ENODEV; 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()
225 return -ENOMEM; in intel_pxp_init()
227 /* init common info used by all feature-mode usages*/ 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()
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()
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()
270 struct intel_gt *gt = pxp->ctrl_gt; in pxp_queue_termination()
273 * We want to get the same effect as if we received a termination in pxp_queue_termination()
276 spin_lock_irq(gt->irq_lock); 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()
280 spin_unlock_irq(gt->irq_lock); in pxp_queue_termination()
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()
297 if (HAS_ENGINE(pxp->ctrl_gt, GSC0)) in intel_pxp_get_backend_timeout_ms()
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()
320 if (!wait_for_completion_timeout(&pxp->termination, msecs_to_jiffies(timeout))) in __pxp_global_teardown_final()
321 return -ETIMEDOUT; in __pxp_global_teardown_final()
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()
335 * The arb-session is currently inactive and we are doing a reset and restart 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()
345 return -ETIMEDOUT; in __pxp_global_teardown_restart()
353 struct drm_i915_private *i915 = pxp->ctrl_gt->i915; in intel_pxp_end()
359 wakeref = intel_runtime_pm_get(&i915->runtime_pm); in intel_pxp_end()
361 mutex_lock(&pxp->arb_mutex); 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()
369 intel_runtime_pm_put(&i915->runtime_pm, wakeref); in intel_pxp_end()
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()
385 if (HAS_ENGINE(pxp->ctrl_gt, GSC0)) in pxp_fw_dependencies_completed()
399 return -ENODEV; in intel_pxp_get_readiness_status()
402 return -ENODEV; in intel_pxp_get_readiness_status()
404 if (pxp->platform_cfg_is_bad) in intel_pxp_get_readiness_status()
405 return -ENODEV; in intel_pxp_get_readiness_status()
418 * termination completion interrupt
428 drm_dbg(&pxp->ctrl_gt->i915->drm, "PXP: tried but not-avail (%d)", ret); in intel_pxp_start()
431 return -EIO; /* per UAPI spec, user may retry later */ in intel_pxp_start()
434 mutex_lock(&pxp->arb_mutex); in intel_pxp_start()
443 if (!pxp->arb_is_valid) in intel_pxp_start()
444 ret = -EIO; in intel_pxp_start()
447 mutex_unlock(&pxp->arb_mutex); in intel_pxp_start()
468 return -ENODEV; in intel_pxp_key_check()
471 return -EINVAL; in intel_pxp_key_check()
473 GEM_BUG_ON(!pxp->key_instance); in intel_pxp_key_check()
477 * encrypted yet; it will be encrypted with the current key, so mark it in intel_pxp_key_check()
481 if (!obj->pxp_key_instance && assign) 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()
485 return -ENOEXEC; in intel_pxp_key_check()
492 struct drm_i915_private *i915 = pxp->ctrl_gt->i915; in intel_pxp_invalidate()
496 spin_lock_irq(&i915->gem.contexts.lock); in intel_pxp_invalidate()
497 list_for_each_entry_safe(ctx, cn, &i915->gem.contexts.list, link) { in intel_pxp_invalidate()
501 if (!kref_get_unless_zero(&ctx->ref)) in intel_pxp_invalidate()
509 spin_unlock_irq(&i915->gem.contexts.lock); in intel_pxp_invalidate()
529 if (ctx->pxp_wakeref) { in intel_pxp_invalidate()
530 intel_runtime_pm_put(&i915->runtime_pm, in intel_pxp_invalidate()
531 ctx->pxp_wakeref); in intel_pxp_invalidate()
532 ctx->pxp_wakeref = 0; in intel_pxp_invalidate()
535 spin_lock_irq(&i915->gem.contexts.lock); in intel_pxp_invalidate()
539 spin_unlock_irq(&i915->gem.contexts.lock); in intel_pxp_invalidate()