/* * The binding of the component is asynchronous from i915 probe, so we * can't be sure it has happened.
*/ if (!pxp_component) {
ret = -ENODEV; goto unlock;
}
ret = pxp_component->ops->send(pxp_component->tee_dev, msg_in, msg_in_size,
PXP_TRANSPORT_TIMEOUT_MS); if (ret) {
drm_err(&i915->drm, "Failed to send PXP TEE message\n"); goto unlock;
}
ret = pxp_component->ops->recv(pxp_component->tee_dev, msg_out, msg_out_max_size,
PXP_TRANSPORT_TIMEOUT_MS); if (ret < 0) {
drm_err(&i915->drm, "Failed to receive PXP TEE message\n"); goto unlock;
}
if (ret > msg_out_max_size) {
drm_err(&i915->drm, "Failed to receive PXP TEE message due to unexpected output size\n");
ret = -ENOSPC; goto unlock;
}
if (msg_out_rcv_size)
*msg_out_rcv_size = ret;
ret = 0;
unlock:
mutex_unlock(&pxp->tee_mutex); return ret;
}
int intel_pxp_tee_stream_message(struct intel_pxp *pxp,
u8 client_id, u32 fence_id, void *msg_in, size_t msg_in_len, void *msg_out, size_t msg_out_len)
{ /* TODO: for bigger objects we need to use a sg of 4k pages */ const size_t max_msg_size = PAGE_SIZE; struct drm_i915_private *i915 = pxp->ctrl_gt->i915; struct i915_pxp_component *pxp_component = pxp->pxp_component; unsignedint offset = 0; struct scatterlist *sg; int ret;
if (msg_in_len > max_msg_size || msg_out_len > max_msg_size) return -ENOSPC;
mutex_lock(&pxp->tee_mutex);
if (unlikely(!pxp_component || !pxp_component->ops->gsc_command)) {
ret = -ENODEV; goto unlock;
}
/** * 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.
*/ staticint 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); struct intel_pxp *pxp = i915->pxp; struct intel_gt *gt = pxp->ctrl_gt; struct intel_uc *uc = >->uc;
intel_wakeref_t wakeref; int ret = 0;
if (!HAS_HECI_PXP(i915)) {
pxp->dev_link = device_link_add(i915_kdev, tee_kdev, DL_FLAG_STATELESS); if (drm_WARN_ON(&i915->drm, !pxp->dev_link)) return -ENODEV;
}
if (intel_uc_uses_huc(uc) && intel_huc_is_loaded_by_gsc(&uc->huc)) {
with_intel_runtime_pm(&i915->runtime_pm, wakeref) { /* load huc via pxp */
ret = intel_huc_fw_load_and_auth_via_gsc(&uc->huc); if (ret < 0)
gt_probe_error(gt, "failed to load huc via gsc %d\n", ret);
}
}
/* if we are suspended, the HW will be re-initialized on resume */
wakeref = intel_runtime_pm_get_if_in_use(&i915->runtime_pm); if (!wakeref) return 0;
/* the component is required to fully start the PXP HW */ if (intel_pxp_is_enabled(pxp))
intel_pxp_init_hw(pxp);
/* allocate lmem object of one page for PXP command memory and store it */
obj = i915_gem_object_create_lmem(i915, PAGE_SIZE, I915_BO_ALLOC_CONTIGUOUS); if (IS_ERR(obj)) {
drm_err(&i915->drm, "Failed to allocate pxp streaming command!\n"); return PTR_ERR(obj);
}
err = i915_gem_object_pin_pages_unlocked(obj); if (err) {
drm_err(&i915->drm, "Failed to pin gsc message page!\n"); goto out_put;
}
/* map the lmem into the virtual memory pointer */
cmd = i915_gem_object_pin_map_unlocked(obj,
intel_gt_coherent_map_type(pxp->ctrl_gt,
obj, true)); if (IS_ERR(cmd)) {
drm_err(&i915->drm, "Failed to map gsc message page!\n");
err = PTR_ERR(cmd); goto out_unpin;
}
ret = intel_pxp_tee_io_message(pxp,
&msg_in, sizeof(msg_in),
&msg_out, sizeof(msg_out),
NULL);
/* Cleanup coherency between GT and Firmware is critical, so try again if it fails */ if ((ret || msg_out.header.status != 0x0) && ++trials < 3) goto try_again;
if (ret) {
drm_err(&i915->drm, "Failed to send tee msg for inv-stream-key-%u, ret=[%d]\n",
session_id, ret);
} elseif (msg_out.header.status != 0) { if (is_fw_err_platform_config(pxp, msg_out.header.status)) {
drm_info_once(&i915->drm, "PXP inv-stream-key-%u failed due to BIOS/SOC :0x%08x:%s\n",
session_id, msg_out.header.status,
fw_err_to_string(msg_out.header.status));
} else {
drm_dbg(&i915->drm, "PXP inv-stream-key-%u failed 0x%08x:%s:\n",
session_id, msg_out.header.status,
fw_err_to_string(msg_out.header.status));
drm_dbg(&i915->drm, " cmd-detail: ID=[0x%08x],API-Ver-[0x%08x]\n",
msg_in.header.command_id, msg_in.header.api_version);
}
}
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.9 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.